API reference¶
- class trio_serial.abstract.AbstractSerialStream(port, *, exclusive=False, baudrate=115200, bytesize=8, parity=<Parity.NONE: 1>, stopbits=<StopBits.ONE: 1>, xonxoff=False, rtscts=False)[source]¶
Operating system independant public interface of
SerialStream
.Create new SerialStream object.
- Parameters
port (str) – Name of port. Format depends on implementation. This could be “/dev/ttyUSB0” on Linux or “COM7” on Windows.
exclusive (bool) – Lock port for exclusive use
baudrate (int) – Initial Port speed
bytesize (int) – Number of bits per byte
parity (Parity) – Parity
stopbits (StopBits) – Number of stop bits
xonxoff (bool) – Software Flow Control with XON/XOFF
rtscts (bool) – Hardware Flow Control with RTS/CTS
- Return type
None
- abstractmethod await aclose()[source]¶
Cleanly close the port.
Do nothing if already closed.
- Return type
None
- abstractmethod await aopen()[source]¶
Open the port and configure it with the initial state from
__init__()
.- Return type
None
- abstractmethod await get_cts()[source]¶
Retrieve current Clear To Send state.
- Returns
Current CTS state
- Return type
bool
- abstractmethod await get_hangup()[source]¶
Retrieve current Hangup on Close state.
- Returns
Current Hangup on Close state
- Return type
bool
- abstractmethod await get_rts()[source]¶
Retrieve current Ready To Send state.
- Returns
Current RTS state
- Return type
bool
- property port: str¶
Get the port name.
- Returns
port name or device
- await receive_some(max_bytes=None)[source]¶
Receive between 1 and
max_bytes
bytes from the serial port.- Parameters
max_bytes (Optional[int]) – Maximum number of bytes to receive.
- Return type
bytes
- await send_all(data)[source]¶
Send
data
to the serial port. :param data: Data to send- Parameters
data (ByteString) –
- Return type
None
- abstractmethod await send_break(duration=0.25)[source]¶
Transmit a continuous stream of zero-valued bits for a specific duration.
- Params:
duration: Number of seconds
- Parameters
duration (float) –
- Return type
None
- abstractmethod await set_hangup(value)[source]¶
Set Hangup on Close state.
- Parameters
value (bool) – New Hangup on Close state
- Return type
None