The serial module¶
This is a bus module intended to communicate through serial devices such as RS-232 or USB ports.
See documentation of buses for details of its behavior.
API¶
-
cmd_serial.
init_serial
(serial_id, conf_string)[source]¶ Initialize a serial link.
conf_string must include either:
vendor and product: vendor and product id’s of a USB device
or
device: UNIX device name. e.g.: /dev/ttyUSB0
it can optionally include:
- serialnum: serial number of the USB device.
- baudrate: rate in bits per second
- bytesize: byte size in bits
- stopbits: number of stop bits (1, 1.5 or 2)
- parity: parity (N, E, O, M or S for None, Even, Odd, Mark and Space)
- timeout: default timeout in seconds for this link. Can be float.
-
cmd_serial.
write_bin_serial
(serial_id, data)[source]¶ Write binary data to serial link serial_id. data is a string where each character represents 4 bits in hexadecimal base. Little endian for each group of 8 bits.
-
cmd_serial.
read_serial
(serial_id, bytes_to_read, timeout='undef')[source]¶ Read up to bytes_to_read bytes from serial link serial_id
-
cmd_serial.
read_bin_serial
(serial_id, bytes_to_read, timeout='undef')[source]¶ Read up to bytes_to_read bytes from serial link serial_id in binary format. The data read is encoded by blocks of 8 bits with two hexadecimal characters little endian.
-
cmd_serial.
read_until_serial
(serial_id, eot, timeout='undef')[source]¶ Read from serial link serial_id until a character from eot comma-separated list is found
-
cmd_serial.
read_bin_until_serial
(serial_id, eot, timeout='undef')[source]¶ Read from serial link serial_id until a character from eot comma-separated list is found. The data read is encoded by blocks of 8 bits with two hexadecimal characters little endian.
-
cmd_serial.
wrnrd_serial
(serial_id, data, bytes_to_read, timeout='undef')[source]¶ Write and read data to and from serial link serial_id
-
cmd_serial.
wrnrd_bin_serial
(serial_id, data, bytes_to_read, timeout='undef')[source]¶ Write and read binary data to and from serial link serial_id. data is a string where each character represents 4 bits in hexadecimal base. Little endian for each group of 8 bits.
-
cmd_serial.
wrnrd_until_serial
(serial_id, data, eot, timeout='undef')[source]¶ Write and read data to and from serial link serial_id until a character from comma-separated list eot is found
-
cmd_serial.
wrnrd_bin_until_serial
(serial_id, data, eot, timeout='undef')[source]¶ Write and read data to and from serial link serial_id until a character from comma-separated list eot is found. data is a string where each character represents 4 bits in hexadecimal base. Little endian for each group of 8 bits. Read data is return in the same format.