author | etisserant |
Thu, 12 Apr 2007 16:36:31 +0200 | |
changeset 155 | 746b49869cbc |
parent 149 | fe50ada8020b |
child 156 | 515d11cb496e |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
This file is part of CanFestival, a library implementing CanOpen Stack. |
|
3 |
||
4 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
|
5 |
||
6 |
See COPYING file for copyrights details. |
|
7 |
||
8 |
This library is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU Lesser General Public |
|
10 |
License as published by the Free Software Foundation; either |
|
11 |
version 2.1 of the License, or (at your option) any later version. |
|
12 |
||
13 |
This library is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
Lesser General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU Lesser General Public |
|
19 |
License along with this library; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
*/ |
|
22 |
||
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
23 |
#if defined(WIN32) && !defined(__CYGWIN__) |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
24 |
#include <windows.h> |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
25 |
#include "getopt.h" |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
26 |
void pause(void) |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
27 |
{ |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
28 |
system("PAUSE"); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
29 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
30 |
#else |
0 | 31 |
#include <stdio.h> |
32 |
#include <string.h> |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
33 |
//#include <sys/time.h> |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
34 |
//#include <unistd.h> |
0 | 35 |
#include <stdlib.h> |
36 |
#include <signal.h> |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
37 |
#endif |
0 | 38 |
|
39 |
#include <applicfg.h> |
|
40 |
#include <can_driver.h> |
|
41 |
#include <timers_driver.h> |
|
42 |
||
43 |
#include "Master.h" |
|
44 |
#include "Slave.h" |
|
45 |
#include "TestMasterSlave.h" |
|
46 |
||
47 |
#define MyCase(fc) case fc: eprintf(#fc);break; |
|
48 |
void print_message(Message *m) |
|
49 |
{ |
|
50 |
int i; |
|
51 |
switch(m->cob_id.w >> 7) |
|
52 |
{ |
|
53 |
MyCase(SYNC) |
|
54 |
MyCase(TIME_STAMP) |
|
55 |
MyCase(PDO1tx) |
|
56 |
MyCase(PDO1rx) |
|
57 |
MyCase(PDO2tx) |
|
58 |
MyCase(PDO2rx) |
|
59 |
MyCase(PDO3tx) |
|
60 |
MyCase(PDO3rx) |
|
61 |
MyCase(PDO4tx) |
|
62 |
MyCase(PDO4rx) |
|
63 |
MyCase(SDOtx) |
|
64 |
MyCase(SDOrx) |
|
65 |
MyCase(NODE_GUARD) |
|
66 |
MyCase(NMT) |
|
67 |
} |
|
68 |
eprintf(" rtr:%d", m->rtr); |
|
69 |
eprintf(" len:%d", m->len); |
|
70 |
for (i = 0 ; i < m->len ; i++) |
|
71 |
eprintf(" %02x", m->data[i]); |
|
72 |
eprintf("\n"); |
|
73 |
} |
|
74 |
||
75 |
UNS32 OnMasterMap1Update(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex) |
|
76 |
{ |
|
77 |
eprintf("OnSlaveMap1Update:%d\n", SlaveMap1); |
|
31 | 78 |
return 0; |
0 | 79 |
} |
80 |
||
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
81 |
s_BOARD SlaveBoard = {"0", "500K"}; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
82 |
s_BOARD MasterBoard = {"1", "500K"}; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
83 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
84 |
#if !defined(WIN32) || defined(__CYGWIN__) |
0 | 85 |
void catch_signal(int sig) |
86 |
{ |
|
87 |
signal(SIGTERM, catch_signal); |
|
88 |
signal(SIGINT, catch_signal); |
|
32 | 89 |
eprintf("Got Signal %d\n",sig); |
90 |
} |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
91 |
#endif |
0 | 92 |
|
93 |
void help() |
|
94 |
{ |
|
95 |
printf("**************************************************************\n"); |
|
96 |
printf("* TestMasterSlave *\n"); |
|
97 |
printf("* *\n"); |
|
98 |
printf("* A simple example for PC. It does implement 2 CanOpen *\n"); |
|
99 |
printf("* nodes in the same process. A master and a slave. Both *\n"); |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
100 |
printf("* communicate together, exchanging periodically NMT, SYNC, *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
101 |
printf("* SDO and PDO. *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
102 |
printf("* *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
103 |
printf("* Usage: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
104 |
printf("* ./TestMasterSlave [OPTIONS] *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
105 |
printf("* *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
106 |
printf("* OPTIONS: *\n"); |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
107 |
printf("* -l : Can library [\"libcanfestival_can_virtual.so\"] *\n"); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
108 |
printf("* *\n"); |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
109 |
printf("* Slave: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
110 |
printf("* -s : bus name [\"0\"] *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
111 |
printf("* -S : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
112 |
printf("* *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
113 |
printf("* Master: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
114 |
printf("* -m : bus name [\"1\"] *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
115 |
printf("* -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *\n"); |
0 | 116 |
printf("* *\n"); |
117 |
printf("**************************************************************\n"); |
|
118 |
} |
|
119 |
||
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
120 |
/*************************** INIT *****************************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
121 |
void InitNodes(CO_Data* d, UNS32 id) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
122 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
123 |
/****************************** INITIALISATION SLAVE *******************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
124 |
if(SlaveBoard.baudrate) { |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
125 |
/* Defining the node Id */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
126 |
setNodeId(&TestSlave_Data, 0x02); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
127 |
/* init */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
128 |
setState(&TestSlave_Data, Initialisation); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
129 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
130 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
131 |
/****************************** INITIALISATION MASTER *******************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
132 |
if(MasterBoard.baudrate){ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
133 |
RegisterSetODentryCallBack(&TestMaster_Data, 0x2000, 0, &OnMasterMap1Update); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
134 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
135 |
/* Defining the node Id */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
136 |
setNodeId(&TestMaster_Data, 0x01); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
137 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
138 |
/* init */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
139 |
setState(&TestMaster_Data, Initialisation); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
140 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
141 |
/****************************** START *******************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
142 |
/* Put the master in operational mode */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
143 |
setState(&TestMaster_Data, Operational); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
144 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
145 |
/* Ask slave node to go in operational mode */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
146 |
masterSendNMTstateChange (&TestMaster_Data, 0x02, NMT_Start_Node); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
147 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
148 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
149 |
|
0 | 150 |
/****************************************************************************/ |
151 |
/*************************** MAIN *****************************************/ |
|
152 |
/****************************************************************************/ |
|
153 |
int main(int argc,char **argv) |
|
154 |
{ |
|
155 |
||
156 |
char c; |
|
157 |
extern char *optarg; |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
158 |
char* LibraryPath="libcanfestival_can_virtual.so"; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
159 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
160 |
while ((c = getopt(argc, argv, "-m:s:M:S:l:")) != EOF) |
0 | 161 |
{ |
162 |
switch(c) |
|
163 |
{ |
|
164 |
case 's' : |
|
165 |
if (optarg[0] == 0) |
|
166 |
{ |
|
167 |
help(); |
|
168 |
exit(1); |
|
169 |
} |
|
170 |
SlaveBoard.busname = optarg; |
|
171 |
break; |
|
172 |
case 'm' : |
|
173 |
if (optarg[0] == 0) |
|
174 |
{ |
|
175 |
help(); |
|
176 |
exit(1); |
|
177 |
} |
|
178 |
MasterBoard.busname = optarg; |
|
179 |
break; |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
180 |
case 'S' : |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
181 |
if (optarg[0] == 0) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
182 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
183 |
help(); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
184 |
exit(1); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
185 |
} |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
186 |
SlaveBoard.baudrate = optarg; |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
187 |
break; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
188 |
case 'M' : |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
189 |
if (optarg[0] == 0) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
190 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
191 |
help(); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
192 |
exit(1); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
193 |
} |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
194 |
MasterBoard.baudrate = optarg; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
195 |
break; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
196 |
case 'l' : |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
197 |
if (optarg[0] == 0) |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
198 |
{ |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
199 |
help(); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
200 |
exit(1); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
201 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
202 |
LibraryPath = optarg; |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
203 |
break; |
0 | 204 |
default: |
205 |
help(); |
|
206 |
exit(1); |
|
207 |
} |
|
208 |
} |
|
209 |
||
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
210 |
#if !defined(WIN32) || defined(__CYGWIN__) |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
211 |
/* install signal handler for manual break */ |
0 | 212 |
signal(SIGTERM, catch_signal); |
213 |
signal(SIGINT, catch_signal); |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
214 |
#endif |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
215 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
216 |
#ifndef NOT_USE_DYNAMIC_LOADING |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
217 |
LoadCanDriver(LibraryPath); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
218 |
#endif |
0 | 219 |
// Open CAN devices |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
220 |
if(SlaveBoard.baudrate){ |
149 | 221 |
|
222 |
TestSlave_Data.heartbeatError = TestSlave_heartbeatError; |
|
223 |
TestSlave_Data.SDOtimeoutError = TestSlave_SDOtimeoutError; |
|
224 |
TestSlave_Data.initialisation = TestSlave_initialisation; |
|
225 |
TestSlave_Data.preOperational = TestSlave_preOperational; |
|
226 |
TestSlave_Data.operational = TestSlave_operational; |
|
227 |
TestSlave_Data.stopped = TestSlave_stopped; |
|
228 |
TestSlave_Data.post_sync = TestSlave_post_sync; |
|
229 |
TestSlave_Data.post_TPDO = TestSlave_post_TPDO; |
|
230 |
||
231 |
if(!canOpen(&SlaveBoard,&TestSlave_Data)){ |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
232 |
eprintf("Cannot open Slave Board (%s,%s)\n",SlaveBoard.busname, SlaveBoard.baudrate); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
233 |
goto fail_slave; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
234 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
235 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
236 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
237 |
if(MasterBoard.baudrate){ |
149 | 238 |
|
239 |
TestMaster_Data.heartbeatError = TestMaster_heartbeatError; |
|
240 |
TestMaster_Data.SDOtimeoutError = TestMaster_SDOtimeoutError; |
|
241 |
TestMaster_Data.initialisation = TestMaster_initialisation; |
|
242 |
TestMaster_Data.preOperational = TestMaster_preOperational; |
|
243 |
TestMaster_Data.operational = TestMaster_operational; |
|
244 |
TestMaster_Data.stopped = TestMaster_stopped; |
|
245 |
TestMaster_Data.post_sync = TestMaster_post_sync; |
|
246 |
TestMaster_Data.post_TPDO = TestMaster_post_TPDO; |
|
247 |
||
248 |
if(!canOpen(&MasterBoard,&TestMaster_Data)){ |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
249 |
eprintf("Cannot open Master Board (%s,%s)\n",SlaveBoard.busname, SlaveBoard.baudrate); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
250 |
goto fail_master; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
251 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
252 |
} |
0 | 253 |
|
32 | 254 |
// Start timer thread |
255 |
StartTimerLoop(&InitNodes); |
|
256 |
||
257 |
// wait Ctrl-C |
|
258 |
pause(); |
|
259 |
eprintf("Finishing.\n"); |
|
260 |
||
261 |
// Stop timer thread |
|
262 |
StopTimerLoop(); |
|
263 |
||
264 |
// Close CAN devices (and can threads) |
|
149 | 265 |
if(SlaveBoard.baudrate) canClose(&TestSlave_Data); |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
266 |
fail_master: |
149 | 267 |
if(MasterBoard.baudrate) canClose(&TestMaster_Data); |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
268 |
fail_slave: |
0 | 269 |
|
270 |
||
271 |
return 0; |
|
272 |
} |