Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
authoretisserant
Fri, 29 Jun 2007 19:51:39 +0200
changeset 235 f812bf6b7237
parent 234 5a17bcb520ef
child 236 905677ed00f3
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
+ re-organisation and cleanup of pdo.c.
examples/TestMasterMicroMod/TestMaster.c
examples/TestMasterSlave/TestMaster.c
examples/TestMasterSlave/TestMaster.h
examples/TestMasterSlave/TestSlave.c
examples/TestMasterSlave/TestSlave.h
examples/TestMasterSlave/TestSlave.od
include/can.h
include/data.h
include/def.h
include/objdictdef.h
include/pdo.h
include/sync.h
objdictgen/gen_cfile.py
src/pdo.c
src/states.c
src/sync.c
--- a/examples/TestMasterMicroMod/TestMaster.c	Fri Jun 29 19:48:22 2007 +0200
+++ b/examples/TestMasterMicroMod/TestMaster.c	Fri Jun 29 19:51:39 2007 +0200
@@ -310,11 +310,12 @@
 	return &TestMaster_objdict[i];
 }
 
-/* To count at which received SYNC a PDO must be sent.
+/* 
+ * To count at which received SYNC a PDO must be sent.
  * Even if no pdoTransmit are defined, at least one entry is computed
  * for compilations issues.
  */
-UNS8 TestMaster_count_sync[1] = {0,};
+s_PDO_status TestMaster_PDO_status[1] = {s_PDO_staus_Initializer};
 
 quick_index TestMaster_firstIndex = {
   0, /* SDO_SVR */
--- a/examples/TestMasterSlave/TestMaster.c	Fri Jun 29 19:48:22 2007 +0200
+++ b/examples/TestMasterSlave/TestMaster.c	Fri Jun 29 19:51:39 2007 +0200
@@ -382,11 +382,12 @@
 	return &TestMaster_objdict[i];
 }
 
-/* To count at which received SYNC a PDO must be sent.
+/* 
+ * To count at which received SYNC a PDO must be sent.
  * Even if no pdoTransmit are defined, at least one entry is computed
  * for compilations issues.
  */
-UNS8 TestMaster_count_sync[1] = {0,};
+s_PDO_status TestMaster_PDO_status[1] = {s_PDO_staus_Initializer};
 
 quick_index TestMaster_firstIndex = {
   0, /* SDO_SVR */
--- a/examples/TestMasterSlave/TestMaster.h	Fri Jun 29 19:48:22 2007 +0200
+++ b/examples/TestMasterSlave/TestMaster.h	Fri Jun 29 19:51:39 2007 +0200
@@ -1,6 +1,9 @@
 
 /* File generated by gen_cfile.py. Should not be modified. */
 
+#ifndef TESTMASTER_H
+#define TESTMASTER_H
+
 #include "data.h"
 
 /* Prototypes of function provided by object dictionnary */
@@ -9,7 +12,6 @@
 
 /* Master node data struct */
 extern CO_Data TestMaster_Data;
-
 extern UNS8 MasterMap1;		/* Mapped at index 0x2000, subindex 0x00*/
 extern UNS8 MasterMap2;		/* Mapped at index 0x2001, subindex 0x00*/
 extern UNS8 MasterMap3;		/* Mapped at index 0x2002, subindex 0x00*/
@@ -21,3 +23,5 @@
 extern UNS8 MasterMap9;		/* Mapped at index 0x2008, subindex 0x00*/
 extern UNS32 MasterMap10;		/* Mapped at index 0x2009, subindex 0x00*/
 extern UNS16 MasterMap11;		/* Mapped at index 0x200A, subindex 0x00*/
+
+#endif // TESTMASTER_H
--- a/examples/TestMasterSlave/TestSlave.c	Fri Jun 29 19:48:22 2007 +0200
+++ b/examples/TestMasterSlave/TestSlave.c	Fri Jun 29 19:51:39 2007 +0200
@@ -17,6 +17,7 @@
 UNS8 SlaveMap9 = 0x0;		/* Mapped at index 0x2008, subindex 0x00 */
 UNS32 SlaveMap10 = 0x0;		/* Mapped at index 0x2009, subindex 0x00 */
 UNS16 SlaveMap11 = 0x0;		/* Mapped at index 0x200A, subindex 0x00 */
+INTEGER16 SlaveMap12 = 0x0;		/* Mapped at index 0x200B, subindex 0x00 */
 
 /**************************************************************************/
 /* Declaration of the value range types                                   */
@@ -207,6 +208,23 @@
                        { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Event_Timer }
                      };
 
+/* index 0x1802 :   Transmit PDO 3 Parameter. */
+                    UNS8 TestSlave_highestSubIndex_obj1802 = 5; /* number of subindex - 1*/
+                    UNS32 TestSlave_obj1802_COB_ID_used_by_PDO = 0x380;	/* 896 */
+                    UNS8 TestSlave_obj1802_Transmission_Type = 0xFF;	/* 255 */
+                    UNS16 TestSlave_obj1802_Inhibit_Time = 0x1388;	/* 5000 */
+                    UNS8 TestSlave_obj1802_Compatibility_Entry = 0x0;	/* 0 */
+                    UNS16 TestSlave_obj1802_Event_Timer = 0x3E8;	/* 1000 */
+                    subindex TestSlave_Index1802[] = 
+                     {
+                       { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1802 },
+                       { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1802_COB_ID_used_by_PDO },
+                       { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1802_Transmission_Type },
+                       { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1802_Inhibit_Time },
+                       { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1802_Compatibility_Entry },
+                       { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1802_Event_Timer }
+                     };
+
 /* index 0x1A00 :   Transmit PDO 1 Mapping. */
                     UNS8 TestSlave_highestSubIndex_obj1A00 = 10; /* number of subindex - 1*/
                     UNS32 TestSlave_obj1A00[] = 
@@ -249,6 +267,18 @@
                        { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A01[0] }
                      };
 
+/* index 0x1A02 :   Transmit PDO 3 Mapping. */
+                    UNS8 TestSlave_highestSubIndex_obj1A02 = 1; /* number of subindex - 1*/
+                    UNS32 TestSlave_obj1A02[] = 
+                    {
+                      0x200B0010	/* 537591824 */
+                    };
+                    subindex TestSlave_Index1A02[] = 
+                     {
+                       { RW, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1A02 },
+                       { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A02[0] }
+                     };
+
 /* index 0x2000 :   Mapped variable SlaveMap1 */
                     subindex TestSlave_Index2000[] = 
                      {
@@ -315,6 +345,12 @@
                        { RW, uint16, sizeof (UNS16), (void*)&SlaveMap11 }
                      };
 
+/* index 0x200B :   Mapped variable SlaveMap12 */
+                    subindex TestSlave_Index200B[] = 
+                     {
+                       { RW, int16, sizeof (INTEGER16), (void*)&SlaveMap12 }
+                     };
+
 const indextable TestSlave_objdict[] = 
 {
   { (subindex*)TestSlave_Index1000,sizeof(TestSlave_Index1000)/sizeof(TestSlave_Index1000[0]), 0x1000},
@@ -328,8 +364,10 @@
   { (subindex*)TestSlave_Index1200,sizeof(TestSlave_Index1200)/sizeof(TestSlave_Index1200[0]), 0x1200},
   { (subindex*)TestSlave_Index1800,sizeof(TestSlave_Index1800)/sizeof(TestSlave_Index1800[0]), 0x1800},
   { (subindex*)TestSlave_Index1801,sizeof(TestSlave_Index1801)/sizeof(TestSlave_Index1801[0]), 0x1801},
+  { (subindex*)TestSlave_Index1802,sizeof(TestSlave_Index1802)/sizeof(TestSlave_Index1802[0]), 0x1802},
   { (subindex*)TestSlave_Index1A00,sizeof(TestSlave_Index1A00)/sizeof(TestSlave_Index1A00[0]), 0x1A00},
   { (subindex*)TestSlave_Index1A01,sizeof(TestSlave_Index1A01)/sizeof(TestSlave_Index1A01[0]), 0x1A01},
+  { (subindex*)TestSlave_Index1A02,sizeof(TestSlave_Index1A02)/sizeof(TestSlave_Index1A02[0]), 0x1A02},
   { (subindex*)TestSlave_Index2000,sizeof(TestSlave_Index2000)/sizeof(TestSlave_Index2000[0]), 0x2000},
   { (subindex*)TestSlave_Index2001,sizeof(TestSlave_Index2001)/sizeof(TestSlave_Index2001[0]), 0x2001},
   { (subindex*)TestSlave_Index2002,sizeof(TestSlave_Index2002)/sizeof(TestSlave_Index2002[0]), 0x2002},
@@ -341,6 +379,7 @@
   { (subindex*)TestSlave_Index2008,sizeof(TestSlave_Index2008)/sizeof(TestSlave_Index2008[0]), 0x2008},
   { (subindex*)TestSlave_Index2009,sizeof(TestSlave_Index2009)/sizeof(TestSlave_Index2009[0]), 0x2009},
   { (subindex*)TestSlave_Index200A,sizeof(TestSlave_Index200A)/sizeof(TestSlave_Index200A[0]), 0x200A},
+  { (subindex*)TestSlave_Index200B,sizeof(TestSlave_Index200B)/sizeof(TestSlave_Index200B[0]), 0x200B},
 };
 
 const indextable * TestSlave_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks)
