Fixed generated CF code to match latest changes
authorEdouard Tisserant
Mon, 18 Jun 2012 02:35:21 +0200
changeset 776 c81397b665b6
parent 775 172be32a2482
child 777 daa6941fe21a
Fixed generated CF code to match latest changes
canfestival/canfestival.py
canfestival/cf_runtime.c
--- a/canfestival/canfestival.py	Sun Jun 17 12:33:22 2012 +0200
+++ b/canfestival/canfestival.py	Mon Jun 18 02:35:21 2012 +0200
@@ -415,28 +415,13 @@
                     format_dict["slavebootups"] += (
                         "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){}\n"%(nodename))
                 else:
-                    for id in SlaveIDs:
-                        format_dict["slavebootups"] += (
-                        "int %s_slave_%d_booted = 0;\n"%(nodename, id))
+                    # for id in SlaveIDs:
+                    #     format_dict["slavebootups"] += (
+                    #     "int %s_slave_%d_booted = 0;\n"%(nodename, id))
                     # define post_SlaveBootup lookup functions
                     format_dict["slavebootups"] += (
                         "static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){\n"%(nodename)+
-                        "    switch(nodeId){\n")
-                    # one case per declared node, mark node as booted
-                    for id in SlaveIDs:
-                        format_dict["slavebootups"] += (
-                        "        case %d:\n"%(id)+
-                        "            %s_slave_%d_booted = 1;\n"%(nodename, id)+
-                        "            break;\n")
-                    format_dict["slavebootups"] += (
-                        "        default:\n"+
-                        "            break;\n"+
-                        "    }\n"+
-                        "    if( ")
-                    # expression to test if all declared nodes booted
-                    format_dict["slavebootups"] += " && ".join(["%s_slave_%d_booted"%(nodename, id) for id in SlaveIDs])
-                    format_dict["slavebootups"] += " )\n" + (
-                        "        Master_post_SlaveBootup(d,nodeId);\n"+
+                        "    check_and_start_node(d, nodeId);\n"+
                         "}\n")
                 # register previously declared func as post_SlaveBootup callback for that node
                 format_dict["slavebootup_register"] += (
--- a/canfestival/cf_runtime.c	Sun Jun 17 12:33:22 2012 +0200
+++ b/canfestival/cf_runtime.c	Mon Jun 18 02:35:21 2012 +0200
@@ -1,5 +1,6 @@
 
 #include "canfestival.h"
+#include "dcf.h"
 
 /* CanFestival nodes generated OD headers*/
 %(nodes_includes)s
@@ -15,16 +16,6 @@
 /* Retrieve PLC cycle time */
 extern int common_ticktime__;
 
-/* Called once all NetworkEdit declares slaves have booted*/
-static void Master_post_SlaveBootup(CO_Data* d, UNS8 nodeId)
-{
-    /* Put the master in operational mode */
-    setState(d, Operational);
-
-    /* Ask slave node to go in operational mode */
-    masterSendNMTstateChange (d, 0, NMT_Start_Node);
-}
-
 /* Per master node slavebootup callbacks. Checks that
  * every node have booted before calling Master_post_SlaveBootup */
 %(slavebootups)s
@@ -126,7 +117,9 @@
 }
 
 #define NODE_SEND_SYNC(nodename)\
-    sendSYNCMessage(&nodename##_Data);
+    if(getState(&nodename##_Data)==Operational){\
+        sendSYNCMessage(&nodename##_Data);\
+    }
 
 void __retrieve_%(locstr)s(void)
 {