uart
¶
CLI reference¶
glasgow run uart¶
Transmit and receive data via UART.
Any baud rate is supported. Only 8 data bits and 1 stop bits are supported, with configurable parity.
The automatic baud rate determination algorithm works by locking onto the shortest bit time in the receive stream. It will determine the baud rate incorrectly in presence of glitches as well as insufficiently diverse data (e.g. when receiving data consisting only of the letter “a”, the baud rate that is determined will be one half of the actual baud rate). To reduce spurious baud rate changes, the algorithm is only consulted when frame or (if enabled) parity errors are present in received data.
usage: glasgow run uart [-h] [-V SPEC] [--rx PIN] [--tx PIN] [--parity PARITY]
[-b RATE] [-a]
OPERATION ...
- -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’)
- --rx <pin>¶
bind the applet I/O line ‘rx’ to PIN (default: ‘A0’, optional)
- --tx <pin>¶
bind the applet I/O line ‘tx’ to PIN (default: ‘A1’, optional)
- --parity {none,zero,one,odd,even}¶
send and receive parity bit as PARITY (default: none)
- -b <rate>, --baud <rate>¶
set baud rate to RATE bits per second (default: 115200)
- -a, --auto-baud¶
automatically estimate baud rate in response to RX errors
glasgow run uart pty¶
usage: glasgow run uart pty [-h]
- -h, --help¶
show this help message and exit
glasgow run uart socket¶
usage: glasgow run uart socket [-h] ENDPOINT
- endpoint¶
listen at ENDPOINT, either unix:PATH or tcp:HOST:PORT
- -h, --help¶
show this help message and exit
glasgow run uart tty¶
usage: glasgow run uart tty [-h] [-s]
- -h, --help¶
show this help message and exit
- -s, --stream¶
continue reading from I/O port even after an end-of-file condition on stdin
API reference¶
- class glasgow.applet.interface.uart.UARTInterface(logger: Logger, assembly: AbstractAssembly, *, rx: GlasgowPin | None, tx: GlasgowPin | None, parity: Literal['none', 'zero', 'one', 'odd', 'even'] = 'none')¶
- async get_baud()¶
Returns the baud rate used by the UART, whether manually or automatically configured.
- async set_baud(baud)¶
Configures baud rate to
baud
bits per second, overriding any automatically detected baud rate.
- async use_auto_baud()¶
Configures UART to automatically determine baud rate from incoming bit stream.
- async read(length: int, *, flush=True) memoryview ¶
Reads one or more bytes from the UART. If
flush
is true, transmits any buffered writes before starting to receive.
- async read_all(*, flush=True) memoryview ¶
Reads all buffered bytes from the UART, but no less than one byte. If
flush
is true, transmits any buffered writes before starting to read.
- async read_until(trailer: bytes | Tuple[bytes, ...]) memoryview ¶
Reads bytes from the UART until
trailer
, which can be a single byte sequence or a choice of multiple byte sequences, is encountered. The return value includes the trailer.
- async write(data: bytes | bytearray | memoryview, *, flush=False)¶
Buffers bytes to be transmitted. Until
flush()
is called, bytes are not guaranteed to be transmitted (they may or may not be).
- async flush()¶
Transmits all buffered bytes from the UART.
- async monitor(*, interval=1.0)¶
Logs receive errors and automatic baud rate changes.