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

Last change on this file since 770 was 732, checked in by tbretz, 24 years ago
*** empty log message ***
File size: 1.8 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#include "gendef.h"
10
11class VmodIcan : public Log
12{
13private:
14 int fd; // file descriptor for can module
15 pthread_t *fRxThrd;
16
17 int Ioctl(int msg, void *arg);
18
19 static void *ReceiveThread(void *data);
20
21 void HandleMessage(Message *msg, struct timeval *tv);
22 virtual void HandleCanMessage(WORD_t cobid, BYTE_t *data, struct timeval *tv) {}
23
24 int Receive(Message *pm);
25 int ReceiveFast(FastMessage *pm);
26
27 void SetBaudRate(int rate);
28 void EnableCanBusConnection();
29 int EnableFastCan(int rbuffers, int wbuffers);
30 void DisableCanBusConnection();
31 int EnableFifo();
32 int Reset();
33 void SetTermination(int strate=1);
34 int StdHost2NewStyle(int rbuffers, int wbuffers, int wbuffers_hi, int wbuffers_low);
35 void DisableAllCobIds();
36
37 void PrintMsg(Message *m);
38
39 int Send(Message *pm);
40 int SendHi(Message *pm);
41 int SendLo(Message *pm);
42 int Send(FastMessage *pm);
43
44 void Close();
45 int Open(const char *devname); /* pathname of device */
46
47 WORD_t MsgDescr(const WORD_t cobid, const BYTE_t dlc, const BYTE_t rtr=0)
48 {
49 return (cobid<<5) | ((rtr&0x1)<<4) | (dlc&0xf);
50 }
51
52 virtual void TerminateApp() { exit(-1); }
53
54protected:
55 void StartReceiver();
56 void StopReceiver();
57
58public:
59 VmodIcan(const char *dev, const int baud, ostream &out=cout);
60 virtual ~VmodIcan();
61
62 void EnableCobId(WORD_t cobid, int flag=TRUE);
63
64 void SendCanFrame(WORD_t cobid, BYTE_t m[8]);
65 void SendCanFrame(WORD_t cobid,
66 BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
67 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
68};
69
70#endif
Note: See TracBrowser for help on using the repository browser.