diff -r 66f007300c10 -r 118c1cabd0b0 src/states.c --- a/src/states.c Fri Dec 14 16:32:38 2007 +0100 +++ b/src/states.c Mon Dec 17 13:22:35 2007 +0100 @@ -34,7 +34,9 @@ #include "dcf.h" #include "nmtSlave.h" #include "emcy.h" - +#ifdef CO_ENABLE_LSS +#include "lss.h" +#endif /** Prototypes for internals functions */ /*! ** @@ -102,6 +104,19 @@ { proceedNMTstateChange(d,m); } +#ifdef CO_ENABLE_LSS + case LSS: + if (!d->CurrentCommunicationState.csLSS)break; + if ((*(d->iam_a_slave)) && m->cob_id.w==MLSS_ADRESS) + { + proceedLSS_Slave(d,m); + } + else if(!(*(d->iam_a_slave)) && m->cob_id.w==SLSS_ADRESS) + { + proceedLSS_Master(d,m); + } + break; +#endif } } @@ -131,6 +146,9 @@ StartOrStop(csEmergency, emergencyInit(d), emergencyStop(d)) StartOrStop(csPDO, PDOInit(d), PDOStop(d)) StartOrStop(csBoot_Up, None, slaveSendBootUp(d)) +#ifdef CO_ENABLE_LSS + StartOrStop(csLSS, startLSS(d), stopLSS(d)) +#endif } /*! @@ -147,7 +165,7 @@ switch( newState ){ case Initialisation: { - s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0}; + s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0, 0}; /* This will force a second loop for the state switch */ d->nodeState = Initialisation; newState = Pre_operational; @@ -161,7 +179,7 @@ case Pre_operational: { - s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 0}; + s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 0, 1}; d->nodeState = Pre_operational; newState = Pre_operational; switchCommunicationState(d, &newCommunicationState); @@ -180,7 +198,7 @@ case Operational: if(d->nodeState == Initialisation) return 0xFF; { - s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 1}; + s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 1, 0}; d->nodeState = Operational; newState = Operational; switchCommunicationState(d, &newCommunicationState); @@ -191,13 +209,23 @@ case Stopped: if(d->nodeState == Initialisation) return 0xFF; { - s_state_communication newCommunicationState = {0, 0, 0, 0, 1, 0}; + s_state_communication newCommunicationState = {0, 0, 0, 0, 1, 0, 1}; d->nodeState = Stopped; newState = Stopped; switchCommunicationState(d, &newCommunicationState); (*d->stopped)(); } break; +#ifdef CO_ENABLE_LSS + case LssTimingDelay: + { + s_state_communication newCommunicationState = {0, 0, 0, 0, 0, 0, 0}; + d->nodeState = LssTimingDelay; + newState = LssTimingDelay; + switchCommunicationState(d, &newCommunicationState); + } + break; +#endif default: return 0xFF; @@ -228,6 +256,15 @@ void setNodeId(CO_Data* d, UNS8 nodeId) { UNS16 offset = d->firstIndex->SDO_SVR; + +#ifdef CO_ENABLE_LSS + if(nodeId==0xFF) + { + *d->bDeviceNodeId = nodeId; + return; + } +#endif + if(offset){ /* Adjust COB-ID Client->Server (rx) only id already set to default value*/ if(*(UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + *d->bDeviceNodeId){