# eric7.MicroPython.MicroPythonSerialPort

Module implementing a QSerialPort with additional functionality for MicroPython devices.

### Global Attributes

None

### Classes

MicroPythonSerialPort | Class implementing a QSerialPort with additional functionality for MicroPython devices.

### Functions

None

## MicroPythonSerialPort

Class implementing a QSerialPort with additional functionality for MicroPython devices.

### Derived from

QSerialPort

### Class Attributes

None

### Class Methods

None

### Methods

MicroPythonSerialPort | Constructor
closeSerialLink | Public method to close the open serial connection.
hasTimedOut | Public method to check, if the last 'readUntil' has timed out.
isConnected | Public method to get the connection state.
openSerialLink | Public method to open a serial link to a given serial port.
readUntil | Public method to read data until an expected sequence is found (default: \n) or a specific size is exceeded.
setTimeout | Public method to set the timeout for device operations.

### Static Methods

None

#### MicroPythonSerialPort (Constructor)

MicroPythonSerialPort(timeout=10000, parent=None)

Constructor

timeout (int)
  timout in milliseconds to be set
parent (QObject)
  reference to the parent object

#### MicroPythonSerialPort.closeSerialLink

closeSerialLink()

Public method to close the open serial connection.

#### MicroPythonSerialPort.hasTimedOut

hasTimedOut()

Public method to check, if the last 'readUntil' has timed out.

Return:
  flag indicating a timeout

Return Type:
  bool

#### MicroPythonSerialPort.isConnected

isConnected()

Public method to get the connection state.

Return:
  flag indicating the connection state

Return Type:
  bool

#### MicroPythonSerialPort.openSerialLink

openSerialLink(port)

Public method to open a serial link to a given serial port.

port (str)
  port name to connect to

Return:
  flag indicating success and an error message

Return Type:
  tuple of (bool, str)

#### MicroPythonSerialPort.readUntil

readUntil(expected=b"\n", size=None, timeout=0)

Public method to read data until an expected sequence is found (default: \n) or a specific size is exceeded.

expected (bytes)
  expected bytes sequence
size (int (optional))
  maximum data to be read (defaults to None)
timeout (int (optional))
  timeout in milliseconds (0 for configured default) (defaults to 0)

Return:
  bytes read from the device including the expected sequence

Return Type:
  bytes

#### MicroPythonSerialPort.setTimeout

setTimeout(timeout)

Public method to set the timeout for device operations.

timeout (int)
  timout in milliseconds to be set

Up