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

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