Public Slots |
Public Member Functions |
Protected Member Functions |
Protected Attributes |
List of all members
dfti::SerialSensor Class Referenceabstract
Base class for interfacing with sensors over a serial port (UART/RS-232). More...
#include <serialsensor.hh>
Inheritance diagram for dfti::SerialSensor:

Collaboration diagram for dfti::SerialSensor:

Public Slots | |
virtual void | readData (void)=0 |
Slot to read in data over serial and parse complete packets. | |
Public Member Functions | |
SerialSensor (Settings *_settings, QObject *_parent=nullptr) | |
Constructor. More... | |
~SerialSensor () | |
Destructor. | |
void | configureSerial (QString _portName) |
Set the serial port parameters. More... | |
void | init () |
Initialize the serial port. | |
bool | isOpen (void) |
Returns true if the serial port is open. More... | |
virtual void | open (void) |
Opens the serial port. More... | |
void | setBaudRate (quint32 rate) |
Set the serial port baud rate. More... | |
void | threadStart (void) |
Start the sensor in a thread. | |
Protected Member Functions | |
QString | validateSerialPort (QString _port) |
Validates a proposed serial port. More... | |
Protected Attributes | |
QPointer< Settings > | settings = nullptr |
Settings object. | |
QString | portName {""} |
Serial port name. | |
QSerialPort::BaudRate | baudRate {QSerialPort::Baud115200} |
Serial port baud rate. | |
bool | _valid_serial = false |
Indicates if serial port passed validation. | |
QPointer< QSerialPort > | _port = nullptr |
Serial port object. | |
Detailed Description
Base class for interfacing with sensors over a serial port (UART/RS-232).
Constructor & Destructor Documentation
|
inlineexplicit |
Constructor.
- Parameters
-
_settings Pointer to settings object. _parent Pointer to parent QObject.
Member Function Documentation
void dfti::SerialSensor::configureSerial | ( | QString | _portName | ) |
Set the serial port parameters.
- Parameters
-
_portName The serial port name.
bool dfti::SerialSensor::isOpen | ( | void | ) |
Returns true if the serial port is open.
- Returns
- True if the serial port is open.
|
virtual |
Opens the serial port.
Since we may not initially know which serial port corresponds to which sensor, we need to wait to open the serial port associated with the sensor until we know which port it is. Once we do, we call this open method to start reading the serial port.
Reimplemented in dfti::Autopilot.
void dfti::SerialSensor::setBaudRate | ( | quint32 | rate | ) |
Set the serial port baud rate.
- Parameters
-
rate The serial port baud rate. Must be one of 57600, 115200.
- Remarks
- If an unsupported baud rate is given, the sensor falls back to 57600 baud.
|
protected |
Validates a proposed serial port.
Checks to see if the given serial port name is a valid serial port.
- Parameters
-
_port Proposed serial port.
- Returns
- True if the port name corresponds to a valid system serial port.
The documentation for this class was generated from the following files: