diff options
author | RITUait | 2018-06-02 19:23:20 +0530 |
---|---|---|
committer | RITUait | 2018-06-02 19:23:20 +0530 |
commit | 5d49ecc930d6428512798f4bdb1cb8b1bb816ca5 (patch) | |
tree | 682a3a752313e666de47d365c2029b130f916590 /Source/serial.h | |
parent | c4223ee955f9af546b9ece9a0ef8d77f9c8b03d8 (diff) | |
parent | fefaf700250d88595273b038909fe95d7602d125 (diff) | |
download | OpenModelicaEmbedded-5d49ecc930d6428512798f4bdb1cb8b1bb816ca5.tar.gz OpenModelicaEmbedded-5d49ecc930d6428512798f4bdb1cb8b1bb816ca5.tar.bz2 OpenModelicaEmbedded-5d49ecc930d6428512798f4bdb1cb8b1bb816ca5.zip |
resolved issues between master and Ritu-Kanwar-Shekhawat branch
Diffstat (limited to 'Source/serial.h')
-rwxr-xr-x | Source/serial.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Source/serial.h b/Source/serial.h new file mode 100755 index 0000000..e49b4a7 --- /dev/null +++ b/Source/serial.h @@ -0,0 +1,57 @@ +#ifndef __serial_h__ +#define __serial_h__ + +#include <stdint.h> + +#if defined(LINUX) +#include <termios.h> +#elif defined(MACOSX) +#include <termios.h> +#elif defined(WINDOWS) +#include <windows.h> +#endif + +#include <vector> +#include <string> +#include <sstream> +#include <algorithm> + +using namespace std; + +class Serial +{ +public: + Serial(); + ~Serial(); + vector<string> port_list(); + int Open(const string& name); + string error_message(); + int Set_baud(int baud); + int Set_baud(const string& baud_str); + int Read(void *ptr, int count); + int Write(const void *ptr, int len); + int Input_wait(int msec); + void Input_discard(void); + int Set_control(int dtr, int rts); + void Output_flush(); + void Close(void); + int Is_open(void); + string get_name(void); +private: + int port_is_open; + string port_name; + int baud_rate; + string error_msg; +private: +#if defined(LINUX) || defined(MACOSX) + int port_fd; + struct termios settings_orig; + struct termios settings; +#elif defined(WINDOWS) + HANDLE port_handle; + COMMCONFIG port_cfg_orig; + COMMCONFIG port_cfg; +#endif +}; + +#endif // __serial_h__ |