Low-level communication class to access a CAN port.
More...
#include <tcpserial.h>
|
void | Close (void) |
| Close the previously opened CAN ESD interface port. More...
|
|
| cTCPSerial (char const *_tcp_adr, int _tcp_port, double _timeout) |
|
virtual tErrorCode | GetErrorNumber () |
|
bool | IsOpen (void) throw () |
| Return true if interface to CAN ESD is open. More...
|
|
void | Open (void) |
|
ssize_t | Read (void *data, ssize_t size, long timeout_us, bool return_on_less_data) |
|
void | SetTimeout (double _timeout) |
| set the timeout for next readline() calls (negative value means: no timeout, wait for ever) More...
|
|
int | write (char const *ptr, int len=0) |
| Write data to a previously opened port. More...
|
|
| cSerialBase () |
| ctor More...
|
|
virtual char const * | GetErrorMessage (tErrorCode dw) |
|
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 bool | UseCRC16 () |
|
virtual | ~cSerialBase (void) |
| dtor More...
|
|
|
typedef int | tErrorCode |
| type of the error code, DWORD on windows and int on Linux/cygwin More...
|
|
cDBG | dbg |
| A stream object to print colored debug messages. More...
|
|
Low-level communication class to access a CAN port.
Definition at line 88 of file tcpserial.h.
cTCPSerial::cTCPSerial |
( |
char const * |
_tcp_adr, |
|
|
int |
_tcp_port, |
|
|
double |
_timeout |
|
) |
| |
Constructor: constructs an object to communicate with an SDH via TCP on _tcp_adr and _tcp_port.
- Parameters
-
_tcp_adr | - a string describing the hostname or IP address of the SDH |
_tcp_port | - the port number on the SDH |
_timeout | - the timeout when receiving / sending data:
- < 0.0 : no timeout = wait for ever
- == 0.0 : zero timeout = return immediately
- > 0.0 : timeout in seconds
|
Definition at line 116 of file tcpserial.cpp.
void cTCPSerial::Close |
( |
void |
| ) |
|
|
virtual |
Overloaded helper function that returns the last TCP error number.
Reimplemented from cSerialBase.
Definition at line 167 of file tcpserial.h.
bool cTCPSerial::IsOpen |
( |
void |
| ) |
|
throw | ( | |
| ) | | |
|
virtual |
void cTCPSerial::Open |
( |
void |
| ) |
|
|
virtual |
Open the device as configured by the parameters given to the constructor
Implements cSerialBase.
Definition at line 137 of file tcpserial.cpp.
ssize_t cTCPSerial::Read |
( |
void * |
data, |
|
|
ssize_t |
size, |
|
|
long |
timeout_us, |
|
|
bool |
return_on_less_data |
|
) |
| |
|
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 240 of file tcpserial.cpp.
void cTCPSerial::SetTimeout |
( |
double |
_timeout | ) |
|
|
virtual |
int cTCPSerial::write |
( |
char const * |
ptr, |
|
|
int |
len = 0 |
|
) |
| |
|
virtual |
Write data to a previously opened port.
Write len bytes from *ptr to the CAN device
- Parameters
-
ptr | - pointer the byte array to send in memory |
len | - number of bytes to send |
- Returns
- the number of bytes actually written
Implements cSerialBase.
Definition at line 214 of file tcpserial.cpp.
the file descriptor of the socket
Definition at line 102 of file tcpserial.h.
const int cTCPSerial::INVALID_SOCKET = -1 |
|
staticprotected |
std::string cTCPSerial::tcp_adr |
|
protected |
double const cTCPSerial::TIMEOUT_RETURN_IMMEDITELY_S = 0.0 |
|
static |
long const cTCPSerial::TIMEOUT_RETURN_IMMEDITELY_US = 0 |
|
static |
struct timeval cTCPSerial::timeout_timeval |
|
private |
long cTCPSerial::timeout_us |
|
private |
cached timeout in us for read()
Definition at line 109 of file tcpserial.h.
double const cTCPSerial::TIMEOUT_WAIT_FOR_EVER_S = -1.0 |
|
static |
long const cTCPSerial::TIMEOUT_WAIT_FOR_EVER_US = -1 |
|
static |
The documentation for this class was generated from the following files: