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

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