author | etisserant |
Fri, 13 Apr 2007 21:54:13 +0200 | |
changeset 159 | c7c84c68717b |
parent 156 | 515d11cb496e |
child 161 | c4908cc776a9 |
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 |
|
156 | 39 |
#include "canfestival.h" |
40 |
//#include <can_driver.h> |
|
41 |
//#include <timers_driver.h> |
|
0 | 42 |
|
43 |
#include "Master.h" |
|
44 |
#include "Slave.h" |
|
45 |
#include "TestMasterSlave.h" |
|
46 |
||
47 |
UNS32 OnMasterMap1Update(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex) |
|
48 |
{ |
|
49 |
eprintf("OnSlaveMap1Update:%d\n", SlaveMap1); |
|
31 | 50 |
return 0; |
0 | 51 |
} |
52 |
||
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
53 |
s_BOARD SlaveBoard = {"0", "500K"}; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
54 |
s_BOARD MasterBoard = {"1", "500K"}; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
55 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
56 |
#if !defined(WIN32) || defined(__CYGWIN__) |
0 | 57 |
void catch_signal(int sig) |
58 |
{ |
|
59 |
signal(SIGTERM, catch_signal); |
|
60 |
signal(SIGINT, catch_signal); |
|
32 | 61 |
eprintf("Got Signal %d\n",sig); |
62 |
} |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
63 |
#endif |
0 | 64 |
|
65 |
void help() |
|
66 |
{ |
|
67 |
printf("**************************************************************\n"); |
|
68 |
printf("* TestMasterSlave *\n"); |
|
69 |
printf("* *\n"); |
|
70 |
printf("* A simple example for PC. It does implement 2 CanOpen *\n"); |
|
71 |
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
|
72 |
printf("* communicate together, exchanging periodically NMT, SYNC, *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
73 |
printf("* SDO and PDO. *\n"); |
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 *******************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
96 |
if(SlaveBoard.baudrate) { |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
97 |
/* Defining the node Id */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
98 |
setNodeId(&TestSlave_Data, 0x02); |
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 *******************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
104 |
if(MasterBoard.baudrate){ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
105 |
RegisterSetODentryCallBack(&TestMaster_Data, 0x2000, 0, &OnMasterMap1Update); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
106 |
|
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); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
112 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
113 |
/****************************** START *******************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
114 |
/* Put the master in operational mode */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
115 |
setState(&TestMaster_Data, Operational); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
116 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
117 |
/* Ask slave node to go in operational mode */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
118 |
masterSendNMTstateChange (&TestMaster_Data, 0x02, NMT_Start_Node); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
119 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
120 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
121 |
|
0 | 122 |
/****************************************************************************/ |
123 |
/*************************** MAIN *****************************************/ |
|
124 |
/****************************************************************************/ |
|
125 |
int main(int argc,char **argv) |
|
126 |
{ |
|
127 |
||
128 |
char c; |
|
129 |
extern char *optarg; |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
130 |
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
|
131 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
132 |
while ((c = getopt(argc, argv, "-m:s:M:S:l:")) != EOF) |
0 | 133 |
{ |
134 |
switch(c) |
|
135 |
{ |
|
136 |
case 's' : |
|
137 |
if (optarg[0] == 0) |
|
138 |
{ |
|
139 |
help(); |
|
140 |
exit(1); |
|
141 |
} |
|
142 |
SlaveBoard.busname = optarg; |
|
143 |
break; |
|
144 |
case 'm' : |
|
145 |
if (optarg[0] == 0) |
|
146 |
{ |
|
147 |
help(); |
|
148 |
exit(1); |
|
149 |
} |
|
150 |
MasterBoard.busname = optarg; |
|
151 |
break; |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
152 |
case 'S' : |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
153 |
if (optarg[0] == 0) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
154 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
155 |
help(); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
156 |
exit(1); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
157 |
} |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
158 |
SlaveBoard.baudrate = optarg; |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
159 |
break; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
160 |
case 'M' : |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
161 |
if (optarg[0] == 0) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
162 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
163 |
help(); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
164 |
exit(1); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
165 |
} |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
166 |
MasterBoard.baudrate = optarg; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
167 |
break; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
168 |
case 'l' : |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
169 |
if (optarg[0] == 0) |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
170 |
{ |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
171 |
help(); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
172 |
exit(1); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
173 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
174 |
LibraryPath = optarg; |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
175 |
break; |
0 | 176 |
default: |
177 |
help(); |
|
178 |
exit(1); |
|
179 |
} |
|
180 |
} |
|
181 |
||
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
182 |
#if !defined(WIN32) || defined(__CYGWIN__) |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
183 |
/* install signal handler for manual break */ |
0 | 184 |
signal(SIGTERM, catch_signal); |
185 |
signal(SIGINT, catch_signal); |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
186 |
#endif |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
187 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
188 |
#ifndef NOT_USE_DYNAMIC_LOADING |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
189 |
LoadCanDriver(LibraryPath); |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
190 |
#endif |
0 | 191 |
// Open CAN devices |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
192 |
if(SlaveBoard.baudrate){ |
149 | 193 |
|
194 |
TestSlave_Data.heartbeatError = TestSlave_heartbeatError; |
|
195 |
TestSlave_Data.SDOtimeoutError = TestSlave_SDOtimeoutError; |
|
196 |
TestSlave_Data.initialisation = TestSlave_initialisation; |
|
197 |
TestSlave_Data.preOperational = TestSlave_preOperational; |
|
198 |
TestSlave_Data.operational = TestSlave_operational; |
|
199 |
TestSlave_Data.stopped = TestSlave_stopped; |
|
200 |
TestSlave_Data.post_sync = TestSlave_post_sync; |
|
201 |
TestSlave_Data.post_TPDO = TestSlave_post_TPDO; |
|
202 |
||
203 |
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
|
204 |
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
|
205 |
goto fail_slave; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
206 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
207 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
208 |
|
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
209 |
if(MasterBoard.baudrate){ |
149 | 210 |
|
211 |
TestMaster_Data.heartbeatError = TestMaster_heartbeatError; |
|
212 |
TestMaster_Data.SDOtimeoutError = TestMaster_SDOtimeoutError; |
|
213 |
TestMaster_Data.initialisation = TestMaster_initialisation; |
|
214 |
TestMaster_Data.preOperational = TestMaster_preOperational; |
|
215 |
TestMaster_Data.operational = TestMaster_operational; |
|
216 |
TestMaster_Data.stopped = TestMaster_stopped; |
|
217 |
TestMaster_Data.post_sync = TestMaster_post_sync; |
|
218 |
TestMaster_Data.post_TPDO = TestMaster_post_TPDO; |
|
219 |
||
220 |
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
|
221 |
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
|
222 |
goto fail_master; |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
223 |
} |
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
40
diff
changeset
|
224 |
} |
0 | 225 |
|
32 | 226 |
// Start timer thread |
227 |
StartTimerLoop(&InitNodes); |
|
228 |
||
229 |
// wait Ctrl-C |
|
230 |
pause(); |
|
231 |
eprintf("Finishing.\n"); |
|
232 |
||
233 |
// Stop timer thread |
|
234 |
StopTimerLoop(); |
|
235 |
||
236 |
// Close CAN devices (and can threads) |
|
149 | 237 |
if(SlaveBoard.baudrate) canClose(&TestSlave_Data); |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
238 |
fail_master: |
149 | 239 |
if(MasterBoard.baudrate) canClose(&TestMaster_Data); |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
240 |
fail_slave: |
0 | 241 |
|
242 |
||
243 |
return 0; |
|
244 |
} |