bindings: cxx: allow empty default values in line_bulk::request()
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 19 Feb 2018 10:43:36 +0000 (11:43 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 19 Feb 2018 10:43:36 +0000 (11:43 +0100)
The core library now supports NULL default values in output requests.

Update the C++ bindings and the relevant example.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
bindings/cxx/examples/gpio_cxx_tests.cpp
bindings/cxx/line_bulk.cpp

index c20a9c981033d3332fc5892282a75ba003a0b3c3..7b12f957cb4304c4bff42612b71bb4534c8afd6b 100644 (file)
@@ -161,7 +161,7 @@ void multiple_lines_test(void)
        config.consumer = "gpiod_cxx_tests";
        config.request_type = ::gpiod::line_request::DIRECTION_OUTPUT;
 
-       lines.request(config, { 0, 0, 0, 0, 0 });
+       lines.request(config);
 
        ::std::cout << "Setting values" << ::std::endl;
 
index 3ce8d94c3b1377dd549b6d660b00c0fa43a0bd16..6f0d08f58b3a646286e3feb953b704e0a212b3e8 100644 (file)
@@ -104,9 +104,6 @@ void line_bulk::request(const line_request& config, const std::vector<int> defau
        if (!default_vals.empty() && this->size() != default_vals.size())
                throw ::std::invalid_argument("the number of default values must correspond with the number of lines");
 
-       if (config.request_type == line_request::DIRECTION_OUTPUT && default_vals.empty())
-               throw ::std::invalid_argument("default values are required for output mode");
-
        ::gpiod_line_request_config conf;
        ::gpiod_line_bulk bulk;
        int rv;
@@ -123,7 +120,8 @@ void line_bulk::request(const line_request& config, const std::vector<int> defau
        }
 
        rv = ::gpiod_line_request_bulk(::std::addressof(bulk),
-                                      ::std::addressof(conf), default_vals.data());
+                                      ::std::addressof(conf),
+                                      default_vals.empty() ? NULL : default_vals.data());
        if (rv)
                throw ::std::system_error(errno, ::std::system_category(),
                                          "error requesting GPIO lines");