31 #ifndef SERIALREADERWRITER_H_ 32 #define SERIALREADERWRITER_H_ 34 #include "../Exception.h" 35 #include "../Managers/FileDescriptorManager.h" 36 #include "../IEvents.h" 64 virtual void lineReceived(
const std::string &data) = 0;
86 bool isOpen() {
return _fileDescriptor && _fileDescriptor->descriptor != -1; }
98 void openDevice(
bool parity,
bool oddParity,
bool events =
true,
CharacterSize characterSize = CharacterSize::Eight,
bool twoStopBits =
false);
112 int32_t readLine(std::string &data, uint32_t timeout = 500000,
char splitChar =
'\n');
120 int32_t readChar(
char &data, uint32_t timeout = 500000);
126 void writeLine(std::string &data);
132 void writeData(
const std::vector<char> &data);
138 void writeData(
const std::vector<uint8_t> &data);
144 void writeChar(
char data);
149 bool _writeOnly =
false;
150 struct termios _termios;
151 int32_t _baudrate = 0;
153 int32_t _readThreadPriority = 0;
154 int32_t _handles = 0;
163 void readThread(
bool parity,
bool oddParity,
CharacterSize characterSize,
bool twoStopBits);
std::thread _openDeviceThread
Definition: SerialReaderWriter.h:161
std::atomic_bool _stopReadThread
Definition: SerialReaderWriter.h:156
std::mutex _sendMutex
Definition: SerialReaderWriter.h:159
This is the base library main class.
Definition: BaseLib.h:95
SerialReaderWriterException(std::string message)
Definition: SerialReaderWriter.h:49
Definition: BaseLib.cpp:34
CharacterSize
Definition: SerialReaderWriter.h:54
std::shared_ptr< FileDescriptor > _fileDescriptor
Definition: SerialReaderWriter.h:147
bool isOpen()
Definition: SerialReaderWriter.h:86
Definition: SerialReaderWriter.h:52
Definition: SerialReaderWriter.h:62
std::mutex _readThreadMutex
Definition: SerialReaderWriter.h:157
Definition: SerialReaderWriter.h:47
std::thread _readThread
Definition: SerialReaderWriter.h:158
Base class for all exceptions defined in Homegear.
Definition: Exception.h:41
std::mutex _openDeviceThreadMutex
Definition: SerialReaderWriter.h:160
std::shared_ptr< FileDescriptor > fileDescriptor()
Definition: SerialReaderWriter.h:87
std::string _device
Definition: SerialReaderWriter.h:148