@@ -359,19 +398,22 @@
 		case 0x1200: i = 8;break;
 		case 0x1800: i = 9;break;
 		case 0x1801: i = 10;break;
-		case 0x1A00: i = 11;break;
-		case 0x1A01: i = 12;break;
-		case 0x2000: i = 13;break;
-		case 0x2001: i = 14;break;
-		case 0x2002: i = 15;break;
-		case 0x2003: i = 16;break;
-		case 0x2004: i = 17;break;
-		case 0x2005: i = 18;break;
-		case 0x2006: i = 19;break;
-		case 0x2007: i = 20;break;
-		case 0x2008: i = 21;break;
-		case 0x2009: i = 22;break;
-		case 0x200A: i = 23;break;
+		case 0x1802: i = 11;break;
+		case 0x1A00: i = 12;break;
+		case 0x1A01: i = 13;break;
+		case 0x1A02: i = 14;break;
+		case 0x2000: i = 15;break;
+		case 0x2001: i = 16;break;
+		case 0x2002: i = 17;break;
+		case 0x2003: i = 18;break;
+		case 0x2004: i = 19;break;
+		case 0x2005: i = 20;break;
+		case 0x2006: i = 21;break;
+		case 0x2007: i = 22;break;
+		case 0x2008: i = 23;break;
+		case 0x2009: i = 24;break;
+		case 0x200A: i = 25;break;
+		case 0x200B: i = 26;break;
 		default:
 			*errorCode = OD_NO_SUCH_OBJECT;
 			return NULL;
@@ -380,11 +422,12 @@
 	return &TestSlave_objdict[i];
 }
 
-/* To count at which received SYNC a PDO must be sent.
+/* 
+ * To count at which received SYNC a PDO must be sent.
  * Even if no pdoTransmit are defined, at least one entry is computed
  * for compilations issues.
  */
-UNS8 TestSlave_count_sync[2] = {0,};
+s_PDO_status TestSlave_PDO_status[3] = {s_PDO_staus_Initializer,s_PDO_staus_Initializer,s_PDO_staus_Initializer};
 
 quick_index TestSlave_firstIndex = {
   8, /* SDO_SVR */
@@ -392,7 +435,7 @@
   0, /* PDO_RCV */
   0, /* PDO_RCV_MAP */
   9, /* PDO_TRS */
-  11 /* PDO_TRS_MAP */
+  12 /* PDO_TRS_MAP */
 };
 
 quick_index TestSlave_lastIndex = {
@@ -400,8 +443,8 @@
   0, /* SDO_CLT */
   0, /* PDO_RCV */
   0, /* PDO_RCV_MAP */
-  10, /* PDO_TRS */
-  12 /* PDO_TRS_MAP */
+  11, /* PDO_TRS */
+  14 /* PDO_TRS_MAP */
 };
 
 UNS16 TestSlave_ObjdictSize = sizeof(TestSlave_objdict)/sizeof(TestSlave_objdict[0]); 
--- a/examples/TestMasterSlave/TestSlave.h	Fri Jun 29 19:48:22 2007 +0200
+++ b/examples/TestMasterSlave/TestSlave.h	Fri Jun 29 19:51:39 2007 +0200
@@ -1,6 +1,9 @@
 
 /* File generated by gen_cfile.py. Should not be modified. */
 
+#ifndef TESTSLAVE_H
+#define TESTSLAVE_H
+
 #include "data.h"
 
 /* Prototypes of function provided by object dictionnary */
@@ -9,7 +12,6 @@
 
 /* Master node data struct */
 extern CO_Data TestSlave_Data;
-
 extern ODCallback_t Store_parameters_callbacks[];		/* Callbacks of index0x1010 */
 extern ODCallback_t Restore_Default_Parameters_callbacks[];		/* Callbacks of index0x1011 */
 extern UNS8 SlaveMap1;		/* Mapped at index 0x2000, subindex 0x00*/
@@ -23,3 +25,6 @@
 extern UNS8 SlaveMap9;		/* Mapped at index 0x2008, subindex 0x00*/
 extern UNS32 SlaveMap10;		/* Mapped at index 0x2009, subindex 0x00*/
 extern UNS16 SlaveMap11;		/* Mapped at index 0x200A, subindex 0x00*/
+extern INTEGER16 SlaveMap12;		/* Mapped at index 0x200B, subindex 0x00*/
+
+#endif // TESTSLAVE_H
--- a/examples/TestMasterSlave/TestSlave.od	Fri Jun 29 19:48:22 2007 +0200
+++ b/examples/TestMasterSlave/TestSlave.od	Fri Jun 29 19:51:39 2007 +0200
@@ -1,10 +1,10 @@
 <?xml version="1.0"?>
 <!DOCTYPE PyObject SYSTEM "PyObjects.dtd">
-<PyObject module="node" class="Node" id="141443180">
-<attr name="Profile" type="dict" id="141437916" >
+<PyObject module="node" class="Node" id="16608648">
+<attr name="Profile" type="dict" id="19295616" >
 </attr>
 <attr name="Name" type="string" value="TestSlave" />
-<attr name="Dictionary" type="dict" id="140114092" >
+<attr name="Dictionary" type="dict" id="16868496" >
   <entry>
     <key type="numeric" value="4096" />
     <val type="numeric" value="301" />
@@ -50,8 +50,22 @@
     <val type="numeric" value="0" />
   </entry>
   <entry>
+    <key type="numeric" value="8203" />
+    <val type="numeric" value="0" />
+  </entry>
+  <entry>
+    <key type="numeric" value="6146" />
+    <val type="list" id="18608784" >
+      <item type="string" value="{True:self.ID+(base+1)*0x100+0x80,False:0}[base&lt;4]" />
+      <item type="numeric" value="255" />
+      <item type="numeric" value="5000" />
+      <item type="numeric" value="0" />
+      <item type="numeric" value="1000" />
+    </val>
+  </entry>
+  <entry>
     <key type="numeric" value="4112" />
-    <val type="list" id="140021004" >
+    <val type="list" id="16609864" >
       <item type="numeric" value="0" />
       <item type="numeric" value="0" />
       <item type="numeric" value="0" />
@@ -60,16 +74,22 @@
   </entry>
   <entry>
     <key type="numeric" value="4113" />
-    <val type="list" id="140021068" >
-      <item type="numeric" value="0" />
-      <item type="numeric" value="0" />
-      <item type="numeric" value="0" />
-      <item type="numeric" value="0" />
+    <val type="list" id="16609720" >
+      <item type="numeric" value="0" />
+      <item type="numeric" value="0" />
+      <item type="numeric" value="0" />
+      <item type="numeric" value="0" />
+    </val>
+  </entry>
+  <entry>
+    <key type="numeric" value="6658" />
+    <val type="list" id="18609144" >
+      <item type="numeric" value="537591824" />
     </val>
   </entry>
   <entry>
     <key type="numeric" value="4608" />
-    <val type="list" id="140021228" >
+    <val type="list" id="16610080" >
       <item type="numeric" value="1537" />
       <item type="numeric" value="1409" />
     </val>
@@ -80,7 +100,7 @@
   </entry>
   <entry>
     <key type="numeric" value="4120" />
-    <val type="list" id="140029996" >
+    <val type="list" id="16611376" >
       <item type="numeric" value="0" />
       <item type="numeric" value="0" />
       <item type="numeric" value="0" />
@@ -92,20 +112,20 @@
     <val type="numeric" value="0" />
   </entry>
   <entry>
+    <key type="numeric" value="8198" />
+    <val type="numeric" value="0" />
+  </entry>
+  <entry>
+    <key type="numeric" value="8199" />
+    <val type="numeric" value="0" />
+  </entry>
+  <entry>
     <key type="numeric" value="4102" />
     <val type="numeric" value="0" />
   </entry>
   <entry>
-    <key type="numeric" value="8199" />
-    <val type="numeric" value="0" />
-  </entry>
-  <entry>
-    <key type="numeric" value="8198" />
-    <val type="numeric" value="0" />
-  </entry>
-  <entry>
     <key type="numeric" value="6144" />
-    <val type="list" id="140030028" >
+    <val type="list" id="16611448" >
       <item type="numeric" value="386" />
       <item type="numeric" value="0" />
       <item type="numeric" value="0" />
