diff options
| author | Ján Sučan <sucanjan@fit.cvut.cz> | 2017-05-10 15:13:29 +0200 |
|---|---|---|
| committer | Ján Sučan <sucanjan@fit.cvut.cz> | 2017-05-10 15:13:29 +0200 |
| commit | 02e24f0f533fe904c3a5275c4060c10c38d7c17a (patch) | |
| tree | 19d05c60e3d6a6782c4712de960a8f6705054063 /SerialPort/SerialPortWin32.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/SerialPortWin32.hpp')
| -rwxr-xr-x | SerialPort/SerialPortWin32.hpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/SerialPort/SerialPortWin32.hpp b/SerialPort/SerialPortWin32.hpp new file mode 100755 index 0000000..2cba0f7 --- /dev/null +++ b/SerialPort/SerialPortWin32.hpp @@ -0,0 +1,49 @@ +#ifndef SERIAL_PORT_WIN32_H +#define SERIAL_PORT_WIN32_H 1 + +#include <windows.h> +#include <list> +#include "SerialPort.hpp" + +using std::pair; +using std::list; + +class CSerialPortWin32 : public CSerialPort { +private: + HANDLE mSerialPortH; + + struct s_speed { + string name; + DWORD key; + DWORD value; + + s_speed(string n, DWORD k, DWORD v) { + name = n; + key = k; + value = v; + } + }; + + list<struct s_speed> mMaxBaudrates; + + + void openPort(string portName); + s_speed getMaxSpeed(string portName); + void setTimeouts(int ms); + string getLastErrorAsString(); + + ssize_t readSingle(uint8_t *data, int data_length); + ssize_t writeSingle(uint8_t *data, int data_length); +public: + CSerialPortWin32(); + ~CSerialPortWin32(); + + void open(string portName, string speed); + string getSpeeds(string portName); + + void close(); + void write(uint8_t *data, int data_length, int padd_to); + void read(uint8_t *data, int data_length); +}; + +#endif |
