[1] | 1 | /*********************************************************************
|
---|
| 2 | // created: 2008/2/11 - 12:01
|
---|
| 3 | // filename: Win32CanInterface.h
|
---|
| 4 | //
|
---|
| 5 | // author: Gerald Dherbomez
|
---|
| 6 | // Copyright Heudiasyc UMR UTC/CNRS 6599
|
---|
| 7 | //
|
---|
| 8 | // version: $Id: $
|
---|
| 9 | //
|
---|
[59] | 10 | // purpose: Management of the Can Interface
|
---|
[1] | 11 | //
|
---|
| 12 | *********************************************************************/
|
---|
| 13 |
|
---|
| 14 | #ifndef WIN32CANINTERFACE_H
|
---|
| 15 | #define WIN32CANINTERFACE_H
|
---|
| 16 |
|
---|
| 17 | // we use the Vector driver
|
---|
| 18 | #ifdef WIN32
|
---|
[74] | 19 | //# define CAN_DRIVER_TYPE VECTOR_CAN_DRIVER
|
---|
[89] | 20 | //# define CAN_DRIVER_TYPE VECTOR_CANXL_DRIVER
|
---|
[59] | 21 | //# define CAN_DRIVER_TYPE PEAK_CAN_DRIVER_WIN
|
---|
[89] | 22 | # define CAN_DRIVER_TYPE KVASER_CAN_DRIVER_WIN
|
---|
[1] | 23 | #else
|
---|
[94] | 24 | //# define CAN_DRIVER_TYPE IGEP_CAN_DRIVER
|
---|
| 25 | # define CAN_DRIVER_TYPE KVASER_CAN_DRIVER_WIN
|
---|
[1] | 26 | #endif
|
---|
| 27 |
|
---|
| 28 | #include <iostream>
|
---|
| 29 | #include <qsemaphore.h>
|
---|
| 30 | #include <qthread.h>
|
---|
| 31 |
|
---|
[2] | 32 | #include "CanDecoderBase.h"
|
---|
[1] | 33 |
|
---|
[2] | 34 | #include "driver/CanDriver.h"
|
---|
[4] | 35 | #include "structureCan.h"
|
---|
[2] | 36 |
|
---|
[1] | 37 | namespace pacpus {
|
---|
| 38 |
|
---|
[94] | 39 | // class ShMem; // runtime crash because PosixShMem
|
---|
[1] | 40 |
|
---|
| 41 | class Win32CanInterface
|
---|
| 42 | : public QThread
|
---|
| 43 | {
|
---|
| 44 | public:
|
---|
| 45 | Win32CanInterface();
|
---|
| 46 | ~Win32CanInterface();
|
---|
| 47 |
|
---|
[89] | 48 | enum DataSource {VectorCard, SharedMemory, PeakCard, XLVectorCard, igepCard, KvaserCard};
|
---|
[1] | 49 |
|
---|
| 50 | bool openInterface(const int number, const unsigned int speed);
|
---|
| 51 | bool openInterface(char* port, char* accessMode);
|
---|
| 52 | bool closeInterface(const int number);
|
---|
| 53 | void stop();
|
---|
| 54 |
|
---|
| 55 | void setSignalSempahore(QSemaphore * semaphore) { semaphore_ = semaphore;};
|
---|
| 56 | void setExchangeBuffer(TimestampedCanFrame * framesArray, const int framesArraySize);
|
---|
| 57 | void setSource(DataSource source);
|
---|
| 58 | CanDriver * canDriver_;
|
---|
| 59 | protected:
|
---|
| 60 | void run();
|
---|
| 61 | void vectorLoop();
|
---|
[94] | 62 | //void shMemLoop(); // runtime crash because PosixShMem
|
---|
[1] | 63 | void peakLoop();
|
---|
[4] | 64 | void igepLoop();
|
---|
[1] | 65 | void vectorXlLoop();
|
---|
[89] | 66 | void kvaserLoop();
|
---|
[1] | 67 |
|
---|
[89] | 68 |
|
---|
[1] | 69 | private:
|
---|
| 70 | CanFrame frame_;
|
---|
| 71 | bool continue_;
|
---|
| 72 | DataSource source_;
|
---|
| 73 |
|
---|
| 74 | QSemaphore *semaphore_;
|
---|
| 75 | TimestampedCanFrame * receivedFrames_;
|
---|
| 76 | int receivedFramesArraySize_;
|
---|
| 77 |
|
---|
[94] | 78 | // ShMem * shMem_; // runtime crash because PosixShMem
|
---|
[1] | 79 |
|
---|
| 80 | int counter_;
|
---|
| 81 | };
|
---|
| 82 |
|
---|
| 83 | } // namespace pacpus
|
---|
| 84 |
|
---|
| 85 | #endif // WIN32CANINTERFACE_H
|
---|