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 //======================================================================
virtual bool IsOpen(void)=0
Return true if communication channel is open.
unsigned long baudrate
the baudrate to use in bit/s
virtual void SetTimeout(double _timeout)
set the timeout for next readline() calls (negative value means: no timeout, wait for ever) ...
Definition: serialbase.h:151
int tErrorCode
type of the error code, DWORD on windows and int on Linux/cygwin
Definition: serialbase.h:233
cCANSerial_PEAK_Internal * pimpl
ptr to private, implementation specific members (using the &#39;Pimpl&#39; (pointer to implementatino) design...
Interface of the exception base class #SDH::cSDHLibraryException and #SDH::cMsg.
Derived exception class for low-level CAN PEAK related exceptions.
Low-level communication class to access a serial port.
Definition: serialbase.h:105
#define NAMESPACE_SDH_START
int id_read
the CAN ID used for reading
cCANSerial_PEAKException(cMsg const &_msg)
virtual char const * GetErrorMessage(tErrorCode dw)
Definition: serialbase.cpp:127
UInt16 size
Definition: dsa.h:269
virtual int write(char const *ptr, int len=0)=0
Write data to a previously opened port.
#define NAMESPACE_SDH_END
This file contains settings to make the SDHLibrary compile on differen systems:
Low-level communication class to access a CAN port from company PEAK (http://www.peak-system.com)
virtual void Open(void)=0
Open rs232 port port.
This file contains some basic definitions (defines, macros, datatypes)
Interface of class #SDH::cSerialBase, a virtal base class to access serial communication channels lik...
Derived exception class for low-level serial communication related exceptions.
Definition: serialbase.h:86
virtual void Close(void)=0
Close the previously opened communication channel.
Class for short, fixed maximum length text messages.
Definition: sdhexception.h:77
virtual ssize_t Read(void *data, ssize_t size, long timeout_us, bool return_on_less_data)=0
internal hardware specific implementation details of the lowlevel PEAK CAN interface ...
NAMESPACE_SDH_START typedef void * tDeviceHandle
generic device handle for CAN devices
Definition: serialbase.h:64
int id_write
the CAN ID used for writing
virtual tErrorCode GetErrorNumber()
Definition: serialbase.h:241


sdhlibrary_cpp
Author(s): Dirk Osswald
autogenerated on Mon Feb 28 2022 23:41:51