HLR  0.0.1
Serial.hpp
1 #ifndef KINEMATICS_RV2AJ_DRIVER_SERIAL_HPP
2 #define KINEMATICS_RV2AJ_DRIVER_SERIAL_HPP
3 
4 #include <string>
5 
6 namespace HLR
7 {
8 namespace Kinematics
9 {
10 namespace RV2AJ
11 {
13 class Serial
14 {
15 public:
17  Serial() = default;
18 
23  virtual ~Serial();
24 
29  Serial(const Serial& s) = delete;
30 
35  Serial(Serial&& s) = delete;
36 
42  Serial& operator=(const Serial& s) = delete;
43 
49  Serial& operator=(Serial&& s) = delete;
50 
60  void open(const std::string& dev);
61 
66  void close();
67 
72  bool opened() const;
73 
81  std::string read(char delim);
82 
90  void write(const std::string& msg);
91 
92 private:
94  int fd = -1;
95 };
96 
97 } // namespace RV2AJ
98 } // namespace Kinematics
99 } // namespace HLR
100 
101 #endif // KINEMATICS_RV2AJ_DRIVER_SERIAL_HPP
Serial()=default
Constructor.
OO wrapper around POSIX serial devices.
Definition: Serial.hpp:13
void write(const std::string &msg)
Writes message to open serial device.
bool opened() const
Returns whether serial device is open.
virtual ~Serial()
Destructor.
std::string read(char delim)
Reads message from open serial device up to (including) delimiter.
void close()
Closes active serial device.
Serial & operator=(const Serial &s)=delete
Copy assignment operator, deleted.
void open(const std::string &dev)
Open specified serial device.