@@ -115,7 +135,7 @@
   </entry>
   <entry>
     <key type="numeric" value="6656" />
-    <val type="list" id="140021164" >
+    <val type="list" id="16609936" >
       <item type="numeric" value="536870913" />
       <item type="numeric" value="536936449" />
       <item type="numeric" value="537001985" />
@@ -130,7 +150,7 @@
   </entry>
   <entry>
     <key type="numeric" value="6145" />
-    <val type="list" id="140020940" >
+    <val type="list" id="16609432" >
       <item type="numeric" value="0" />
       <item type="numeric" value="0" />
       <item type="numeric" value="0" />
@@ -140,17 +160,17 @@
   </entry>
   <entry>
     <key type="numeric" value="6657" />
-    <val type="list" id="140030444" >
+    <val type="list" id="16612384" >
       <item type="numeric" value="537526288" />
     </val>
   </entry>
 </attr>
-<attr name="SpecificMenu" type="list" id="140020332" >
+<attr name="SpecificMenu" type="list" id="16608288" >
 </attr>
-<attr name="ParamsDictionary" type="dict" id="141438732" >
+<attr name="ParamsDictionary" type="dict" id="19297248" >
   <entry>
     <key type="numeric" value="8192" />
-    <val type="dict" id="140113412" >
+    <val type="dict" id="14729024" >
       <entry>
         <key type="string" value="callback" />
         <val type="False" value="" />
@@ -158,29 +178,11 @@
     </val>
   </entry>
   <entry>
-    <key type="numeric" value="4112" />
-    <val type="dict" id="141447620" >
-      <entry>
-        <key type="string" value="callback" />
-        <val type="True" value="" />
-      </entry>
-    </val>
-  </entry>
-  <entry>
-    <key type="numeric" value="4113" />
-    <val type="dict" id="141447212" >
-      <entry>
-        <key type="string" value="callback" />
-        <val type="True" value="" />
-      </entry>
-    </val>
-  </entry>
-  <entry>
     <key type="numeric" value="6144" />
-    <val type="dict" id="141447756" >
+    <val type="dict" id="17162800" >
       <entry>
         <key type="numeric" value="2" />
-        <val type="dict" id="141447348" >
+        <val type="dict" id="19297824" >
           <entry>
             <key type="string" value="save" />
             <val type="True" value="" />
@@ -189,7 +191,7 @@
       </entry>
       <entry>
         <key type="numeric" value="3" />
-        <val type="dict" id="141448436" >
+        <val type="dict" id="19605184" >
           <entry>
             <key type="string" value="save" />
             <val type="True" value="" />
@@ -199,27 +201,77 @@
     </val>
   </entry>
   <entry>
-    <key type="numeric" value="4119" />
-    <val type="dict" id="141447892" >
+    <key type="numeric" value="6146" />
+    <val type="dict" id="14214240" >
+      <entry>
+        <key type="numeric" value="3" />
+        <val type="dict" id="21063040" >
+          <entry>
+            <key type="string" value="comment" />
+            <val type="string">5000*100 µC = 500 ms</val>
+          </entry>
+        </val>
+      </entry>
+      <entry>
+        <key type="numeric" value="4" />
+        <val type="dict" id="20146992" >
+          <entry>
+            <key type="string" value="comment" />
+            <val type="string"></val>
+          </entry>
+        </val>
+      </entry>
+      <entry>
+        <key type="numeric" value="5" />
+        <val type="dict" id="20159808" >
+          <entry>
+            <key type="string" value="comment" />
+            <val type="string">1000 ms</val>
+          </entry>
+        </val>
+      </entry>
+    </val>
+  </entry>
+  <entry>
+    <key type="numeric" value="4112" />
+    <val type="dict" id="17144432" >
       <entry>
         <key type="string" value="callback" />
         <val type="True" value="" />
       </entry>
     </val>
   </entry>
+  <entry>
+    <key type="numeric" value="4113" />
+    <val type="dict" id="17172352" >
+      <entry>
+        <key type="string" value="callback" />
+        <val type="True" value="" />
+      </entry>
+    </val>
+  </entry>
+  <entry>
+    <key type="numeric" value="4119" />
+    <val type="dict" id="19297536" >
+      <entry>
+        <key type="string" value="callback" />
+        <val type="True" value="" />
+      </entry>
+    </val>
+  </entry>
 </attr>
-<attr name="UserMapping" type="dict" id="141438324" >
+<attr name="UserMapping" type="dict" id="16869072" >
   <entry>
     <key type="numeric" value="8192" />
-    <val type="dict" id="141448164" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140030540" >
-          <item type="dict" id="141448980" >
+    <val type="dict" id="17170240" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16612600" >
+          <item type="dict" id="19604864" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -251,15 +303,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8193" />
-    <val type="dict" id="141448844" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140021708" >
-          <item type="dict" id="141449252" >
+    <val type="dict" id="19607600" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16611232" >
+          <item type="dict" id="17173712" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -291,15 +343,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8194" />
-    <val type="dict" id="141448708" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140020748" >
-          <item type="dict" id="141438188" >
+    <val type="dict" id="19605760" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16609008" >
+          <item type="dict" id="16868784" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -331,15 +383,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8195" />
-    <val type="dict" id="141448300" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140021484" >
-          <item type="dict" id="141449116" >
+    <val type="dict" id="19606192" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16610872" >
+          <item type="dict" id="17173424" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -371,15 +423,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8196" />
-    <val type="dict" id="141449524" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140021420" >
-          <item type="dict" id="141449388" >
+    <val type="dict" id="19716512" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16610584" >
+          <item type="dict" id="19714784" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -411,15 +463,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8197" />
-    <val type="dict" id="141449796" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140030828" >
-          <item type="dict" id="141449660" >
+    <val type="dict" id="19717280" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16613176" >
+          <item type="dict" id="19716992" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -451,15 +503,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8198" />
-    <val type="dict" id="141450068" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140030060" >
-          <item type="dict" id="141449932" >
+    <val type="dict" id="19717728" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16611520" >
+          <item type="dict" id="19715136" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -491,15 +543,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8199" />
-    <val type="dict" id="141450340" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140019436" >
-          <item type="dict" id="141450204" >
+    <val type="dict" id="19715776" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16606056" >
+          <item type="dict" id="19715488" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -531,15 +583,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8200" />
-    <val type="dict" id="141450612" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140021324" >
-          <item type="dict" id="141450476" >
+    <val type="dict" id="19716064" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16610368" >
+          <item type="dict" id="19718208" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -571,15 +623,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8201" />
-    <val type="dict" id="141450884" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140021644" >
-          <item type="dict" id="141450748" >
+    <val type="dict" id="19721328" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16611088" >
+          <item type="dict" id="19718608" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -611,15 +663,15 @@
   </entry>
   <entry>
     <key type="numeric" value="8202" />
-    <val type="dict" id="141451308" >
-      <entry>
-        <key type="string" value="need" />
-        <val type="False" value="" />
-      </entry>
-      <entry>
-        <key type="string" value="values" />
-        <val type="list" id="140021452" >
-          <item type="dict" id="141451020" >
+    <val type="dict" id="19721952" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="16610656" >
+          <item type="dict" id="19721664" >
             <entry>
               <key type="string" value="access" />
               <val type="string" value="rw" />
@@ -649,8 +701,48 @@
       </entry>
     </val>
   </entry>
+  <entry>
+    <key type="numeric" value="8203" />
+    <val type="dict" id="20272576" >
+      <entry>
+        <key type="string" value="need" />
+        <val type="False" value="" />
+      </entry>
+      <entry>
+        <key type="string" value="values" />
+        <val type="list" id="18679784" >
+          <item type="dict" id="20295280" >
+            <entry>
+              <key type="string" value="access" />
+              <val type="string" value="rw" />
+            </entry>
+            <entry>
+              <key type="string" value="pdo" />
+              <val type="True" value="" />
+            </entry>
+            <entry>
+              <key type="string" value="type" />
+              <val type="numeric" value="3" />
+            </entry>
+            <entry>
+              <key type="string" value="name" />
+              <val type="string">SlaveMap12</val>
+            </entry>
+          </item>
+        </val>
+      </entry>
+      <entry>
+        <key type="string" value="name" />
+        <val type="string">SlaveMap12</val>
+      </entry>
+      <entry>
+        <key type="string" value="struct" />
+        <val type="numeric" value="1" />
+      </entry>
+    </val>
+  </entry>
 </attr>
-<attr name="DS302" type="dict" id="141451580" >
+<attr name="DS302" type="dict" id="19720576" >
 </attr>
 <attr name="ProfileName" type="string" value="DS-301" />
 <attr name="Type" type="string" value="slave" />
