control-gpio¶
CLI reference¶
glasgow run control-gpio¶
Sample and drive individual I/O pins via the CLI, the REPL, or a script.
CLI pin actions can be used to configure a pin to be driven strongly (A0=0 or A0=1),
to be driven weakly using a pull resistor (A0=H or A0=L), undriven (A0=Z), or
specified without a value (A0) to sample a pin. The actions are executed in the order they
are provided on the command line.
Socket pin actions may be used to interface with the applet from an external application.
Send each action over the socket in the same format as the CLI pin action described above,
terminating with a \n. (Spaces are ignored.) When sampling a pin, the value is sent back
over the socket terminated with a n`, otherwise no response is provided.
usage: glasgow run control-gpio [-h] [-V SPEC] --pins PINS [--socket SOCKET]
[PIN-ACTION ...]
- pin-action¶
pins to drive or sample, e.g.: ‘A0=1’, ‘A1=L’, ‘B5’
- -h, --help¶
show this help message and exit
- -V <spec>, --voltage <spec>¶
configure I/O port voltage to SPEC (e.g.: ‘3.3’, ‘A=5.0,B=3.3’, ‘A=SA’)
- --pins <pins>¶
bind the applet I/O lines ‘pins’ to PINS (required)
- --socket <socket>¶
listen at ENDPOINT, either unix:PATH or tcp:HOST:PORT
API reference¶
- exception glasgow.applet.control.gpio.GPIOException¶
- class glasgow.applet.control.gpio.GPIOInterface(logger: Logger, assembly: AbstractAssembly, *, pins: tuple[GlasgowPin], name='gpio')¶
-
- async input(index: int)¶
Configure pin
indexas input.- Raises:
IndexError – If
indexdoes not specify a valid pin index.
- async output(index: int, value: bool)¶
Configure pin
indexas output, initially drivingvalue.- Raises:
IndexError – If
indexdoes not specify a valid pin index.
- async get(index: int) bool¶
Sample state of pin
index.- Raises:
IndexError – If
indexdoes not specify a valid pin index.
- async set(index: int, value: bool)¶
Update value driven by pin
indexto bevalue.- Raises:
IndexError – If
indexdoes not specify a valid pin index.GPIOException – If pin
indexis not configured as an ouptut.
- async get_all() int¶
Sample state of every pin simultaneously.
In the returned value, the least significant bit corresponds to the first pin in the port provided to the constructor.
- async set_all(value: int)¶
Update value of every pin simultaneously.
In
value, the least significant bit corresponds to the first pin in the port provided to the constructor. The bits corresponding to pins that are configured as inputs, as well as the bits that do not correspond to any pins, are ignored.