Skip to content
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

Gpio acitve low and button protocol #1583

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

pmelange
Copy link

Description

  • Adds a new protocol ButtonProtocol and the drivers ManualButtonDriver, ExternalButtonDriver, and DigitalOutputButtonDriver to simulate pushing a button (via GPIO lines). This is needed for the tests I will be doing with the logic behind it.
  • Adds a new field to the existing SysfsGPIO / NetworkSysfsGPIO / MatchedSysfsGPIO resource classes to support the active_low option of a GPIO line, used to invert the logical value of an IO line.
  • Adds support to GPIODigitalOutputDriver to support ResetProtocol, PowerProtocol, the new ButtonProtocol and implements the new "invert" command for the DigitalOutputProtocol.
  • Updates the GPIOSysFSExport to support the active_low attribute
  • Adds support the labgrid-client to support the Button actions and the "invert" action for IO.
  • Updates corresponding documentation
  • Updates the examples for sysfsgpio

As far as new features go...

ButtonProtocol is to be used in my test environment to control pressing the reset button of DUTs. For many of the DUTs, pressing the reset button when powering on provides (via uboot) a TFTP client or server or simply access to a web socket to be able to upload a new firmware image. A logical button is better for the test environment I am creating since it encapsulates the high/low logic levels of IO ports into something logical.

Extending the GPIO based drivers to the Reset, Power, and Button protocols was very straight forward and I did wonder why the Reset and Power protocols had not jet been implemented. They seem like logical extensions to general purpose IO lines.

Adding the active_low attribute was necessary because the IO lines used in the testbed are connected to relays which are active_low.


All development and testing was done on a raspberry pi 4 with opto-coupler relays connected to the GPIO lines to control power and reset buttons.


Checklist

  • Documentation for the feature
  • Tests for the feature can be found in the examples/sysfsgpio directory
  • The arguments and description in doc/configuration.rst have been updated
  • PR has been tested by pulling high and low IO lines using various calls from the DigitalOutput, Reset, Power and Button protocols, both using the exporter/client and as a standalone python script.

A button can be used to simulate pressing a physical button on a device. For
example a DigitalOutputButtonDriver can be used when a reset button is
connected via a relay to a DigitalOutput.  In addition there are the
ManualButtonDriver and ExternalButtonDriver drivers analogous to the
ManualPowerDriver and ExternalPowerDriver drivers.

Operations on a button include "press", "release", "press_for", and "get".

Signed-off-by: Perry Melange <[email protected]>
…tput

The "invert" method should invert the value of a digital output.

Signed-off-by: Perry Melange <[email protected]>
The resources SysfsGPIO, NetworkSysfsGPIO and MatchedSysfsGPIO have
been modified to have an additional optional active_low attribute
(default False) which can be used to invert the logical value used
on the gpio line.

Signed-off-by: Perry Melange <[email protected]>
Update the GPIODigitalOutputDriver to also implement the ResetProtocol,
PowerProtocol, and ButtonProtocol.

Update the GpioDigitalOutput agent to use the new active_low attribute

Signed-off-by: Perry Melange <[email protected]>
Add support for the power and button protocols and add the "invert" method
of the io protocol to SysffsGPIO

Signed-off-by: Perry Melange <[email protected]>
Add documentations for ManualButtonDriver, ExternalButtonDriver,
DigitalOutputButtonDriver.

Update the SysfsGPIO, MatchedSysfsGPIO, and GpioDigitalOutputDriver to
add the new active_low attribute and the new protocols supported by the
GpioDigitalOutputDriver.

Signed-off-by: Perry Melange <[email protected]>
Also expand examples to call methods from the Power and Button protocols

Signed-off-by: Perry Melange <[email protected]>
@pmelange
Copy link
Author

This PR is a reduced version of #1569 without the libgpiod code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant