author | Christian Taedcke <hacking@taedcke.com> |
Thu, 22 Dec 2011 16:03:39 +0100 | |
changeset 682 | dce1e0af6604 |
parent 629 | b9274b595650 |
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> |
|
169
90c0a676e631
Removed compilation warnings with some GCC. + Fixed test for baudrate = none
etisserant
parents:
161
diff
changeset
|
33 |
#include <unistd.h> |
0 | 34 |
#include <stdlib.h> |
35 |
#include <signal.h> |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
36 |
#endif |
0 | 37 |
|
156 | 38 |
#include "canfestival.h" |
39 |
//#include <can_driver.h> |
|
40 |
//#include <timers_driver.h> |
|
0 | 41 |
|
42 |
#include "Master.h" |
|
43 |
#include "Slave.h" |
|
44 |
#include "TestMasterSlave.h" |
|
45 |
||
46 |
UNS32 OnMasterMap1Update(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex) |
|
47 |
{ |
|
466 | 48 |
eprintf("OnMasterMap1Update:%d\n", MasterMap1); |
31 | 49 |
return 0; |
0 | 50 |
} |
51 |
||
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
52 |
s_BOARD SlaveBoard = {"0", "125K"}; |
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
53 |
s_BOARD MasterBoard = {"1", "125K"}; |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
54 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
55 |
#if !defined(WIN32) || defined(__CYGWIN__) |
0 | 56 |
void catch_signal(int sig) |
57 |
{ |
|
58 |
signal(SIGTERM, catch_signal); |
|
59 |
signal(SIGINT, catch_signal); |
|
32 | 60 |
eprintf("Got Signal %d\n",sig); |
61 |
} |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
62 |
#endif |
0 | 63 |
|
454 | 64 |
void help(void) |
0 | 65 |
{ |
66 |
printf("**************************************************************\n"); |
|
67 |
printf("* TestMasterSlave *\n"); |
|
68 |
printf("* *\n"); |
|
69 |
printf("* A simple example for PC. It does implement 2 CanOpen *\n"); |
|
70 |
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
|
71 |
printf("* communicate together, exchanging periodically NMT, SYNC, *\n"); |
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
72 |
printf("* SDO and PDO. Master configure heartbeat producer time *\n"); |
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
73 |
printf("* at 1000 ms for slave node-id 0x02 by concise DCF. *\n"); |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
74 |
printf("* *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
75 |
printf("* Usage: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
76 |
printf("* ./TestMasterSlave [OPTIONS] *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
77 |
printf("* *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
78 |
printf("* OPTIONS: *\n"); |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
79 |
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
|
80 |
printf("* *\n"); |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
81 |
printf("* Slave: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
82 |
printf("* -s : bus name [\"0\"] *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
83 |
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
|
84 |
printf("* *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
85 |
printf("* Master: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
86 |
printf("* -m : bus name [\"1\"] *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
87 |
printf("* -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *\n"); |
0 | 88 |
printf("* *\n"); |
89 |
printf("**************************************************************\n"); |
|
90 |
} |
|
91 |
||
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
92 |
/*************************** INIT *****************************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
93 |
void InitNodes(CO_Data* d, UNS32 id) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
94 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
95 |
/****************************** INITIALISATION SLAVE *******************************/ |
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
96 |
if(strcmp(SlaveBoard.baudrate, "none")) { |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
97 |
setNodeId(&TestSlave_Data, 0x02); |
343 | 98 |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
99 |
/* init */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
100 |
setState(&TestSlave_Data, Initialisation); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
101 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
102 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
103 |
/****************************** INITIALISATION MASTER *******************************/ |
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
104 |
if(strcmp(MasterBoard.baudrate, "none")){ |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
105 |
RegisterSetODentryCallBack(&TestMaster_Data, 0x2000, 0, &OnMasterMap1Update); |
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
106 |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
107 |
/* Defining the node Id */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
108 |
setNodeId(&TestMaster_Data, 0x01); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
109 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
110 |
/* init */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
111 |
setState(&TestMaster_Data, Initialisation); |
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
112 |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
113 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
114 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
115 |
|
454 | 116 |
/*************************** EXIT *****************************************/ |
117 |
void Exit(CO_Data* d, UNS32 id) |
|
118 |
{ |
|
465 | 119 |
if(strcmp(MasterBoard.baudrate, "none")){ |
120 |
||
121 |
masterSendNMTstateChange(&TestMaster_Data, 0x02, NMT_Reset_Node); |
|
454 | 122 |
|
465 | 123 |
//Stop master |
124 |
setState(&TestMaster_Data, Stopped); |
|
125 |
} |
|
454 | 126 |
} |
127 |
||
0 | 128 |
/****************************************************************************/ |
129 |
/*************************** MAIN *****************************************/ |
|
130 |
/****************************************************************************/ |
|
131 |
int main(int argc,char **argv) |
|
132 |
{ |
|
133 |
||
191 | 134 |
int c; |
0 | 135 |
extern char *optarg; |
343 | 136 |
char* LibraryPath="../../drivers/can_virtual/libcanfestival_can_virtual.so"; |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
137 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
138 |
while ((c = getopt(argc, argv, "-m:s:M:S:l:")) != EOF) |
0 | 139 |
{ |
140 |
switch(c) |
|
141 |
{ |
|
142 |
case 's' : |
|
143 |
if (optarg[0] == 0) |
|
144 |
{ |
|
145 |
help(); |
|
146 |
exit(1); |
|
147 |
} |
|
148 |
SlaveBoard.busname = optarg; |
|
149 |
break; |
|
150 |
case 'm' : |
|
151 |
if (optarg[0] == 0) |
|
152 |
{ |
|
153 |
help(); |
|
154 |
exit(1); |
|
155 |
} |
|
156 |
MasterBoard.busname = optarg; |
|
157 |
break; |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
158 |
case 'S' : |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
159 |
if (optarg[0] == 0) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
160 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
161 |
help(); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
162 |
exit(1); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
163 |
} |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
164 |
SlaveBoard.baudrate = optarg; |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
165 |
break; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
166 |
case 'M' : |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
167 |
if (optarg[0] == 0) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
168 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
169 |
help(); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
170 |
exit(1); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
171 |
} |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
172 |
MasterBoard.baudrate = optarg; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
173 |
break; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
174 |
case 'l' : |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
175 |
if (optarg[0] == 0) |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
176 |
{ |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
177 |
help(); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
178 |
exit(1); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
179 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
180 |
LibraryPath = optarg; |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
181 |
break; |
0 | 182 |
default: |
183 |
help(); |
|
184 |
exit(1); |
|
185 |
} |
|
186 |
} |
|
187 |
||
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
188 |
#if !defined(WIN32) || defined(__CYGWIN__) |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
189 |
/* install signal handler for manual break */ |
0 | 190 |
signal(SIGTERM, catch_signal); |
191 |
signal(SIGINT, catch_signal); |
|
629 | 192 |
#endif |
193 |
// Also Windows needs to initialize the Timer! |
|
194 |
// Moving this line into the ifndef leads to a lethal crash! |
|
454 | 195 |
TimerInit(); |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
196 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
197 |
#ifndef NOT_USE_DYNAMIC_LOADING |
331 | 198 |
if (LoadCanDriver(LibraryPath) == NULL) |
199 |
printf("Unable to load library: %s\n",LibraryPath); |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
200 |
#endif |
0 | 201 |
// Open CAN devices |
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
202 |
|
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
203 |
if(strcmp(SlaveBoard.baudrate, "none")){ |
149 | 204 |
|
205 |
TestSlave_Data.heartbeatError = TestSlave_heartbeatError; |
|
206 |
TestSlave_Data.initialisation = TestSlave_initialisation; |
|
207 |
TestSlave_Data.preOperational = TestSlave_preOperational; |
|
208 |
TestSlave_Data.operational = TestSlave_operational; |
|
209 |
TestSlave_Data.stopped = TestSlave_stopped; |
|
210 |
TestSlave_Data.post_sync = TestSlave_post_sync; |
|
211 |
TestSlave_Data.post_TPDO = TestSlave_post_TPDO; |
|
284 | 212 |
TestSlave_Data.storeODSubIndex = TestSlave_storeODSubIndex; |
213 |
TestSlave_Data.post_emcy = TestSlave_post_emcy; |
|
149 | 214 |
|
215 |
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
|
216 |
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
|
217 |
goto fail_slave; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
218 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
219 |
} |
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
220 |
if(strcmp(MasterBoard.baudrate, "none")){ |
149 | 221 |
|
222 |
TestMaster_Data.heartbeatError = TestMaster_heartbeatError; |
|
223 |
TestMaster_Data.initialisation = TestMaster_initialisation; |
|
224 |
TestMaster_Data.preOperational = TestMaster_preOperational; |
|
225 |
TestMaster_Data.operational = TestMaster_operational; |
|
226 |
TestMaster_Data.stopped = TestMaster_stopped; |
|
227 |
TestMaster_Data.post_sync = TestMaster_post_sync; |
|
228 |
TestMaster_Data.post_TPDO = TestMaster_post_TPDO; |
|
284 | 229 |
TestMaster_Data.post_emcy = TestMaster_post_emcy; |
343 | 230 |
TestMaster_Data.post_SlaveBootup=TestMaster_post_SlaveBootup; |
149 | 231 |
|
232 |
if(!canOpen(&MasterBoard,&TestMaster_Data)){ |
|
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
233 |
eprintf("Cannot open Master Board (%s,%s)\n",MasterBoard.busname, MasterBoard.baudrate); |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
234 |
goto fail_master; |
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 |
} |
194 | 237 |
|
32 | 238 |
// Start timer thread |
239 |
StartTimerLoop(&InitNodes); |
|
240 |
||
241 |
// wait Ctrl-C |
|
242 |
pause(); |
|
262
f1c892f3f93c
Added exclusion mechanism to TestMasterSlave finish code
etisserant
parents:
194
diff
changeset
|
243 |
|
32 | 244 |
// Stop timer thread |
454 | 245 |
StopTimerLoop(&Exit); |
32 | 246 |
|
247 |
// Close CAN devices (and can threads) |
|
454 | 248 |
if(strcmp(MasterBoard.baudrate, "none")) canClose(&TestMaster_Data); |
249 |
fail_master: |
|
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
250 |
if(strcmp(SlaveBoard.baudrate, "none")) canClose(&TestSlave_Data); |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
251 |
fail_slave: |
454 | 252 |
TimerCleanup(); |
179
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
253 |
return 0; |
763b6d32c1a6
Master configure slave's heartbeat producer time by concise DCF.
greg
parents:
172
diff
changeset
|
254 |
} |