Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
cCANSerial_ESD Class Reference

Low-level communication class to access a CAN port from company ESD (http://www.esd.eu/) More...

#include <canserial-esd.h>

Inheritance diagram for cCANSerial_ESD:
Inheritance graph
[legend]

Public Member Functions

 cCANSerial_ESD (int _net, unsigned long _baudrate, double _timeout, int _id_read, int _id_write)
 
 cCANSerial_ESD (tDeviceHandle _ntcan_handle, double _timeout, int _id_read, int _id_write)
 
void Close (void)
 Close the previously opened CAN ESD interface port. More...
 
virtual char const * GetErrorMessage (tErrorCode dw)
 
virtual tErrorCode GetErrorNumber ()
 
tDeviceHandle GetHandle ()
 return the internally used NTCAN_HANDLE cast to a tDeviceHandle More...
 
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...
 
 ~cCANSerial_ESD ()
 destructor: clean up More...
 
- Public Member Functions inherited from cSerialBase
 cSerialBase ()
 ctor More...
 
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...
 

Protected Member Functions

unsigned int 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 to use in bit/s More...
 
int id_read
 the CAN ID used for reading More...
 
int id_write
 the CAN ID used for writing More...
 
int net
 the ESD CAN net 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 Member Functions

 cCANSerial_ESD (cCANSerial_ESD const &other)
 private copy constructor without implementation, since copying of cCANSerial_ESD objects makes no sense More...
 
cCANSerial_ESDoperator= (cCANSerial_ESD const &rhs)
 private copy assignment operator without implementation, since copying of cCANSerial_ESD objects makes no sense More...
 

Private Attributes

cCANSerial_ESD_Internalpimpl
 ptr to private, implementation specific members (using the 'Pimpl' (pointer to implementatino) design pattern) More...
 

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...
 

Detailed Description

Low-level communication class to access a CAN port from company ESD (http://www.esd.eu/)

Since SDHLibrary-C++ release 0.0.2.0 implementation specific parts of the access to ESD CAN devices have been removed from the header file here in order to get rid of dependencies from the weird ntcan.h. Specifically the ntcan_handle of type NTCAN_HANDLE member was removed. You can still provide an existing handle for reuse on construction, but you must cast your NTCAN_HANDLE to a tDeviceHandle. You can get the internally used NTCAN_HANDLE cast to a tDeviceHandle with GetHandle().

Definition at line 97 of file canserial-esd.h.

Constructor & Destructor Documentation

cCANSerial_ESD::cCANSerial_ESD ( cCANSerial_ESD const &  other)
private

private copy constructor without implementation, since copying of cCANSerial_ESD objects makes no sense

cCANSerial_ESD::cCANSerial_ESD ( int  _net,
unsigned long  _baudrate,
double  _timeout,
int  _id_read,
int  _id_write 
)

Constructor: constructs an object to communicate with an SDH via CAN bus using an ESD CAN card.

Parameters
_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)

Definition at line 182 of file canserial-esd.cpp.

cCANSerial_ESD::cCANSerial_ESD ( tDeviceHandle  _ntcan_handle,
double  _timeout,
int  _id_read,
int  _id_write 
)

Constructor: constructs an object to communicate with an SDH via CAN bus using an ESD CAN card by reusing an already existing handle.

Parameters
_ntcan_handle- the ESD CAN handle to reuse (please cast your NTCAN_HANDLE to tDeviceHandle! It is save to do that!)
_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)

Definition at line 202 of file canserial-esd.cpp.

cCANSerial_ESD::~cCANSerial_ESD ( )

destructor: clean up

Definition at line 225 of file canserial-esd.cpp.

Member Function Documentation

unsigned int cCANSerial_ESD::BaudrateToBaudrateCode ( unsigned long  baudrate)
protected

Translate a baudrate given as unsigned long into a baudrate code for struct termios.

Definition at line 342 of file canserial-esd.cpp.

void cCANSerial_ESD::Close ( void  )
virtual

Close the previously opened CAN ESD interface port.

Implements cSerialBase.

Definition at line 332 of file canserial-esd.cpp.

char const * cCANSerial_ESD::GetErrorMessage ( tErrorCode  dw)
virtual

Overloaded helper function that returns an ESD error message for ESD error code dw.

Remarks
The string returned will be overwritten by the next call to the function

Reimplemented from cSerialBase.

Definition at line 499 of file canserial-esd.cpp.

cSerialBase::tErrorCode cCANSerial_ESD::GetErrorNumber ( )
virtual

Overloaded helper function that returns the last ESD error number.

Reimplemented from cSerialBase.

Definition at line 509 of file canserial-esd.cpp.

tDeviceHandle cCANSerial_ESD::GetHandle ( )

return the internally used NTCAN_HANDLE cast to a tDeviceHandle

Definition at line 515 of file canserial-esd.cpp.

bool cCANSerial_ESD::IsOpen ( void  )
throw (
)
virtual

Return true if interface to CAN ESD is open.

Implements cSerialBase.

Definition at line 324 of file canserial-esd.cpp.

void cCANSerial_ESD::Open ( void  )
virtual

Open the device as configured by the parameters given to the constructor

Implements cSerialBase.

Definition at line 284 of file canserial-esd.cpp.

cCANSerial_ESD& cCANSerial_ESD::operator= ( cCANSerial_ESD const &  rhs)
private

private copy assignment operator without implementation, since copying of cCANSerial_ESD objects makes no sense

ssize_t cCANSerial_ESD::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 416 of file canserial-esd.cpp.

void cCANSerial_ESD::SetTimeout ( double  _timeout)
virtual

set the timeout for next readline() calls (negative value means: no timeout, wait for ever)

Reimplemented from cSerialBase.

Definition at line 478 of file canserial-esd.cpp.

int cCANSerial_ESD::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 361 of file canserial-esd.cpp.

Member Data Documentation

unsigned long cCANSerial_ESD::baudrate
protected

the baudrate to use in bit/s

Definition at line 106 of file canserial-esd.h.

int cCANSerial_ESD::id_read
protected

the CAN ID used for reading

Definition at line 109 of file canserial-esd.h.

int cCANSerial_ESD::id_write
protected

the CAN ID used for writing

Definition at line 112 of file canserial-esd.h.

int cCANSerial_ESD::net
protected

the ESD CAN net to use

Definition at line 103 of file canserial-esd.h.

cCANSerial_ESD_Internal* cCANSerial_ESD::pimpl
private

ptr to private, implementation specific members (using the 'Pimpl' (pointer to implementatino) design pattern)

Definition at line 123 of file canserial-esd.h.

int cCANSerial_ESD::status
protected

Definition at line 119 of file canserial-esd.h.


The documentation for this class was generated from the following files:


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