From c4223ee955f9af546b9ece9a0ef8d77f9c8b03d8 Mon Sep 17 00:00:00 2001 From: ritu Date: Sat, 2 Jun 2018 21:14:06 +0530 Subject: simplified Pins and boards,double click issue, SynchronizeREalTime added --- OpenModelicaArduino/Source/serial.h | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 OpenModelicaArduino/Source/serial.h (limited to 'OpenModelicaArduino/Source/serial.h') diff --git a/OpenModelicaArduino/Source/serial.h b/OpenModelicaArduino/Source/serial.h new file mode 100755 index 0000000..e49b4a7 --- /dev/null +++ b/OpenModelicaArduino/Source/serial.h @@ -0,0 +1,57 @@ +#ifndef __serial_h__ +#define __serial_h__ + +#include + +#if defined(LINUX) +#include +#elif defined(MACOSX) +#include +#elif defined(WINDOWS) +#include +#endif + +#include +#include +#include +#include + +using namespace std; + +class Serial +{ +public: + Serial(); + ~Serial(); + vector 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__ -- cgit