Roomba App  1.0
Communication Class Reference

The class connecting main application and serial port. More...

#include <communication.hh>

Collaboration diagram for Communication:

Public Member Functions

 Communication ()=default
 Construct a new Communication object. More...
 
 ~Communication ()=default
 Destroy the Communication object. More...
 
void setDeviceName (const std::string &name)
 Set the serial device name. More...
 
const std::string & getDeviceName () const
 Get the serial device name. More...
 
void setDevice (QSerialPort *device)
 Set a new handle to the serial device. More...
 
bool openSerialPort (const char *serialPort)
 Open the serial port. More...
 
bool openSerialPort ()
 Wrapper function for opening a serial port. More...
 
bool closeSerialPort ()
 Close the serial port. More...
 
bool isOpen () const
 Check if the serial port is open. More...
 
FrameBufferuseFrameBuffer ()
 Get a modifiable frame from the circular buffer. More...
 
const FrameBuffergetFrameBuffer () const
 Get a unmodifiable frame from the circular buffer. More...
 
bool toContinue () const
 Check wether to continue communication with the serial device. More...
 
void endCommunication ()
 Set the end of communication flag to end communication. More...
 
void receiveData ()
 Receive line one by one from the serial device in loop until end of communication. More...
 

Private Attributes

QSerialPort * _device = nullptr
 Serial device handle. More...
 
FrameBuffer _frame
 Circular buffer for frames. More...
 
std::string _deviceName
 Serial device name. More...
 
bool _continue = true
 Identifier whether to continue communication with serial device. More...
 
bool _opened = false
 Identifier whether serial device is open. More...
 

Detailed Description

Contain handle to the serial port device and circular buffer which store individual frames from device.

Definition at line 29 of file communication.hh.

Constructor & Destructor Documentation

◆ Communication()

Communication::Communication ( )
default

Default constructor.

◆ ~Communication()

Communication::~Communication ( )
default

Default destructor.

Member Function Documentation

◆ closeSerialPort()

bool Communication::closeSerialPort ( )
Returns
Identifier wether the serial port was closed successfully.
Return values
trueSerial port closed successfully.
falseSerial port closed incorrectly.

Definition at line 42 of file communication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endCommunication()

void Communication::endCommunication ( )
inline

Definition at line 130 of file communication.hh.

Here is the caller graph for this function:

◆ getDeviceName()

const std::string& Communication::getDeviceName ( ) const
inline
Returns
Name of the serial device.

Definition at line 64 of file communication.hh.

Here is the caller graph for this function:

◆ getFrameBuffer()

const FrameBuffer& Communication::getFrameBuffer ( ) const
inline
Returns
Immutable reference to the one frame from buffer.

Definition at line 117 of file communication.hh.

Here is the caller graph for this function:

◆ isOpen()

bool Communication::isOpen ( ) const
inline
Returns
Identifier wether the serial port is open.
Return values
trueSerial port is open.
falseSerial port is closed.

Definition at line 105 of file communication.hh.

Here is the caller graph for this function:

◆ openSerialPort() [1/2]

bool Communication::openSerialPort ( )
inline
See also
openSerialPort

Definition at line 89 of file communication.hh.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openSerialPort() [2/2]

bool Communication::openSerialPort ( const char *  serialPort)

Set the serial port parameters and open it in read only mode.

Parameters
[in]serialPortThe serial port name.
Returns
Identifier wether the serial port was opened successfully.
Return values
trueSerial port opened successfully.
falseSerial port opened incorrectly.

Definition at line 21 of file communication.cpp.

Here is the caller graph for this function:

◆ receiveData()

void Communication::receiveData ( )

Definition at line 56 of file communication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDevice()

void Communication::setDevice ( QSerialPort *  device)
inline
Parameters
[in]deviceHandle to a new serial device.

Definition at line 71 of file communication.hh.

Here is the caller graph for this function:

◆ setDeviceName()

void Communication::setDeviceName ( const std::string &  name)
inline
Parameters
[in]nameNew name of the serial device.

Definition at line 57 of file communication.hh.

Here is the caller graph for this function:

◆ toContinue()

bool Communication::toContinue ( ) const
inline
Returns
Identifier wether to continue communication.
Return values
trueContinue communication.
falseEnd communication.

Definition at line 125 of file communication.hh.

◆ useFrameBuffer()

FrameBuffer& Communication::useFrameBuffer ( )
inline
Returns
Mutable reference to the one frame from buffer.

Definition at line 111 of file communication.hh.

Here is the caller graph for this function:

Member Data Documentation

◆ _continue

bool Communication::_continue = true
private

Definition at line 34 of file communication.hh.

◆ _device

QSerialPort* Communication::_device = nullptr
private

Definition at line 31 of file communication.hh.

◆ _deviceName

std::string Communication::_deviceName
private

Definition at line 33 of file communication.hh.

◆ _frame

FrameBuffer Communication::_frame
private

Definition at line 32 of file communication.hh.

◆ _opened

bool Communication::_opened = false
private

Definition at line 35 of file communication.hh.


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