# HG changeset patch # User etisserant # Date 1191184548 -7200 # Node ID 6165554cbfe900f72af0c17a24ceb831f362d01b # Parent 43c3b2bf3e322aa4375a322f20356ab41fcfe042 Some tricks in communication services status struct (states.c) and in sync.c to fit with Beremiz generated node code. diff -r 43c3b2bf3e32 -r 6165554cbfe9 include/states.h --- 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 diff -r 43c3b2bf3e32 -r 6165554cbfe9 include/sync.h --- 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). diff -r 43c3b2bf3e32 -r 6165554cbfe9 src/states.c --- 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;\ diff -r 43c3b2bf3e32 -r 6165554cbfe9 src/sync.c --- 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 ; }