--- a/plugins/canfestival/canfestival.py Mon Sep 24 17:06:36 2007 +0200
+++ b/plugins/canfestival/canfestival.py Mon Sep 24 17:07:42 2007 +0200
@@ -22,6 +22,8 @@
<xsd:element name="CanFestivalNode">
<xsd:attribute name="CAN_Device" type="xsd:string" use="required" />
+ <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="required" /> + <xsd:attribute name="NodeId" type="xsd:string" use="required" /> <xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="required" default="true"/>
@@ -81,11 +83,12 @@
Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix )
# Create a new copy of the model with DCF loaded with PDO mappings for desired location
master = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs())
+ master.SetNodeName("OD_%s"%prefix) res = gen_cfile.GenerateFile(Gen_OD_path, master)
- return [(Gen_OD_path,canfestival_config.getCFLAGS(CanFestivalPath))],""
+ return [(Gen_OD_path,canfestival_config.getCFLAGS(CanFestivalPath))],"",False XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
@@ -101,6 +104,35 @@
PlugChildsTypes = [("CanOpenNode",_NodeListPlug)]
def PlugGenerate_C(self, buildpath, locations, logger):
- return [],canfestival_config.getLDFLAGS(CanFestivalPath)
+ format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())), + "candriver" : self.CanFestivalInstance.getCAN_Driver(), + for child in self.IECSortedChilds(): + childlocstr = "_".join(map(str,child.GetCurrentLocation())) + nodename = "OD_%s" % childlocstr + format_dict["nodes_includes"] += '#include "%s.h"\n'%(nodename) + format_dict["board_decls"] += 'BOARD_DECL(%s, "%s", "%s")\n'%( + child.CanFestivalNode.getCAN_Device(), + child.CanFestivalNode.getCAN_Baudrate()) + format_dict["nodes_init"] += 'NODE_INIT(%s, %s)\n'%( + child.CanFestivalNode.getNodeId()) + format_dict["nodes_open"] += 'NODE_OPEN(%s)\n'%(nodename) + format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n'%(nodename) + filename = os.path.join(os.path.split(__file__)[0],"cf_runtime.c") + cf_main = open(filename).read() % format_dict + cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c"%format_dict) + f = open(cf_main_path,'w') + return [(cf_main_path, canfestival_config.getCFLAGS(CanFestivalPath))],canfestival_config.getLDFLAGS(CanFestivalPath), True --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/canfestival/cf_runtime.c Mon Sep 24 17:07:42 2007 +0200
@@ -0,0 +1,75 @@
+#include "canfestival.h" +#define BOARD_DECL(nodename, busname, baudrate)\ + s_BOARD nodename##Board = {busname, baudrate}; +static int init_level=0; +#define NODE_INIT(nodename, nodeid) \ + /* Defining the node Id */\ + setNodeId(&nodename##_Data, nodeid);\ + setState(&nodename##_Data, Initialisation); +void InitNodes(CO_Data* d, UNS32 id) +#define NODE_CLOSE(nodename) \ + setState(&nodename##_Data, Stopped);\ + canClose(&nodename##_Data);\ +void __cleanup_%(locstr)s() +#define NODE_OPEN(nodename)\ + if(!canOpen(&nodename##Board,&nodename##_Data)){\ + printf("Cannot open " #nodename " Board (%%s,%%s)\n",nodename##Board.busname, nodename##Board.baudrate);\ + __cleanup_%(locstr)s();\ +/*************************** INIT *****************************************/ +int __init_%(locstr)s(int argc,char **argv) +#ifndef NOT_USE_DYNAMIC_LOADING + LoadCanDriver("libcanfestival_can_%(candriver)s.so"); + StartTimerLoop(&InitNodes); +void __retrive_%(locstr)s() +void __publish_%(locstr)s() + /*TODO: Call SendPDOEvent */