source: pacpussensors/trunk/CanGateway/Win32CanInterface.h@ 118

Last change on this file since 118 was 116, checked in by ydroniou, 9 years ago

Fix KVaser for Linux \o/

File size: 2.1 KB
Line 
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//
10// purpose: Management of the Can Interface
11//
12*********************************************************************/
13
14#ifndef WIN32CANINTERFACE_H
15#define WIN32CANINTERFACE_H
16
17// we use the Vector driver
18#ifdef WIN32
19//# define CAN_DRIVER_TYPE VECTOR_CAN_DRIVER
20//# define CAN_DRIVER_TYPE VECTOR_CANXL_DRIVER
21//# define CAN_DRIVER_TYPE PEAK_CAN_DRIVER_WIN
22# define CAN_DRIVER_TYPE KVASER_CAN_DRIVER_WIN
23#else
24//# define CAN_DRIVER_TYPE IGEP_CAN_DRIVER
25# define CAN_DRIVER_TYPE KVASER_CAN_DRIVER_WIN
26#endif
27
28#include <iostream>
29#include <qsemaphore.h>
30#include <qthread.h>
31
32#include "CanDecoderBase.h"
33
34#include "driver/CanDriver.h"
35#include "structureCan.h"
36
37namespace pacpus {
38
39// class ShMem; // runtime crash because PosixShMem
40
41class Win32CanInterface
42 : public QThread
43{
44public:
45 Win32CanInterface();
46 ~Win32CanInterface();
47
48 enum DataSource {VectorCard, SharedMemory, PeakCard, XLVectorCard, igepCard, KvaserCard};
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_;
59protected:
60 void run();
61
62 //void shMemLoop(); // runtime crash because PosixShMem
63 void defaultLoop();
64
65
66private:
67 CanFrame frame_;
68 bool continue_;
69 DataSource source_;
70
71 QSemaphore *semaphore_;
72 TimestampedCanFrame * receivedFrames_;
73 int receivedFramesArraySize_;
74
75 // ShMem * shMem_; // runtime crash because PosixShMem
76
77 int counter_;
78};
79
80} // namespace pacpus
81
82#endif // WIN32CANINTERFACE_H
Note: See TracBrowser for help on using the repository browser.