htLib.bserial module

class htLib.bserial.BSerial(**kwargs)

Bases: serial.serialposix.Serial

Class makes the connection, sends data and receives data from serial port.

Parameters

Serial (Serial) – inherits from Serial class

__init__(**kwargs)

constructor of Serial. see more information: init from Serial.

Parameters

**kwargs (see in https://pyserial.readthedocs.io/en/latest/pyserial_api.html.) – like in init Serial in pyserial.

Example: port=’COM3’, baudrate=9600

property separator: str

It works with start_read_string_port

Getter

Returns separator

Setter

Sets separator

Type

str

start_read_string_port(function: Callable[[list], None])

start read on port

Parameters

callable (Callable[[list], None]) – set value to this callable

stop_read_string_port()

method to stop receiving values

property terminator: str

It works with write_string_port

Getter

Return terminator

Setter

Sets terminator

Type

str

property value_received: Optional[list]

get value received after to call start_read_string_port

Returns

If there are data in port return a list with values received. If not return None

Return type

list or None

write_string_port(value)

write string like bytes in serial port.

Parameters

value (list or None) – send value to serial port. It will be converted to string, you have to control it.