--- a/include/can.h	Fri Jun 29 19:48:22 2007 +0200
+++ b/include/can.h	Fri Jun 29 19:51:39 2007 +0200
@@ -46,6 +46,7 @@
   UNS8 data[8]; /* data */
 } Message;
 
+#define Message_Initializer {0,0,0,{0,0,0,0,0,0,0,0}}
 
 typedef UNS8 (*canSend_t)(Message *);
 
--- a/include/data.h	Fri Jun 29 19:48:22 2007 +0200
+++ b/include/data.h	Fri Jun 29 19:51:39 2007 +0200
@@ -46,7 +46,7 @@
 	/* Object dictionary */
 	UNS8 *bDeviceNodeId;
 	const indextable *objdict;
-	UNS8 *count_sync;
+	s_PDO_status *PDO_status;
 	quick_index *firstIndex;
 	quick_index *lastIndex;
 	UNS16 *ObjdictSize;
@@ -82,9 +82,6 @@
 	post_sync_t post_sync;
 	post_TPDO_t post_TPDO;
 	
-	/* PDO */
-	s_process_var process_var;
-	
 	/* General */
 	UNS8 toggle;
 	CAN_HANDLE canHandle;	
@@ -121,7 +118,7 @@
 	/* Object dictionary*/\
 	& NODE_PREFIX ## _bDeviceNodeId,     /* bDeviceNodeId */\
 	NODE_PREFIX ## _objdict,             /* objdict  */\
-	NODE_PREFIX ## _count_sync,          /* count_sync */\
+	NODE_PREFIX ## _PDO_status,          /* PDO_status */\
 	& NODE_PREFIX ## _firstIndex,        /* firstIndex */\
 	& NODE_PREFIX ## _lastIndex,         /* lastIndex */\
 	& NODE_PREFIX ## _ObjdictSize,       /* ObjdictSize */\
@@ -168,12 +165,6 @@
 	_post_sync,                 /* post_sync */\
 	_post_TPDO,                 /* post_TPDO */\
 	\
-	/* PDO, structure s_process_var */\
-        {\
-		0,          /* count */\
-		{0}         /* data (static use, so that all the table is initialize at 0)*/\
-        },\
-        \
 	/* General */\
 	0,                                         /* toggle */\
 	NULL,                   /* canSend */\
--- a/include/def.h	Fri Jun 29 19:48:22 2007 +0200
+++ b/include/def.h	Fri Jun 29 19:51:39 2007 +0200
@@ -62,9 +62,7 @@
 #define TRUE  1
 #define FALSE 0
 
-/* TODO: remove this limitation. do bit granularity mapping */
-#define PDO_MAX_LEN 8    
-                               
+    
 /** Status of the SDO transmission
  */
 #define SDO_RESET                0x0      /* Transmission not started. Init state. */
--- a/include/objdictdef.h	Fri Jun 29 19:48:22 2007 +0200
+++ b/include/objdictdef.h	Fri Jun 29 19:51:39 2007 +0200
@@ -67,18 +67,6 @@
  */
 
 
-
-/** definitions of the different types of PDOs' transmission
- * 
- * SYNCHRO(n) means that the PDO will be transmited every n SYNC signal.
- */
-#define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */
-#define TRANS_SYNC_MIN        1    /* Trans after reception of n SYNC. n = 1 to 240 */
-#define TRANS_SYNC_MAX        240  /* Trans after reception of n SYNC. n = 1 to 240 */
-#define TRANS_RTR_SYNC        252  /* Transmission on request */
-#define TRANS_RTR             253  /* Transmission on request */
-#define TRANS_EVENT           255  /* Transmission on event */
-
 /** Each entry of the object dictionary can be READONLY (RO), READ/WRITE (RW),
  *  WRITE-ONLY (WO)
  */
--- a/include/pdo.h	Fri Jun 29 19:48:22 2007 +0200
+++ b/include/pdo.h	Fri Jun 29 19:51:39 2007 +0200
@@ -26,49 +26,46 @@
 #include <applicfg.h>
 #include <def.h>
 
-/* The process_var structure
- Used to store the PDO before the transmission or the reception.
-*/
-typedef struct struct_s_process_var {
-  UNS8 count; /* Size of data. Ex : for a PDO of 6 bytes of data, count = 6 */
-  /* WARNING s_process_var.data is subject to ENDIANISATION 
-   * (with respect to CANOPEN_BIG_ENDIAN)
-   */
-  UNS8 data[PDO_MAX_LEN];
-}s_process_var;
+#include "can.h"
+
+typedef struct struct_s_PDO_status s_PDO_status;
 
 #include "data.h"
 
+/* Status of the TPDO : */
+#define PDO_INHIBITED 0x01
+
 /** The PDO structure */
-typedef struct struct_s_PDO {
-  UNS32 cobId;	  /* COB-ID */
-  UNS8           len;	  /* Number of data transmitted (in data[]) */
-  UNS8           data[8]; /* Contain the data */
-}s_PDO;
+struct struct_s_PDO_status {
+  UNS8 transmit_type_parameter;
+  TIMER_HANDLE event_timer;
+  TIMER_HANDLE inhibit_timer;
+  Message last_message;
+};
 
-/** Transmit a PDO data frame on the bus bus_id
- * pdo is a structure which contains the pdo to transmit
- * bus_id is hardware dependant
- * return canSend(bus_id,&m) or 0xFF if error
- * request can take the value  REQUEST or NOT_A_REQUEST
+#define s_PDO_staus_Initializer {0, TIMER_NONE, TIMER_NONE, Message_Initializer}
+
+/** definitions of the different types of PDOs' transmission
+ * 
+ * SYNCHRO(n) means that the PDO will be transmited every n SYNC signal.
  */
-UNS8 sendPDO (CO_Data* d, s_PDO pdo, UNS8 request);
+#define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */
+#define TRANS_SYNC_MIN        1    /* Trans after reception of n SYNC. n = 1 to 240 */
+#define TRANS_SYNC_MAX        240  /* Trans after reception of n SYNC. n = 1 to 240 */
+#define TRANS_RTR_SYNC        252  /* Transmission on request */
+#define TRANS_RTR             253  /* Transmission on request */
+#define TRANS_EVENT_SPECIFIC  254  /* Transmission on event */
+#define TRANS_EVENT_PROFILE   255  /* Transmission on event */
 
-/** Prepare a PDO frame transmission, 
- * whose different parameters are stored in process_var table,
- * to the slave.
- * bus_id is hardware dependant
- * call the function sendPDO
- * return the result of the function sendPDO or 0xFF if error
- */
-UNS8 PDOmGR (CO_Data* d, UNS32 cobId);
-
-/** Prepare the PDO defined at index to be sent by  PDOmGR
+/** Prepare the PDO defined at index to be sent 
+ * 
+ * 
+ * 
  * Copy all the data to transmit in process_var
  * *pwCobId : returns the value of the cobid. (subindex 1)
  * Return 0 or 0xFF if error.
  */
-UNS8 buildPDO (CO_Data* d, UNS16 index);
+UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo);
 
 /** Transmit a PDO request frame on the bus bus_id
  * to the slave.
@@ -83,16 +80,24 @@
  */
 UNS8 proceedPDO (CO_Data* d, Message *m);
 
-/* used by the application to send a variable by PDO.
- * Check in which PDO the variable is mapped, and send the PDO. 
- * of course, the others variables mapped in the PDO are also sent !
- * ( ie when a specific event occured)
- * bus_id is hardware dependant
- * variable is a pointer to the variable which has to be sent. Must be
- * defined in the object dictionary
- * return 0xFF if error, else return 0
+/** Used by the application to signal changes in process data
+ * that could be mapped to some TPDO.
+ * This do not necessarily imply PDO emission.
+ * Function iterates on all TPDO and look TPDO transmit 
+ * type and content change before sending it.    
  */
-UNS8 sendPDOevent (CO_Data* d, void * variable);
+UNS8 sendPDOevent (CO_Data* d);
+
+/** Function iterates on all TPDO and look TPDO transmit 
+ * type and content change before sending it.
+ */
+UNS8 _sendPDOevent(CO_Data* d, UNS8 isSyncEvent);
+
+
+void PDOInit(CO_Data* d);
+void PDOStop(CO_Data* d);
+void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum);
+void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum);
 
 /* copy bit per bit in little endian */
 void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian);
--- a/include/sync.h	Fri Jun 29 19:48:22 2007 +0200
+++ b/include/sync.h	Fri Jun 29 19:51:39 2007 +0200
@@ -39,20 +39,11 @@
  */
 UNS8 sendSYNC (CO_Data* d, UNS32 cob_id);
 
