diff options
author | Bartosz Golaszewski <bartekgola@gmail.com> | 2018-02-19 11:43:36 +0100 |
---|---|---|
committer | Bartosz Golaszewski <bartekgola@gmail.com> | 2018-02-19 11:43:36 +0100 |
commit | 0d4b0e51c6801bf3bf606299acb8ce7b2400bfd5 (patch) | |
tree | 2bd28c910f555038c69bb05331c1983b86d0140a | |
parent | 12badc212cbc8c29480f64bb556de0989281e8d4 (diff) | |
download | libgpiod-0d4b0e51c6801bf3bf606299acb8ce7b2400bfd5.tar.gz |
bindings: cxx: allow empty default values in line_bulk::request()
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>
-rw-r--r-- | bindings/cxx/examples/gpio_cxx_tests.cpp | 2 | ||||
-rw-r--r-- | bindings/cxx/line_bulk.cpp | 6 |
2 files changed, 3 insertions, 5 deletions
diff --git a/bindings/cxx/examples/gpio_cxx_tests.cpp b/bindings/cxx/examples/gpio_cxx_tests.cpp index c20a9c98..7b12f957 100644 --- a/bindings/cxx/examples/gpio_cxx_tests.cpp +++ b/bindings/cxx/examples/gpio_cxx_tests.cpp @@ -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; diff --git a/bindings/cxx/line_bulk.cpp b/bindings/cxx/line_bulk.cpp index 3ce8d94c..6f0d08f5 100644 --- a/bindings/cxx/line_bulk.cpp +++ b/bindings/cxx/line_bulk.cpp @@ -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"); |