serialinterface.h
Go to the documentation of this file.
1 
7 #ifndef SERIALINTERFACE_H
8 #define SERIALINTERFACE_H
9 
10 #include <serial/serial.h>
11 #include <string>
12 #include <dirent.h>
13 #include <stdlib.h>
14 #include <unistd.h>
15 
25 {
26 public:
32  {
33  static SerialInterface _instance;
34  return _instance;
35  }
46  void setBaudRate(unsigned int baudRate);
51  void setDeviceTag(const std::string& deviceTag);
59  void setSerialTimeout(unsigned int serialTimeout);
67  void setMaxLineLength(unsigned int maxLineLength);
72  void setSerialDevicesFolder(const std::string& serialDevicesFolder);
77  void connect();
83  void send(std::string& message);
90  void read(std::string& message, std::string& delimiter);
95  void disconnect();
96 
97 private:
98  // private class attributes
99  unsigned int baudRate;
100  std::string deviceTag;
101  unsigned int serialTimeout;
102  unsigned int maxLineLength;
103  std::string serialDevicesFolder;
104  serial::Serial serialConnection;
105  // private methods & constructors
109  SerialInterface();
118 
119  void findDeviceName(std::string& deviceName);
120 };
121 
122 #endif // SERIALINTERFACE_H
static SerialInterface & instance()
Returns a singleton auf this class.
serial::Serial serialConnection
unsigned int serialTimeout
void setSerialTimeout(unsigned int serialTimeout)
Setter for the serial timeout.
void setMaxLineLength(unsigned int maxLineLength)
Setter for the maximum line length.
SerialInterface & operator=(const SerialInterface &)
SerialInterface default assign operator.
unsigned int baudRate
void disconnect()
try to close the connection to the serial device
std::string serialDevicesFolder
unsigned int maxLineLength
void setBaudRate(unsigned int baudRate)
Setter for the baudrate, which defines the bandwith of the communication.
void findDeviceName(std::string &deviceName)
~SerialInterface()
SerialInterface default destructor.
SerialInterface()
SerialInterface default constructor.
void setDeviceTag(const std::string &deviceTag)
Setter for the device tag, which is an identifier a the connected serial device.
void connect()
try to open a connection to the serial device
void setSerialDevicesFolder(const std::string &serialDevicesFolder)
Setter for the path to the devices folder.
void send(std::string &message)
try to send a message to the serial device
The SerialInterface class provides an interface to a connected serial device.
void read(std::string &message, std::string &delimiter)
read a message from the serial input buffer
std::string deviceTag


pses_ucbridge
Author(s): Sebastian Ehmes
autogenerated on Sat Oct 28 2017 19:16:13