36 # pragma warning(disable : 4290) 67 # define snprintf _snprintf 123 ungetch_valid(false),
141 virtual void Open(
void ) = 0;
144 virtual bool IsOpen(
void )
148 virtual void Close(
void ) = 0;
170 : serial_base(_serial_base),
171 old_timeout( serial_base->GetTimeout() )
173 if ( new_timeout != old_timeout )
180 if ( old_timeout != serial_base->
GetTimeout() )
195 virtual int write(
char const *ptr,
int len=0 ) = 0;
205 virtual ssize_t Read(
void *data, ssize_t
size,
long timeout_us,
bool return_on_less_data ) = 0;
224 virtual char* readline(
char* line,
int size,
char const* eol =
"\n",
bool return_on_less_data =
false );
244 return GetLastError();
257 virtual char const* GetErrorMessage( tErrorCode dw );
262 return GetErrorMessage( GetErrorNumber() );
A class to print colored debug messages.
virtual double GetTimeout()
get the timeout for next readline() calls (negative value means: no timeout, wait for ever) ...
cSerialBase * serial_base
cSerialBaseException(char const *_type, cMsg const &_msg)
virtual void SetTimeout(double _timeout)
set the timeout for next readline() calls (negative value means: no timeout, wait for ever) ...
This file contains interface and implementation of class #SDH::cDBG, a class for colorfull debug mess...
int tErrorCode
type of the error code, DWORD on windows and int on Linux/cygwin
Interface of the exception base class #SDH::cSDHLibraryException and #SDH::cMsg.
helper class to set timeout of _serial_base on construction and reset to previous value on destructio...
Low-level communication class to access a serial port.
#define NAMESPACE_SDH_START
virtual ~cSerialBase(void)
dtor
~cSetTimeoutTemporarily()
DTOR: restore the remembered timeout.
char const * GetLastErrorMessage(void)
return the last error message as string. The string returned will be overwritten by the next call to ...
Interface of class #SDH::cSDHBase.
double timeout
timeout in seconds
#define NAMESPACE_SDH_END
Derived exception class for exceptions related to communication between the SDHLibrary and the SDH...
This file contains settings to make the SDHLibrary compile on differen systems:
char ungetch
an already read data byte of the next line
Derived exception class for low-level serial communication related exceptions.
bool ungetch_valid
Flag, true if ungetch is valid.
USING_NAMESPACE_SDH NAMESPACE_SDH_START std::ostream * g_sdh_debug_log
Class for short, fixed maximum length text messages.
cDBG dbg
A stream object to print colored debug messages.
NAMESPACE_SDH_START typedef void * tDeviceHandle
generic device handle for CAN devices
cSetTimeoutTemporarily(cSerialBase *_serial_base, double new_timeout)
CTOR: remember current timeout of _serial_base and set its timeout to new_timeout, but only if current timeout and new_timeout differ.
virtual tErrorCode GetErrorNumber()
cSerialBaseException(cMsg const &_msg)