Class: QgsSerialPortSensor

A serial port sensor class.

Added in version 3.32.

Class Hierarchy

Inheritance diagram of qgis.core.QgsSerialPortSensor

Base classes

QgsIODeviceSensor

An abstract class for QIODevice-based sensors.

QgsAbstractSensor

An abstract base class for sensors.

QObject

Methods

baudRate

Returns the baudrate of the serial port the sensor connects to.

delimiter

Returns the current delimiter used to separate data frames.

portName

Returns the serial port the sensor connects to.

setBaudRate

Sets the baudrate of the serial port the sensor connects to.

setDelimiter

Sets the delimiter used to identify data frames out of the data received from the serial port.

setPortName

Sets the serial port the sensor connects to.

Static Methods

create

Returns a new serial port sensor.

class qgis.core.QgsSerialPortSensor[source]

Bases: QgsIODeviceSensor

__init__(parent: QObject | None = None)

Constructor for a serial port sensor, bound to the specified parent.

Parameters:

parent (Optional[QObject] = None)

baudRate(self) QSerialPort.BaudRate[source]

Returns the baudrate of the serial port the sensor connects to.

Added in version 3.36.

Return type:

QSerialPort.BaudRate

static create(parent: QObject | None) QgsSerialPortSensor | None[source]

Returns a new serial port sensor.

The caller takes responsibility for deleting the returned object.

Parameters:

parent (Optional[QObject])

Return type:

Optional[QgsSerialPortSensor]

delimiter(self) QByteArray[source]

Returns the current delimiter used to separate data frames. If empty, each serial port data update will be considered a data frame.

Added in version 3.38.

Return type:

QByteArray

portName(self) str[source]

Returns the serial port the sensor connects to.

Return type:

str

setBaudRate(self, baudRate: QSerialPort.BaudRate)[source]

Sets the baudrate of the serial port the sensor connects to.

Parameters:

baudRate (QSerialPort.BaudRate) – the baudrate (e.g. 9600)

Added in version 3.36.

setDelimiter(self, delimiter: QByteArray | bytes | bytearray)[source]

Sets the delimiter used to identify data frames out of the data received from the serial port. If empty, each serial port data update will be considered a data frame.

Parameters:

delimiter (Union[QByteArray, bytes, bytearray]) – Character used to identify data frames

Added in version 3.38.

setPortName(self, portName: str | None)[source]

Sets the serial port the sensor connects to.

Parameters:

portName (Optional[str]) – the port name (e.g. COM4)