Added NMT reset callbacks, patch from Edward
authoretisserant
Wed, 04 Jun 2008 11:23:49 +0200
changeset 475 4b63ea646964
parent 474 09c8c4b6c7df
child 476 08cdcb021beb
Added NMT reset callbacks, patch from Edward
include/data.h
src/nmtSlave.c
--- a/include/data.h	Wed Jun 04 11:04:24 2008 +0200
+++ b/include/data.h	Wed Jun 04 11:23:49 2008 +0200
@@ -55,9 +55,9 @@
 	UNS8 *bDeviceNodeId;
 	const indextable *objdict;
 	s_PDO_status *PDO_status;
-	quick_index *firstIndex;
-	quick_index *lastIndex;
-	UNS16 *ObjdictSize;
+	const quick_index *firstIndex;
+	const quick_index *lastIndex;
+	const UNS16 *ObjdictSize;
 	const UNS8 *iam_a_slave;
 	valueRangeTest_t valueRangeTest;
 	
@@ -72,7 +72,9 @@
 	preOperational_t preOperational;
 	operational_t operational;
 	stopped_t stopped;
-
+     void (*NMT_Slave_Node_Reset_Callback)(CO_Data*);
+     void (*NMT_Slave_Communications_Reset_Callback)(CO_Data*);
+     
 	/* NMT-heartbeat */
 	UNS8 *ConsumerHeartbeatCount;
 	UNS32 *ConsumerHeartbeatEntries;
@@ -219,6 +221,8 @@
 	_preOperational,     /* preOperational */\
 	_operational,        /* operational */\
 	_stopped,            /* stopped */\
+	NULL,                /* NMT node reset callback */\
+	NULL,                /* NMT communications reset callback */\
 	\
 	/* NMT-heartbeat */\
 	& NODE_PREFIX ## _highestSubIndex_obj1016, /* ConsumerHeartbeatCount */\
--- a/src/nmtSlave.c	Wed Jun 04 11:04:24 2008 +0200
+++ b/src/nmtSlave.c	Wed Jun 04 11:23:49 2008 +0200
@@ -73,6 +73,8 @@
         break;
 
       case NMT_Reset_Node:
+         if(d->NMT_Slave_Node_Reset_Callback != NULL)
+            d->NMT_Slave_Node_Reset_Callback(d);
 #ifdef CO_ENABLE_LSS
   		if(getNodeId(d)!=d->lss_transfer.nodeID)
   			setNodeId(d, d->lss_transfer.nodeID);
@@ -81,6 +83,8 @@
         break;
 
       case NMT_Reset_Comunication:
+         if(d->NMT_Slave_Communications_Reset_Callback != NULL)
+            d->NMT_Slave_Communications_Reset_Callback(d);
 #ifdef CO_ENABLE_LSS
   		if(getNodeId(d)!=d->lss_transfer.nodeID && getNodeId(d)>0 && getNodeId(d)<=127)
   			setNodeId(d, d->lss_transfer.nodeID);