rs232-cygwin.h
Go to the documentation of this file.
1 //======================================================================
28 //======================================================================
29 
30 #ifndef RS232_CYGWIN_H_
31 #define RS232_CYGWIN_H_
32 
33 //----------------------------------------------------------------------
34 // System Includes - include with <>
35 //----------------------------------------------------------------------
36 
37 #include <string>
38 #include <termios.h>
39 
40 //----------------------------------------------------------------------
41 // Project Includes - include with ""
42 //----------------------------------------------------------------------
43 
44 #include "sdhexception.h"
45 #include "serialbase.h"
46 #include "sdhlibrary_settings.h"
47 
48 //----------------------------------------------------------------------
49 // Defines, enums, unions, structs,
50 //----------------------------------------------------------------------
51 
53 
54 
55 //----------------------------------------------------------------------
56 // Global variables
57 //----------------------------------------------------------------------
58 
59 
60 //----------------------------------------------------------------------
61 // Function and class member declarations
62 //----------------------------------------------------------------------
63 
64 
65 
66 
67 
72 {
73 public:
74  cRS232Exception( cMsg const & _msg )
75  : cSerialBaseException( "cRS232Exception", _msg )
76  {}
77 };
78 //======================================================================
79 
80 
84 class cRS232 : public cSerialBase
85 {
86 
87 protected:
89  int port;
90 
92  std::string device_format_string;
93 
95  unsigned long baudrate;
96 
98  int fd;
99 
101  tcflag_t BaudrateToBaudrateCode( unsigned long baudrate );
102 
103  int status;
104 
105  termios io_set_old;
106 
107 public:
118  cRS232( int _port, unsigned long _baudrate, double _timeout, char const* _device_format_string = "/dev/ttyS%d" );
119 
132  void Open( void );
133 
135  bool IsOpen( void )
136  throw();
137 
139  void Close( void );
140 
142 
150  int write( char const *ptr, int len=0 );
151 
160  ssize_t Read( void *data, ssize_t size, long timeout_us, bool return_on_less_data );
161 
163  virtual bool UseCRC16()
164  {
165  return true;
166  }
167 
168 };
169 //======================================================================
170 
172 
173 #endif
174 
175 
176 //======================================================================
177 /*
178  Here are some settings for the emacs/xemacs editor (and can be safely ignored):
179  (e.g. to explicitely set C++ mode for *.h header files)
180 
181  Local Variables:
182  mode:C++
183  mode:ELSE
184  End:
185 */
186 //======================================================================
int status
Definition: rs232-cygwin.h:103
std::string device_format_string
the sprintf format string to generate the device name from the port, see Constructor ...
Definition: rs232-cygwin.h:92
Interface of the exception base class #SDH::cSDHLibraryException and #SDH::cMsg.
Low-level communication class to access a serial port.
Definition: serialbase.h:105
#define NAMESPACE_SDH_START
cRS232Exception(cMsg const &_msg)
Definition: rs232-cygwin.h:74
Low-level communication class to access a serial port on Cygwin and Linux.
Definition: rs232-cygwin.h:84
int fd
the file descriptor of the RS232 port
Definition: rs232-cygwin.h:98
UInt16 size
Definition: dsa.h:269
int port
the RS232 portnumber to use
Definition: rs232-cygwin.h:89
#define NAMESPACE_SDH_END
This file contains settings to make the SDHLibrary compile on differen systems:
termios io_set_old
Definition: rs232-cygwin.h:105
unsigned long baudrate
the baudrate in bit/s
Definition: rs232-cygwin.h:95
Interface of class #SDH::cSerialBase, a virtal base class to access serial communication channels lik...
Derived exception class for low-level serial communication related exceptions.
Definition: serialbase.h:86
Derived exception class for low-level RS232 related exceptions.
Definition: rs232-cygwin.h:71
Class for short, fixed maximum length text messages.
Definition: sdhexception.h:77


sdhlibrary_cpp
Author(s): Dirk Osswald
autogenerated on Sun Aug 18 2019 03:42:20