Edward's patch fixing nmtSlave compilation with LSS enabled.
authoretisserant
Tue, 22 Jul 2008 23:47:05 +0200
changeset 498 aae8531341df
parent 497 a040156aa72f
child 499 061f12bd838b
Edward's patch fixing nmtSlave compilation with LSS enabled.
src/nmtSlave.c
--- a/src/nmtSlave.c	Tue Jul 22 23:44:07 2008 +0200
+++ b/src/nmtSlave.c	Tue Jul 22 23:47:05 2008 +0200
@@ -79,16 +79,26 @@
         break;
 
       case NMT_Reset_Comunication:
-         if(d->NMT_Slave_Communications_Reset_Callback != NULL)
-            d->NMT_Slave_Communications_Reset_Callback(d);
+         {
+         UNS8 newNodeId = getNodeId(d);
+         
+            if(d->NMT_Slave_Communications_Reset_Callback != NULL)
+               d->NMT_Slave_Communications_Reset_Callback(d);
 #ifdef CO_ENABLE_LSS
-         // LSS changes NodeId here in case lss_transfer.nodeID
-         // doesn't match current getNodeId()
-         if(newNodeId!=d->lss_transfer.nodeID && newNodeId>0 && newNodeId<=127 )
-            newNodeId = d->lss_transfer.nodeID;
+            // LSS changes NodeId here in case lss_transfer.nodeID doesn't 
+            // match current getNodeId()
+            if(newNodeId!=d->lss_transfer.nodeID && newNodeId>0 && newNodeId<=127 )
+               newNodeId = d->lss_transfer.nodeID;
 #endif
-        setState(d,Initialisation);
-        break;
+
+            // clear old NodeId to make SetNodeId reinitializing
+            // SDO, EMCY and other COB Ids
+            *d->bDeviceNodeId = 0xFF; 
+         
+            setNodeId(d, newNodeId);
+         }
+         setState(d,Initialisation);
+         break;
 
       }/* end switch */