source: trunk/MagicSoft/Cosy/candrv/nodedrv.cc@ 850

Last change on this file since 850 was 808, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 3.0 KB
Line 
1#include "nodedrv.h"
2
3#include <iomanip.h>
4#include <iostream.h>
5
6#include "network.h"
7
8NodeDrv::NodeDrv(BYTE_t nodeid, ostream &out) : Log(out), fNetwork(NULL), fId(32), fError(0)
9{
10 if (nodeid>31)
11 {
12 cout << "SetNode - Error: Only node Numbers < 32 are allowed"<< endl;
13 return;
14 }
15
16 fId = nodeid;
17}
18
19void NodeDrv::InitDevice(Network *net)
20{
21 fNetwork = net;
22
23 EnableCanMsg(kPDO1_TX);
24 EnableCanMsg(kPDO2_TX);
25 EnableCanMsg(kPDO3_TX);
26 EnableCanMsg(kPDO4_TX);
27 EnableCanMsg(kSDO_RX);
28 EnableCanMsg(kSDO_TX);
29}
30
31void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx)
32{
33 lout << hex << setfill('0');
34 lout << "Sdo=" << idx << "/" << (int)subidx << " set.";
35 lout << endl;
36}
37
38void NodeDrv::HandleSDOError(LWORD_t data)
39{
40 lout << "Err: 0x";
41 lout << hex << setfill('0') << setw(4) << data;
42 lout << endl;;
43}
44
45void NodeDrv::HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv)
46{
47 cout << "SdoRx: Idx=0x"<< hex << idx << "/" << (int)subidx;
48 cout << ", val=0x" << val << endl;
49}
50
51void NodeDrv::SendPDO1(BYTE_t data[8])
52{
53 fNetwork->SendPDO1(fId, data);
54}
55
56void NodeDrv::SendPDO2(BYTE_t data[8])
57{
58 fNetwork->SendPDO2(fId, data);
59}
60
61void NodeDrv::SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
62 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0)
63{
64 fNetwork->SendPDO1(fId, m0, m1, m2, m3, m4, m5, m6, m7);
65}
66
67void NodeDrv::SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
68 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0)
69{
70 fNetwork->SendPDO2(fId, m0, m1, m2, m3, m4, m5, m6, m7);
71}
72
73void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val)
74{
75 fNetwork->SendSDO(fId, idx, subidx, val);
76}
77
78void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val)
79{
80 fNetwork->SendSDO(fId, idx, subidx, val);
81}
82
83void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val)
84{
85 fNetwork->SendSDO(fId, idx, subidx, val);
86}
87
88void NodeDrv::SendSDO(WORD_t idx, BYTE_t val)
89{
90 fNetwork->SendSDO(fId, idx, val);
91}
92
93void NodeDrv::SendSDO(WORD_t idx, WORD_t val)
94{
95 fNetwork->SendSDO(fId, idx, val);
96}
97
98void NodeDrv::SendSDO(WORD_t idx, LWORD_t val)
99{
100 fNetwork->SendSDO(fId, idx, val);
101}
102
103void NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx=0)
104{
105 fNetwork->RequestSDO(fId, idx, subidx);
106}
107
108void NodeDrv::SendNMT(BYTE_t cmd)
109{
110 fNetwork->SendNMT(fId, cmd);
111}
112
113void NodeDrv::EnableCanMsg(BYTE_t fcode)
114{
115 fNetwork->EnableCanMsg(fId, fcode, TRUE);
116}
117
118void NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx)
119{
120 while (fNetwork->WaitingForSdo(fId, idx, subidx))
121 usleep(1);
122}
123
124void NodeDrv::WaitForSdos()
125{
126 while (fNetwork->WaitingForSdo(fId))
127 usleep(1);
128}
129
130void NodeDrv::WaitForNextPdo1()
131{
132 fNetwork->WaitForNextPdo1(fId);
133}
134
135void NodeDrv::WaitForNextPdo2()
136{
137 cout << "WAIT: " << (int)fId << " " << fNetwork << endl;
138 fNetwork->WaitForNextPdo2(fId);
139}
140
141void NodeDrv::WaitForNextPdo3()
142{
143 fNetwork->WaitForNextPdo3(fId);
144}
145
146void NodeDrv::WaitForNextPdo4()
147{
148 fNetwork->WaitForNextPdo4(fId);
149}
150
Note: See TracBrowser for help on using the repository browser.