Low-level communication class to access a serial port on Cygwin and Linux. More...
#include <rs232-cygwin.h>

| Public Member Functions | |
| void | Close (void) | 
| Close the previously opened communication channel.  More... | |
| void | Close (void) | 
| Close the previously opened rs232 port.  More... | |
| cRS232 (int _port, unsigned long _baudrate, double _timeout, char const *_device_format_string="") | |
| cRS232 (int _port, unsigned long _baudrate, double _timeout, char const *_device_format_string="/dev/ttyS%d") | |
| bool | IsOpen () throw () | 
| Return true if communication channel is open.  More... | |
| bool | IsOpen (void) throw () | 
| Return true if port to RS232 is open.  More... | |
| void | Open (void) | 
| Open rs232 port port.  More... | |
| void | Open (void) | 
| ssize_t | Read (void *data, ssize_t size, long timeout_us, bool return_on_less_data) | 
| ssize_t | Read (void *data, ssize_t size, long timeout_us, bool return_on_less_data) | 
| char * | readline (char *line, int size, char *eol, bool return_on_less_data) | 
| virtual void | SetTimeout (double _timeout) | 
| set the timeout for next readline() calls (negative value means: no timeout, wait for ever)  More... | |
| virtual bool | UseCRC16 () | 
| overloaded from cSerialBase::UseCRC16 since we want to use a CRC16 to protect binary RS232 communication  More... | |
| virtual bool | UseCRC16 () | 
| overloaded from cSerialBase::UseCRC16 since we want to use a CRC16 to protect binary RS232 communication  More... | |
| int | write (char const *ptr, int len=0) | 
| Write data to a previously opened port.  More... | |
| int | write (char const *ptr, int len=0) | 
| Write data to a previously opened port.  More... | |
| ~cRS232 (void) | |
|  Public Member Functions inherited from cSerialBase | |
| cSerialBase () | |
| ctor  More... | |
| virtual char const * | GetErrorMessage (tErrorCode dw) | 
| virtual tErrorCode | GetErrorNumber () | 
| char const * | GetLastErrorMessage (void) | 
| return the last error message as string. The string returned will be overwritten by the next call to the function  More... | |
| virtual double | GetTimeout () | 
| get the timeout for next readline() calls (negative value means: no timeout, wait for ever)  More... | |
| virtual char * | readline (char *line, int size, char const *eol="\n", bool return_on_less_data=false) | 
| Read a line from the device.  More... | |
| virtual | ~cSerialBase (void) | 
| dtor  More... | |
| Protected Member Functions | |
| tcflag_t | BaudrateToBaudrateCode (unsigned long baudrate) | 
| Translate a baudrate given as unsigned long into a baudrate code for struct termios.  More... | |
| Protected Attributes | |
| unsigned long | baudrate | 
| the baudrate in bit/s  More... | |
| std::string | device_format_string | 
| the sprintf format string to generate the device name from the port, see Constructor  More... | |
| int | fd | 
| the file descriptor of the RS232 port  More... | |
| termios | io_set_old | 
| int | port | 
| the RS232 portnumber to use  More... | |
| int | status | 
|  Protected Attributes inherited from cSerialBase | |
| double | timeout | 
| timeout in seconds  More... | |
| char | ungetch | 
| an already read data byte of the next line  More... | |
| bool | ungetch_valid | 
| Flag, true if ungetch is valid.  More... | |
| Private Attributes | |
| HANDLE | _hCOM | 
| COMMTIMEOUTS | comm_timeouts | 
| long | read_timeout_us | 
| Additional Inherited Members | |
|  Public Types inherited from cSerialBase | |
| typedef int | tErrorCode | 
| type of the error code, DWORD on windows and int on Linux/cygwin  More... | |
|  Public Attributes inherited from cSerialBase | |
| cDBG | dbg | 
| A stream object to print colored debug messages.  More... | |
Low-level communication class to access a serial port on Cygwin and Linux.
Low-level communication class to access a serial port on VCC Windows.
Definition at line 84 of file rs232-cygwin.h.
| cRS232::cRS232 | ( | int | _port, | 
| unsigned long | _baudrate, | ||
| double | _timeout, | ||
| char const * | _device_format_string = "/dev/ttyS%d" | ||
| ) | 
Constructor: constructs an object to communicate with an SDH via RS232
| _port | - rs232 device number: 0='COM1'='/dev/ttyS0', 1='COM2'='/dev/ttyS1', ... | 
| _baudrate | - the baudrate in bit/s | 
| _timeout | - the timeout in seconds | 
| _device_format_string | - a format string (C string) for generating the device name, like "/dev/ttyS%d" (default) or "/dev/ttyUSB%d". Must contain a d where the port number should be inserted. This char array is duplicated on construction | 
Definition at line 107 of file rs232-cygwin.cpp.
| cRS232::cRS232 | ( | int | _port, | 
| unsigned long | _baudrate, | ||
| double | _timeout, | ||
| char const * | _device_format_string = "" | ||
| ) | 
Constructor: constructs an object to communicate with an SDH via RS232
| _port | - rs232 device number: 0='COM1'='/dev/ttyS0', 1='COM2'='/dev/ttyS1', ... | 
| _baudrate | - the baudrate in bit/s | 
| _timeout | - the timeout in seconds | 
| _device_format_string | - ignored for this VCC version | 
| cRS232::~cRS232 | ( | void | ) | 
Definition at line 107 of file rs232-vcc.cpp.
| 
 | protected | 
