equal
deleted
inserted
replaced
183 d->nodeState = Pre_operational; |
183 d->nodeState = Pre_operational; |
184 newState = Pre_operational; |
184 newState = Pre_operational; |
185 switchCommunicationState(d, &newCommunicationState); |
185 switchCommunicationState(d, &newCommunicationState); |
186 if (!(*(d->iam_a_slave))) |
186 if (!(*(d->iam_a_slave))) |
187 { |
187 { |
188 send_consise_dcf(d,0x01); |
188 //send_consise_dcf(d,0x01); |
189 /*(*d->preOperational)() will be called once dcf sent */ |
189 masterSendNMTstateChange (d, 0, NMT_Reset_Node); |
|
190 (*d->preOperational)(); |
190 } |
191 } |
191 else |
192 else |
192 { |
193 { |
193 (*d->preOperational)(); |
194 (*d->preOperational)(); |
194 } |
195 } |
264 return; |
265 return; |
265 } |
266 } |
266 #endif |
267 #endif |
267 |
268 |
268 if(offset){ |
269 if(offset){ |
269 /* Adjust COB-ID Client->Server (rx) only id already set to default value*/ |
270 /* Adjust COB-ID Client->Server (rx) only id already set to default value or id not valid (id==0xFF)*/ |
270 if(*(UNS32*)d->objdict[offset].pSubindex[1].pObject == 0x600 + *d->bDeviceNodeId){ |
271 if((*(UNS32*)d->objdict[offset].pSubindex[1].pObject == 0x600 + *d->bDeviceNodeId)||(*d->bDeviceNodeId==0xFF)){ |
271 /* cob_id_client = 0x600 + nodeId; */ |
272 /* cob_id_client = 0x600 + nodeId; */ |
272 *(UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + nodeId; |
273 *(UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + nodeId; |
273 } |
274 } |
274 /* Adjust COB-ID Server -> Client (tx) only id already set to default value*/ |
275 /* Adjust COB-ID Server -> Client (tx) only id already set to default value or id not valid (id==0xFF)*/ |
275 if(*(UNS32*)d->objdict[offset].pSubindex[2].pObject == 0x580 + *d->bDeviceNodeId){ |
276 if((*(UNS32*)d->objdict[offset].pSubindex[2].pObject == 0x580 + *d->bDeviceNodeId)||(*d->bDeviceNodeId==0xFF)){ |
276 /* cob_id_server = 0x580 + nodeId; */ |
277 /* cob_id_server = 0x580 + nodeId; */ |
277 *(UNS32*)d->objdict[offset].pSubindex[2].pObject = 0x580 + nodeId; |
278 *(UNS32*)d->objdict[offset].pSubindex[2].pObject = 0x580 + nodeId; |
278 } |
279 } |
279 } |
280 } |
280 |
281 |
290 UNS8 i = 0; |
291 UNS8 i = 0; |
291 UNS16 offset = d->firstIndex->PDO_RCV; |
292 UNS16 offset = d->firstIndex->PDO_RCV; |
292 UNS16 lastIndex = d->lastIndex->PDO_RCV; |
293 UNS16 lastIndex = d->lastIndex->PDO_RCV; |
293 UNS32 cobID[] = {0x200, 0x300, 0x400, 0x500}; |
294 UNS32 cobID[] = {0x200, 0x300, 0x400, 0x500}; |
294 if( offset ) while( (offset <= lastIndex) && (i < 4)) { |
295 if( offset ) while( (offset <= lastIndex) && (i < 4)) { |
295 if(*(UNS32*)d->objdict[offset].pSubindex[1].pObject == cobID[i] + *d->bDeviceNodeId) |
296 if((*(UNS32*)d->objdict[offset].pSubindex[1].pObject == cobID[i] + *d->bDeviceNodeId)||(*d->bDeviceNodeId==0xFF)) |
296 *(UNS32*)d->objdict[offset].pSubindex[1].pObject = cobID[i] + nodeId; |
297 *(UNS32*)d->objdict[offset].pSubindex[1].pObject = cobID[i] + nodeId; |
297 i ++; |
298 i ++; |
298 offset ++; |
299 offset ++; |
299 } |
300 } |
300 } |
301 } |
304 UNS16 offset = d->firstIndex->PDO_TRS; |
305 UNS16 offset = d->firstIndex->PDO_TRS; |
305 UNS16 lastIndex = d->lastIndex->PDO_TRS; |
306 UNS16 lastIndex = d->lastIndex->PDO_TRS; |
306 UNS32 cobID[] = {0x180, 0x280, 0x380, 0x480}; |
307 UNS32 cobID[] = {0x180, 0x280, 0x380, 0x480}; |
307 i = 0; |
308 i = 0; |
308 if( offset ) while ((offset <= lastIndex) && (i < 4)) { |
309 if( offset ) while ((offset <= lastIndex) && (i < 4)) { |
309 if(*(UNS32*)d->objdict[offset].pSubindex[1].pObject == cobID[i] + *d->bDeviceNodeId) |
310 if((*(UNS32*)d->objdict[offset].pSubindex[1].pObject == cobID[i] + *d->bDeviceNodeId)||(*d->bDeviceNodeId==0xFF)) |
310 *(UNS32*)d->objdict[offset].pSubindex[1].pObject = cobID[i] + nodeId; |
311 *(UNS32*)d->objdict[offset].pSubindex[1].pObject = cobID[i] + nodeId; |
311 i ++; |
312 i ++; |
312 offset ++; |
313 offset ++; |
313 } |
314 } |
314 } |
315 } |
315 |
316 |
316 /* Update EMCY COB-ID if already set to default*/ |
317 /* Update EMCY COB-ID if already set to default*/ |
317 if(*d->error_cobid == *d->bDeviceNodeId + 0x80) |
318 if((*d->error_cobid == *d->bDeviceNodeId + 0x80)||(*d->bDeviceNodeId==0xFF)) |
318 *d->error_cobid = nodeId + 0x80; |
319 *d->error_cobid = nodeId + 0x80; |
319 |
320 |
320 /* bDeviceNodeId is defined in the object dictionary. */ |
321 /* bDeviceNodeId is defined in the object dictionary. */ |
321 *d->bDeviceNodeId = nodeId; |
322 *d->bDeviceNodeId = nodeId; |
322 } |
323 } |