src/states.c
changeset 284 24bf3d692993
parent 263 d221d387ad2f
child 291 6165554cbfe9
--- a/src/states.c	Tue Sep 25 15:29:37 2007 +0200
+++ b/src/states.c	Wed Sep 26 16:02:00 2007 +0200
@@ -33,6 +33,7 @@
 #include "def.h"
 #include "dcf.h"
 #include "nmtSlave.h"
+#include "emcy.h"
 
 /** Prototypes for internals functions */
 /*!                                                                                                
@@ -66,9 +67,14 @@
 {
 	 switch(m->cob_id.w >> 7)
 	{
-		case SYNC:
-			if(d->CurrentCommunicationState.csSYNC)
-				proceedSYNC(d);
+		case SYNC:		/* can be a SYNC or a EMCY message */
+			if(m->cob_id.w == 0x080)	/* SYNC */
+			{
+				if(d->CurrentCommunicationState.csSYNC)
+					proceedSYNC(d);
+			} else 		/* EMCY */
+				if(d->CurrentCommunicationState.csEmergency)
+					proceedEMCY(d,m);
 			break;
 		/* case TIME_STAMP: */
 		case PDO1tx:
@@ -122,7 +128,7 @@
 	StartOrStop(csSDO,	None,		resetSDO(d))
 	StartOrStop(csSYNC,	startSYNC(d),		stopSYNC(d))
 	StartOrStop(csHeartbeat,	heartbeatInit(d),	heartbeatStop(d))
-/*	StartOrStop(Emergency,,) */
+	StartOrStop(csEmergency,	emergencyInit(d),	emergencyStop(d)) 
 	StartOrStop(csPDO,	PDOInit(d),	PDOStop(d))
 	StartOrStop(csBoot_Up,	None,	slaveSendBootUp(d))
 }