[1] | 1 | /********************************************************************
|
---|
| 2 | // created: 2011/02/21 - 10:39
|
---|
| 3 | // filename: PeakCanDriver.h
|
---|
| 4 | //
|
---|
| 5 | // author: Sergio Rodriguez
|
---|
| 6 | //
|
---|
| 7 | // version: $Id: PeakCanDriver.h srodrigu $
|
---|
| 8 | //
|
---|
| 9 | // purpose: Inherits from the CanDriver class
|
---|
| 10 | // Reimplement all the virtual members of the CanDriverBase
|
---|
| 11 | // class in order to be used with the Peak driver.
|
---|
| 12 | // platform : Linux specific
|
---|
| 13 | //
|
---|
| 14 | *********************************************************************/
|
---|
| 15 |
|
---|
| 16 | #ifndef PEAKCANDRIVER_H
|
---|
| 17 | #define PEAKCANDRIVER_H
|
---|
| 18 |
|
---|
| 19 | #include "CanDriverBase.h"
|
---|
[23] | 20 | #include <libpcan.h>
|
---|
[1] | 21 | #include <fcntl.h> // O_RDWR
|
---|
| 22 | #include <errno.h>
|
---|
| 23 | #include <string>
|
---|
| 24 |
|
---|
| 25 | #define PSUCCESS 0
|
---|
[23] | 26 | #define READ_TIMEOUT 100000// 100 miliseconds timeout
|
---|
[1] | 27 |
|
---|
| 28 | class PeakCanDriver : public CanDriverBase
|
---|
| 29 | {
|
---|
| 30 | public:
|
---|
| 31 | PeakCanDriver(void);
|
---|
| 32 | PeakCanDriver(int);
|
---|
| 33 | PeakCanDriver(const char* port, const char* mode);
|
---|
| 34 | PeakCanDriver(int channel, unsigned int bitRate);
|
---|
| 35 | ~PeakCanDriver(void);
|
---|
| 36 |
|
---|
| 37 | short initPort (void);
|
---|
| 38 | short cleanUpPort (void);
|
---|
| 39 |
|
---|
| 40 | short sendFrame (struct CanFrame frame);
|
---|
| 41 | short receiveFrame (struct CanFrame &frame);
|
---|
| 42 | void waitReceivingFrame(void);
|
---|
| 43 |
|
---|
| 44 | enum OperationMode{ReadOnly, WriteOnly, ReadWrite};
|
---|
| 45 |
|
---|
| 46 | protected:
|
---|
| 47 |
|
---|
| 48 | private:
|
---|
| 49 | char * szDevNode_;
|
---|
| 50 | OperationMode mode_;
|
---|
| 51 |
|
---|
| 52 | HANDLE canDeviceHandle_;
|
---|
| 53 |
|
---|
| 54 | void print_message(TPCANMsg *m);
|
---|
| 55 |
|
---|
| 56 | };
|
---|
| 57 |
|
---|
| 58 | #endif // PEAKCANDRIVER_H
|
---|