-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSerialControl.h
51 lines (40 loc) · 1017 Bytes
/
SerialControl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* @file SerialControl.h
* @Author BeeeOn team - Peter Tisovcik <[email protected]>
* @date August, 2016
* @brief This class implements work with serial port. Opens and closes
* the serial port reads and writes data to the serial port.
*/
#ifndef SERIAL_OPEN_MODULE_H
#define SERIAL_OPEN_MODULE_H
#include <string>
#include <Poco/Mutex.h>
class SerialControl {
public:
SerialControl(std::string serialDevice);
~SerialControl();
bool isValidFd();
bool initSerial();
/*
* It is safe to call even after closure
*/
void closeSerial();
/*
* This will send message to Dongle. Failed transmission
* must be handled at a higher layer.
* @param &data text to be sent
* @return If the message was sent successfully
*/
bool ssend(const std::string& data);
/*
* This will read message from Dongle.
* @return Read message
*/
std::string sread();
private:
Poco::Mutex _mutex;
int m_serialFd;
std::string m_serialDevice;
int sopen();
};
#endif /*SERIAL_OPEN_MODULE_H*/