Add more test cases/examples, implement some helper functions, tweak
the output messages, mention the need for a dummy chip in the system
in the module's pydoc string.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
gpiod_Line_event_wait() works differently than its LineBulk
counterpart. While the latter returns either a list of lines or False,
the former returns True if an event occurred on this line or False
otherwise.
False is not a good counterpart for an actual object, so instead return
None if no events occurred on any of the monitored lines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
We don't return the object returned from gpiod_LineBulk_event_wait()
back to the interpreter. We need to collect it before returning True.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
We're not collecting the bulk object we're creating in this method. Add
Py_DECREF() where needed.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
For both find_line() variants (Chip's method and global function)
return None if the internal call to the C find_line function fails
with ENOENT. This is not an error so don't raise an exception.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
When returning back to the interpreter from gpiod_Module_find_line(),
there's only one chip object reference holder, but we set the refcount
to 2 (as if the chip object existed separately in the interpreter).
Fix it by decreasing the chip's refcount by one before returning the
line object.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
We should release the python global interpreter lock when performing
blocking operations and reacquire it again when we're done. Use the
relevant APIs provided by libpython.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
AX_PYTHON_DEVEL macro from the autoconf-archive collection doesn't work
when we're trying to cross-compile python bindings in environments such
as buildroot or yocto. It can't properly detect the location of python
headers.
Let's use AM_PATH_PYTHON to detect the python3 interpreter and then
either take the PYTHON_CPPFLAGS and PYTHON_LIBS variables from the
environment (so that cross-compiling build systems can pass their
custom locations to autotools) or try to detect them ourselves using
the python3-config tool.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Create a C extension module wrapping the functionality of libgpiod
in a set of Python classes.
Add code examples including simplified reimplementations of gpio-tools
in Python.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>