Low-level communication class to access a CAN port. More...
#include <canserial-esd.h>
Public Member Functions | |
cCANSerial_ESD (NTCAN_HANDLE _ntcan_handle, double _timeout, Int32 _id_read, Int32 _id_write) throw (cCANSerial_ESDException*) | |
cCANSerial_ESD (int _net, unsigned long _baudrate, double _timeout, Int32 _id_read, Int32 _id_write) throw (cCANSerial_ESDException*) | |
void | Close (void) throw (cCANSerial_ESDException*) |
Close the previously opened CAN ESD interface port. | |
bool | IsOpen (void) throw () |
Return true if interface to CAN ESD is open. | |
void | Open (void) throw (cCANSerial_ESDException*) |
ssize_t | Read (void *data, ssize_t size, long timeout_us, bool return_on_less_data) throw (cCANSerial_ESDException*) |
void | SetTimeout (double _timeout) throw (cSerialBaseException*) |
set the timeout for next readline() calls (negative value means: no timeout, wait for ever) | |
int | write (char const *ptr, int len=0) throw (cCANSerial_ESDException*) |
Write data to a previously opened port. | |
Protected Member Functions | |
UInt32 | BaudrateToBaudrateCode (unsigned long baudrate) throw (cCANSerial_ESDException*) |
Translate a baudrate given as unsigned long into a baudrate code for struct termios. | |
Protected Attributes | |
unsigned long | baudrate |
the baudrate to use in bit/s | |
Int32 | id_read |
the CAN ID used for reading | |
Int32 | id_write |
the CAN ID used for writing | |
int | net |
the ESD CAN net to use | |
NTCAN_HANDLE | ntcan_handle |
the handle to the driver | |
int | status |
Private Attributes | |
CMSG | m_cmsg |
int | m_cmsg_next |
index of next received data byte to return to user in m_cmsg | |
UInt32 | timeout_ms |
Low-level communication class to access a CAN port.
Definition at line 127 of file canserial-esd.h.
cCANSerial_ESD::cCANSerial_ESD | ( | int | _net, | |
unsigned long | _baudrate, | |||
double | _timeout, | |||
Int32 | _id_read, | |||
Int32 | _id_write | |||
) | throw (cCANSerial_ESDException*) |
Constructor: constructs an object to communicate with an SDH via CAN bus using an ESD CAN card.
_net | - the ESD CAN net to use | |
_baudrate | - the baudrate in bit/s. Only some bitrates are valid: (1000000,800000,500000,250000,125000,100000,50000,20000,10000) | |
_timeout | - the timeout in seconds (0 for no timeout = wait for ever) | |
_id_read | - the CAN ID to use for reading (The SDH sends data on this ID) | |
_id_write | - the CAN ID to use for writing (The SDH receives data on this ID) |
cCANSerial_ESD::cCANSerial_ESD | ( | NTCAN_HANDLE | _ntcan_handle, | |
double | _timeout, | |||
Int32 | _id_read, | |||
Int32 | _id_write | |||
) | throw (cCANSerial_ESDException*) |
Constructor: constructs an object to communicate with an SDH via CAN bus using an ESD CAN card by reusing an already existing handle.
_ntcan_handle | - the ESD CAN handle to reuse | |
_timeout | - the timeout in seconds (0 for no timeout = wait for ever) | |
_id_read | - the CAN ID to use for reading (The SDH sends data on this ID) | |
_id_write | - the CAN ID to use for writing (The SDH receives data on this ID) |
UInt32 cCANSerial_ESD::BaudrateToBaudrateCode | ( | unsigned long | baudrate | ) | throw (cCANSerial_ESDException*) [protected] |
Translate a baudrate given as unsigned long into a baudrate code for struct termios.
void cCANSerial_ESD::Close | ( | void | ) | throw (cCANSerial_ESDException*) [virtual] |
Close the previously opened CAN ESD interface port.
Implements cSerialBase.
bool cCANSerial_ESD::IsOpen | ( | void | ) | throw () [virtual] |
Return true if interface to CAN ESD is open.
Implements cSerialBase.
void cCANSerial_ESD::Open | ( | void | ) | throw (cCANSerial_ESDException*) [virtual] |
Open the device as configured by the parameters given to the constructor
Implements cSerialBase.
ssize_t cCANSerial_ESD::Read | ( | void * | data, | |
ssize_t | size, | |||
long | timeout_us, | |||
bool | return_on_less_data | |||
) | throw (cCANSerial_ESDException*) [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.
void cCANSerial_ESD::SetTimeout | ( | double | _timeout | ) | throw (cSerialBaseException*) [virtual] |
set the timeout for next readline() calls (negative value means: no timeout, wait for ever)
Reimplemented from cSerialBase.
int cCANSerial_ESD::write | ( | char const * | ptr, | |
int | len = 0 | |||
) | throw (cCANSerial_ESDException*) [virtual] |
Write data to a previously opened port.
Write len bytes from *ptr to the CAN device
ptr | - pointer the byte array to send in memory | |
len | - number of bytes to send |
Implements cSerialBase.
unsigned long cCANSerial_ESD::baudrate [protected] |
the baudrate to use in bit/s
Definition at line 136 of file canserial-esd.h.
Int32 cCANSerial_ESD::id_read [protected] |
the CAN ID used for reading
Definition at line 139 of file canserial-esd.h.
Int32 cCANSerial_ESD::id_write [protected] |
the CAN ID used for writing
Definition at line 142 of file canserial-esd.h.
CMSG cCANSerial_ESD::m_cmsg [private] |
received messages might be split over several CAN messages it might therefore happen that more data is received than can be returned to the user. To not loose that data it is kept here to be be returned in a later call
Definition at line 168 of file canserial-esd.h.
int cCANSerial_ESD::m_cmsg_next [private] |
index of next received data byte to return to user in m_cmsg
Definition at line 170 of file canserial-esd.h.
int cCANSerial_ESD::net [protected] |
the ESD CAN net to use
Definition at line 133 of file canserial-esd.h.
NTCAN_HANDLE cCANSerial_ESD::ntcan_handle [protected] |
the handle to the driver
Definition at line 145 of file canserial-esd.h.
int cCANSerial_ESD::status [protected] |
Definition at line 157 of file canserial-esd.h.
UInt32 cCANSerial_ESD::timeout_ms [private] |
Definition at line 160 of file canserial-esd.h.