-/** This function is called when the node is receiving a SYNC 
- * message (cob-id = 0x80).
- * What does the function :
- * check if the node is in OERATIONAL mode. (other mode : return 0 but does nothing).
- * Get the SYNC cobId by reading the dictionary index 1005. (Return -1 if it does not correspond 
- * to the cobId received).
- * Scan the dictionary from index 0x1800 to the last PDO defined (dict_cstes.max_count_of_PDO_transmit)
- *   for each PDO whose transmission type is on synchro (transmission type < 241) and if the msg must
- *   be send at this SYNC. read the COBID. Verify that the nodeId inside the 
- *   nodeId correspond to bDeviceNodeId. (Assume that the cobId of a PDO Transmit is made 
- *   with the node id of the node who transmit), get the mapping, launch PDOmGR to send the PDO
- * *m is a pointer to the message received
- * bus_id is hardware dependant
- * return 0 if OK, 0xFF if error
+/** 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).
+ *  - Get the SYNC cobId by reading the dictionary index 1005, check it does correspond to the received cobId
+ *  - Trigger sync TPDO emission 
+ *  - return 0 if OK, 0xFF if error
  */
 UNS8 proceedSYNC (CO_Data* d, Message * m);
 
--- a/objdictgen/gen_cfile.py	Fri Jun 29 19:48:22 2007 +0200
+++ b/objdictgen/gen_cfile.py	Fri Jun 29 19:51:39 2007 +0200
@@ -448,12 +448,16 @@
 	return &%(NodeName)s_objdict[i];
 }
 
-/* To count at which received SYNC a PDO must be sent.
+/* 
+ * To count at which received SYNC a PDO must be sent.
  * Even if no pdoTransmit are defined, at least one entry is computed
  * for compilations issues.
  */
