The SerialInterface class provides an interface to a connected serial device. More...
#include <serialinterface.h>
Public Member Functions | |
| void | connect () |
| try to open a connection to the serial device More... | |
| void | disconnect () |
| try to close the connection to the serial device More... | |
| void | read (std::string &message, std::string &delimiter) |
| read a message from the serial input buffer More... | |
| void | send (std::string &message) |
| try to send a message to the serial device More... | |
| void | setBaudRate (unsigned int baudRate) |
| Setter for the baudrate, which defines the bandwith of the communication. More... | |
| void | setDeviceTag (const std::string &deviceTag) |
| Setter for the device tag, which is an identifier a the connected serial device. More... | |
| void | setMaxLineLength (unsigned int maxLineLength) |
| Setter for the maximum line length. More... | |
| void | setSerialDevicesFolder (const std::string &serialDevicesFolder) |
| Setter for the path to the devices folder. More... | |
| void | setSerialTimeout (unsigned int serialTimeout) |
| Setter for the serial timeout. More... | |
| ~SerialInterface () | |
| SerialInterface default destructor. More... | |
Static Public Member Functions | |
| static SerialInterface & | instance () |
| Returns a singleton auf this class. More... | |
Private Member Functions | |
| void | findDeviceName (std::string &deviceName) |
| SerialInterface & | operator= (const SerialInterface &) |
| SerialInterface default assign operator. More... | |
| SerialInterface () | |
| SerialInterface default constructor. More... | |
| SerialInterface (const SerialInterface &) | |
| SerialInterface default copy constructor. More... | |
Private Attributes | |
| unsigned int | baudRate |
| std::string | deviceTag |
| unsigned int | maxLineLength |
| serial::Serial | serialConnection |
| std::string | serialDevicesFolder |
| unsigned int | serialTimeout |
The SerialInterface class provides an interface to a connected serial device.
This class follows the singleton pattern paradigm. For object instatiation call the instance methond, wich returns a singleton of this class.
Definition at line 24 of file serialinterface.h.
|
inline |
SerialInterface default destructor.
Definition at line 39 of file serialinterface.h.
|
private |
SerialInterface default constructor.
<SerialConnection object.
Definition at line 10 of file serialinterface.cpp.
|
private |
SerialInterface default copy constructor.
| void SerialInterface::connect | ( | ) |
try to open a connection to the serial device
| std::exception |
Definition at line 39 of file serialinterface.cpp.
| void SerialInterface::disconnect | ( | ) |
try to close the connection to the serial device
| std::exception |
Definition at line 70 of file serialinterface.cpp.
|
private |
Definition at line 77 of file serialinterface.cpp.
|
inlinestatic |
Returns a singleton auf this class.
Definition at line 31 of file serialinterface.h.
|
private |
SerialInterface default assign operator.
| void SerialInterface::read | ( | std::string & | message, |
| std::string & | delimiter | ||
| ) |
read a message from the serial input buffer
| [out] | message | received message |
| [in] | delimiter | stop symbol for the input buffer parser |
| std::exception |
Definition at line 62 of file serialinterface.cpp.
| void SerialInterface::send | ( | std::string & | message | ) |
try to send a message to the serial device
| [in] | message | message to be transmitted |
| std::exception |
Definition at line 52 of file serialinterface.cpp.
| void SerialInterface::setBaudRate | ( | unsigned int | baudRate | ) |
Setter for the baudrate, which defines the bandwith of the communication.
For a serial connection using the UART protocol baudrate equals bit/s.
| [in] | baudRate | in Baud per second |
Definition at line 19 of file serialinterface.cpp.
| void SerialInterface::setDeviceTag | ( | const std::string & | deviceTag | ) |
Setter for the device tag, which is an identifier a the connected serial device.
| [in] | deviceTag | identifier of the serial device |
Definition at line 23 of file serialinterface.cpp.
| void SerialInterface::setMaxLineLength | ( | unsigned int | maxLineLength | ) |
Setter for the maximum line length.
What is the maximum amount of symbols that can be retrieved from the serial input buffer in one go.
| [in] | maxLineLength | amount of symbols in a single frame |
Definition at line 31 of file serialinterface.cpp.
| void SerialInterface::setSerialDevicesFolder | ( | const std::string & | serialDevicesFolder | ) |
Setter for the path to the devices folder.
| [in] | serialDeviceFolger | path where the serial devices are located in an OS |
Definition at line 35 of file serialinterface.cpp.
| void SerialInterface::setSerialTimeout | ( | unsigned int | serialTimeout | ) |
Setter for the serial timeout.
How long should the interface wait for activity on the serial connection befor a retry is attempted?
| [in] | serialTimeout | timeout in milliseconds |
Definition at line 27 of file serialinterface.cpp.
|
private |
Baudrate which defines the bandwith of the communication
Definition at line 99 of file serialinterface.h.
|
private |
Device tag which is an identifier a the connected serial device
Definition at line 100 of file serialinterface.h.
|
private |
<Max interface wait time for activity.
Definition at line 102 of file serialinterface.h.
|
private |
<Path to the serial devices folder.
Definition at line 104 of file serialinterface.h.
|
private |
<Max amount of symbols in a line.
Definition at line 103 of file serialinterface.h.
|
private |
Definition at line 101 of file serialinterface.h.