Skip to content

protocol/driver: add DigitalInputProtocol, GpioDigitalInputDriver - #1458

Closed
flxzt wants to merge 1 commit into
labgrid-project:masterfrom
flxzt:digital-input
Closed

protocol/driver: add DigitalInputProtocol, GpioDigitalInputDriver#1458
flxzt wants to merge 1 commit into
labgrid-project:masterfrom
flxzt:digital-input

Conversation

@flxzt

@flxzt flxzt commented Jul 31, 2024

Copy link
Copy Markdown
Contributor

Description

this adds a new protocol DigitalInputProtocol and a GPIO driver that implements it.

The DigitalOutputProtocol ABC now also inherits it, ensuring it can be used in all existing driver implementations.

Additionally the client now automatically uses DigitalInputProtocol when the command is io get.

By seperating the input from output protocol it is possible to make sure the GPIO line is configured in direction input in sysfs, which avoids shorts when reading out digital states from DUT's. Otherwise, one would have to rely on the circuitry of the GPIO line.

Tested on two Raspberry Pi's as exporter and DUT.

Note:

the sysfsgpioin.py part duplicates most of the sysfsgpio.py code but because of the way this code is executed by agentwrapper I thought it was cleaner to separate it into a new file.

Checklist

  • Documentation for the feature
  • Tests for the feature
  • The arguments and description in doc/configuration.rst have been updated
  • PR has been tested

closes #1457

@flxzt

flxzt commented Aug 2, 2024

Copy link
Copy Markdown
Contributor Author

I think the way I implemented the behaviour of the client doesn't work well - if labgrid-client io get is used after labgrid-client io high/low, the sysfs direction is changed from out to in which can result in state low even if it was set high previously.

I'll revert to the previous behaviour where DigitialOutputProtocol is used for all client io subcommands.
So DigitalInputProtocol will only be available for usage with the library, which is also acceptable imo.

@flxzt

flxzt commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

can anyone review this?

this adds a new protocol `DigitalInputProtocol` and a GPIO driver
that implements it.
The `DigitalOutputProtocol` ABC now also inherits it, ensuring it can be
used in all existing driver implementations.

By seperating the input from output protocol it is possible
to make sure the GPIO line is configured in direction `input` in sysfs,
which avoids possible shorts when reading out digital states from DUT's.
Otherwise, one would have to rely on the circuitry of the GPIO line to
prevent that.

Signed-off-by: Felix Zwettler <Felix.Zwettler@duagon.com>
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 23.75000% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.8%. Comparing base (5818762) to head (fca7559).
⚠️ Report is 46 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/util/agents/sysfsgpioin.py 0.0% 46 Missing ⚠️
labgrid/driver/gpiodriver.py 55.0% 9 Missing ⚠️
labgrid/remote/client.py 0.0% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1458     +/-   ##
========================================
- Coverage    46.0%   45.8%   -0.2%     
========================================
  Files         180     182      +2     
  Lines       14462   14529     +67     
========================================
+ Hits         6654    6668     +14     
- Misses       7808    7861     +53     
Flag Coverage Δ
3.10 45.8% <23.7%> (-0.2%) ⬇️
3.11 45.8% <23.7%> (-0.2%) ⬇️
3.12 45.8% <23.7%> (-0.2%) ⬇️
3.13 45.8% <23.7%> (-0.2%) ⬇️
3.14 45.8% <23.7%> (-0.2%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@Emantor Emantor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not need an additional agent that duplicates the code, the existing agent should be extended to support the direction setting as well.

If possible it would also be great if the new gpiochip based sysfs interface that is not deprecated could be used.

Comment thread labgrid/remote/client.py
drv.set(False)
if not drv:
raise UserError("target has no compatible resource available")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the get() action removed here?

@ozan956

ozan956 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Hey @Emantor,

I took a look at this PR and would like to open a new PR based on it, with the review feedback addressed since its 2 years old and we need it.

I leave the gpiochip/libgpiod work as future work for now. I agree that it would be nice to support the newer non-deprecated GPIO interface, but that seems like a larger design topic and should not block a smaller sysfs-based digital input PR.

@Emantor

Emantor commented Aug 26, 2026

Copy link
Copy Markdown
Member

Superseded by #1935

@Emantor Emantor closed this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add DigitalInputProtocol, GpioDigitalInputDriver

4 participants