canserial-peak.h
Go to the documentation of this file.
1 //======================================================================
12 //======================================================================
13 
14 #ifndef CANSERIAL_PEAK_H_
15 #define CANSERIAL_PEAK_H_
16 
17 //----------------------------------------------------------------------
18 // System Includes - include with <>
19 //----------------------------------------------------------------------
20 
21 
22 //----------------------------------------------------------------------
23 // Project Includes - include with ""
24 //----------------------------------------------------------------------
25 
26 #include "sdhexception.h"
27 #include "serialbase.h"
28 #include "basisdef.h"
29 #include "sdhlibrary_settings.h"
30 
31 //----------------------------------------------------------------------
32 // Defines, enums, unions, structs,
33 //----------------------------------------------------------------------
34 
36 
37 //----------------------------------------------------------------------
38 // Global variables
39 //----------------------------------------------------------------------
40 
41 
42 //----------------------------------------------------------------------
43 // Function and class member declarations
44 //----------------------------------------------------------------------
45 
46 
49 
50 
51 
56 {
57 public:
59  : cSerialBaseException( "cCANSerial_PEAKException", _msg )
60  {}
61 };
62 //======================================================================
63 
64 
78 class VCC_EXPORT cCANSerial_PEAK : public cSerialBase
79 {
80 
81 protected:
82 
84  unsigned long baudrate;
85 
87  int id_read;
88 
90  int id_write;
91 
92  // handle was removed from here, see class comment and GetHandle()
93 
95  int BaudrateToBaudrateCode( unsigned long baudrate );
96 
97  char m_device[64];
98 
99 private:
102 
104  cCANSerial_PEAK( cCANSerial_PEAK const& other );
105 
107  cCANSerial_PEAK& operator=( cCANSerial_PEAK const& rhs );
108 
109 public:
120  cCANSerial_PEAK( unsigned long _baudrate, double _timeout, int _id_read, int _id_write, const char *device="/dev/pcanusb0" );
121 
131  cCANSerial_PEAK( tDeviceHandle _peak_handle, double _timeout, int _id_read, int _id_write );
132 
134  ~cCANSerial_PEAK();
135 
143  tDeviceHandle GetHandle();
144 
148  void Open( void );
149 
151  bool IsOpen( void )
152  throw();
153 
155  void Close( void );
156 
158 
166  int write( char const *ptr, int len=0 );
167 
176  ssize_t Read( void *data, ssize_t size, long timeout_us, bool return_on_less_data );
177 
179  void SetTimeout( double _timeout );
180 
184  virtual tErrorCode GetErrorNumber();
185 
191  virtual char const* GetErrorMessage( tErrorCode dw );
192 
193 };
194 //======================================================================
195 
197 
198 #endif
199 
200 
201 //======================================================================
202 /*
203  Here are some settings for the emacs/xemacs editor (and can be safely ignored):
204  (e.g. to explicitely set C++ mode for *.h header files)
205 
206  Local Variables:
207  mode:C++
208  mode:ELSE
209  End:
210 */
211 //======================================================================
serialbase.h
Interface of class #SDH::cSerialBase, a virtal base class to access serial communication channels lik...
cSerialBase::Close
virtual void Close(void)=0
Close the previously opened communication channel.
size
UInt16 size
Definition: dsa.h:269
NAMESPACE_SDH_END
#define NAMESPACE_SDH_END
Definition: sdhlibrary_settings.h:80
cSerialBase
Low-level communication class to access a serial port.
Definition: serialbase.h:105
cCANSerial_PEAK::id_write
int id_write
the CAN ID used for writing
Definition: canserial-peak.h:90
cSerialBase::IsOpen
virtual bool IsOpen(void)=0
Return true if communication channel is open.
cSerialBaseException
Derived exception class for low-level serial communication related exceptions.
Definition: serialbase.h:86
cCANSerial_PEAK
Low-level communication class to access a CAN port from company PEAK (http://www.peak-system....
Definition: canserial-peak.h:78
cSerialBase::tErrorCode
int tErrorCode
type of the error code, DWORD on windows and int on Linux/cygwin
Definition: serialbase.h:233
cCANSerial_PEAK_Internal
internal hardware specific implementation details of the lowlevel PEAK CAN interface
Definition: canserial-peak.cpp:126
cCANSerial_PEAK::id_read
int id_read
the CAN ID used for reading
Definition: canserial-peak.h:87
tDeviceHandle
NAMESPACE_SDH_START typedef void * tDeviceHandle
generic device handle for CAN devices
Definition: serialbase.h:64
cSerialBase::SetTimeout
virtual void SetTimeout(double _timeout)
set the timeout for next readline() calls (negative value means: no timeout, wait for ever)
Definition: serialbase.h:151
cMsg
Class for short, fixed maximum length text messages.
Definition: sdhexception.h:77
cCANSerial_PEAK::pimpl
cCANSerial_PEAK_Internal * pimpl
ptr to private, implementation specific members (using the 'Pimpl' (pointer to implementatino) design...
Definition: canserial-peak.h:101
cCANSerial_PEAKException::cCANSerial_PEAKException
cCANSerial_PEAKException(cMsg const &_msg)
Definition: canserial-peak.h:58
cCANSerial_PEAK::baudrate
unsigned long baudrate
the baudrate to use in bit/s
Definition: canserial-peak.h:84
NAMESPACE_SDH_START
#define NAMESPACE_SDH_START
Definition: sdhlibrary_settings.h:79
cSerialBase::Open
virtual void Open(void)=0
Open rs232 port port.
cSerialBase::GetErrorMessage
virtual char const * GetErrorMessage(tErrorCode dw)
Definition: serialbase.cpp:127
sdhexception.h
Interface of the exception base class #SDH::cSDHLibraryException and #SDH::cMsg.
basisdef.h
This file contains some basic definitions (defines, macros, datatypes)
cCANSerial_PEAKException
Derived exception class for low-level CAN PEAK related exceptions.
Definition: canserial-peak.h:55
cSerialBase::Read
virtual ssize_t Read(void *data, ssize_t size, long timeout_us, bool return_on_less_data)=0
cSerialBase::write
virtual int write(char const *ptr, int len=0)=0
Write data to a previously opened port.
sdhlibrary_settings.h
This file contains settings to make the SDHLibrary compile on differen systems:
cSerialBase::GetErrorNumber
virtual tErrorCode GetErrorNumber()
Definition: serialbase.h:241


sdhlibrary_cpp
Author(s): Dirk Osswald
autogenerated on Wed Mar 2 2022 01:00:58