libgpiod
libgpiod copied to clipboard
[python] LineRequest.reconfigure_lines problems
Hello,
HW: RPi 3B, OS: ArchLinux, Kernel: 6.1.69-1-rpi-ARCH, Python: 3.11, gpiod: 2.1.3 from pypi.org
I'm porting some of my python scripts to libgpiod and I've run into a problem with request.reconfigure_lines method. Instead of succeeding, it raises ValueError with (22, 'Invalid argument')
.
The script basically opens 7 lines (some inputs, some outputs) in one request, does some work, and at the end wants to switch all output lines back to inputs so HW stops driving them. Both config dictionaries (first for request_lines, second for reconfigure_lines) are constructed dynamically from different metadata, and what I believe to be important, are likely to be in different order. When I pass the same dict to both methods, there's no exception (but obviously nothing changes).
Toy reproducer attached - it works reliably cause nowadays python dicts remember insertion order. Before Python 3.6 (or 3.7?) it would fail randomly. I've also included a third dict in the reproducer - with just one line to be reconfigured - this also fails, which I find counterintuitive, cause other functions like get/set values can operate on a subset of requested lines.
Can this be fixed inside gpiod or is the user expected to take care of sorting config dicts somehow?