-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement GPIO support via sysfs with agent interface #468
Conversation
I've just noticed, that the output port is not switched as expected. I'm investigating the issue and will comment as soon as the issue is resolved. |
This was a false assumption. The output is indeed toggled. It just turns back to its initial state once the instance is destroyed/the line gets released. This happens really quickly with the current code appearing as if it was never toggled in the first place.
Okay, turns out that when lines are released they recover their former state. I'll modify the code to work around eventual pin default state recovery. |
Since I'm not firm with the Python ecosystem: Where would the distro-specific requirement declaration for |
Hmm, it seems that this is a limitation of the /dev/gpiochip interface. The current assumption of the DigitalOutputProtocol is that any configured value is kept until overwritten. This is relevant for usage with labgrid-client io, as no process is around to keep the device node open. https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/TODO#n11 mentions the plan to write a dbus-based daemon to handle that case, adding even more complexity. Maybe using the sysfs interface is the better approach? ;) |
The documentation section on the driver should mention the requirement. Updating the Debian file is also useful. |
Yeah. I think that the effort of transforming the libgpiod implementation into an agent was futile. So maybe the state prior to agent implementation (8de1391) could be merged? Should I force-push a state that removes all the commits on top? |
That would be premature. Compared to that state, you now have network support. Is there some way in libgpiod to make the state persistent? |
Yes. But with Maybe I could implement the networked variant using sysfs and keep the local implementation using
Yeah. That's true. Maybe instead of implementing the
Citing the libgpiod project author here:
His reasoning behind that design:
As all character devices are supposed to behave like this, there must be some general implementation in the kernel? Skimming through the kernel source ( |
I think I'd perfer to just use the sysfs interface via the agent. This avoids the additional dependency and solves the problem of keeping the configured output even after a process exits.
That would be much less useful. :/
Given that even gpiolib still has that missing daemon as a TODO, the pragmatic approach for labgrid seems to come down to using the sysfs interface via the agent, as that does everything we need and fits our current model better. If there is a daemon in the future (or we decide to build that ourselves), we can still add an additional driver for the same resource. It should be possible to translate the gpiochip number + offset information the the global index also via sysfs. That would allow us to use the same resource for both alternative drivers. |
Alright. For the given reasons, I'll change the agent to use the (deprecated) sysfs instead of libgpiod then. |
Codecov Report
@@ Coverage Diff @@
## master #468 +/- ##
========================================
+ Coverage 57.5% 57.7% +0.1%
========================================
Files 118 120 +2
Lines 7569 7693 +124
========================================
+ Hits 4358 4443 +85
- Misses 3211 3250 +39
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you squash your own commits together? They seem to change code that is changed again in your rewrite.
About squashing: Sure. Which range? All of my code? All of the libgpiod code? Feel free to do it in a way you like/see fit. |
c9d1f5c
to
d281b38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small improvment requests, which could also be done after merge. Thanks!
db91e47
to
4018c2a
Compare
GpioDigitalOutputDriver uses libgpiod to write a digital signal to a GPIO line. The minimum requirement to use libgpiod's kernel interface is Linux 4.8. The python binding is neither commonly available in Linux distributions nor on PyPI, so import it only on usage. Signed-off-by: Bastian Germann <[email protected]>
Signed-off-by: Bastian Germann <[email protected]>
This allows to export local GPIO resources for consumption by remote clients. It is implemented using the deprecated `sysfs` interface, because the `libgpiod` interface does not retain its state once the process exits. A behavior that is expected by labgrid. Signed-off-by: Leif Middelschulte <[email protected]> [Jan Luebbe: squashed additional fixes into this commit] Signed-off-by: Jan Luebbe <[email protected]>
Adds simple tests for: - instantiating a `GpioDigitialOutput` - setting (and verifying set) values. Signed-off-by: Leif Middelschulte <[email protected]>
Thanks! |
I am currently working on trying to implement libgpio into labgrid instead of using sysfs. And I believe I have found the solution to the problem of the configured value being kept uptil overwritten. When creating a line request, do it with
|
Description
This is only complementary work for #407
Checklist
Complements #407