gpio

package
v1.0.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2025 License: BSD-2-Clause Imports: 7 Imported by: 0

README

The gpio package is a collection of the following dutagent modules:

The modules are designed to use different ways to interact with GPIO. At the moment only one such backend is supported and set by default. That is memory mapping dev/mem memory region and manipulating GPIO registers by writing to that memory.

[!IMPORTANT]
It is the users responsibility to ensure that the used GPIO pin is not also used by other modules or otherwise occupied by the system.

Button

This module simulates a button press by changing the state of a GPIO pin.

ARGUMENTS:
	[duration]

The duration controls the time the button is pressed. If no duration is passed, a default is used.

A duration string is a possibly signed sequence of decimal numbers, each with optional fraction
and a unit suffix, such as "300ms", "-1.5h" or "2h45m".
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`

See gpio-example-cfg.yml for examples.

Configuration Options

Option Value Description
pin int Raw BCM2835/BCM2711 pin number
activelow bool If true, the idle state is high, and low when pressed. Default is false
backend string For future use. Name of the backend to use. Default is "devmem"

Switch

This module simulates an on/off switch by changing the state of a GPIO pin.

ARGUMENTS:
	[on|off|toggle]

The on, off and toggle commands control the state of the switch.
If no argument is passed, the current state is printed.

The Switch is initially turned off and by default off means 'low' and on means 'high'.

See gpio-example-cfg.yml for examples.

Configuration Options

Option Value Description
pin int Raw BCM2835/BCM2711 pin number
initial string Initial state of the switch: "on" or "off" (case insensitive). Default and fallback is "off".
activelow bool If true, the switch is active low (switch on means gpio pin low). Default is false.
backend string For future use. Name of the backend to use. Default is "devmem"

Documentation

Overview

The gpio package provides two modules that simulate buttons and switches respectively, using the GPIO pins of the Raspberry Pi. Used pins of Raspberry Pi needs to be wired to respective pads/connections on the DUT.

E.g. this module can be used to pull down the reset line of the DUT.

Index

Constants

View Source
const DefaultButtonPressDuration = 500 * time.Millisecond

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	Pin       Pin    // Raw BCM2835/BCM2711 pin number
	ActiveLow bool   // If set, the idle state is high, and low when pressed. Default is false
	Backend   string // For future use. Name of the backend to use. Default and fallback is "devmem"
	// contains filtered or unexported fields
}

A Button simulates a button press by changing the state of a GPIO pin.

func (*Button) Deinit

func (b *Button) Deinit() error

func (*Button) Help

func (b *Button) Help() string

func (*Button) Init

func (b *Button) Init() error

func (*Button) Run

func (b *Button) Run(_ context.Context, s module.Session, args ...string) error

type Pin

type Pin uint8

type State

type State uint8
const (
	Low  State = 0
	High State = 1
)

type Switch

type Switch struct {
	// Raw BCM2835/BCM2711 pin number
	Pin Pin
	// Initial state of the switch: "on" or "off" (case insensitive). Default and fallback is "off".
	Initial string
	// If true, the switch is active low (switch on means gpio pin low). Default is false.
	ActiveLow bool
	// For future use. Name of the backend to use. Default is "devmem"
	Backend string
	// contains filtered or unexported fields
}

A Switch simulates an on/off switch by changing the state of a GPIO pin. By default, the switch is off and off means the pin is low.

func (*Switch) Deinit

func (s *Switch) Deinit() error

func (*Switch) Help

func (s *Switch) Help() string

func (*Switch) Init

func (s *Switch) Init() error

func (*Switch) Run

func (s *Switch) Run(_ context.Context, sesh module.Session, args ...string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL