21 */ |
21 */ |
22 |
22 |
23 #include "Master.h" |
23 #include "Master.h" |
24 #include "SlaveA.h" |
24 #include "SlaveA.h" |
25 #include "SlaveB.h" |
25 #include "SlaveB.h" |
26 #include "TestMasterSlaveLSS.h" |
26 #include "TestMasterSlaveLSS.h" |
27 |
27 |
28 extern s_BOARD MasterBoard; |
28 extern s_BOARD MasterBoard; |
29 |
|
30 /*****************************************************************************/ |
29 /*****************************************************************************/ |
31 void TestMaster_heartbeatError(CO_Data* d, UNS8 heartbeatID) |
30 void TestMaster_heartbeatError(CO_Data* d, UNS8 heartbeatID) |
32 { |
31 { |
33 eprintf("TestMaster_heartbeatError %d\n", heartbeatID); |
32 eprintf("TestMaster_heartbeatError %d\n", heartbeatID); |
34 } |
33 } |
215 UNS32 SINC_cicle=50000;// us |
214 UNS32 SINC_cicle=50000;// us |
216 UNS8 size = sizeof(UNS32); |
215 UNS8 size = sizeof(UNS32); |
217 |
216 |
218 /* The slaves are now configured (nodeId and Baudrate) via the LSS services. |
217 /* The slaves are now configured (nodeId and Baudrate) via the LSS services. |
219 * Switch the LSS state to WAITING and restart the slaves. */ |
218 * Switch the LSS state to WAITING and restart the slaves. */ |
|
219 MasterBoard.baudrate="250K"; |
220 |
220 |
221 printf("Master : Switch Delay period finished. Switching to LSS WAITING state\n"); |
221 printf("Master : Switch Delay period finished. Switching to LSS WAITING state\n"); |
222 configNetworkNode(&TestMaster_Data,LSS_SM_GLOBAL,&LSS_mode,0,NULL); |
222 configNetworkNode(d,LSS_SM_GLOBAL,&LSS_mode,0,NULL); |
223 |
223 |
224 printf("Master : Restarting all the slaves\n"); |
224 printf("Master : Restarting all the slaves\n"); |
225 masterSendNMTstateChange (&TestMaster_Data, 0x00, NMT_Reset_Node); |
225 masterSendNMTstateChange (d, 0x00, NMT_Reset_Node); |
226 |
226 |
227 printf("Master : Starting the SYNC producer\n"); |
227 printf("Master : Starting the SYNC producer\n"); |
228 writeLocalDict( &TestMaster_Data, /*CO_Data* d*/ |
228 writeLocalDict( d, /*CO_Data* d*/ |
229 0x1006, /*UNS16 index*/ |
229 0x1006, /*UNS16 index*/ |
230 0x00, /*UNS8 subind*/ |
230 0x00, /*UNS8 subind*/ |
231 &SINC_cicle, /*void * pSourceData,*/ |
231 &SINC_cicle, /*void * pSourceData,*/ |
232 &size, /* UNS8 * pExpectedSize*/ |
232 &size, /* UNS8 * pExpectedSize*/ |
233 RW); /* UNS8 checkAccess */ |
233 RW); /* UNS8 checkAccess */ |
234 |
234 |
235 return; |
235 return; |
236 } |
236 } |
237 else{ |
237 else{ |
238 printf("Master : unable to activate bit timing. trying again\n"); |
238 UNS16 Switch_delay=1; |
239 init_step_LSS--; |
239 UNS8 LSS_mode=LSS_CONFIGURATION_MODE; |
|
240 |
|
241 eprintf("Master : unable to activate bit timing. trying again\n"); |
|
242 configNetworkNode(d,LSS_CONF_ACT_BIT_TIMING,&Switch_delay,0,CheckLSSAndContinue); |
|
243 return; |
240 } |
244 } |
241 break; |
245 break; |
242 case LSS_SM_SELECTIVE_SERIAL: |
246 case LSS_SM_SELECTIVE_SERIAL: |
243 printf("Slave in LSS CONFIGURATION state\n"); |
247 printf("Slave in LSS CONFIGURATION state\n"); |
244 break; |
248 break; |
255 |
259 |
256 /*The configuration of the slaves' nodeId ended. |
260 /*The configuration of the slaves' nodeId ended. |
257 * Start the configuration of the baud rate. */ |
261 * Start the configuration of the baud rate. */ |
258 eprintf("Master : There are not no-configured slaves in the net\n", command); |
262 eprintf("Master : There are not no-configured slaves in the net\n", command); |
259 eprintf("Switching all the nodes to LSS CONFIGURATION state\n"); |
263 eprintf("Switching all the nodes to LSS CONFIGURATION state\n"); |
260 configNetworkNode(&TestMaster_Data,LSS_SM_GLOBAL,&LSS_mode,0,NULL); |
264 configNetworkNode(d,LSS_SM_GLOBAL,&LSS_mode,0,NULL); |
261 eprintf("LSS=>Activate Bit Timing\n"); |
265 eprintf("LSS=>Activate Bit Timing\n"); |
262 configNetworkNode(&TestMaster_Data,LSS_CONF_ACT_BIT_TIMING,&Switch_delay,0,CheckLSSAndContinue); |
266 configNetworkNode(d,LSS_CONF_ACT_BIT_TIMING,&Switch_delay,0,CheckLSSAndContinue); |
263 return; |
267 return; |
264 } |
268 } |
265 break; |
269 break; |
266 case LSS_INQ_VENDOR_ID: |
270 case LSS_INQ_VENDOR_ID: |
267 printf("Slave VendorID %x\n", dat1); |
271 printf("Slave VendorID %x\n", dat1); |
324 UNS32 Revision_Number_low=0x78901230; |
328 UNS32 Revision_Number_low=0x78901230; |
325 UNS32 Serial_Number_high=0x56789020; |
329 UNS32 Serial_Number_high=0x56789020; |
326 UNS32 Serial_Number_low=0x56789010; |
330 UNS32 Serial_Number_low=0x56789010; |
327 UNS8 LSS_mode=LSS_WAITING_MODE; |
331 UNS8 LSS_mode=LSS_WAITING_MODE; |
328 UNS8 Baud_Table=0; |
332 UNS8 Baud_Table=0; |
329 UNS8 Baud_BitTiming=3; |
333 //UNS8 Baud_BitTiming=3; |
|
334 char* Baud_BitTiming="250K"; |
330 UNS8 res; |
335 UNS8 res; |
331 eprintf("ConfigureLSSNode step %d -> ",init_step_LSS); |
336 eprintf("ConfigureLSSNode step %d -> ",init_step_LSS); |
332 |
337 |
333 switch(init_step_LSS){ |
338 switch(init_step_LSS){ |
334 case 1: /* LSS=>identify non-configured remote slave */ |
339 case 1: /* LSS=>identify non-configured remote slave */ |
448 /* Wait until the new baud rate is stored before configure the slaves*/ |
453 /* Wait until the new baud rate is stored before configure the slaves*/ |
449 if(MasterBoard.baudrate=="250K") |
454 if(MasterBoard.baudrate=="250K") |
450 ConfigureSlaveNode(d, nodeid); |
455 ConfigureSlaveNode(d, nodeid); |
451 } |
456 } |
452 |
457 |
453 void TestMaster_ChangeBaudRate(CO_Data* d, char *baudrate) |
|
454 { |
|
455 eprintf("TestMaster_ChangeBaudRate from %s to %s\n", MasterBoard.baudrate, baudrate); |
|
456 MasterBoard.baudrate=baudrate; |
|
457 /* something to do with the new baudrate */ |
|
458 } |
|