A class implementing a serial port input and output.
Methods
Create a serial port input and output.
The port argument will accept the number of the port (e.g. 0 for COM1) as well as a string describing the full port location (“COM1” or “/dev/ttyS0”).
Parameters : | port : int or str
baudrate : int, optional bytesize : int, optional parity : str, optional
stopbits : int, optional timeout : int, optional
xonxoff : int, optional rtscts : int, optional dsrdtr : int, optional input_history : bool, optional
os_buffer_size : int, optional
clock : misc.Clock, optional
|
---|
Notes
An input_history can be used to overcome the size limitation of the receive buffer of the operating system. An input_history consists of a misc.ByteBuffer instance. In order to not miss any input, the serial port has to be updated regularly (i.e. calling read_input() or clear() before the receive buffer will be full). If the receive buffer size is set correctly, a warning will be given, when the input_history was not updated fast enough. Importantly, the fuller the receive buffer is, the longer clearing and polling will take (this can be more than 1 ms!), since all the bytes have to be transfered to the input_history.
Getter for baudrate.
Getter for bytesize.
Clear the serial port.
Parameters : | skip_input_history : bool, optional
|
---|
Notes
If an input_history is used, all data in the receive buffer, will be added to the history before clearing (via read_input()). Note: The copy process might take a few milliseconds. If you need a very fast clearing of the device buffer, you should skip copying the data into the input_history using the skip_input_history parameter.
Getter for clock.
Close the serial port.
Getter for dsrdtr.
Return an list of strings representing the available serial ports.
Returns : | arr : list
|
---|
Notes
If pyserial is not installed, ‘None’ will be returned.
Returns if a input_history exists or not (True / False).
Getter for input_history.
Getter for os_buffer_size.
Getter for parity.
Poll the serial port.
If a input_history is used, it will be added.
Returns : | out : byte
|
---|
Read all input from serial port.
If a input_history is used, all received data will be added.
Returns : | out : list of bytes |
---|
Read a line from serial port (until newline) and return string.
Parameters : | duration : int, optional
|
---|---|
Returns : | line : str |
Notes
The function is waiting for input. Use the duration parameter to avoid too long program blocking.
Getter for rtscts.
Send data via the serial port.
Parameters : | data : int
|
---|
Getter for serial.
Getter for stopbits.
Getter for timeout.
Getter for xonxoff.