source: trunk/MagicSoft/Cosy/candrv/vmodican.h@ 5138

Last change on this file since 5138 was 4105, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 2.0 KB
Line 
1#ifndef COSY_VmodIcan
2#define COSY_VmodIcan
3
4#include <pthread.h>
5
6#include <unistd.h> // gettimeofday
7
8#include "log.h"
9
10#ifdef __CINT__
11//#include <TROOT.h>
12typedef UShort_t WORD_t;
13typedef Byte_t BYTE_t;
14#else
15#include "gendef.h"
16#endif
17
18#ifndef COSY_MThread
19#include "MThread.h"
20#endif
21
22class Message;
23class FastMessage;
24
25typedef struct timeval timeval_t;
26
27class VmodIcan : public Log, protected MThread
28{
29 friend class VmodIcanRX;
30
31private:
32 int fd; // file descriptor for can module
33
34 int Ioctl(int msg, void *arg);
35
36 void *Thread();
37
38 void HandleMessage(Message *msg, timeval_t *tv);
39 virtual void HandleCanMessage(WORD_t cobid, BYTE_t *data, timeval_t *tv) {}
40
41 int Receive(Message *pm);
42 int ReceiveFast(FastMessage *pm);
43
44 void SetBaudRate(int rate);
45 void EnableCanBusConnection();
46 int EnableFastCan(int rbuffers, int wbuffers);
47 void DisableCanBusConnection();
48 int EnableFifo();
49 int Reset();
50 void SetTermination(int strate=1);
51 int StdHost2NewStyle(int rbuffers, int wbuffers, int wbuffers_hi, int wbuffers_low);
52 void DisableAllCobIds();
53
54 void PrintMsg(Message *m);
55
56 int Send(Message *pm);
57 int SendHi(Message *pm);
58 int SendLo(Message *pm);
59 int Send(FastMessage *pm);
60
61 void Close();
62 int Open(const char *devname); /* pathname of device */
63
64 WORD_t MsgDescr(const WORD_t cobid, const BYTE_t dlc, const BYTE_t rtr=0)
65 {
66 return (cobid<<5) | ((rtr&0x1)<<4) | (dlc&0xf);
67 }
68
69 virtual void TerminateApp() { exit(-1); }
70
71public:
72 VmodIcan(const char *dev, const int baud, MLog &out=gLog);
73 virtual ~VmodIcan();
74
75 void EnableCobId(WORD_t cobid, int flag=TRUE);
76
77 void SendCanFrame(WORD_t cobid, BYTE_t m[8], BYTE_t rtr=0);
78 void SendCanFrame(WORD_t cobid,
79 BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
80 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
81
82 ClassDef(VmodIcan, 0) // hardware interface to the vmodican can module (Janz)
83};
84
85#endif
Note: See TracBrowser for help on using the repository browser.