Kent Gibson [Wed, 17 Jun 2020 03:06:39 +0000 (11:06 +0800)]
core: fix gpiod_line_get_value_bulk for events
Extend gpiod_line_get_value_bulk so that it works for bulks of
lineevents, not only linehandles.
Reported-by: Gerrit Wyen <ml@ionscale.com>
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Wed, 17 Jun 2020 03:06:38 +0000 (11:06 +0800)]
tests: event: add tests for gpiod_line_get_value_bulk events
Add tests to verify the behaviour of gpiod_line_get_value_bulk when
applied to a bulk of event lines.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Wed, 17 Jun 2020 03:06:37 +0000 (11:06 +0800)]
bindings: cxx: tests: add tests for bulk events get_values
Add tests to verify the behaviour of get_values when applied to a bulk
of event lines.
Reported-by: Gerrit Wyen <ml@ionscale.com>
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Wed, 27 May 2020 01:10:55 +0000 (09:10 +0800)]
doc: fix comment mix up in gpiod.h
A couple of the doc comments for GPIOD_LINE_REQUEST_XX values document
the wrong value. Switch them so that they document the appropriate value.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Wed, 27 May 2020 01:09:04 +0000 (09:09 +0800)]
tests: remove debug asserts
Remove asserts that are a hangover from debugging test cases.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 11 May 2020 14:41:24 +0000 (16:41 +0200)]
bindings: cxx: fix the forward declaration for line_event
line_event is defined as a struct, not a class. Fix the forward
declaration for consistency.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 29 Apr 2020 12:38:23 +0000 (14:38 +0200)]
gpioinfo: print bias flags if set
When printing line information: check the bias configuration and include
the current value in the 'flags' column of output.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 30 Apr 2020 15:07:37 +0000 (17:07 +0200)]
tools: unduplicate signalfd() code
The code creating the signal file descriptor in gpiomon and gpioset is
pretty much the same. Move it into tools-common.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 28 Apr 2020 15:35:03 +0000 (17:35 +0200)]
bindings: cxx: drop a stray newline
Drop an unnecessary newline from struct line_event.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 28 Apr 2020 11:24:19 +0000 (13:24 +0200)]
doc: improve the description of gpiod_line_event_read()
The description of gpiod_line_event_read() states that it reads the last
event that occurred for this line. This is not true: the kernel stores
the events in a FIFO and this function reads the next event from it.
Fix the confusing statement.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 27 Apr 2020 17:04:37 +0000 (19:04 +0200)]
TODO: add a list of planned API changes for v2.0
At some point in the future we'll make non-compatible changes to the
API and increase the major version number. Add a list of changes planned
for v2.0 to the TODO file.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 14 Apr 2020 12:45:25 +0000 (14:45 +0200)]
tools: tests: fix regex patterns for timestamps in gpiomon test cases
Commit
f8850206e160 ("gpio: Switch timestamps to ktime_get_ns()") in the
linux kernel (released in v5.7-rc1) changed the clock used to generate
line events from real-time to monotonic. This has the effect of making
the timestamp values much smaller and it uncovered a bug in regex
patterns used to verify gpiomon output: they don't expect there to be
any whitespace characters in the timestamp part of the line.
Fix it by accepting any number of whitespace chars between the opening
'[' and the first digit of the timestamp.
Fixes: 9c5a6f31ebff ("tests: use GLib for library test cases and bats for gpio-tools")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 9 Apr 2020 10:19:22 +0000 (12:19 +0200)]
doc: add descriptions for doxygen sub-sections
Add additional descriptions fox doxygen sub-sections under the line
section.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 2 Apr 2020 08:11:23 +0000 (10:11 +0200)]
bindings: python: add the __version__ module attribute
The python module provides the version_string() function that returns
the API version but the standard way to do this according to PEP 396
is by providing the __version__ attribute at the module level.
Add __version__ constant to gpiod module and mark version_string() as
deprecated in the doc.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 17 Mar 2020 17:08:36 +0000 (18:08 +0100)]
build: use the gnu89 C standard explicitly
We're already using it implicitly but GCC may change the default
standard to gnu99 at some point, so use gnu89 explicitly whenever
building C files.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 13 Feb 2020 14:13:42 +0000 (15:13 +0100)]
core: reuse the err_close_fd label in gpiod_chip_open()
Remove redundant resource cleanup in error path after is_gpiochip_cdev()
and reuse the already existing label.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sat, 8 Feb 2020 19:16:59 +0000 (20:16 +0100)]
build: check for realpath() in configure.ac
Core library is now using realpath(). Check its availability in
configure.ac.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Andy Shevchenko [Thu, 6 Feb 2020 18:13:58 +0000 (20:13 +0200)]
core: relax gpiod_chip_open() for symbolic links
User may ask device helper tool, for example, udev, to create a specific
symbolic link to a device node. GPIO chip character device node is not
exceptional. However, libgpiod in the commit
d9b1c1f14c6b
("core: harden gpiod_chip_open()") went way too far in the hardening device
node check.
Relax that hardening for symbolic link to fix the regression.
Reproducer:
% gpioinfo /dev/gpiochip5
gpiochip5 - 16 lines:
line 0: "MUX33_DIR" "uart1-rx-oe" output active-high [used]
...
% ln -sf /dev/gpiochip5 /dev/MyGPIO_5
% gpioinfo /dev/MyGPIO_5
gpioinfo: looking up chip /dev/MyGPIO_5: Inappropriate ioctl for device
Link: https://stackoverflow.com/questions/60057494/gpio-issue-with-sym-link
Fixes: d9b1c1f14c6b ("core: harden gpiod_chip_open()")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 3 Feb 2020 10:24:03 +0000 (11:24 +0100)]
bindings: cxx: fix std namespace resolution
We try to always resolve symbols from std starting from the global
namespace by using the '::' prefix but there are a couple places where
this was missed. This patch makes the resolution consistent treewide.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 3 Feb 2020 10:19:07 +0000 (11:19 +0100)]
tests: misc: fix the version string test case
The current development version is v1.6-devel. The '-' character is
there to differentiate between the "main" version part and the extra
suffix.
The existing test case for the version string is now failing because
we used '.' previously for the extra version suffix. Fix it by extending
the regex pattern.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 29 Jan 2020 09:47:40 +0000 (10:47 +0100)]
Merge branch 'next'
Bartosz Golaszewski [Wed, 29 Jan 2020 09:47:12 +0000 (10:47 +0100)]
libgpiod: start v1.6 development cycle
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 27 Jan 2020 16:59:59 +0000 (17:59 +0100)]
libgpiod v1.5
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sat, 25 Jan 2020 18:20:51 +0000 (19:20 +0100)]
README: remove the reference to v4.8 kernel headers
The project now depends on v5.5 kernel headers to build. Drop the
reference to v4.8 headers and instead refer readers to the contents
of configure.ac for the exact required version.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Chris Nisbet [Fri, 24 Jan 2020 17:43:14 +0000 (06:43 +1300)]
iter: remove unnecessary indirection in free_dirs
It is not necessary to pass the address of the 'dirs' variable to
dirs_free(), so this commit removes the unecessary indirection.
Signed-off-by: Chris Nisbet <chris@nisbet.kiwi.nz>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 24 Jan 2020 16:35:40 +0000 (17:35 +0100)]
configure: move the ABI version definition for libgpiomockup
Having it separated from the other ABI versions already led to it almost
being forgotten when incrementing versions before release. Group all
versions together.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 15 Jan 2020 16:33:12 +0000 (17:33 +0100)]
build: increment the revision in libgpiomockup's ABI version
This helper library too has a separate ABI version, but we missed it
when incrementing other ABI numbers for v1.5-rc1. Increment the revision
only as no new interfaces were added or old ones removed.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 14 Jan 2020 07:48:13 +0000 (08:48 +0100)]
libgpiod v1.5-rc2
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 6 Jan 2020 14:31:10 +0000 (15:31 +0100)]
bindings: python: tests: package the python test-suite in the dist tarball
The test-suite python scripts is added to bin_SCRIPTS in Makefile.am.
This means it's not distributed by default. Add it to dist_bin_SCRIPTS
and make it part of the distribution tarball.
Fixes: 452696601ae5 ("bindings: python: use unittest to implement a proper test-suite")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 6 Jan 2020 14:20:57 +0000 (15:20 +0100)]
libgpiod v1.5-rc1
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 6 Jan 2020 11:11:01 +0000 (12:11 +0100)]
NEWS: updates for v1.5
Add release notes for libgpiod v1.5.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 6 Jan 2020 10:31:21 +0000 (11:31 +0100)]
tools: add a newline between the usage and summary sections of help text
Improve the readability of help messages in all tools by adding
a newline between the usage and summary sections.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 3 Jan 2020 09:03:48 +0000 (10:03 +0100)]
treewide: split .gitignore into separate files
Cleanup the main .gitignore: remove explicit filenames which are already
implicitly ignored with pattern entries and move all the specific
entries into appropriate sub-directories.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 18 Dec 2019 13:26:33 +0000 (14:26 +0100)]
bindings: python: tests: add a test-case for reading multiple line events
Extend the test coverage of Python bindings with tests of reading of
multiple line events at once.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 18 Dec 2019 12:54:46 +0000 (13:54 +0100)]
bindings: python: add a method for reading multiple line events
Add a new method to the Line class allowing to read up to 16 line
events at once.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 18 Dec 2019 12:32:09 +0000 (13:32 +0100)]
bindings: cxx: tests: add a test-case for reading multiple line events
Extend the test coverage of C++ bindings with tests of reading of
multiple line events at once.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 18 Dec 2019 08:31:35 +0000 (09:31 +0100)]
bindings: cxx: provide a method for reading multiple line events
Add a new method to gpiod::line class allowing to read up to 16 line
events at once.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 16 Dec 2019 17:34:38 +0000 (18:34 +0100)]
tests: event: extend test coverage for reading multiple line events at once
Add test cases for new helpers allowing users to read multiple events
at once.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 16 Dec 2019 17:34:17 +0000 (18:34 +0100)]
core: provide functions for reading multiple line events at once
The kernel allows us to read multiple (up to 16) line events with
a single read() call, but up to this point libgpiod only supported
reading one event at a time. Add two new functions that allow users
to read more events at the same time.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 16 Dec 2019 13:17:59 +0000 (14:17 +0100)]
core: use gpiod_line_event_get_fd() in gpiod_line_event_read()
We can drop the redundant line state check if we directly call
gpiod_line_event_get_fd() from gpiod_line_event_read(). As opposed
to line_get_fd() it checks if the line was requested for events.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 16 Dec 2019 17:25:14 +0000 (18:25 +0100)]
gitignore: ignore libtool scripts created when cross-compiling
When '--host' option is passed to configure, the name of the generated
libtool script will be prefixed with the value used as argument for
'--host'. Add a pattern for prefixed 'libtool' scripts to .gitignore.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sat, 14 Dec 2019 21:33:33 +0000 (22:33 +0100)]
build: drop a redundant check for linux/version.h header
We're now checking for linux/version.h on every build - not only when
building tests. Drop the redundant check.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 11 Dec 2019 15:39:53 +0000 (16:39 +0100)]
build: check linux headers version at build-time
Original libgpiod relied on linux headers v4.8 to build but it was only
documented in README and not enforced at build-time. We now support
features first available in linux v5.5. Add a check to configure.ac that
verifies if recent enough kernel headers are available - otherwise we'd
fail only when trying to build the library.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Joel Savitz [Tue, 3 Dec 2019 19:23:05 +0000 (14:23 -0500)]
bindings: python: fix segfault when calling Line.request()
When Line.request() is called without the required 'consumer=value'
argument, the module attempts access an empty dictionary object
resulting in a segfault. This patch avoids such access when the
dictionary is empty and maintains the current design where the
LineBulk object is responsible for validation of arguments.
Signed-off-by: Joel Savitz <jsavitz@redhat.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:24:07 +0000 (11:24 +0800)]
bindings: python: make vals in gpiod_Line_set_value consistent with other functions
Change the vals in gpiod_Line_set_value from a tuple of tuples to just a
tuple. This brings it into line with other vals in the module such as
gpiod_Line_set_config and gpiod_Line_set_direction_output.
The previous usage made the vals equivalent to an args (a tuple of
arguments equivalent to argc,argv in C), as per gpiod_Line_set_flags.
Renaming vals to args in gpiod_Line_set_value was not an option as there
is already an args parameter.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:24:06 +0000 (11:24 +0800)]
bindings: cxx: fix indentation of wrapped field descriptions
Minor formatting fix to make long text descriptions of params wrap under
the text, not under the param name.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:24:05 +0000 (11:24 +0800)]
doc: document gpiod_line_set_value_bulk NULL values behaviour
The handling of NULL values by gpiod_line_set_value_bulk has been changed
to interpret NULL as low values for all lines. This patch updates the
documentation of the function to describe that.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:24:04 +0000 (11:24 +0800)]
tools: add tests for drive flags
Add tests for drive flags in gpioset.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:24:03 +0000 (11:24 +0800)]
tools: gpioset: add support for drive flags
Add support for drive flags to gpioset so that line drive flags
(open-drain,open-source) can be set from the command line.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:24:02 +0000 (11:24 +0800)]
tools: add tests for bias flags
Add tests for bias flags to applicable tools - gpioget, gpioset, and
gpiomon.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:24:01 +0000 (11:24 +0800)]
tools: add support for bias flags
Add support for bias flags to applicable tools - gpioget, gpioset, and
gpiomon.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:24:00 +0000 (11:24 +0800)]
bindings: python: tests: add tests for SET_CONFIG methods
Extend test coverage over set_config, set_flags, set_direction_input, and
set_direction_output methods.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:59 +0000 (11:23 +0800)]
bindings: python: add support for SET_CONFIG
Add methods to support setting line configuration.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:58 +0000 (11:23 +0800)]
bindings: python: move tuple to int array conversion into helper function
Restructured gpiod_LineBulk_set_values to move the conversion of values
from Python tuple to int array into a helper function as it is useful for
similar functions.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:57 +0000 (11:23 +0800)]
bindings: cxx: tests: add tests for SET_CONFIG methods
Extend test coverage over set_config, set_flags, set_direction_input, and
set_direction_output methods.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:56 +0000 (11:23 +0800)]
bindings: cxx: add support for SET_CONFIG
Add methods to support setting line configuration.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:55 +0000 (11:23 +0800)]
tests: add tests for SET_CONFIG
Extend test coverage over the SET_CONFIG functions.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:54 +0000 (11:23 +0800)]
core: add support for SET_CONFIG
Extend the libgpiod API to support the setting line configuration using the
GPIO GPIOHANDLE_SET_CONFIG_IOCTL uAPI ioctl.
The core change is the addition of gpiod_line_set_config, which provides a
low level wrapper around the ioctl.
Additionally, higher level helper functions, gpiod_line_set_flags,
gpiod_line_set_direction_input, and gpiod_line_set_direction_output provide
slightly simplified APIs for common use cases.
Bulk forms of all functions are also provided.
Documented the fields of gpiod_line to better identify the purpose of
each where the field name alone is not sufficiently clear, and to
indicate which flags are applicable to each field.
Implementation includes a few helper functions that serve to keep the
code tidier and are consistent with similar helper functions already
present.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:53 +0000 (11:23 +0800)]
bindings: python: tests: add tests for bias flags
Extend test coverage to cover the bias flags in requests and the bias
setting returned by line.bias().
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:52 +0000 (11:23 +0800)]
bindings: python: add support for bias flags
Add support for bias flags in line requests and returning the line bias
setting via a bias accessor.
Based on initial work by Drew Fustini <drew@pdp7.com>.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:51 +0000 (11:23 +0800)]
bindings: cxx: tests: add tests for bias flags
Extend test coverage over the bias flags in requests and the bias setting
returned by line.bias().
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:50 +0000 (11:23 +0800)]
bindings: cxx: add support for bias flags
Add support for bias flags in line requests and returning the line bias
setting via a bias accessor.
Based on initial work by Drew Fustini <drew@pdp7.com>.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:49 +0000 (11:23 +0800)]
tests: add tests for bias flags
Extend test coverage over the bias flags, gpiod_line_bias and the extended
ctxless functions.
Also update existing tests to check bias flags where line state is checked.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Sun, 1 Dec 2019 03:23:48 +0000 (11:23 +0800)]
core: add support for bias flags
Extend the libgpiod API to support the bias flags recently added to the
kernel GPIO uAPI. The core change is the addition of
GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE, GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP
and GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN flags to be passed into
line_request functions, and the addition of gpiod_line_bias to return the
bias state of lines.
Variants of the ctxless functions that accept an active_low flag
are added to also accept other flags. The variant names add a "_ext"
suffix to the name of the original function.
Based on initial work by Drew Fustini <drew@pdp7.com>.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 26 Nov 2019 10:01:56 +0000 (11:01 +0100)]
tests: fix a typo in comment
s/There/These.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 25 Nov 2019 08:41:08 +0000 (09:41 +0100)]
build: use AC_CHECK_PROG() instead of AC_CHECK_FILE() for python3-config
Commit
9ed02fc793b3 ("build: check for python-config in configure")
breaks cross-compilation because AC_CHECK_FILE() only checks the host
machine. Use AC_CHECK_PROG() instead.
Cc: Joel Savitz <joelsavitz@gmail.com>
Fixes: 9ed02fc793b3 ("build: check for python-config in configure")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 22 Nov 2019 10:35:12 +0000 (11:35 +0100)]
core: deprecate gpiod_needs_update()
This function and the logic behind have been introduced in an early
version of libgpiod for reasons that have been long forgotten.
When updating the line info after a line request fails, just propagate
the error out of the request function instead of setting the internal
needs_update variable. Drop the entire logic behind gpiod_needs_update(),
make this routine always return false and mark it as deprecated in the
header.
Suggested-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Mon, 18 Nov 2019 14:46:12 +0000 (15:46 +0100)]
treewide: change "correspond with" to "correspond to"
Trivial grammar fix. "correspond with" can mean either being in agreement
with, happening at the same time, or communication between parties.
"correspond to" is used to mean equivalance, which is the intended use
throughout the documentation.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Mon, 18 Nov 2019 14:41:04 +0000 (15:41 +0100)]
core: allow gpiod_line_set_value_bulk() to accept null values
Change gpiod_line_set_value_bulk to interpret a NULL values pointer as an
array of zero, as per gpiod_line_request_bulk, gpiod_line_set_config_bulk,
and gpiod_line_set_direction_bulk_output.
The old behaviour was to segfault.
Add a corresponding test case for gpiod_line_set_value_bulk().
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Fri, 15 Nov 2019 14:43:42 +0000 (22:43 +0800)]
bindings: cxx: initialize bitset with integer instead of string
Initializing bitsets with string is inefficient and confusing.
Initialize them with the corresponding int instead.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Fri, 15 Nov 2019 14:43:41 +0000 (22:43 +0800)]
bindings: cxx: drop noexcept from direction() and active_state()
Both line::direction() and line::active_state() methods can throw and
so should not be declared as noexcept.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 18 Nov 2019 14:26:23 +0000 (15:26 +0100)]
bindings: cxx: tests: fix misspelling of parameter
Trivial misspelling fix: s/paramter/parameter.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Fri, 15 Nov 2019 14:43:39 +0000 (22:43 +0800)]
core: fix misspelling of parameter
Trivial fix to bring gpiod_ctxless_event_monitor_multiple() documentation
into line with gpiod_ctxless_event_monitor_multiple_ext().
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Kent Gibson [Fri, 15 Nov 2019 14:43:37 +0000 (22:43 +0800)]
core: move request flag to handle flag conversion into a separate function
Move common conversion code from line_request_values and
line_request_event_single() into a separate function to simplify adding
additional flags.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Joel Savitz [Fri, 4 Oct 2019 16:11:26 +0000 (12:11 -0400)]
build: check for python-config in configure
Currently, configure succeeds when python is installed without its
development components, i.e. python-config and headers. The subsequent
make will fail when gcc cannot locate Python.h.
This patch fixes that behavior by throwing an error at configure-time if
python-config cannot be found.
Signed-off-by: Joel Savitz <joelsavitz@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 19 Sep 2019 16:51:27 +0000 (18:51 +0200)]
bindings: python: directly return the value from PyErr_SetFromErrno()
PyErr_SetFromErrno() always returns NULL. We can return from functions
on failure directly instead of calling it and then returning NULL in
the next line.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 19 Sep 2019 16:31:00 +0000 (18:31 +0200)]
README: update the testing section
Add information about the tests included in Python and C++ bindings.
Move the BINDINGS section above TESTING so that the user first knows
that bindings exist before learning they also provide their own
test-suites.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 17 Sep 2019 14:50:31 +0000 (16:50 +0200)]
TODO: add a task for a re-write of python bindings
The python bindings should be improved but without breaking the existing
programs. Add an appropriate task to the TODO list.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sat, 14 Sep 2019 13:29:48 +0000 (15:29 +0200)]
bindings: python: provide Line.update()
Python bindings are missing the functionality provided by the core C
library's gpiod_line_update(). Extend the Line class with the update()
method that allows to re-read the line information from the kernel.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sat, 14 Sep 2019 13:18:20 +0000 (15:18 +0200)]
bindings: cxx: provide line::update()
The C++ bindings are missing the functionality provided by the core C
library's gpiod_line_update(). Extend the line class with the update()
method that allows to re-read the line information from the kernel.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 6 Sep 2019 13:51:04 +0000 (15:51 +0200)]
build: tweak formatting of multi-line variables in Makefiles
Don't put a tab between the asignment and the first string - just move
the whole list one line below.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 5 Sep 2019 15:00:24 +0000 (17:00 +0200)]
bindings: python: examples: check if '__main__' is set
The examples are programs meant to be executed directly and not
imported. Use the standard "if __name__ == '__main__':" before
any code.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sun, 8 Sep 2019 17:19:54 +0000 (19:19 +0200)]
TODO: remove the task for running external processes in gpiomon
This functionality can be achieved with a shell oneliner, for example:
gpiomon --line-buffered --format="%o %e" 0 0 | while read line; \
do cut -d" " -f2; done
There's no need to add this to the program. It would make the code
much more complicated without any real benefit.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 5 Sep 2019 12:48:57 +0000 (14:48 +0200)]
core: rename up_to_date to needs_update in struct gpiod_line
This variable is called up_to_date which can lead readers to the wrong
conclusion that libgpiod can somehow know when external actors (such as
a different process or a kernel driver) change the state of a GPIO line.
This is not the case and libgpiod only ever knows if a line needs info
update when a previous internal call to gpiod_line_update() fails.
The kernel does not provide any notification mechanism currently.
For that reason: rename the variable to needs_update.
While at it: clarify the documentation for gpiod_line_needs_update().
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 10 Sep 2019 08:39:12 +0000 (10:39 +0200)]
bindings: python: tests: fix checking the kernel version
Kernel release candidate version strings seem to not be working
correctly with python's version.parse() function. Split the string
retrieved with os.uname().release using '-' as delimiter and pass
only the first part - 'major.minor.release' - to version.parse().
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 3 Sep 2019 10:00:25 +0000 (12:00 +0200)]
core: fix the major:minor number comparison between the device and sysfs
Current code will incorrectly conclude that a device "1:1" matches
a sysfs device "1:10" as the length it reads from sysfsp is based on
the devstr length, which in this example is 3.
Always read the whole sysfs attribute and compare the string generated
from actual major:minor numbers against it (minus the trailing newline).
Fixes: d9b1c1f14c6b ("core: harden gpiod_chip_open()")
Reported-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 29 Aug 2019 07:41:37 +0000 (09:41 +0200)]
treewide: tests: uncomment previously failing test assertions
Mainline commit
2c60e6b5c924 ("gpiolib: never report open-drain/source
lines as 'input' to user-space") in the linux kernel has now been
backported to v5.2 stable branch and released in linux v5.2.11. We can
now enable back the assertions that were previously failed in test
suites (core, C++ and python). The required kernel versions must be
updated as well.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 21 Aug 2019 07:47:41 +0000 (09:47 +0200)]
tests: specify G_LOG_DOMAIN
We're using GLib for tests so let's specify a log domain for the
test-suit code.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 19 Aug 2019 13:27:39 +0000 (15:27 +0200)]
gitignore: ignore all files with .pc extension
We now have two .pc generated files and a third one will be added for
the GLib bindings, so ignore all files with this extension.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 19 Aug 2019 09:52:22 +0000 (11:52 +0200)]
build: move libgpiod.pc.in into lib/
This file is specific to the core library. Move it into the lib/ source
directory.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 14 Aug 2019 12:24:29 +0000 (14:24 +0200)]
bindings: python: tests: verify the errno field of OSError exceptions
When a call is expected to raise the OSError exception, verify that its
errno field is set to the expected value.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 12 Aug 2019 14:44:48 +0000 (16:44 +0200)]
bindings: cxx: tests: simplify the event fd polling test case
The mapping of file descriptors to lines was copied over from the
pre-catch2 set of C++ examples. It's not needed here as we know which
line the event will be generated on.
While at it: use a vector for the pollfd array.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 12 Aug 2019 12:27:32 +0000 (14:27 +0200)]
bindings: python: examples: wait for ENTER press in gpioset.py
After setting the line values in gpioset.py: don't exit until the user
presses ENTER. This makes the example work the same as the 'wait' mode
in the original gpioset utility.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 12 Aug 2019 12:18:54 +0000 (14:18 +0200)]
bindings: python: examples: don't store the return value unnecessarily
In gpioset.py: when calling lines.set_values(), there's no point in
storing the return value as it's always None. It's also not used
anywhere.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 12 Aug 2019 12:12:13 +0000 (14:12 +0200)]
bindings: python: examples: make gpiomon.py output resemble the original
Modify the gpiomon.py example to describe the detected events in
a format similar to the one used by the original gpiomon tool.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 7 Aug 2019 12:28:30 +0000 (14:28 +0200)]
bindings: python: use unittest to implement a proper test-suite
Currently the only tests we have for python bindings are in a simple
script that makes a lot of assumptions about the environment and
doesn't even work anymore with recent kernels.
Remove it and replace it with a proper test-suite implemented using
libgpiod and the standard python unittest package.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 9 Aug 2019 09:47:24 +0000 (11:47 +0200)]
bindings: python: fix the default_val argument name in the doc string
The argument in Line.request() is called default_val, not default_vals.
For backward compatibility with older versions default_vals would still
work if it was passed a tuple or list, but let's not confuse users:
default_val is the preferred way for single lines.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Alexander Stein [Wed, 7 Aug 2019 19:51:32 +0000 (21:51 +0200)]
bindings: cxx: add a workaround for --success run
If run with --success, all expressions are evaluated and printed out.
But REQUIRE_FALSE(chip) tries to iterate over the chip resulting in this
backtrace:
[...]
Work around this by forcing catch2 to call gpiod::chip::operator bool().
Signed-off-by: Alexander Stein <alexander.stein@mailbox.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Alexander Stein [Wed, 7 Aug 2019 19:51:31 +0000 (21:51 +0200)]
bindings: cxx: vix compile errors
This fixes the following compile errors:
tests-event.cpp:152:3: error: cannot declare reference to
'class std::system_error&', which is not a typedef or a template type
argument
152 | REQUIRE_THROWS_AS(line.event_get_fd(), ::std::system_error&);
This occurs on catch2 but not on catch.
Signed-off-by: Alexander Stein <alexander.stein@mailbox.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Alexander Stein [Wed, 7 Aug 2019 19:51:30 +0000 (21:51 +0200)]
bindings: cxx: split out catch's main()
Compiling the source using CATCH_CONFIG_MAIN to provide main() takes
several seconds, so split it out from any library testing code, so it
really needs to be built once only.
Signed-off-by: Alexander Stein <alexander.stein@mailbox.org>
[Bartosz: added the copyright notice for consistency with other files]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>