author | leonid |
Wed, 14 Feb 2007 22:19:53 +0100 | |
changeset 97 | 9b7ec2c68a6f |
parent 40 | ddeeb217ed71 |
child 145 | e747d2e26af0 |
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 |
||
23 |
#include <stdio.h> |
|
24 |
#include <string.h> |
|
25 |
#include <sys/time.h> |
|
26 |
#include <unistd.h> |
|
27 |
#include <stdlib.h> |
|
28 |
#include <signal.h> |
|
29 |
||
30 |
#include <applicfg.h> |
|
31 |
#include <can_driver.h> |
|
32 |
#include <timers_driver.h> |
|
33 |
||
34 |
#include "Master.h" |
|
35 |
#include "Slave.h" |
|
36 |
#include "TestMasterSlave.h" |
|
37 |
||
38 |
#define MyCase(fc) case fc: eprintf(#fc);break; |
|
39 |
void print_message(Message *m) |
|
40 |
{ |
|
41 |
int i; |
|
42 |
switch(m->cob_id.w >> 7) |
|
43 |
{ |
|
44 |
MyCase(SYNC) |
|
45 |
MyCase(TIME_STAMP) |
|
46 |
MyCase(PDO1tx) |
|
47 |
MyCase(PDO1rx) |
|
48 |
MyCase(PDO2tx) |
|
49 |
MyCase(PDO2rx) |
|
50 |
MyCase(PDO3tx) |
|
51 |
MyCase(PDO3rx) |
|
52 |
MyCase(PDO4tx) |
|
53 |
MyCase(PDO4rx) |
|
54 |
MyCase(SDOtx) |
|
55 |
MyCase(SDOrx) |
|
56 |
MyCase(NODE_GUARD) |
|
57 |
MyCase(NMT) |
|
58 |
} |
|
59 |
eprintf(" rtr:%d", m->rtr); |
|
60 |
eprintf(" len:%d", m->len); |
|
61 |
for (i = 0 ; i < m->len ; i++) |
|
62 |
eprintf(" %02x", m->data[i]); |
|
63 |
eprintf("\n"); |
|
64 |
} |
|
65 |
||
66 |
UNS32 OnMasterMap1Update(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex) |
|
67 |
{ |
|
68 |
eprintf("OnSlaveMap1Update:%d\n", SlaveMap1); |
|
31 | 69 |
return 0; |
0 | 70 |
} |
71 |
||
72 |
CAN_HANDLE SlaveCanHandle; |
|
73 |
CAN_HANDLE MasterCanHandle; |
|
74 |
||
75 |
// Baudrate values for Peak board : |
|
76 |
// CAN_BAUD_1M CAN_BAUD_500K CAN_BAUD_250K CAN_BAUD_125K CAN_BAUD_100K CAN_BAUD_50K |
|
77 |
// CAN_BAUD_20K CAN_BAUD_10K CAN_BAUD_5K |
|
78 |
||
79 |
#ifdef CAN_BAUD_500K |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
80 |
int TranslateBaudeRate(char* optarg){ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
81 |
if(!strcmp( optarg, "1M")) return CAN_BAUD_1M; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
82 |
if(!strcmp( optarg, "500K")) return CAN_BAUD_500K; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
83 |
if(!strcmp( optarg, "250K")) return CAN_BAUD_250K; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
84 |
if(!strcmp( optarg, "125K")) return CAN_BAUD_125K; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
85 |
if(!strcmp( optarg, "100K")) return CAN_BAUD_100K; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
86 |
if(!strcmp( optarg, "50K")) return CAN_BAUD_50K; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
87 |
if(!strcmp( optarg, "20K")) return CAN_BAUD_20K; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
88 |
if(!strcmp( optarg, "10K")) return CAN_BAUD_10K; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
89 |
if(!strcmp( optarg, "5K")) return CAN_BAUD_5K; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
90 |
if(!strcmp( optarg, "none")) return 0; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
91 |
return 0x0000; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
92 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
93 |
s_BOARD SlaveBoard = {"0", CAN_BAUD_500K, &TestSlave_Data}; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
94 |
s_BOARD MasterBoard = {"1", CAN_BAUD_500K, &TestMaster_Data}; |
0 | 95 |
#else |
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
96 |
int TranslateBaudeRate(char* optarg){ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
97 |
if(!strcmp( optarg, "1M")) return 1000; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
98 |
if(!strcmp( optarg, "500K")) return 500; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
99 |
if(!strcmp( optarg, "250K")) return 250; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
100 |
if(!strcmp( optarg, "125K")) return 125; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
101 |
if(!strcmp( optarg, "100K")) return 100; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
102 |
if(!strcmp( optarg, "50K")) return 50; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
103 |
if(!strcmp( optarg, "20K")) return 20; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
104 |
if(!strcmp( optarg, "10K")) return 10; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
105 |
if(!strcmp( optarg, "5K")) return 5; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
106 |
if(!strcmp( optarg, "none")) return 0; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
107 |
return 0; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
108 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
109 |
s_BOARD SlaveBoard = {"0", 500, &TestSlave_Data}; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
110 |
s_BOARD MasterBoard = {"1", 500, &TestMaster_Data}; |
0 | 111 |
#endif |
112 |
||
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
113 |
|
0 | 114 |
void catch_signal(int sig) |
115 |
{ |
|
116 |
signal(SIGTERM, catch_signal); |
|
117 |
signal(SIGINT, catch_signal); |
|
32 | 118 |
eprintf("Got Signal %d\n",sig); |
119 |
} |
|
0 | 120 |
|
121 |
void help() |
|
122 |
{ |
|
123 |
printf("**************************************************************\n"); |
|
124 |
printf("* TestMasterSlave *\n"); |
|
125 |
printf("* *\n"); |
|
126 |
printf("* A simple example for PC. It does implement 2 CanOpen *\n"); |
|
127 |
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
|
128 |
printf("* communicate together, exchanging periodically NMT, SYNC, *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
129 |
printf("* SDO and PDO. *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
130 |
printf("* *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
131 |
printf("* Usage: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
132 |
printf("* ./TestMasterSlave [OPTIONS] *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
133 |
printf("* *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
134 |
printf("* OPTIONS: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
135 |
printf("* Slave: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
136 |
printf("* -s : bus name [\"0\"] *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
137 |
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
|
138 |
printf("* *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
139 |
printf("* Master: *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
140 |
printf("* -m : bus name [\"1\"] *\n"); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
141 |
printf("* -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *\n"); |
0 | 142 |
printf("* *\n"); |
143 |
printf("**************************************************************\n"); |
|
144 |
} |
|
145 |
||
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
146 |
/*************************** INIT *****************************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
147 |
void InitNodes(CO_Data* d, UNS32 id) |
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 |
/****************************** INITIALISATION SLAVE *******************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
150 |
if(SlaveBoard.baudrate) { |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
151 |
/* Defining the node Id */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
152 |
setNodeId(&TestSlave_Data, 0x02); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
153 |
/* init */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
154 |
setState(&TestSlave_Data, Initialisation); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
155 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
156 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
157 |
/****************************** INITIALISATION MASTER *******************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
158 |
if(MasterBoard.baudrate){ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
159 |
RegisterSetODentryCallBack(&TestMaster_Data, 0x2000, 0, &OnMasterMap1Update); |
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 |
/* Defining the node Id */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
162 |
setNodeId(&TestMaster_Data, 0x01); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
163 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
164 |
/* init */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
165 |
setState(&TestMaster_Data, Initialisation); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
166 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
167 |
/****************************** START *******************************/ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
168 |
/* Put the master in operational mode */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
169 |
setState(&TestMaster_Data, Operational); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
170 |
|
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
171 |
/* Ask slave node to go in operational mode */ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
172 |
masterSendNMTstateChange (&TestMaster_Data, 0x02, NMT_Start_Node); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
173 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
174 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
175 |
|
0 | 176 |
/****************************************************************************/ |
177 |
/*************************** MAIN *****************************************/ |
|
178 |
/****************************************************************************/ |
|
179 |
int main(int argc,char **argv) |
|
180 |
{ |
|
181 |
||
182 |
char c; |
|
183 |
extern char *optarg; |
|
184 |
||
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
185 |
while ((c = getopt(argc, argv, "-m:s:M:S:")) != EOF) |
0 | 186 |
{ |
187 |
switch(c) |
|
188 |
{ |
|
189 |
case 's' : |
|
190 |
if (optarg[0] == 0) |
|
191 |
{ |
|
192 |
help(); |
|
193 |
exit(1); |
|
194 |
} |
|
195 |
SlaveBoard.busname = optarg; |
|
196 |
break; |
|
197 |
case 'm' : |
|
198 |
if (optarg[0] == 0) |
|
199 |
{ |
|
200 |
help(); |
|
201 |
exit(1); |
|
202 |
} |
|
203 |
MasterBoard.busname = optarg; |
|
204 |
break; |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
205 |
case 'S' : |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
206 |
if (optarg[0] == 0) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
207 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
208 |
help(); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
209 |
exit(1); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
210 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
211 |
SlaveBoard.baudrate = TranslateBaudeRate(optarg); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
212 |
break; |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
213 |
case 'M' : |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
214 |
if (optarg[0] == 0) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
215 |
{ |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
216 |
help(); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
217 |
exit(1); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
218 |
} |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
219 |
MasterBoard.baudrate = TranslateBaudeRate(optarg); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
220 |
break; |
0 | 221 |
default: |
222 |
help(); |
|
223 |
exit(1); |
|
224 |
} |
|
225 |
} |
|
226 |
||
227 |
/* install signal handler for manual break */ |
|
228 |
signal(SIGTERM, catch_signal); |
|
229 |
signal(SIGINT, catch_signal); |
|
230 |
||
231 |
// Open CAN devices |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
232 |
if(SlaveBoard.baudrate) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
233 |
if((SlaveCanHandle = canOpen(&SlaveBoard))==NULL) goto fail_slave; |
40
ddeeb217ed71
Updated configure and fixes in Makefiles.in for cygwin compiling.
etisserant
parents:
36
diff
changeset
|
234 |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
235 |
if(MasterBoard.baudrate) |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
236 |
if((MasterCanHandle = canOpen(&MasterBoard))==NULL) goto fail_master; |
0 | 237 |
|
32 | 238 |
// Start timer thread |
239 |
StartTimerLoop(&InitNodes); |
|
240 |
||
241 |
// wait Ctrl-C |
|
242 |
pause(); |
|
243 |
eprintf("Finishing.\n"); |
|
244 |
||
245 |
// Stop timer thread |
|
246 |
StopTimerLoop(); |
|
247 |
||
248 |
// Close CAN devices (and can threads) |
|
36
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
249 |
if(SlaveBoard.baudrate) canClose(SlaveCanHandle); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
250 |
fail_master: |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
251 |
if(MasterBoard.baudrate) canClose(MasterCanHandle); |
ff3ba4a90548
Added bauderate/disable option to TestMasterSlave Master and Slave nodes.
etisserant
parents:
32
diff
changeset
|
252 |
fail_slave: |
0 | 253 |
|
254 |
||
255 |
return 0; |
|
256 |
} |