Translate a baudrate given as unsigned long into a baudrate code for struct termios.
Definition at line 258 of file rs232-cygwin.cpp.
| 
 | virtual | 
Close the previously opened communication channel.
Implements cSerialBase.
| 
 | virtual | 
Close the previously opened rs232 port.
Implements cSerialBase.
Definition at line 248 of file rs232-cygwin.cpp.
| 
 | inlinevirtual | |||||||||||||
Return true if communication channel is open.
Implements cSerialBase.
Definition at line 109 of file rs232-vcc.h.
| 
 | virtual | ||||||||||||||
Return true if port to RS232 is open.
Implements cSerialBase.
Definition at line 240 of file rs232-cygwin.cpp.
| 
 | virtual | 
Open rs232 port port.
Open the device with the parameters provided in the constructor
Implements cSerialBase.
| 
 | virtual | 
Open the device as configured by the parameters given to the constructor
Implements cSerialBase.
Definition at line 121 of file rs232-cygwin.cpp.
| 
 | virtual | 
Read data from device. This function waits until max_time_us us passed or the expected number of bytes are received via serial line. if (return_on_less_data is true (default value), the number of bytes that have been received are returned and the data is stored in data If the return_on_less_data is false, data is only read from serial line, if at least size bytes are available.
Implements cSerialBase.
| 
 | virtual | 
Read data from device. This function waits until max_time_us us passed or the expected number of bytes are received via serial line. if (return_on_less_data is true (default value), the number of bytes that have been received are returned and the data is stored in data If the return_on_less_data is false, data is only read from serial line, if at least size bytes are available.
Implements cSerialBase.
Definition at line 341 of file rs232-cygwin.cpp.
| char * cRS232::readline | ( | char * | line, | 
| int | size, | ||
| char * | eol, | ||
| bool | return_on_less_data | ||
| ) | 
Definition at line 292 of file rs232-vcc.cpp.
| 
 | virtual | 
set the timeout for next readline() calls (negative value means: no timeout, wait for ever)
Reimplemented from cSerialBase.
Definition at line 183 of file rs232-vcc.cpp.
| 
 | inlinevirtual | 
overloaded from cSerialBase::UseCRC16 since we want to use a CRC16 to protect binary RS232 communication
Reimplemented from cSerialBase.
Definition at line 130 of file rs232-vcc.h.
| 
 | inlinevirtual | 
overloaded from cSerialBase::UseCRC16 since we want to use a CRC16 to protect binary RS232 communication
Reimplemented from cSerialBase.
Definition at line 163 of file rs232-cygwin.h.
| 
 | virtual | 
Write data to a previously opened port.
Write len bytes from *ptr to the rs232 device
| ptr | - pointer the byte array to send in memory | 
| len | - number of bytes to send | 
Implements cSerialBase.
| 
 | virtual | 
Write data to a previously opened port.
Write len bytes from *ptr to the rs232 device
| ptr | - pointer the byte array to send in memory | 
| len | - number of bytes to send | 
!! dwWritten is always 0! Damn bloody windows
Implements cSerialBase.
Definition at line 321 of file rs232-cygwin.cpp.
| 
 | private | 
Definition at line 75 of file rs232-vcc.h.
| 
 | protected | 
the baudrate in bit/s
Definition at line 95 of file rs232-cygwin.h.
| 
 | private | 
Definition at line 80 of file rs232-vcc.h.
| 
 | protected | 
the sprintf format string to generate the device name from the port, see Constructor
Definition at line 92 of file rs232-cygwin.h.
| 
 | protected | 
the file descriptor of the RS232 port
Definition at line 98 of file rs232-cygwin.h.
| 
 | protected | 
Definition at line 105 of file rs232-cygwin.h.
| 
 | protected | 
the RS232 portnumber to use
the RS232 port number to use (port 0 is COM1)
Definition at line 89 of file rs232-cygwin.h.
| 
 | private | 
Definition at line 81 of file rs232-vcc.h.
| 
 | protected | 
Definition at line 103 of file rs232-cygwin.h.