This is a C++ method for getting all lines exposed by a GPIO chip. It
corresponds with the helper function recently added to the C API.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
return ::std::move(lines);
}
+line_bulk chip::get_all_lines(void) const
+{
+ line_bulk lines;
+
+ for (unsigned int i = 0; i < this->num_lines(); i++)
+ lines.add(this->get_line(i));
+
+ return ::std::move(lines);
+}
+
line_bulk chip::find_lines(const ::std::vector<::std::string>& names) const
{
line_bulk lines;
}
TEST_CASE(multiple_lines_test);
+void get_all_lines(void)
+{
+ ::gpiod::chip chip("gpiochip0");
+
+ ::std::cout << "Getting all lines from a chip" << ::std::endl;
+
+ auto lines = chip.get_all_lines();
+
+ for (auto& it: lines)
+ ::std::cout << "Offset: " << it.offset() << ::std::endl;
+}
+TEST_CASE(get_all_lines);
+
} /* namespace */
int main(int, char **)
*/
GPIOD_API line_bulk get_lines(const ::std::vector<unsigned int>& offsets) const;
+ /**
+ * @brief Get all lines exposed by this chip.
+ * @return All lines exposed by this chip held by a line_bulk object.
+ */
+ GPIOD_API line_bulk get_all_lines(void) const;
+
/**
* @brief Get a set of lines exposed by this chip by their names.
* @param names Vector of line names.