aboutsummaryrefslogtreecommitdiff
path: root/SerialPort/SerialPortUnix.hpp
diff options
context:
space:
mode:
authorJán Sučan <sucanjan@fit.cvut.cz>2017-05-10 15:13:29 +0200
committerJán Sučan <sucanjan@fit.cvut.cz>2017-05-10 15:13:29 +0200
commit02e24f0f533fe904c3a5275c4060c10c38d7c17a (patch)
tree19d05c60e3d6a6782c4712de960a8f6705054063 /SerialPort/SerialPortUnix.hpp
Uvodny commit, subory su rovnake ako na CD prilozenom k vytlacenemu texu bakalarskej prace, naviac je pridany len subor LICENCIA
Diffstat (limited to 'SerialPort/SerialPortUnix.hpp')
-rwxr-xr-xSerialPort/SerialPortUnix.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/SerialPort/SerialPortUnix.hpp b/SerialPort/SerialPortUnix.hpp
new file mode 100755
index 0000000..db1ae73
--- /dev/null
+++ b/SerialPort/SerialPortUnix.hpp
@@ -0,0 +1,35 @@
+#ifndef SERIAL_PORT_UNIX_H
+#define SERIAL_PORT_UNIX_H 1
+
+#include <termios.h>
+
+#include <vector>
+#include "SerialPort.hpp"
+
+using std::vector;
+using std::pair;
+
+class CSerialPortUnix : public CSerialPort {
+private:
+ int mSerialPortFd;
+ string mPortName;
+ vector< pair<string, speed_t> > mBaudrates;
+
+ vector<pair<string, speed_t>> getDeviceSpeeds();
+ pair<string, speed_t> findSpeed(string speed, const vector<pair<string, speed_t>> & list);
+ void setSpeed(pair<string, speed_t> speed);
+ void openPort(string portName);
+
+ ssize_t readSingle(uint8_t *data, int data_length);
+ ssize_t writeSingle(uint8_t *data, int data_length);
+public:
+ CSerialPortUnix();
+ ~CSerialPortUnix();
+
+ void open(string portName, string speed);
+ string getSpeeds(string portName);
+
+ void close();
+};
+
+#endif