Enhancements in CanFestival plugin. Now PLC with CanFestival plugin compiles and run, exchanging CanOpen PDOs
--- a/plugins/canfestival/canfestival.py Mon Oct 01 21:52:41 2007 +0200
+++ b/plugins/canfestival/canfestival.py Tue Oct 02 18:02:32 2007 +0200
@@ -108,6 +108,7 @@
"candriver" : self.CanFestivalInstance.getCAN_Driver(),
"nodes_includes" : "",
"board_decls" : "",
+ "nodes_declare" : "",
"nodes_init" : "",
"nodes_open" : "",
"nodes_close" : "",
@@ -122,6 +123,9 @@
nodename,
child.CanFestivalNode.getCAN_Device(),
child.CanFestivalNode.getCAN_Baudrate())
+ format_dict["nodes_declare"] += 'NODE_DECLARE(%s, %s)\n '%(
+ nodename,
+ child.CanFestivalNode.getNodeId())
format_dict["nodes_init"] += 'NODE_INIT(%s, %s)\n '%(
nodename,
child.CanFestivalNode.getNodeId())
--- a/plugins/canfestival/cf_runtime.c Mon Oct 01 21:52:41 2007 +0200
+++ b/plugins/canfestival/cf_runtime.c Tue Oct 02 18:02:32 2007 +0200
@@ -11,6 +11,25 @@
static int init_level=0;
extern int common_ticktime__;
+
+static void ConfigureSlaveNode(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);
+}
+
+#define NODE_DECLARE(nodename, nodeid)\
+void nodename##_preOperational()\
+{\
+ ConfigureSlaveNode(&nodename##_Data, nodeid);\
+}\
+
+%(nodes_declare)s
+
+
#define NODE_INIT(nodename, nodeid) \
/* Artificially force sync state to 1 so that it is not started */\
nodename##_Data.CurrentCommunicationState.csSYNC = -1;\
@@ -47,6 +66,7 @@
}
#define NODE_OPEN(nodename)\
+ nodename##_Data.preOperational = nodename##_preOperational;\
if(!canOpen(&nodename##Board,&nodename##_Data)){\
printf("Cannot open " #nodename " Board (%%s,%%s)\n",nodename##Board.busname, nodename##Board.baudrate);\
return -1;\
--- a/plugins/canfestival/config_utils.py Mon Oct 01 21:52:41 2007 +0200
+++ b/plugins/canfestival/config_utils.py Tue Oct 02 18:02:32 2007 +0200
@@ -493,8 +493,8 @@
self.MasterNode.SetEntry(current_idx, 0x02, 0xFF)
# Add some subentries to PDO mapping if there is not enough
- if len(pdo_infos["mapping"]) > 2:
- self.Manager.AddSubentriesToCurrent(current_idx + 0x200, len(pdo_infos["mapping"]) - 2, self.MasterNode)
+ if len(pdo_infos["mapping"]) > 1:
+ self.Manager.AddSubentriesToCurrent(current_idx + 0x200, len(pdo_infos["mapping"]) - 1, self.MasterNode)
# Generate MasterNode's PDO mapping
for subindex, variable in enumerate(pdo_infos["mapping"]):