9. cc_serial

9.1. Communication Channel Via Serial

module

cc_serial

synopsis

Serial communication channel

class pykiso.lib.connectors.cc_serial.ByteSize(value)[source]

An enumeration.

class pykiso.lib.connectors.cc_serial.CCSerial(port, baudrate=9600, bytesize=ByteSize.EIGHT_BITS, parity=Parity.PARITY_NONE, stopbits=StopBits.STOPBITS_ONE, timeout=None, xonxoff=False, rtscts=False, write_timeout=None, dsrdtr=False, inter_byte_timeout=None, exclusive=None, **kwargs)[source]

Connector for serial devices

Init Serial settings

Parameters
  • port (str) – Device name (e.g. “COM1” for Windows or “/dev/ttyACM0” for Linux)

  • baudrate (int) – Baud rate such as 9600 or 115200 etc, defaults to 9600

  • bytesize (ByteSize) – Number of data bits. Possible values: FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS, defaults to EIGHTBITS

  • parity (Parity) – Enable parity checking. Possible values: PARITY_NONE, PARITY_EVEN, PARITY_ODD PARITY_MARK, PARITY_SPACE, defaults to PARITY_NONE

  • stopbits (StopBits) – Number of stop bits. Possible values: STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO, defaults to STOPBITS_ONE

  • timeout (Optional[float]) – Set a read timeout value in seconds, defaults to None

  • xonxoff (bool) – Enable software flow contro, defaults to False

  • rtscts (bool) – Enable hardware (RTS/CTS) flow control, defaults to False

  • write_timeout (Optional[float]) – Set a write timeout value in seconds, defaults to None

  • dsrdtr (bool) – Enable hardware (DSR/DTR) flow control, defaults to False

  • inter_byte_timeout (Optional[float]) – Inter-character timeout, None to disable, defaults to None

  • exclusive (Optional[bool]) – Set exclusive access mode (POSIX only). A port cannot be opened in exclusive access mode if it is already open in exclusive access mode., defaults to None

_cc_close()[source]

Close serial port

Return type

None

_cc_open()[source]

Open serial port

Return type

None

_cc_receive(timeout=1e-05, raw=True)[source]

Read bytes from the serial port. Try to read one byte in blocking mode. After blocking read check remaining bytes and read them without a blocking call.

Parameters
  • timeout – timeout in seconds, 0 for non blocking read, defaults to 0.00001

  • raw (bool) – raw mode only, defaults to True

Raises

NotImplementedError – if raw is to True

Return type

Dict[str, bytes]

Returns

received bytes

_cc_send(msg, raw=True, timeout=None)[source]

Sends data to the serial port

Parameters
  • msg (ByteString) – data to send

  • raw (bool) – unused

  • timeout (Optional[float]) – write timeout in seconds. None sets it to blocking, defaults to None

Raises

SerialTimeoutException - In case a write timeout is configured for the port and the time is exceeded.

Return type

None

class pykiso.lib.connectors.cc_serial.Parity(value)[source]

An enumeration.

_member_type_

alias of str

class pykiso.lib.connectors.cc_serial.StopBits(value)[source]

An enumeration.