Some fixes suggested by Luis Jim?nez, plus some minor enhancements in DCF.
authoretisserant
Mon, 03 Dec 2007 11:30:38 +0100
changeset 320 f82e758840bd
parent 319 4b331759169a
child 321 994457edada8
Some fixes suggested by Luis Jim?nez, plus some minor enhancements in DCF.
.cproject
include/data.h
include/dcf.h
include/def.h
src/dcf.c
src/pdo.c
src/states.c
src/win32/CanFestival-3.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.cproject	Mon Dec 03 11:30:38 2007 +0100
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject>
+<storageModule moduleId="org.eclipse.cdt.core.settings">
+<cconfiguration id="converted.config.1524392451">
+<storageModule moduleId="scannerConfiguration">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="false" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="false"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="false" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="false"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="false" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="false"/>
+</scannerInfoProvider>
+</profile>
+</storageModule>
+<storageModule moduleId="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
+</storageModule>
+<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+<buildTargets>
+<target name="all" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder">
+<buildCommand>make</buildCommand>
+<buildArguments/>
+<buildTarget>all</buildTarget>
+<stopOnError>true</stopOnError>
+<useDefaultCommand>true</useDefaultCommand>
+</target>
+<target name="clean" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder">
+<buildCommand>make</buildCommand>
+<buildArguments/>
+<buildTarget>clean</buildTarget>
+<stopOnError>false</stopOnError>
+<useDefaultCommand>true</useDefaultCommand>
+</target>
+</buildTargets>
+</storageModule>
+<storageModule buildSystemId="org.eclipse.cdt.core.defaultConfigDataProvider" id="converted.config.1524392451" moduleId="org.eclipse.cdt.core.settings" name="convertedConfig">
+<externalSettings/>
+<extensions>
+<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+</extensions>
+</storageModule>
+</cconfiguration>
+</storageModule>
+</cproject>
--- 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 */\
--- 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);
--- 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
  */
--- 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)();
-
 }
--- 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. */
         
--- 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 
 				{
--- 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