-UNS8 %(NodeName)s_count_sync[%(maxPDOtransmit)d] = {0,};
-"""%texts
+s_PDO_status %(NodeName)s_PDO_status[%(maxPDOtransmit)d] = {"""%texts
+
+    fileContent += ",".join(["s_PDO_staus_Initializer"]*texts["maxPDOtransmit"]) + """};
+"""
+
     fileContent += strQuickIndex
     fileContent += """
 UNS16 %(NodeName)s_ObjdictSize = sizeof(%(NodeName)s_objdict)/sizeof(%(NodeName)s_objdict[0]); 
--- a/src/pdo.c	Fri Jun 29 19:48:22 2007 +0200
+++ b/src/pdo.c	Fri Jun 29 19:51:39 2007 +0200
@@ -34,141 +34,64 @@
 **
 **
 */
-UNS8 sendPDO(CO_Data* d, s_PDO pdo, UNS8 req)
-{
-  UNS8 i;
-  if( d->nodeState == Operational ) {
-    Message m;
-
-    /* Message copy for sending */
-    m.cob_id.w = pdo.cobId & 0x7FF; /* Because the cobId is 11 bytes
-                                      length */
-    if ( req == NOT_A_REQUEST ) {
-      UNS8 i;
-      m.rtr = NOT_A_REQUEST;
-      m.len = pdo.len;
-      /* memcpy(&m.data, &pdo.data, m.len); */
-      /* This Memcpy depends on packing structure. Avoid */
-      for (i = 0 ; i < pdo.len ; i++)
-        m.data[i] = pdo.data[i];
-    }
-    else {
-      m.rtr = REQUEST;
-      m.len = 0;
-    }
-
-    MSG_WAR(0x3901, "sendPDO cobId :", m.cob_id.w);
-    MSG_WAR(0x3902,  "     Nb octets  : ",  m.len);
-    for (i = 0 ; i < m.len ; i++) {
-      MSG_WAR(0x3903,"           data : ", m.data[i]);
-    }
-
-    return canSend(d->canHandle,&m);
-  } /* end if */
-  return 0xFF;
-}
-
-/*!
-** PDO Manager
+
+/*!
+**
 **
 ** @param d
-** @param cobId
+** @param TPDO_com TPDO communication parameters OD entry
+** @param TPDO_map TPDO mapping parameters OD entry
 **
 ** @return
 **/
-UNS8 PDOmGR(CO_Data* d, UNS32 cobId)
-{
-  UNS8 res;
-  UNS8 i;
-  s_PDO pdo;
-
-  MSG_WAR(0x3905, "PDOmGR",0);
-
-  /* if PDO is waiting for transmission,
-    preparation of the message to send */
-  pdo.cobId = cobId;
-  pdo.len =  d->process_var.count;
-  /* memcpy(&(pdo.data), &(process_var.data), pdo.len); */
-     /* Ce memcpy devrait tre portable */
-    for ( i = 0 ; i < pdo.len ; i++) 
-      pdo.data[i] = d->process_var.data[i];
-
-    res = sendPDO(d, pdo, NOT_A_REQUEST);
-
-    return res;
-}
-
-#if 0
-/*********************************************************************/
-/* TODO : implement bit mapping                          			 */
-/*********************************************************************/
-
-UNS8 buildPDO(CO_Data* d, UNS16 index)
-{ /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails. */	
-  UNS16 ind;
-  UNS8      subInd;
-
-  UNS8 *     pMappingCount = NULL;      /* count of mapped objects... */
-  /* pointer to the var which is mapped to a pdo */
-/*  void *     pMappedAppObject = NULL;  */
-  /* pointer fo the var which holds the mapping parameter of an mapping entry  */ 
- 
-  UNS32 *    pMappingParameter = NULL;
-
-  UNS8      Size;
-  UNS8      dataType;
-  UNS8      offset;
-  UNS16     offsetObjdict;
-  UNS16     offsetObjdictPrm;
-  UNS32     objDict;
-
-  subInd=(UNS8)0x00;
-  offset = 0x00;
-  ind = index - 0x1800;
-
-  MSG_WAR(0x3910,"Prepare PDO to send index :", index);
-
-  /* only operational state allows PDO transmission */
-  if( d->nodeState != Operational ) {
-    MSG_WAR(0x2911, "Unable to send the PDO (node not in OPERATIONAL mode). Node : ", index);
-    return 0xFF;
-  }
-  offsetObjdictPrm = d->firstIndex->PDO_TRS;
-  offsetObjdict = d->firstIndex->PDO_TRS_MAP;
-
-  if (offsetObjdictPrm && offsetObjdict)
-    {
-      /* get mapped objects number to transmit with this PDO */
-      pMappingCount = (d->objdict + offsetObjdict + ind)->pSubindex[0].pObject;
-      MSG_WAR(0x3912, "Nb maped objects : ",* pMappingCount);
-      MSG_WAR(0x3913, "        at index : ", 0x1A00 + ind);
-      while (subInd < *pMappingCount) { /* Loop on mapped variables */
-        /* get mapping parameters */
-        pMappingParameter = (d->objdict + offsetObjdict + ind)->pSubindex[subInd + 1].pObject;
-        MSG_WAR(0x3914, "Get the mapping      at index : ", (UNS16)0x1A00 + ind);
-        MSG_WAR(0x3915, "                     subIndex : ", subInd + 1);
-        MSG_WAR(0x3916, "                     value    : ", *(UNS32 *)pMappingParameter);
-        /* Get the mapped variable */
-        Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
-        objDict = getODentry(d, (UNS16)((*pMappingParameter) >> 16),
-                             (UNS8)(((*pMappingParameter) >> 8 ) & 0x000000FF),
-                             (void *)&d->process_var.data[offset], &Size, &dataType, 0 );
-
-        if (objDict != OD_SUCCESSFUL) {
-          MSG_WAR(0x2919, "error accessing to the mapped var : ", subInd + 1);
-          MSG_WAR(0x2920, "         Mapped at index : ", (*pMappingParameter) >> 16);
-          MSG_WAR(0x2921, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
-          return 0xFF;
-        }
-
-        offset += Size;
-        d->process_var.count = offset;
-        subInd++;
-      }/* end Loop on mapped variables  */
-    }
-  return 0;
-}
-#endif
+
+UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo)
+{
+	const indextable* TPDO_com = d->objdict + d->firstIndex->PDO_TRS + numPdo; 
+	const indextable* TPDO_map = d->objdict + d->firstIndex->PDO_TRS_MAP + numPdo;
+	
+	UNS8 prp_j = 0x00;
+	UNS8 offset = 0x00;
+	const UNS8* pMappingCount = (UNS8*) TPDO_map->pSubindex[0].pObject;
+
+	pdo->cob_id.w = *(UNS32*)TPDO_com->pSubindex[1].pObject;
+	pdo->rtr = NOT_A_REQUEST;
+
+	MSG_WAR(0x3009, "  PDO CobId is : ", *(UNS32*)TPDO_com->pSubindex[1].pObject);
+	MSG_WAR(0x300D, "  Number of objects mapped : ",*pMappingCount );
+	
+	do{
+		UNS8 dataType; /* Unused */
+		UNS8 tmp[]= {0,0,0,0,0,0,0,0}; /* temporary space to hold bits */
+
+		/* pointer fo the var which holds the mapping parameter of an mapping entry  */
+		UNS32* pMappingParameter = (UNS32*) TPDO_map->pSubindex[prp_j + 1].pObject;
+		UNS16 index = (UNS16)((*pMappingParameter) >> 16);
+		UNS8 Size = (UNS8)(*pMappingParameter); /* Size in bits */
+		UNS8 ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 => 2, ... */
+		UNS8 subIndex = (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF);
+		
+		MSG_WAR(0x300F, "  got mapping parameter : ", *pMappingParameter);
+		MSG_WAR(0x3050, "    at index : ", TPDO_map->index);
+		MSG_WAR(0x3051, "    sub-index : ", prp_j + 1);
+		
+		if( getODentry(d, index, subIndex, tmp, &ByteSize, &dataType, 0 ) != OD_SUCCESSFUL ){
+			MSG_ERR(0x1013, " Couldn't find mapped variable at index-subindex-size : ", (UNS16)(*pMappingParameter));
+			return 0xFF;
+		}
+		/* copy bit per bit in little endian*/
+		CopyBits(Size, ((UNS8*)tmp), 0 , 0, (UNS8*)&pdo->data[offset>>3], offset%8, 0);
+
+		offset += Size ;
+		prp_j++;
+	}while( prp_j < *pMappingCount );
+
+	pdo->len = 1 + ((offset - 1) >> 3);
+
+	MSG_WAR(0x3015, "  End scan mapped variable", 0);
+
+	return 0;
+}
 
 /*!
 **
@@ -197,11 +120,8 @@
       pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
 
       if ( *pwCobId  == cobId ) {
-        s_PDO pdo;
-        pdo.cobId = *pwCobId;
-        pdo.len = 0;
-        err  = sendPDO(d, pdo, REQUEST);
-        return err;
+        Message pdo = {*pwCobId, REQUEST, 0};
+	return canSend(d->canHandle,&pdo);
       }
       offset++;
     }
@@ -239,7 +159,8 @@
   UNS32      objDict;
   UNS16      offsetObjdict;
   UNS16      lastIndex;
-  status = state1;
+  
+  status = state2;
 
   MSG_WAR(0x3935, "proceedPDO, cobID : ", ((*m).cob_id.w & 0x7ff));
   offset = 0x00;
@@ -247,6 +168,7 @@
   numMap = 0;
   if((*m).rtr == NOT_A_REQUEST ) { /* The PDO received is not a
                                      request. */
+
     offsetObjdict = d->firstIndex->PDO_RCV;
     lastIndex = d->lastIndex->PDO_RCV;
 
@@ -256,16 +178,6 @@
 
         switch( status ) {
 
-        case state1:/* data are stored in process_var array */
-          /* memcpy(&(process_var.data), &m->data, (*m).len); */
-          /* Ce memcpy devrait etre portable */
-          for ( i = 0 ; i < m->len ; i++)
-            d->process_var.data[i] = m->data[i];
-          d->process_var.count = (*m).len;
-
-          status = state2;
-          break;
-
         case state2:
           /* get CobId of the dictionary correspondant to the received
              PDO */
@@ -313,7 +225,7 @@
                Size = (UNS8)(*pMappingParameter);
 
                /* copy bit per bit in little endian */
-               CopyBits(Size, (UNS8*)&d->process_var.data[offset>>3], offset%8, 0, ((UNS8*)tmp), 0, 0);
+               CopyBits(Size, (UNS8*)&m->data[offset>>3], offset%8, 0, ((UNS8*)tmp), 0, 0);
 
                ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 =>
                                                    2, ... */
@@ -335,6 +247,7 @@
                /* MSG_WAR(0x3945, "                data : ",*((UNS32*)pMappedAppObject)); */
                offset += Size;
                numMap++;
+               /*TODO :  check that offset is not not greater that message size (in bit) */
              } /* end loop while on mapped variables */
 
              offset=0x00;
@@ -372,43 +285,38 @@
 
       case state4:/* check transmission type (after request?) */
         pTransmissionType = (UNS8*) d->objdict[offsetObjdict].pSubindex[2].pObject;
-        if ( (*pTransmissionType == TRANS_RTR) || (*pTransmissionType == TRANS_RTR_SYNC ) || (*pTransmissionType == TRANS_EVENT) ) {
+        if ( (*pTransmissionType == TRANS_RTR) ||
+             (*pTransmissionType == TRANS_RTR_SYNC )) {
           status = state5;
           break;
-        }
-        else {
+        }else if(
+             (*pTransmissionType == TRANS_EVENT_PROFILE) ||
+             (*pTransmissionType == TRANS_EVENT_SPECIFIC) ) {
+	  /* Zap all timers and inhibit flag */
+	  d->PDO_status[numPdo].event_timer = DelAlarm(d->PDO_status[numPdo].event_timer);
+	  d->PDO_status[numPdo].inhibit_timer = DelAlarm(d->PDO_status[numPdo].inhibit_timer);
+  	  d->PDO_status[numPdo].transmit_type_parameter &= ~PDO_INHIBITED;
+  	  /* Call  PDOEventTimerAlarm for this TPDO, this will trigger emission et reset timers */
+          PDOEventTimerAlarm(d, numPdo);
+          return 0;
+        }else {
           /* The requested PDO is not to send on request. So, does
             nothing. */
           MSG_WAR(0x2947, "PDO is not to send on request : ", m->cob_id.w);
           return 0xFF;
         }
 
-      case state5:/* get mapped objects number */
-        offsetObjdict = d->firstIndex->PDO_TRS_MAP;
-        lastIndex = d->lastIndex->PDO_TRS_MAP;
-        pMappingCount = (UNS8*) (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
-        numMap = 0;
-        while (numMap < *pMappingCount) {
-          pMappingParameter = (UNS32*) (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
-          /* Get the mapped variable */
-          Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
-          objDict = getODentry( d, (UNS16)((*pMappingParameter) >> (UNS8)16),
-                                (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & 0xFF),
-                                (void *)&d->process_var.data[offset], &Size, &dataType, 0 );
-          if (objDict != OD_SUCCESSFUL) {
-            MSG_ERR(0x1948, "error accessing to the mapped var : ", numMap + 1);
-            MSG_WAR(0x2949, "         Mapped at index : ", (*pMappingParameter) >> 16);
-            MSG_WAR(0x2950, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
-            return 0xFF;
-          }
-          offset += (UNS8) (((*pMappingParameter) & 0xFF) >> 3);
-          d->process_var.count = offset;
-          numMap++;
-
-        } /* end while */
-        PDOmGR( d, *pwCobId ); /* Transmit the PDO */
+      case state5:/* build and send requested PDO */
+      {
+      	Message pdo;
+    	if( buildPDO(d, numPdo, &pdo))
+    	{
+          MSG_ERR(0x1013, " Couldn't find mapped variable at index-subindex-size : ", (UNS16)(*pMappingParameter));
+          //return 0xFF; /*No real reason to stop...*/
+    	}
+    	canSend(d->canHandle,&pdo);
         return 0;
-
+      }
       }/* end switch status */
     }/* end while */
   }/* end if Requete */
@@ -476,109 +384,191 @@
     }
 
 }
-
-#if 0
-
-/*********************************************************************/
-/* TODO : reimplement this using CallBacks
- */
-/*********************************************************************/
-
 /*!
 **
 **
 ** @param d
-** @param variable
 **
 ** @return
 **/
-UNS8 sendPDOevent( CO_Data* d, void * variable )
-{ /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite
-    loop if it fails.*/
-  UNS32           objDict = 0;
-  UNS8            ind, sub_ind;
-  UNS8            status;
-  UNS8            offset;
-  UNS8 *     pMappingCount = NULL;
-  UNS32 *    pMappingParameter = NULL;
-  void *     pMappedAppObject = NULL;
-  UNS8 *     pTransmissionType = NULL; /* pointer to the transmission
-                                         type */
-  UNS32 *    pwCobId = NULL;
-  UNS8 *     pSize;
-  UNS8       size;
-  UNS8       dataType;
-  UNS16      offsetObjdict;
-  UNS16      offsetObjdictPrm;
-  UNS16      lastIndex;
-  UNS8       numMap;
-  ind     = 0x00;
-  sub_ind = 1;
-  offset  = 0x00;
-  pSize   = &size;
-  status  = state1;
-
-
-  /* look for the index and subindex where the variable is mapped */
-  /* Then, send the pdo which contains the variable. */
-
-  MSG_WAR (0x3960, "sendPDOevent", 0);
-  offsetObjdictPrm = d->firstIndex->PDO_TRS;
-
-  offsetObjdict = d->firstIndex->PDO_TRS_MAP;
-  lastIndex = d->lastIndex->PDO_TRS_MAP;
-
-  if (offsetObjdictPrm && offsetObjdict)
-    /* Loop on PDO Transmit */
-    while(offsetObjdict <= lastIndex){
-      /* Check the transmission mode */
-      pTransmissionType = d->objdict[offsetObjdictPrm].pSubindex[2].pObject;
-      if (*pTransmissionType != TRANS_EVENT) {
-        ind++;
-        offsetObjdict++;
-        offsetObjdictPrm++;
-        continue;
+
+UNS8 sendPDOevent( CO_Data* d)
+{
+  /* Calls _sendPDOevent specifying it is not a sync event */
+  return _sendPDOevent(d, 0);
+}
+	
+
+void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum)
+{
+	printf("EV PDOEventTimerAlarm : %d\n", pdoNum);
+	
+	/* This is needed to avoid deletion of re-attribuated timer */
+	d->PDO_status[pdoNum].event_timer = TIMER_NONE;
+	/* force emission of PDO by artificially changing last emitted*/
+	d->PDO_status[pdoNum].last_message.cob_id.w = 0;
+	_sendPDOevent( d, 0 ); /* not a Sync Event*/	
+}
+
+void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum)
+{
+	printf("EV PDOInhibitTimerAlarm : %d\n", pdoNum);
+
+	/* This is needed to avoid deletion of re-attribuated timer */
+	d->PDO_status[pdoNum].inhibit_timer = TIMER_NONE;
+	/* Remove inhibit flag */
+	d->PDO_status[pdoNum].transmit_type_parameter &= ~PDO_INHIBITED;
+	_sendPDOevent( d, 0 ); /* not a Sync Event*/
+}
+
+/*!
+**
+**
+** @param d
+** @param isSyncEvent
+**
+** @return
+**/
+
+UNS8 _sendPDOevent( CO_Data* d, UNS8 isSyncEvent )
+{ 
+  UNS8 	pdoNum = 0x00;       /* number of the actual processed pdo-nr. */
+  UNS8* pTransmissionType = NULL;  
+  UNS8 status = state3;
+  UNS16 offsetObjdict = d->firstIndex->PDO_TRS;
+  UNS16 offsetObjdictMap = d->firstIndex->PDO_TRS_MAP;
+  UNS16 lastIndex = d->lastIndex->PDO_TRS;  
+
+  /* study all PDO stored in the objects dictionary */	
+  if(offsetObjdict){
+   Message clean = Message_Initializer;
+   Message pdo = Message_Initializer;
+   while( offsetObjdict <= lastIndex) {  
+    switch( status ) {
+    case state3:    /* get the PDO transmission type */
+      if (d->objdict[offsetObjdict].bSubCount <= 2) {
+	  MSG_ERR(0x1004, "Subindex 2  not found at index ", 0x1800 + pdoNum);
+	  return 0xFF;
+	}
+      pTransmissionType = (UNS8*) d->objdict[offsetObjdict].pSubindex[2].pObject;    
+      MSG_WAR(0x3005, "Reading PDO at index : ", 0x1800 + pdoNum);
+
+      /* check if transmission type is after (this) SYNC */
+      /* The message may not be transmited every SYNC but every n SYNC */      
+      if( isSyncEvent && 
+      	  (*pTransmissionType >= TRANS_SYNC_MIN) &&
+      	  (*pTransmissionType <= TRANS_SYNC_MAX) &&
+          (++d->PDO_status[pdoNum].transmit_type_parameter == *pTransmissionType) ) {	
+	d->PDO_status[pdoNum].transmit_type_parameter = 0;
+	MSG_WAR(0x3007, "  PDO is on SYNCHRO. Trans type : ", *pTransmissionType);
+	pdo = clean;
+        if(buildPDO(d, pdoNum, &pdo))
+        {
+            MSG_ERR(0x3006, " Couldn't build TPDO number : ", pdoNum);
+	    status = state11;
+	    break;
+        }
+	status = state5;
       }
-      pMappingCount = d->objdict[offsetObjdict].pSubindex[0].pObject;
-      numMap = 1; /* mapped variable */
-      while (numMap <= *pMappingCount) {
-        pMappingParameter = d->objdict[offsetObjdict].pSubindex[numMap].pObject;
-        /* Get the variable */
-        objDict = getODentry( d,
-                              (UNS16)((*pMappingParameter) >> 16),
-                              (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF),
-                              (void * *)&pMappedAppObject, pSize, &dataType, 0 );
-        if( objDict != OD_SUCCESSFUL ) {
-          MSG_WAR(0x2961, "Error in dict. at index : ",
-                  (*pMappingParameter) >> (UNS8)16);
-
-          MSG_WAR(0x2962, "               subindex : ",
-                  ((*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF);
-          return 0xFF;
-        }
-        if (pMappedAppObject == variable) { // Variable found !
-          MSG_WAR(0x3963, "Variable to send found at index : ",
-                  (*pMappingParameter) >> 16);
-          MSG_WAR(0x3964, "                       subIndex : ",
-                  ((*pMappingParameter) >> 8 ) & 0x000000FF);
-          buildPDO(d, 0x1800 + ind);
-          /* Get the cobId */
-          pwCobId = d->objdict[offsetObjdictPrm].pSubindex[1].pObject;
-          PDOmGR( d, *pwCobId ); /* Send the PDO */
-          return 0;
-        }
-        numMap++;
-      } /* End loop on mapped variable */
-      ind++;
-      offsetObjdict++;
-      offsetObjdictPrm++;
-    } /* End loop while on PDO */
-
-  MSG_WAR(0x2965, "Variable not found in a PDO to send on event", 0);
-  return 0xFF;
-
-}
-#endif
-
-
-
+      /* If transmission on Event and not inhibited, check for changes */
+      else if((*pTransmissionType == TRANS_EVENT_PROFILE ||
+               *pTransmissionType == TRANS_EVENT_SPECIFIC )&&
+              !(d->PDO_status[pdoNum].transmit_type_parameter & PDO_INHIBITED)) {
+	MSG_WAR(0x3008, "  PDO is on EVENT. Trans type : ", *pTransmissionType);
+	pdo = pdo = clean;
+        if(buildPDO(d, pdoNum, &pdo))
+        {
+            MSG_ERR(0x3007, " Couldn't build TPDO number : ", pdoNum);
+	    status = state11;
+	    break;
+        }
+        
+	/*Compare new and old PDO*/
+	if(d->PDO_status[pdoNum].last_message.cob_id.w == pdo.cob_id.w &&
+	   d->PDO_status[pdoNum].last_message.len == pdo.len &&
+	   *(UNS64*)(&d->PDO_status[pdoNum].last_message.data[0]) == *(UNS64*)(&pdo.data[0])){
+	   	/* No changes -> go to next pdo*/
+		status = state11;
+	}else{
+		MSG_WAR(0x3008, "Changes TPDO number : ", pdoNum);
+		printf("EV Changes TPDO number : %d\n", pdoNum);
+		/* Changes detected -> transmit message */
+		status = state5;
+		
+		/* Start both event_timer and inhibit_timer*/
+		DelAlarm(d->PDO_status[pdoNum].event_timer);
+		d->PDO_status[pdoNum].event_timer = SetAlarm(d, pdoNum, &PDOEventTimerAlarm, MS_TO_TIMEVAL(*(UNS16*)d->objdict[offsetObjdict].pSubindex[5].pObject), 0);
+		
+		DelAlarm(d->PDO_status[pdoNum].inhibit_timer);
+		d->PDO_status[pdoNum].inhibit_timer = SetAlarm(d, pdoNum, &PDOInhibitTimerAlarm, US_TO_TIMEVAL(*(UNS16*)d->objdict[offsetObjdict].pSubindex[3].pObject * 100), 0);
+		
+		/* and inhibit TPDO */
+		d->PDO_status[pdoNum].transmit_type_parameter |= PDO_INHIBITED;
+	}
+      }else{
+	MSG_WAR(0x3009, "  PDO is not on EVENT or synchro or not at this SYNC. Trans type : ", *pTransmissionType);
+	status = state11;
+      }      
+        break;
+    case state5: /*Send the pdo*/
+	/*store_as_last_message*/
+	d->PDO_status[pdoNum].last_message = pdo;	
+	MSG_WAR(0x3901, "sendPDO cobId :", pdo.cob_id.w);
+	MSG_WAR(0x3902,  "     Nb octets  : ",  pdo.len);
+	{int i;
+	for (i = 0 ; i < pdo.len ; i++) {
+		MSG_WAR(0x3903,"           data : ", pdo.data[i]);
+	}}
+    	
+    	canSend(d->canHandle,&pdo);
+	status = state11;
+	break;     
+    case state11: /*Go to next TPDO*/     
+	pdoNum++;
+	offsetObjdict++;
+	offsetObjdictMap++;
+	MSG_WAR(0x3017, "next pdo index : ", pdoNum);
+	status = state3;
+	break;
+      
+    default:
+      MSG_ERR(0x1019,"Unknown state has been reached : %d",status);
+      return 0xFF;
+    }/* end switch case */
+    
+  }/* end while */
+  }
+  return 0;
+}
+
+void PDOInit(CO_Data* d)
+{
+	
+	/* TODO: implement callbacks on 140xh
+	 * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+	 * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+	 * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+	 * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+	 * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+	 * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+	 * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+	 * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
+	*/	
+	
+  _sendPDOevent(d, 0 );
+}
+
+void PDOStop(CO_Data* d)
+{
+  UNS8 	pdoNum = 0x00;       /* number of the actual processed pdo-nr. */
+  UNS16 offsetObjdict = d->firstIndex->PDO_TRS;
+  UNS16 lastIndex = d->lastIndex->PDO_TRS;
+  if(offsetObjdict) while( offsetObjdict <= lastIndex) {
+	d->PDO_status[pdoNum].event_timer = DelAlarm(d->PDO_status[pdoNum].event_timer);
+	d->PDO_status[pdoNum].inhibit_timer = DelAlarm(d->PDO_status[pdoNum].inhibit_timer);
+	d->PDO_status[pdoNum].transmit_type_parameter = 0;
+	d->PDO_status[pdoNum].last_message.cob_id.w = 0;
+	pdoNum++;
+	offsetObjdict++;
+  }  
+}
--- a/src/states.c	Fri Jun 29 19:48:22 2007 +0200
+++ b/src/states.c	Fri Jun 29 19:51:39 2007 +0200
@@ -123,7 +123,7 @@
 	StartOrStop(csSYNC,	startSYNC(d),		stopSYNC(d))
 	StartOrStop(csHeartbeat,	heartbeatInit(d),	heartbeatStop(d))
 /*	StartOrStop(Emergency,,) */
-	StartOrStop(csPDO,	None,	None)
+	StartOrStop(csPDO,	PDOInit(d),	PDOStop(d))
 	StartOrStop(csBoot_Up,	None,	slaveSendBootUp(d))
 }
 
--- a/src/sync.c	Fri Jun 29 19:48:22 2007 +0200
+++ b/src/sync.c	Fri Jun 29 19:51:39 2007 +0200
@@ -141,33 +141,7 @@
 UNS8 proceedSYNC(CO_Data* d, Message *m)
 {
 
-  UNS8 	pdoNum,       /* number of the actual processed pdo-nr. */
-        prp_j;
-
-  const UNS8 *     pMappingCount = NULL;      /* count of mapped objects...*/
-  /* pointer to the var which is mapped to a pdo */
-  /* void *     pMappedAppObject = NULL; */
-  /* pointer fo the var which holds the mapping parameter of an mapping entry  */
-  UNS32 *    pMappingParameter = NULL;  
-  /* pointer to the transmissiontype...*/
-  UNS8 *     pTransmissionType = NULL;  
-  UNS32 *    pwCobId = NULL;	
-
-  UNS8 dataType;
-  UNS16 index;
-  UNS8 subIndex;
-  UNS8 offset;
-  UNS8 status;
-  UNS8 Size;
-  UNS32 objDict;	
-  UNS16 offsetObjdict;
-  UNS16 offsetObjdictMap;
-  UNS16 lastIndex;
-  
-  status = state3;
-  pdoNum = 0x00;
-  prp_j = 0x00;
-  offset = 0x00;
+  UNS8 res;
   
   MSG_WAR(0x3002, "SYNC received. Proceed. ", 0);
   
@@ -176,117 +150,14 @@
   /* only operational state allows PDO transmission */
   if( d->nodeState != Operational ) 
     return 0;
+
+  res = _sendPDOevent(d, 1 /*isSyncEvent*/ );
   
-  /* So, the node is in operational state */
-  /* study all PDO stored in the objects dictionary */	
- 
-  offsetObjdict = d->firstIndex->PDO_TRS;
-  lastIndex = d->lastIndex->PDO_TRS;
-  offsetObjdictMap = d->firstIndex->PDO_TRS_MAP;
+  /*Call user app callback*/
+  (*d->post_TPDO)();
   
-  if(offsetObjdict) while( offsetObjdict <= lastIndex) {  
-    switch( status ) {
-                    
-    case state3:    /* get the PDO transmission type */
-      if (d->objdict[offsetObjdict].bSubCount <= 2) {
-	  MSG_ERR(0x1004, "Subindex 2  not found at index ", 0x1800 + pdoNum);
-	  return 0xFF;
-	}
-      pTransmissionType = (UNS8*) d->objdict[offsetObjdict].pSubindex[2].pObject;    
-      MSG_WAR(0x3005, "Reading PDO at index : ", 0x1800 + pdoNum);
-      status = state4; 
-      break;     
-    case state4:	/* check if transmission type is after (this) SYNC */
-                        /* The message may not be transmited every SYNC but every n SYNC */      
-      if( (*pTransmissionType >= TRANS_SYNC_MIN) && (*pTransmissionType <= TRANS_SYNC_MAX) &&
-          (++d->count_sync[pdoNum] == *pTransmissionType) ) {	
-	d->count_sync[pdoNum] = 0;
-	MSG_WAR(0x3007, "  PDO is on SYNCHRO. Trans type : ", *pTransmissionType);
-	status = state5;
-	break;
-      }
-      else {
-	MSG_WAR(0x3008, "  Not on synchro or not at this SYNC. Trans type : ", 
-		*pTransmissionType);
-	pdoNum++;
-	offsetObjdict++;
-	offsetObjdictMap++;
-	status = state11;
-	break;
-      }      
-    case state5:	/* get PDO CobId */
-        pwCobId = (UNS32*) d->objdict[offsetObjdict].pSubindex[1].pObject;     
-	MSG_WAR(0x3009, "  PDO CobId is : ", *pwCobId);
-	status = state7;
-	break;     
-    case state7:  /* get mapped objects number to transmit with this PDO */
-      pMappingCount = (UNS8*) d->objdict[offsetObjdictMap].pSubindex[0].pObject;
-	MSG_WAR(0x300D, "  Number of objects mapped : ",*pMappingCount );
-	status = state8;
-    case state8:	/* get mapping parameters */
-      pMappingParameter = (UNS32*) d->objdict[offsetObjdictMap].pSubindex[prp_j + 1].pObject;
-	MSG_WAR(0x300F, "  got mapping parameter : ", *pMappingParameter);
-	MSG_WAR(0x3050, "    at index : ", 0x1A00 + pdoNum);
-	MSG_WAR(0x3051, "    sub-index : ", prp_j + 1);
-	status = state9;
-    
-    case state9:	/* get data to transmit */ 
-	{
-	  UNS8 ByteSize;
-	  UNS8 tmp[]= {0,0,0,0,0,0,0,0};
-	  index = (UNS16)((*pMappingParameter) >> 16);
-          subIndex = (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF);
-	  Size = (UNS8)(*pMappingParameter); /* Size in bits */
-	  ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 => 2, ... */
-	  objDict = getODentry(d, index, subIndex, tmp, &ByteSize, &dataType, 0 );
-	  /* copy bit per bit in little endian*/
-	  CopyBits(Size, ((UNS8*)tmp), 0 , 0, (UNS8*)&d->process_var.data[offset>>3], offset%8, 0);
-	}   
-        if( objDict != OD_SUCCESSFUL ){
-          MSG_ERR(0x1013, " Couldn't find mapped variable at index-subindex-size : ", (UNS16)(*pMappingParameter));
-          return 0xFF;
-        }
-	
-	offset += Size ;
-	d->process_var.count = 1 + ((offset - 1) >> 3);
-	prp_j++;
-	status = state10;	 
-	break;					
-      
-    case state10:	/* loop to get all the data to transmit */
-      if( prp_j < *pMappingCount ){
-	MSG_WAR(0x3014, "  next variable mapped : ", prp_j);
-	status = state8;
-	break;
-      }
-      else {
-	MSG_WAR(0x3015, "  End scan mapped variable", 0);
-	PDOmGR( d, *pwCobId );	
-	MSG_WAR(0x3016, "  End of this pdo. Should have been sent", 0);
-	pdoNum++;
-	offsetObjdict++;
-	offsetObjdictMap++;
-	offset = 0x00;
-	prp_j = 0x00;
-	status = state11;
-	break;
-      }
-      
-    case state11:     
-      MSG_WAR(0x3017, "next pdo index : ", pdoNum);
-      status = state3;
-      break;
-      
-    default:
-      MSG_ERR(0x1019,"Unknown state has been reached : %d",status);
-      return 0xFF;
-    }/* end switch case */
-    
-  }/* end while( prp_i<dict_cstes.max_count_of_PDO_transmit ) */
-   
-  (*d->post_TPDO)();
-
-  return 0;
+  return res;
+  
 }