# HG changeset patch # User etisserant # Date 1196677838 -3600 # Node ID f82e758840bdd720ff3aa37c40b924ee62a1c37c # Parent 4b331759169af3824b601323c7c8fd1d41567a65 Some fixes suggested by Luis Jim?nez, plus some minor enhancements in DCF. diff -r 4b331759169a -r f82e758840bd .cproject --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.cproject Mon Dec 03 11:30:38 2007 +0100 @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +make + +all +true +true + + +make + +clean +false +true + + + + + + + + + + + + + diff -r 4b331759169a -r f82e758840bd include/data.h --- a/include/data.h Thu Nov 29 11:58:02 2007 +0100 +++ b/include/data.h Mon Dec 03 11:30:38 2007 +0100 @@ -93,8 +93,9 @@ storeODSubIndex_t storeODSubIndex; /* DCF concise */ + indextable* dcf_odentry; UNS8* dcf_cursor; - UNS32 dcf_count_targets; + UNS32 dcf_entries_count; /* EMCY */ e_errorState error_state; @@ -191,8 +192,10 @@ NULL, /* canSend */\ NODE_PREFIX ## _scanIndexOD, /* scanIndexOD */\ _storeODSubIndex, /* storeODSubIndex */\ + /* DCF concise */\ + NULL, /*dcf_odentry*/\ NULL, /*dcf_cursor*/\ - 1, /*dcf_count_targets*/\ + 1, /*dcf_entries_count*/\ \ /* EMCY */\ Error_free, /* error_state */\ diff -r 4b331759169a -r f82e758840bd include/dcf.h --- a/include/dcf.h Thu Nov 29 11:58:02 2007 +0100 +++ b/include/dcf.h Mon Dec 03 11:30:38 2007 +0100 @@ -21,4 +21,4 @@ */ -UNS32 decompo_dcf(CO_Data* d, UNS8 nodeId); +void send_consise_dcf(CO_Data* d, UNS8 nodeId); diff -r 4b331759169a -r f82e758840bd include/def.h --- a/include/def.h Thu Nov 29 11:58:02 2007 +0100 +++ b/include/def.h Mon Dec 03 11:30:38 2007 +0100 @@ -60,9 +60,12 @@ /* Should not be modified */ #define Rx 0 #define Tx 1 +#ifndef TRUE #define TRUE 1 +#endif +#ifndef FALSE #define FALSE 0 - +#endif /** Status of the SDO transmission */ diff -r 4b331759169a -r f82e758840bd src/dcf.c --- a/src/dcf.c Thu Nov 29 11:58:02 2007 +0100 +++ b/src/dcf.c Mon Dec 03 11:30:38 2007 +0100 @@ -42,7 +42,6 @@ extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize); -const indextable *ptrTable; /** ** @@ -61,7 +60,7 @@ } closeSDOtransfer(d, nodeId, SDO_CLIENT); - decompo_dcf(d,nodeId); + send_consise_dcf(d,nodeId); } /** @@ -72,49 +71,48 @@ ** ** @return */ -UNS32 decompo_dcf(CO_Data* d,UNS8 nodeId) +void send_consise_dcf(CO_Data* d,UNS8 nodeId) { - UNS32 errorCode; - UNS16 target_Index; - UNS8 target_Subindex; - UNS32 target_Size; - UNS32 res; - ODCallback_t *Callback; + /* Fetch DCF OD entry, if not already done */ + if(!d->dcf_odentry) + { + UNS32 errorCode; + ODCallback_t *Callback; + d->dcf_odentry = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback); + /* If DCF entry do not exist... Nothing to do.*/ + if (errorCode != OD_SUCCESSFUL) goto DCF_finish; + } - ptrTable = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback); - if (errorCode != OD_SUCCESSFUL) - { - return errorCode; - } + /* Loop on all DCF subindexes, corresponding to nodes ID */ + while (nodeId < d->dcf_odentry->bSubCount){ + UNS32 nb_entries; - /* Loop on all Nodes supported in DCF subindexes*/ - while (nodeId < ptrTable->bSubCount){ - UNS32 nb_targets; - - UNS8 szData = ptrTable->pSubindex[nodeId].size; + UNS8 szData = d->dcf_odentry->pSubindex[nodeId].size; UNS8* dcfend; { - UNS8* dcf = *((UNS8**)ptrTable->pSubindex[nodeId].pObject); + UNS8* dcf = *((UNS8**)d->dcf_odentry->pSubindex[nodeId].pObject); dcfend = dcf + szData; if (!d->dcf_cursor){ d->dcf_cursor = (UNS8*)dcf + 4; - d->dcf_count_targets = 0; + d->dcf_entries_count = 0; } - nb_targets = UNS32_LE(*((UNS32*)dcf)); + nb_entries = UNS32_LE(*((UNS32*)dcf)); } /* condition on consise DCF string for NodeID, if big enough */ - if((UNS8*)d->dcf_cursor + 7 < (UNS8*)dcfend && d->dcf_count_targets < nb_targets) + if((UNS8*)d->dcf_cursor + 7 < (UNS8*)dcfend && d->dcf_entries_count < nb_entries) { + UNS16 target_Index; + UNS8 target_Subindex; + UNS32 target_Size; + /* pointer to the DCF string for NodeID */ target_Index = UNS16_LE(*((UNS16*)(d->dcf_cursor))); d->dcf_cursor += 2; target_Subindex = *((UNS8*)((UNS8*)d->dcf_cursor++)); target_Size = UNS32_LE(*((UNS32*)(d->dcf_cursor))); d->dcf_cursor += 4; - /* printf("Master : ConfigureSlaveNode %2.2x (Concise - DCF)\n",nodeId);*/ - res = _writeNetworkDict(d, /* CO_Data* d*/ + _writeNetworkDict(d, /* CO_Data* d*/ nodeId, /* UNS8 nodeId*/ target_Index, /* UNS16 index*/ target_Subindex, /* UNS8 subindex*/ @@ -127,14 +125,15 @@ /* Push d->dcf_cursor to the end of data*/ d->dcf_cursor += target_Size; - d->dcf_count_targets++; + d->dcf_entries_count++; - return ; + /* send_consise_dcf will be called by CheckSDOAndContinue for next DCF entry*/ + return; } nodeId++; d->dcf_cursor = NULL; } + DCF_finish: /* Switch Master to preOperational state */ (*d->preOperational)(); - } diff -r 4b331759169a -r f82e758840bd src/pdo.c --- a/src/pdo.c Thu Nov 29 11:58:02 2007 +0100 +++ b/src/pdo.c Mon Dec 03 11:30:38 2007 +0100 @@ -146,7 +146,6 @@ { UNS8 numPdo; UNS8 numMap; /* Number of the mapped varable */ - UNS8 i; UNS8 * pMappingCount = NULL; /* count of mapped objects... */ /* pointer to the var which is mapped to a pdo... */ /* void * pMappedAppObject = NULL; */ @@ -157,7 +156,6 @@ type */ UNS32 * pwCobId = NULL; UNS8 Size; - UNS8 dataType; UNS8 offset; UNS8 status; UNS32 objDict; @@ -605,7 +603,6 @@ case 3: /* Changed inhibit time */ case 5: /* Changed event time */ { - UNS8 pTransmissionType = *(UNS8*) OD_entry->pSubindex[2].pObject; const indextable* TPDO_com = d->objdict + d->firstIndex->PDO_TRS; UNS8 numPdo = OD_entry - TPDO_com; /* number of the actual processed pdo-nr. */ diff -r 4b331759169a -r f82e758840bd src/states.c --- a/src/states.c Thu Nov 29 11:58:02 2007 +0100 +++ b/src/states.c Mon Dec 03 11:30:38 2007 +0100 @@ -143,10 +143,6 @@ **/ UNS8 setState(CO_Data* d, e_nodeState newState) { - UNS16 wIndex = 0x1F22; - const indextable *ptrTable; - ODCallback_t *Callback; - UNS32 errorCode; while(newState != d->nodeState){ switch( newState ){ case Initialisation: @@ -171,17 +167,8 @@ switchCommunicationState(d, &newCommunicationState); if (!(*(d->iam_a_slave))) { - ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback); - - if (errorCode != OD_SUCCESSFUL) - { - (*d->preOperational)(); - } - else - { - UNS32 res; - res = decompo_dcf(d,0x01); - } + send_consise_dcf(d,0x01); + /*(*d->preOperational)() will be called once dcf sent */ } else { diff -r 4b331759169a -r f82e758840bd src/win32/CanFestival-3.def --- a/src/win32/CanFestival-3.def Thu Nov 29 11:58:02 2007 +0100 +++ b/src/win32/CanFestival-3.def Mon Dec 03 11:30:38 2007 +0100 @@ -25,8 +25,8 @@ EXPORTS - ; dsf.h - decompo_dcf + ; dcf.h + send_consise_dcf ; lifegrd.h _heartbeatError