Developmental Flight Test Instrumentation
Public Slots | Public 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:
dfti::Autopilot dfti::RIO dfti::uADC dfti::VN200

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 Attributes

Settingssettings = 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.
 
QSerialPort * _port = nullptr
 Serial port object.
 

Detailed Description

Base class for interfacing with sensors over a serial port (UART/RS-232).

Constructor & Destructor Documentation

dfti::SerialSensor::SerialSensor ( Settings _settings,
QObject *  _parent = nullptr 
)
inlineexplicit

Constructor.

Parameters
_settingsPointer to settings object.
_parentPointer to parent QObject.

Member Function Documentation

void dfti::SerialSensor::configureSerial ( QString  _portName)

Set the serial port parameters.

Parameters
_portNameThe serial port name.
bool dfti::SerialSensor::isOpen ( void  )

Returns true if the serial port is open.

Returns
True if the serial port is open.
void dfti::SerialSensor::open ( void  )
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
rateThe 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.

The documentation for this class was generated from the following files: