What is on the other end of the port.
How many bytes have been read through the port.
How many steps a script has left, or null when the port is not scripted.
The speed and character format the port runs at.
How long reads have waited without an answer, and waits have waited, in microseconds, whether or not the process slept through it.
How many bytes have been written through the port.
Drops whatever has arrived and not been read, as a client does before a request so a stale reply cannot be taken for the new one.
Reads up to max bytes, waiting up to timeoutMs for the first one when nothing has
arrived. Resolves with what arrived, empty when the timeout passed with nothing.
Waits, as a protocol does to leave the line silent between frames: really on the kernel's device, and anywhere else the wait is only counted.
Writes bytes, resolving once they have left the UART. Rejects when a script expected another write, or with the kernel's reason.
StaticbitsReturns the bits one character takes on the wire: a start bit, eight data bits, the parity bit if there is one, and the stop bits.
StaticcharacterReturns how long one character takes on the wire, in nanoseconds, rounded up.
StaticdescribeWrites settings the way a device's manual does, such as 9600 8E1.
StaticloopedA line looped back on itself: every byte written is waiting to be read.
StaticopenOpens the kernel's serial device raw: /dev/serial0 for a Raspberry Pi's own UART,
/dev/ttyUSB0 or /dev/ttyACM0 for a USB adapter. Throws anywhere but Linux, for a
speed that is not a standard rate from 1200 to 921600, and when the device cannot be
opened.
StaticpairThe two ends of a null-modem pair: what one end writes, the other reads.
StaticscriptedA port that checks each write against the next step of a script, and makes the bytes the far end sends readable as the script reaches them.
StatictransferReturns how long bytes sent back to back take on the wire, in microseconds, rounded
up.
One serial port, shared by the program and every driver built on it.
SerialPort.open(path, settings)opens the kernel's serial device raw on a Linux board and throws anywhere else.SerialPort.looped(settings)is a line with TX wired to RX,SerialPort.pair(settings)the two ends of a null-modem cable, andSerialPort.scripted(settings, steps)a port that checks each write against a script.writeandreadreturn promises that reject with the reason.