Minor changes in SYNC. Splitted SendSync in SendSync and SendSyncMessage to allow manual SYNC message transmission and separate SYNC proceeding (synced TPDOs)
authoretisserant
Fri, 31 Aug 2007 10:19:46 +0200
changeset 263 d221d387ad2f
parent 262 f1c892f3f93c
child 264 6fa295ec7dda
Minor changes in SYNC. Splitted SendSync in SendSync and SendSyncMessage to allow manual SYNC message transmission and separate SYNC proceeding (synced TPDOs)
include/sync.h
src/states.c
src/sync.c
--- a/include/sync.h	Thu Aug 30 17:03:34 2007 +0200
+++ b/include/sync.h	Fri Aug 31 10:19:46 2007 +0200
@@ -33,11 +33,12 @@
 typedef void (*post_TPDO_t)(void);
 void _post_TPDO(void);
 
-/** transmit a SYNC message on the bus number bus_id
- * bus_id is hardware dependant
- * return canSend(bus_id,&m)
+/** transmit a SYNC message and trigger sync TPDOs
  */
 UNS8 sendSYNC (CO_Data* d, UNS32 cob_id);
+/** transmit a SYNC message on CAN bus
+ */
+UNS8 sendSYNCMessage(CO_Data* d, UNS32 cob_id);
 
 /** 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).
@@ -45,6 +46,6 @@
  *  - Trigger sync TPDO emission 
  *  - return 0 if OK, 0xFF if error
  */
-UNS8 proceedSYNC (CO_Data* d, Message * m);
+UNS8 proceedSYNC (CO_Data* d);
 
 #endif
--- a/src/states.c	Thu Aug 30 17:03:34 2007 +0200
+++ b/src/states.c	Fri Aug 31 10:19:46 2007 +0200
@@ -68,7 +68,7 @@
 	{
 		case SYNC:
 			if(d->CurrentCommunicationState.csSYNC)
-				proceedSYNC(d,m);
+				proceedSYNC(d);
 			break;
 		/* case TIME_STAMP: */
 		case PDO1tx:
--- a/src/sync.c	Thu Aug 30 17:03:34 2007 +0200
+++ b/src/sync.c	Fri Aug 31 10:19:46 2007 +0200
@@ -110,9 +110,34 @@
 **/   
 void stopSYNC(CO_Data* d)
 {
+    RegisterSetODentryCallBack(d, 0x1005, 0, NULL);
+    RegisterSetODentryCallBack(d, 0x1006, 0, NULL);
 	d->syncTimer = DelAlarm(d->syncTimer);
 }
 
+
+/*!                                                                                                
+**                                                                                                 
+**                                                                                                 
+** @param d                                                                                        
+** @param cob_id                                                                                   
+**                                                                                                 
+** @return                                                                                         
+**/  
+UNS8 sendSYNCMessage(CO_Data* d, UNS32 cob_id)
+{
+  Message m;
+  
+  MSG_WAR(0x3001, "sendSYNC ", 0);
+  
+  m.cob_id.w = cob_id ;
+  m.rtr = NOT_A_REQUEST;
+  m.len = 0;
+  
+  return canSend(d->canHandle,&m);
+}
+
+
 /*!                                                                                                
 **                                                                                                 
 **                                                                                                 
@@ -123,17 +148,10 @@
 **/  
 UNS8 sendSYNC(CO_Data* d, UNS32 cob_id)
 {
-  Message m;
-  UNS8 resultat ;
-  
-  MSG_WAR(0x3001, "sendSYNC ", 0);
-  
-  m.cob_id.w = cob_id ;
-  m.rtr = NOT_A_REQUEST;
-  m.len = 0;
-  resultat = canSend(d->canHandle,&m) ;
-  proceedSYNC(d, &m) ; 
-  return resultat ;
+  UNS8 res;
+  res = sendSYNCMessage(d, cob_id);
+  proceedSYNC(d) ; 
+  return res ;
 }
 
 /*!                                                                                                
@@ -144,7 +162,7 @@
 **                                                                                                 
 ** @return                                                                                         
 **/ 
-UNS8 proceedSYNC(CO_Data* d, Message *m)
+UNS8 proceedSYNC(CO_Data* d)
 {
 
   UNS8 res;