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="\, 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::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.
◆ Close()
void cTCPSerial::Close |
( |
void |
| ) |
|
|
virtual |
◆ GetErrorNumber()
Overloaded helper function that returns the last TCP error number.
Reimplemented from cSerialBase.
Definition at line 167 of file tcpserial.h.
◆ IsOpen()
bool cTCPSerial::IsOpen |
( |
void |
| ) |
|
throw | ( | |
| ) | | |
|
virtual |
◆ Open()
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.
◆ Read()
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.
◆ SetTimeout()
void cTCPSerial::SetTimeout |
( |
double |
_timeout | ) |
|
|
virtual |
◆ write()
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.
◆ fd
the file descriptor of the socket
Definition at line 102 of file tcpserial.h.
◆ INVALID_SOCKET
const int cTCPSerial::INVALID_SOCKET = -1 |
|
staticprotected |
◆ tcp_adr
std::string cTCPSerial::tcp_adr |
|
protected |
◆ tcp_port
◆ TIMEOUT_RETURN_IMMEDITELY_S
double const cTCPSerial::TIMEOUT_RETURN_IMMEDITELY_S = 0.0 |
|
static |
◆ TIMEOUT_RETURN_IMMEDITELY_US
long const cTCPSerial::TIMEOUT_RETURN_IMMEDITELY_US = 0 |
|
static |
◆ timeout_timeval
struct timeval cTCPSerial::timeout_timeval |
|
private |
◆ timeout_us
long cTCPSerial::timeout_us |
|
private |
cached timeout in us for read()
Definition at line 109 of file tcpserial.h.
◆ TIMEOUT_WAIT_FOR_EVER_S
double const cTCPSerial::TIMEOUT_WAIT_FOR_EVER_S = -1.0 |
|
static |
◆ TIMEOUT_WAIT_FOR_EVER_US
long const cTCPSerial::TIMEOUT_WAIT_FOR_EVER_US = -1 |
|
static |
The documentation for this class was generated from the following files: