client_picod module
Declares constants and interfaces for compatibility with picod.
As common in picod, methods return a tuple of the status of the operation and the actual result (payload).
Interfaces
- class gpiosvr.client_picod.PicodApi
Bases:
PigpioMinimalApiInterface representing a stripped-down, async version of picod’s picod class.
- abstract async serial_open(channel: int, tx: int, rx: int, baud: int, cts: int = 255, rts: int = 255, data_bits: int = 8, stop_bits: int = 1, parity: int = 0) tuple
Opens a serial UART channel.
- Parameters:
channel¶ (int) – The UART channel to open on the Pico device,
0or1. Note: In pigpio, the parameter is called handle.tx¶ (int) – The GPIO to use for transmit. The allowed values depend on the channel. See
TX.rx¶ (int) – The GPIO to use for receive. The allowed values depend on the channel. See
RX.baud¶ (int) – The baud rate in bits per second, from
120to4000000.cts¶ (int) – The GPIO to use for CTS. The allowed values depend on the channel. See
CTS.rts¶ (int) – The GPIO to use for RTS. The allowed values depend on the channel. See
RTS.data_bits¶ (int) – The number of data bits, from
5to8.stop_bits¶ (int) – The number of stop bits,
1or2.parity¶ (int |
PARITY_NONE|PARITY_EVEN|PARITY_ODD) – The parity bit.
- Returns:
A tuple of the processing status and the accepted baud rate.
- Return type:
tuple(
Status, int)
- abstract async serial_read(channel: int, count: int) tuple
Reads bytes from a serial UART channel.
- abstract async serial_write(channel: int, data: bytes) tuple
Writes bytes to a serial UART channel.
- abstract async serial_close(channel: int) tuple
Closes a serial UART channel and frees the associated GPIO.
- abstract async reset() tuple
Resets the Pico device, i.e. frees GPIOs, closes I2C, SPI, serial (UART) and PWM interfaces.
All the GPIOs will be unassigned.
- Returns:
A tuple of status and None.
- Return type:
tuple(
Status, None)
- abstract async uid() tuple
Returns the unique ID of the Pico device (64-bit number).
The Raspberry Pico does not have an on-board unique identifier as all instances of RP2040 silicon are identical and have no persistent state. However, the Pico boots from serial NOR flash devices which have a 64-bit unique ID as a standard feature, and there is a 1:1 association between the Pico device and the flash, so this is suitable for use as a unique identifier.
- Returns:
A tuple of status and the UID.
- Return type:
tuple(
Status, int)
- abstract async sleep(time_s: float) tuple
Sleeps the Pico device for the given duration in seconds.
Sleeping the Pico device may be useful if you are expecting a burst of GPIO level changes. Sleeping will help prevent USB activity during the burst, minimizing lost GPIO level changes.
Constants and defaults
- class gpiosvr.client_picod.GpioFunction(value)
int values representing the functions of specific GPIOs.
- XIP = 0
- SPI = 1
- UART = 2
- I2C = 3
- PWM = 4
- GPIO = 5
- PIO0 = 6
- PIO1 = 7
- GPCK = 8
- USB = 9
- NULL = 15
- class gpiosvr.client_picod.Status(value)
int values representing the processing status of a request.
- OKAY = 0
- BAD_CHANNEL = 1
- CHANNEL_CLOSED = 2
- NO_REPLY = 7
- GPIO_IN_USE = 8
- TIMED_OUT = 10
- ERROR = -1
- class gpiosvr.client_picod.Uart(value)
Constants for the initialization of UART channels.
- TX = ((0, 12, 16, 28, 255), (4, 8, 20, 24, 255))
- RX = ((1, 13, 17, 29, 255), (5, 9, 21, 25, 255))
- CTS = ((2, 14, 18, 255), (6, 10, 22, 26, 255))
- RTS = ((3, 15, 19, 255), (7, 11, 23, 27, 255))
- PARITY_NONE = 0
- PARITY_EVEN = 1
- PARITY_ODD = 2