Some tricks in communication services status struct (states.c) and in sync.c to fit with Beremiz generated node code.
authoretisserant
Sun, 30 Sep 2007 22:35:48 +0200
changeset 291 6165554cbfe9
parent 290 43c3b2bf3e32
child 292 6d21333fed5d
Some tricks in communication services status struct (states.c) and in sync.c to fit with Beremiz generated node code.
include/states.h
include/sync.h
src/states.c
src/sync.c
--- a/include/states.h	Sun Sep 30 22:34:10 2007 +0200
+++ b/include/states.h	Sun Sep 30 22:35:48 2007 +0200
@@ -47,12 +47,12 @@
 
 typedef struct
 {
-	UNS8 csBoot_Up;
-	UNS8 csSDO;
-	UNS8 csEmergency;
-	UNS8 csSYNC;
-	UNS8 csHeartbeat;
-	UNS8 csPDO;
+	INTEGER8 csBoot_Up;
+	INTEGER8 csSDO;
+	INTEGER8 csEmergency;
+	INTEGER8 csSYNC;
+	INTEGER8 csHeartbeat;
+	INTEGER8 csPDO;
 } s_state_communication;
 
 /** Function that user app can overload
--- a/include/sync.h	Sun Sep 30 22:34:10 2007 +0200
+++ b/include/sync.h	Sun Sep 30 22:35:48 2007 +0200
@@ -35,10 +35,10 @@
 
 /** transmit a SYNC message and trigger sync TPDOs
  */
-UNS8 sendSYNC (CO_Data* d, UNS32 cob_id);
+UNS8 sendSYNC (CO_Data* d);
 /** transmit a SYNC message on CAN bus
  */
-UNS8 sendSYNCMessage(CO_Data* d, UNS32 cob_id);
+UNS8 sendSYNCMessage(CO_Data* d);
 
 /** This function is called when the node is receiving a SYNC message (cob-id = 0x80).
  *  - check if the node is in OERATIONAL mode. (other mode : return 0 but does nothing).
--- a/src/states.c	Sun Sep 30 22:34:10 2007 +0200
+++ b/src/states.c	Sun Sep 30 22:35:48 2007 +0200
@@ -106,11 +106,11 @@
 }
 
 #define StartOrStop(CommType, FuncStart, FuncStop) \
-	if(newCommunicationState->CommType && !d->CurrentCommunicationState.CommType){\
+	if(newCommunicationState->CommType && d->CurrentCommunicationState.CommType == 0){\
 		MSG_WAR(0x9999,#FuncStart, 9999);\
 		d->CurrentCommunicationState.CommType = 1;\
 		FuncStart;\
-	}else if(!newCommunicationState->CommType && d->CurrentCommunicationState.CommType){\
+	}else if(!newCommunicationState->CommType && d->CurrentCommunicationState.CommType == 1){\
 		MSG_WAR(0x9999,#FuncStop, 9999);\
 		d->CurrentCommunicationState.CommType = 0;\
 		FuncStop;\
--- a/src/sync.c	Sun Sep 30 22:34:10 2007 +0200
+++ b/src/sync.c	Sun Sep 30 22:35:48 2007 +0200
@@ -60,7 +60,7 @@
 **/   
 void SyncAlarm(CO_Data* d, UNS32 id)
 {
-	sendSYNC(d, *d->COB_ID_Sync & 0x1FFFFFFF) ;
+	sendSYNC(d) ;
 }
 
 /*!                                                                                                
@@ -124,13 +124,13 @@
 **                                                                                                 
 ** @return                                                                                         
 **/  
-UNS8 sendSYNCMessage(CO_Data* d, UNS32 cob_id)
+UNS8 sendSYNCMessage(CO_Data* d)
 {
   Message m;
   
   MSG_WAR(0x3001, "sendSYNC ", 0);
   
-  m.cob_id.w = cob_id ;
+  m.cob_id.w = *d->COB_ID_Sync & 0x1FFFFFFF;
   m.rtr = NOT_A_REQUEST;
   m.len = 0;
   
@@ -146,10 +146,10 @@
 **                                                                                                 
 ** @return                                                                                         
 **/  
-UNS8 sendSYNC(CO_Data* d, UNS32 cob_id)
+UNS8 sendSYNC(CO_Data* d)
 {
   UNS8 res;
-  res = sendSYNCMessage(d, cob_id);
+  res = sendSYNCMessage(d);
   proceedSYNC(d) ; 
   return res ;
 }