author | etisserant |
Wed, 04 Jun 2008 10:59:55 +0200 | |
changeset 472 | 4f5cb68098cf |
parent 453 | c74a73474cce |
child 479 | 92891f53630b |
permissions | -rw-r--r-- |
0 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
73 | 3 |
|
4 |
#This file is part of CanFestival, a library implementing CanOpen Stack. |
|
5 |
# |
|
6 |
#Copyright (C): Edouard TISSERANT and Francis DUPIN |
|
7 |
# |
|
8 |
#See COPYING file for copyrights details. |
|
9 |
# |
|
10 |
#This library is free software; you can redistribute it and/or |
|
11 |
#modify it under the terms of the GNU Lesser General Public |
|
12 |
#License as published by the Free Software Foundation; either |
|
13 |
#version 2.1 of the License, or (at your option) any later version. |
|
14 |
# |
|
15 |
#This library is distributed in the hope that it will be useful, |
|
16 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 |
#Lesser General Public License for more details. |
|
19 |
# |
|
20 |
#You should have received a copy of the GNU Lesser General Public |
|
21 |
#License along with this library; if not, write to the Free Software |
|
22 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
0 | 23 |
|
24 |
from node import * |
|
25 |
from types import * |
|
26 |
||
27 |
import re, os |
|
28 |
||
29 |
word_model = re.compile('([a-zA-Z_0-9]*)') |
|
30 |
type_model = re.compile('([\_A-Z]*)([0-9]*)') |
|
31 |
range_model = re.compile('([\_A-Z]*)([0-9]*)\[([\-0-9]*)-([\-0-9]*)\]') |
|
32 |
||
33 |
categories = [("SDO_SVR", 0x1200, 0x127F), ("SDO_CLT", 0x1280, 0x12FF), |
|
34 |
("PDO_RCV", 0x1400, 0x15FF), ("PDO_RCV_MAP", 0x1600, 0x17FF), |
|
35 |
("PDO_TRS", 0x1800, 0x19FF), ("PDO_TRS_MAP", 0x1A00, 0x1BFF)] |
|
36 |
index_categories = ["firstIndex", "lastIndex"] |
|
37 |
||
38 |
generated_tag = """\n/* File generated by gen_cfile.py. Should not be modified. */\n""" |
|
39 |
||
188 | 40 |
internal_types = {} |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
41 |
default_string_size = 10 |
188 | 42 |
|
0 | 43 |
# Format a string for making a C++ variable |
44 |
def FormatName(name): |
|
45 |
wordlist = [word for word in word_model.findall(name) if word != ''] |
|
227 | 46 |
return "_".join(wordlist) |
0 | 47 |
|
48 |
# Extract the informations from a given type name |
|
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
49 |
def GetValidTypeInfos(typename, items=[]): |
188 | 50 |
if typename in internal_types: |
51 |
return internal_types[typename] |
|
52 |
else: |
|
53 |
result = type_model.match(typename) |
|
54 |
if result: |
|
55 |
values = result.groups() |
|
56 |
if values[0] == "UNSIGNED" and int(values[1]) in [i * 8 for i in xrange(1, 9)]: |
|
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
57 |
typeinfos = ("UNS%s"%values[1], None, "uint%s"%values[1], True) |
188 | 58 |
elif values[0] == "INTEGER" and int(values[1]) in [i * 8 for i in xrange(1, 9)]: |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
59 |
typeinfos = ("INTEGER%s"%values[1], None, "int%s"%values[1], False) |
188 | 60 |
elif values[0] == "REAL" and int(values[1]) in (32, 64): |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
61 |
typeinfos = ("%s%s"%(values[0], values[1]), None, "real%s"%values[1], False) |
188 | 62 |
elif values[0] == "VISIBLE_STRING": |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
63 |
size = default_string_size |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
64 |
for item in items: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
65 |
size = max(size, len(item)) |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
66 |
if values[1] != "": |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
67 |
size = max(size, int(values[1])) |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
68 |
typeinfos = ("UNS8", size, "visible_string", False) |
188 | 69 |
elif values[0] == "DOMAIN": |
420 | 70 |
size = 0 |
71 |
for item in items: |
|
72 |
size = max(size, len(item)) |
|
73 |
typeinfos = ("UNS8*", size, "domain", False) |
|
188 | 74 |
elif values[0] == "BOOLEAN": |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
75 |
typeinfos = ("UNS8", None, "boolean", False) |
188 | 76 |
else: |
77 |
raise ValueError, """!!! %s isn't a valid type for CanFestival."""%typename |
|
78 |
internal_types[typename] = typeinfos |
|
79 |
else: |
|
80 |
raise ValueError, """!!! %s isn't a valid type for CanFestival."""%typename |
|
81 |
return typeinfos |
|
0 | 82 |
|
453 | 83 |
def ComputeValue(type, value): |
84 |
if type == "visible_string": |
|
85 |
return "\"%s\""%value, "" |
|
86 |
elif type == "domain": |
|
87 |
return "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value]), "" |
|
88 |
elif type.startswith("real"): |
|
89 |
return "%f"%value, "" |
|
90 |
else: |
|
91 |
return "0x%X"%value, "\t/* %s */"%str(value) |
|
92 |
||
0 | 93 |
def WriteFile(filepath, content): |
94 |
cfile = open(filepath,"w") |
|
95 |
cfile.write(content) |
|
96 |
cfile.close() |
|
97 |
||
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
98 |
def GenerateFileContent(Node, headerfilepath): |
0 | 99 |
global type |
188 | 100 |
global internal_types |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
101 |
global default_string_size |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
102 |
|
0 | 103 |
texts = {} |
104 |
texts["maxPDOtransmit"] = 0 |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
105 |
texts["NodeName"] = Node.GetNodeName() |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
106 |
texts["NodeID"] = Node.GetNodeID() |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
107 |
texts["NodeType"] = Node.GetNodeType() |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
108 |
texts["Description"] = Node.GetNodeDescription() |
0 | 109 |
texts["iam_a_slave"] = 0 |
110 |
if (texts["NodeType"] == "slave"): |
|
111 |
texts["iam_a_slave"] = 1 |
|
112 |
||
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
113 |
default_string_size = Node.GetDefaultStringSize() |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
114 |
|
0 | 115 |
# Compiling lists of indexes |
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
116 |
rangelist = [idx for idx in Node.GetIndexes() if 0 <= idx <= 0x260] |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
117 |
listIndex = [idx for idx in Node.GetIndexes() if 0x1000 <= idx <= 0xFFFF] |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
118 |
communicationlist = [idx for idx in Node.GetIndexes() if 0x1000 <= idx <= 0x11FF] |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
119 |
sdolist = [idx for idx in Node.GetIndexes() if 0x1200 <= idx <= 0x12FF] |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
120 |
pdolist = [idx for idx in Node.GetIndexes() if 0x1400 <= idx <= 0x1BFF] |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
121 |
variablelist = [idx for idx in Node.GetIndexes() if 0x2000 <= idx <= 0xBFFF] |
0 | 122 |
|
123 |
#------------------------------------------------------------------------------- |
|
124 |
# Declaration of the value range types |
|
125 |
#------------------------------------------------------------------------------- |
|
126 |
||
127 |
valueRangeContent = "" |
|
286
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
128 |
strDefine = "\n#define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */" |
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
129 |
strSwitch = """ case valueRange_EMC: |
288 | 130 |
if (*(UNS8*)value != (UNS8)0) return OD_VALUE_RANGE_EXCEEDED; |
286
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
131 |
break;\n""" |
313 | 132 |
internal_types["valueRange_EMC"] = ("UNS8", "", "valueRange_EMC", True) |
0 | 133 |
num = 0 |
134 |
for index in rangelist: |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
135 |
rangename = Node.GetEntryName(index) |
0 | 136 |
result = range_model.match(rangename) |
137 |
if result: |
|
138 |
num += 1 |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
139 |
typeindex = Node.GetEntry(index, 1) |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
140 |
typename = Node.GetTypeName(typeindex) |
0 | 141 |
typeinfos = GetValidTypeInfos(typename) |
188 | 142 |
internal_types[rangename] = (typeinfos[0], typeinfos[1], "valueRange_%d"%num) |
289
a22ce0314063
Removed warning with lower boundary <= 0 in Valuerange test wuth unsigned types
etisserant
parents:
288
diff
changeset
|
143 |
minvalue = Node.GetEntry(index, 2) |
a22ce0314063
Removed warning with lower boundary <= 0 in Valuerange test wuth unsigned types
etisserant
parents:
288
diff
changeset
|
144 |
maxvalue = Node.GetEntry(index, 3) |
a22ce0314063
Removed warning with lower boundary <= 0 in Valuerange test wuth unsigned types
etisserant
parents:
288
diff
changeset
|
145 |
strDefine += "\n#define valueRange_%d 0x%02X /* Type %s, %s < value < %s */"%(num,index,typeinfos[0],str(minvalue),str(maxvalue)) |
a22ce0314063
Removed warning with lower boundary <= 0 in Valuerange test wuth unsigned types
etisserant
parents:
288
diff
changeset
|
146 |
strSwitch += " case valueRange_%d:\n"%(num) |
313 | 147 |
if typeinfos[3] and minvalue <= 0: |
289
a22ce0314063
Removed warning with lower boundary <= 0 in Valuerange test wuth unsigned types
etisserant
parents:
288
diff
changeset
|
148 |
strSwitch += " /* Negative or null low limit ignored because of unsigned type */;\n" |
a22ce0314063
Removed warning with lower boundary <= 0 in Valuerange test wuth unsigned types
etisserant
parents:
288
diff
changeset
|
149 |
else: |
a22ce0314063
Removed warning with lower boundary <= 0 in Valuerange test wuth unsigned types
etisserant
parents:
288
diff
changeset
|
150 |
strSwitch += " if (*(%s*)value < (%s)%s) return OD_VALUE_TOO_LOW;\n"%(typeinfos[0],typeinfos[0],str(minvalue)) |
a22ce0314063
Removed warning with lower boundary <= 0 in Valuerange test wuth unsigned types
etisserant
parents:
288
diff
changeset
|
151 |
strSwitch += " if (*(%s*)value > (%s)%s) return OD_VALUE_TOO_HIGH;\n"%(typeinfos[0],typeinfos[0],str(maxvalue)) |
a22ce0314063
Removed warning with lower boundary <= 0 in Valuerange test wuth unsigned types
etisserant
parents:
288
diff
changeset
|
152 |
strSwitch += " break;\n" |
0 | 153 |
|
154 |
valueRangeContent += strDefine |
|
155 |
valueRangeContent += "\nUNS32 %(NodeName)s_valueRangeTest (UNS8 typeValue, void * value)\n{"%texts |
|
156 |
valueRangeContent += "\n switch (typeValue) {\n" |
|
157 |
valueRangeContent += strSwitch |
|
158 |
valueRangeContent += " }\n return 0;\n}\n" |
|
159 |
||
160 |
#------------------------------------------------------------------------------- |
|
161 |
# Creation of the mapped variables and object dictionary |
|
162 |
#------------------------------------------------------------------------------- |
|
163 |
||
164 |
mappedVariableContent = "" |
|
165 |
strDeclareHeader = "" |
|
166 |
strDeclareCallback = "" |
|
167 |
indexContents = {} |
|
168 |
indexCallbacks = {} |
|
169 |
for index in listIndex: |
|
170 |
texts["index"] = index |
|
171 |
strIndex = "" |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
172 |
entry_infos = Node.GetEntryInfos(index) |
229 | 173 |
texts["EntryName"] = entry_infos["name"].encode('ascii','replace') |
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
174 |
values = Node.GetEntry(index) |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
175 |
callbacks = Node.HasEntryCallbacks(index) |
0 | 176 |
if index in variablelist: |
177 |
strIndex += "\n/* index 0x%(index)04X : Mapped variable %(EntryName)s */\n"%texts |
|
178 |
else: |
|
179 |
strIndex += "\n/* index 0x%(index)04X : %(EntryName)s. */\n"%texts |
|
180 |
||
181 |
# Entry type is VAR |
|
182 |
if type(values) != ListType: |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
183 |
subentry_infos = Node.GetSubentryInfos(index, 0) |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
184 |
typename = Node.GetTypeName(subentry_infos["type"]) |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
185 |
typeinfos = GetValidTypeInfos(typename, [values]) |
0 | 186 |
texts["subIndexType"] = typeinfos[0] |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
187 |
if typeinfos[1] is not None: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
188 |
texts["suffixe"] = "[%d]"%typeinfos[1] |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
189 |
else: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
190 |
texts["suffixe"] = "" |
453 | 191 |
texts["value"], texts["comment"] = ComputeValue(typeinfos[2], values) |
0 | 192 |
if index in variablelist: |
193 |
texts["name"] = FormatName(subentry_infos["name"]) |
|
76 | 194 |
strDeclareHeader += "extern %(subIndexType)s %(name)s%(suffixe)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x00*/\n"%texts |
195 |
mappedVariableContent += "%(subIndexType)s %(name)s%(suffixe)s = %(value)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x00 */\n"%texts |
|
0 | 196 |
else: |
5
e4365e7d47f0
Bug on number in hexa computed by gen_cfile corrected
lbessard
parents:
0
diff
changeset
|
197 |
strIndex += " %(subIndexType)s %(NodeName)s_obj%(index)04X%(suffixe)s = %(value)s;%(comment)s\n"%texts |
0 | 198 |
values = [values] |
199 |
else: |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
200 |
subentry_infos = Node.GetSubentryInfos(index, 0) |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
201 |
typename = Node.GetTypeName(subentry_infos["type"]) |
188 | 202 |
typeinfos = GetValidTypeInfos(typename) |
286
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
203 |
if index == 0x1003: |
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
204 |
texts["value"] = 0 |
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
205 |
else: |
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
206 |
texts["value"] = values[0] |
188 | 207 |
texts["subIndexType"] = typeinfos[0] |
208 |
strIndex += " %(subIndexType)s %(NodeName)s_highestSubIndex_obj%(index)04X = %(value)d; /* number of subindex - 1*/\n"%texts |
|
0 | 209 |
|
210 |
# Entry type is RECORD |
|
211 |
if entry_infos["struct"] & OD_IdenticalSubindexes: |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
212 |
subentry_infos = Node.GetSubentryInfos(index, 1) |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
213 |
typename = Node.GetTypeName(subentry_infos["type"]) |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
214 |
typeinfos = GetValidTypeInfos(typename, values[1:]) |
0 | 215 |
texts["subIndexType"] = typeinfos[0] |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
216 |
if typeinfos[1] is not None: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
217 |
texts["suffixe"] = "[%d]"%typeinfos[1] |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
218 |
else: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
219 |
texts["suffixe"] = "" |
0 | 220 |
texts["length"] = values[0] |
221 |
if index in variablelist: |
|
222 |
texts["name"] = FormatName(entry_infos["name"]) |
|
76 | 223 |
strDeclareHeader += "extern %(subIndexType)s %(name)s[%(length)d]%(suffixe)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x01 - 0x%(length)02X */\n"%texts |
224 |
mappedVariableContent += "%(subIndexType)s %(name)s[] =\t\t/* Mapped at index 0x%(index)04X, subindex 0x01 - 0x%(length)02X */\n {\n"%texts |
|
0 | 225 |
for subIndex, value in enumerate(values): |
226 |
sep = "," |
|
227 |
if subIndex > 0: |
|
228 |
if subIndex == len(values)-1: |
|
229 |
sep = "" |
|
453 | 230 |
value, comment = ComputeValue(typeinfos[2], value) |
5
e4365e7d47f0
Bug on number in hexa computed by gen_cfile corrected
lbessard
parents:
0
diff
changeset
|
231 |
mappedVariableContent += " %s%s%s\n"%(value, sep, comment) |
28 | 232 |
mappedVariableContent += " };\n" |
0 | 233 |
else: |
234 |
strIndex += " %(subIndexType)s %(NodeName)s_obj%(index)04X[] = \n {\n"%texts |
|
235 |
for subIndex, value in enumerate(values): |
|
236 |
sep = "," |
|
237 |
if subIndex > 0: |
|
238 |
if subIndex == len(values)-1: |
|
239 |
sep = "" |
|
453 | 240 |
value, comment = ComputeValue(typeinfos[2], value) |
5
e4365e7d47f0
Bug on number in hexa computed by gen_cfile corrected
lbessard
parents:
0
diff
changeset
|
241 |
strIndex += " %s%s%s\n"%(value, sep, comment) |
0 | 242 |
strIndex += " };\n" |
243 |
else: |
|
244 |
||
66
94212a58c097
gen_cfile.py modified for avoiding possible conflict in mapped variable names
lbessard
parents:
64
diff
changeset
|
245 |
texts["parent"] = FormatName(entry_infos["name"]) |
0 | 246 |
# Entry type is ARRAY |
247 |
for subIndex, value in enumerate(values): |
|
248 |
texts["subIndex"] = subIndex |
|
249 |
if subIndex > 0: |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
250 |
subentry_infos = Node.GetSubentryInfos(index, subIndex) |
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
251 |
typename = Node.GetTypeName(subentry_infos["type"]) |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
252 |
typeinfos = GetValidTypeInfos(typename, [values[subIndex]]) |
0 | 253 |
texts["subIndexType"] = typeinfos[0] |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
254 |
if typeinfos[1] is not None: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
255 |
texts["suffixe"] = "[%d]"%typeinfos[1] |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
256 |
else: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
257 |
texts["suffixe"] = "" |
453 | 258 |
texts["value"], texts["comment"] = ComputeValue(typeinfos[2], value) |
0 | 259 |
texts["name"] = FormatName(subentry_infos["name"]) |
260 |
if index in variablelist: |
|
76 | 261 |
strDeclareHeader += "extern %(subIndexType)s %(parent)s_%(name)s%(suffixe)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x%(subIndex)02X */\n"%texts |
262 |
mappedVariableContent += "%(subIndexType)s %(parent)s_%(name)s%(suffixe)s = %(value)s;\t\t/* Mapped at index 0x%(index)04X, subindex 0x%(subIndex)02X */\n"%texts |
|
0 | 263 |
else: |
5
e4365e7d47f0
Bug on number in hexa computed by gen_cfile corrected
lbessard
parents:
0
diff
changeset
|
264 |
strIndex += " %(subIndexType)s %(NodeName)s_obj%(index)04X_%(name)s%(suffixe)s = %(value)s;%(comment)s\n"%texts |
0 | 265 |
|
266 |
# Generating Dictionary C++ entry |
|
267 |
if callbacks: |
|
268 |
if index in variablelist: |
|
269 |
name = FormatName(entry_infos["name"]) |
|
270 |
else: |
|
271 |
name = "%(NodeName)s_Index%(index)04X"%texts |
|
272 |
strIndex += " ODCallback_t %s_callbacks[] = \n {\n"%name |
|
273 |
for subIndex in xrange(len(values)): |
|
274 |
strIndex += " NULL,\n" |
|
275 |
strIndex += " };\n" |
|
276 |
indexCallbacks[index] = "*callbacks = %s_callbacks; "%name |
|
277 |
else: |
|
278 |
indexCallbacks[index] = "" |
|
279 |
strIndex += " subindex %(NodeName)s_Index%(index)04X[] = \n {\n"%texts |
|
280 |
for subIndex in xrange(len(values)): |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
281 |
subentry_infos = Node.GetSubentryInfos(index, subIndex) |
0 | 282 |
if subIndex < len(values) - 1: |
283 |
sep = "," |
|
284 |
else: |
|
285 |
sep = "" |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
286 |
typename = Node.GetTypeName(subentry_infos["type"]) |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
287 |
if entry_infos["struct"] & OD_IdenticalSubindexes: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
288 |
typeinfos = GetValidTypeInfos(typename, values) |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
289 |
else: |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
366
diff
changeset
|
290 |
typeinfos = GetValidTypeInfos(typename, [values[subIndex]]) |
0 | 291 |
if subIndex == 0: |
286
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
292 |
if index == 0x1003: |
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
293 |
typeinfos = GetValidTypeInfos("valueRange_EMC") |
0 | 294 |
if entry_infos["struct"] & OD_MultipleSubindexes: |
295 |
name = "%(NodeName)s_highestSubIndex_obj%(index)04X"%texts |
|
296 |
elif index in variablelist: |
|
297 |
name = FormatName(subentry_infos["name"]) |
|
298 |
else: |
|
299 |
name = FormatName("%s_obj%04X"%(texts["NodeName"], texts["index"])) |
|
300 |
elif entry_infos["struct"] & OD_IdenticalSubindexes: |
|
301 |
if index in variablelist: |
|
302 |
name = "%s[%d]"%(FormatName(entry_infos["name"]), subIndex - 1) |
|
303 |
else: |
|
304 |
name = "%s_obj%04X[%d]"%(texts["NodeName"], texts["index"], subIndex - 1) |
|
305 |
else: |
|
306 |
if index in variablelist: |
|
70 | 307 |
name = FormatName("%s_%s"%(entry_infos["name"],subentry_infos["name"])) |
0 | 308 |
else: |
309 |
name = "%s_obj%04X_%s"%(texts["NodeName"], texts["index"], FormatName(subentry_infos["name"])) |
|
421
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
420
diff
changeset
|
310 |
if typeinfos[2] == "visible_string": |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
420
diff
changeset
|
311 |
sizeof = str(max(len(values[subIndex]), default_string_size)) |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
420
diff
changeset
|
312 |
elif typeinfos[2] == "domain": |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
420
diff
changeset
|
313 |
sizeof = str(len(values[subIndex])) |
176 | 314 |
else: |
315 |
sizeof = "sizeof (%s)"%typeinfos[0] |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
316 |
params = Node.GetParamsEntry(index, subIndex) |
0 | 317 |
if params["save"]: |
318 |
save = "|TO_BE_SAVE" |
|
319 |
else: |
|
320 |
save = "" |
|
188 | 321 |
strIndex += " { %s%s, %s, %s, (void*)&%s }%s\n"%(subentry_infos["access"].upper(),save,typeinfos[2],sizeof,name,sep) |
0 | 322 |
strIndex += " };\n" |
323 |
indexContents[index] = strIndex |
|
324 |
||
325 |
#------------------------------------------------------------------------------- |
|
326 |
# Declaration of Particular Parameters |
|
327 |
#------------------------------------------------------------------------------- |
|
328 |
||
284 | 329 |
if 0x1003 not in communicationlist: |
330 |
entry_infos = Node.GetEntryInfos(0x1003) |
|
331 |
texts["EntryName"] = entry_infos["name"] |
|
332 |
indexContents[0x1003] = """\n/* index 0x1003 : %(EntryName)s */ |
|
333 |
UNS8 %(NodeName)s_highestSubIndex_obj1003 = 0; /* number of subindex - 1*/ |
|
334 |
UNS32 %(NodeName)s_obj1003[] = |
|
335 |
{ |
|
336 |
0x0 /* 0 */ |
|
337 |
}; |
|
338 |
ODCallback_t %(NodeName)s_Index1003_callbacks[] = |
|
339 |
{ |
|
340 |
NULL, |
|
341 |
NULL, |
|
342 |
}; |
|
343 |
subindex %(NodeName)s_Index1003[] = |
|
344 |
{ |
|
286
85d5361179f3
Adding support for restricting user to only dynamically set 0 to index 0x1003 subindex 0x00 in gen_cfile.py
lbessard
parents:
284
diff
changeset
|
345 |
{ RW, valueRange_EMC, sizeof (UNS8), (void*)&%(NodeName)s_highestSubIndex_obj1003 }, |
284 | 346 |
{ RO, uint32, sizeof (UNS32), (void*)&%(NodeName)s_obj1003[0] } |
347 |
}; |
|
348 |
"""%texts |
|
349 |
||
261
dbcd80bcab82
Prevent potential problem with missing 0x1005 OD entry
etisserant
parents:
245
diff
changeset
|
350 |
if 0x1005 not in communicationlist: |
dbcd80bcab82
Prevent potential problem with missing 0x1005 OD entry
etisserant
parents:
245
diff
changeset
|
351 |
entry_infos = Node.GetEntryInfos(0x1005) |
dbcd80bcab82
Prevent potential problem with missing 0x1005 OD entry
etisserant
parents:
245
diff
changeset
|
352 |
texts["EntryName"] = entry_infos["name"] |
dbcd80bcab82
Prevent potential problem with missing 0x1005 OD entry
etisserant
parents:
245
diff
changeset
|
353 |
indexContents[0x1005] = """\n/* index 0x1005 : %(EntryName)s */ |
dbcd80bcab82
Prevent potential problem with missing 0x1005 OD entry
etisserant
parents:
245
diff
changeset
|
354 |
UNS32 %(NodeName)s_obj1005 = 0x0; /* 0 */ |
dbcd80bcab82
Prevent potential problem with missing 0x1005 OD entry
etisserant
parents:
245
diff
changeset
|
355 |
"""%texts |
dbcd80bcab82
Prevent potential problem with missing 0x1005 OD entry
etisserant
parents:
245
diff
changeset
|
356 |
|
0 | 357 |
if 0x1006 not in communicationlist: |
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
358 |
entry_infos = Node.GetEntryInfos(0x1006) |
0 | 359 |
texts["EntryName"] = entry_infos["name"] |
360 |
indexContents[0x1006] = """\n/* index 0x1006 : %(EntryName)s */ |
|
76 | 361 |
UNS32 %(NodeName)s_obj1006 = 0x0; /* 0 */ |
0 | 362 |
"""%texts |
363 |
||
314
68e83c3ffbb5
Better EMCY support. Now EMCY COB-ID depend on OD 1014h entry, as told in DS-301.
etisserant
parents:
313
diff
changeset
|
364 |
if 0x1014 not in communicationlist: |
68e83c3ffbb5
Better EMCY support. Now EMCY COB-ID depend on OD 1014h entry, as told in DS-301.
etisserant
parents:
313
diff
changeset
|
365 |
entry_infos = Node.GetEntryInfos(0x1014) |
68e83c3ffbb5
Better EMCY support. Now EMCY COB-ID depend on OD 1014h entry, as told in DS-301.
etisserant
parents:
313
diff
changeset
|
366 |
texts["EntryName"] = entry_infos["name"] |
68e83c3ffbb5
Better EMCY support. Now EMCY COB-ID depend on OD 1014h entry, as told in DS-301.
etisserant
parents:
313
diff
changeset
|
367 |
indexContents[0x1014] = """\n/* index 0x1014 : %(EntryName)s */ |
68e83c3ffbb5
Better EMCY support. Now EMCY COB-ID depend on OD 1014h entry, as told in DS-301.
etisserant
parents:
313
diff
changeset
|
368 |
UNS32 %(NodeName)s_obj1014 = 0x0; /* 0 */ |
68e83c3ffbb5
Better EMCY support. Now EMCY COB-ID depend on OD 1014h entry, as told in DS-301.
etisserant
parents:
313
diff
changeset
|
369 |
"""%texts |
68e83c3ffbb5
Better EMCY support. Now EMCY COB-ID depend on OD 1014h entry, as told in DS-301.
etisserant
parents:
313
diff
changeset
|
370 |
|
0 | 371 |
if 0x1016 in communicationlist: |
325 | 372 |
texts["heartBeatTimers_number"] = Node.GetEntry(0x1016, 0) |
0 | 373 |
else: |
325 | 374 |
texts["heartBeatTimers_number"] = 0 |
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
375 |
entry_infos = Node.GetEntryInfos(0x1016) |
0 | 376 |
texts["EntryName"] = entry_infos["name"] |
377 |
indexContents[0x1016] = """\n/* index 0x1016 : %(EntryName)s */ |
|
378 |
UNS8 %(NodeName)s_highestSubIndex_obj1016 = 0; |
|
91
ed2612282988
- Better array initialization in data.h CANOPEN_NODE_DATA_INITIALIZER macro. Use a little hack with configure and config.h to create the "pure Ansi C" initializer.
etisserant
parents:
76
diff
changeset
|
379 |
UNS32 %(NodeName)s_obj1016[]={0}; |
0 | 380 |
"""%texts |
325 | 381 |
|
0 | 382 |
if 0x1017 not in communicationlist: |
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
383 |
entry_infos = Node.GetEntryInfos(0x1017) |
0 | 384 |
texts["EntryName"] = entry_infos["name"] |
385 |
indexContents[0x1017] = """\n/* index 0x1017 : %(EntryName)s */ |
|
76 | 386 |
UNS16 %(NodeName)s_obj1017 = 0x0; /* 0 */ |
0 | 387 |
"""%texts |
388 |
||
389 |
#------------------------------------------------------------------------------- |
|
390 |
# Declaration of navigation in the Object Dictionary |
|
391 |
#------------------------------------------------------------------------------- |
|
392 |
||
393 |
strDeclareIndex = "" |
|
394 |
strDeclareSwitch = "" |
|
395 |
strQuickIndex = "" |
|
396 |
quick_index = {} |
|
397 |
for index_cat in index_categories: |
|
398 |
quick_index[index_cat] = {} |
|
399 |
for cat, idx_min, idx_max in categories: |
|
400 |
quick_index[index_cat][cat] = 0 |
|
401 |
maxPDOtransmit = 0 |
|
402 |
for i, index in enumerate(listIndex): |
|
403 |
texts["index"] = index |
|
404 |
strDeclareIndex += " { (subindex*)%(NodeName)s_Index%(index)04X,sizeof(%(NodeName)s_Index%(index)04X)/sizeof(%(NodeName)s_Index%(index)04X[0]), 0x%(index)04X},\n"%texts |
|
405 |
strDeclareSwitch += " case 0x%04X: i = %d;%sbreak;\n"%(index, i, indexCallbacks[index]) |
|
406 |
for cat, idx_min, idx_max in categories: |
|
407 |
if idx_min <= index <= idx_max: |
|
408 |
quick_index["lastIndex"][cat] = i |
|
409 |
if quick_index["firstIndex"][cat] == 0: |
|
410 |
quick_index["firstIndex"][cat] = i |
|
411 |
if cat == "PDO_TRS": |
|
412 |
maxPDOtransmit += 1 |
|
413 |
texts["maxPDOtransmit"] = max(1, maxPDOtransmit) |
|
414 |
for index_cat in index_categories: |
|
415 |
strQuickIndex += "\nquick_index %s_%s = {\n"%(texts["NodeName"], index_cat) |
|
416 |
sep = "," |
|
417 |
for i, (cat, idx_min, idx_max) in enumerate(categories): |
|
418 |
if i == len(categories) - 1: |
|
419 |
sep = "" |
|
76 | 420 |
strQuickIndex += " %d%s /* %s */\n"%(quick_index[index_cat][cat],sep,cat) |
0 | 421 |
strQuickIndex += "};\n" |
422 |
||
423 |
#------------------------------------------------------------------------------- |
|
424 |
# Write File Content |
|
425 |
#------------------------------------------------------------------------------- |
|
426 |
||
73 | 427 |
fileContent = generated_tag + """ |
0 | 428 |
#include "%s" |
429 |
"""%(headerfilepath) |
|
430 |
||
431 |
fileContent += """ |
|
432 |
/**************************************************************************/ |
|
433 |
/* Declaration of the mapped variables */ |
|
434 |
/**************************************************************************/ |
|
435 |
""" + mappedVariableContent |
|
436 |
||
437 |
fileContent += """ |
|
438 |
/**************************************************************************/ |
|
439 |
/* Declaration of the value range types */ |
|
440 |
/**************************************************************************/ |
|
441 |
""" + valueRangeContent |
|
442 |
||
443 |
fileContent += """ |
|
444 |
/**************************************************************************/ |
|
445 |
/* The node id */ |
|
446 |
/**************************************************************************/ |
|
447 |
/* node_id default value.*/ |
|
448 |
UNS8 %(NodeName)s_bDeviceNodeId = 0x%(NodeID)02X; |
|
449 |
||
76 | 450 |
/**************************************************************************/ |
0 | 451 |
/* Array of message processing information */ |
452 |
||
453 |
const UNS8 %(NodeName)s_iam_a_slave = %(iam_a_slave)d; |
|
454 |
||
455 |
"""%texts |
|
325 | 456 |
if texts["heartBeatTimers_number"] > 0: |
422
43a4d6deb007
Fixed herbeat timer array partial initialization in generated OD code.
etisserant
parents:
421
diff
changeset
|
457 |
declaration = "TIMER_HANDLE %(NodeName)s_heartBeatTimers[%(heartBeatTimers_number)d]"%texts |
43a4d6deb007
Fixed herbeat timer array partial initialization in generated OD code.
etisserant
parents:
421
diff
changeset
|
458 |
initializer = "{TIMER_NONE" + ",TIMER_NONE" * (texts["heartBeatTimers_number"] - 1) + "}" |
43a4d6deb007
Fixed herbeat timer array partial initialization in generated OD code.
etisserant
parents:
421
diff
changeset
|
459 |
fileContent += declaration + " = " + initializer + ";\n" |
325 | 460 |
else: |
461 |
fileContent += "TIMER_HANDLE %(NodeName)s_heartBeatTimers[1];\n"%texts |
|
0 | 462 |
|
463 |
fileContent += """ |
|
76 | 464 |
/* |
465 |
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ |
|
466 |
||
467 |
OBJECT DICTIONARY |
|
468 |
||
469 |
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ |
|
470 |
*/ |
|
0 | 471 |
"""%texts |
472 |
contentlist = indexContents.keys() |
|
473 |
contentlist.sort() |
|
474 |
for index in contentlist: |
|
475 |
fileContent += indexContents[index] |
|
476 |
||
477 |
fileContent += """ |
|
478 |
const indextable %(NodeName)s_objdict[] = |
|
479 |
{ |
|
480 |
"""%texts |
|
481 |
fileContent += strDeclareIndex |
|
482 |
fileContent += """}; |
|
483 |
||
484 |
const indextable * %(NodeName)s_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks) |
|
485 |
{ |
|
486 |
int i; |
|
487 |
*callbacks = NULL; |
|
488 |
switch(wIndex){ |
|
489 |
"""%texts |
|
490 |
fileContent += strDeclareSwitch |
|
491 |
fileContent += """ default: |
|
492 |
*errorCode = OD_NO_SUCH_OBJECT; |
|
493 |
return NULL; |
|
494 |
} |
|
495 |
*errorCode = OD_SUCCESSFUL; |
|
496 |
return &%(NodeName)s_objdict[i]; |
|
497 |
} |
|
498 |
||
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
229
diff
changeset
|
499 |
/* |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
229
diff
changeset
|
500 |
* To count at which received SYNC a PDO must be sent. |
76 | 501 |
* Even if no pdoTransmit are defined, at least one entry is computed |
502 |
* for compilations issues. |
|
503 |
*/ |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
229
diff
changeset
|
504 |
s_PDO_status %(NodeName)s_PDO_status[%(maxPDOtransmit)d] = {"""%texts |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
229
diff
changeset
|
505 |
|
366 | 506 |
fileContent += ",".join(["s_PDO_status_Initializer"]*texts["maxPDOtransmit"]) + """}; |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
229
diff
changeset
|
507 |
""" |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
229
diff
changeset
|
508 |
|
0 | 509 |
fileContent += strQuickIndex |
510 |
fileContent += """ |
|
511 |
UNS16 %(NodeName)s_ObjdictSize = sizeof(%(NodeName)s_objdict)/sizeof(%(NodeName)s_objdict[0]); |
|
512 |
||
513 |
CO_Data %(NodeName)s_Data = CANOPEN_NODE_DATA_INITIALIZER(%(NodeName)s); |
|
514 |
||
515 |
"""%texts |
|
516 |
||
517 |
#------------------------------------------------------------------------------- |
|
518 |
# Write Header File Content |
|
519 |
#------------------------------------------------------------------------------- |
|
520 |
||
223 | 521 |
texts["file_include_name"] = headerfilepath.replace(".", "_").upper() |
73 | 522 |
HeaderFileContent = generated_tag + """ |
224 | 523 |
#ifndef %(file_include_name)s |
223 | 524 |
#define %(file_include_name)s |
525 |
||
0 | 526 |
#include "data.h" |
527 |
||
76 | 528 |
/* Prototypes of function provided by object dictionnary */ |
63
2be18e405e40
Bug on map variable type changing and on comments with special characters corrected
lbessard
parents:
60
diff
changeset
|
529 |
UNS32 %(NodeName)s_valueRangeTest (UNS8 typeValue, void * value); |
2be18e405e40
Bug on map variable type changing and on comments with special characters corrected
lbessard
parents:
60
diff
changeset
|
530 |
const indextable * %(NodeName)s_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks); |
2be18e405e40
Bug on map variable type changing and on comments with special characters corrected
lbessard
parents:
60
diff
changeset
|
531 |
|
76 | 532 |
/* Master node data struct */ |
0 | 533 |
extern CO_Data %(NodeName)s_Data; |
534 |
"""%texts |
|
535 |
HeaderFileContent += strDeclareHeader |
|
536 |
||
223 | 537 |
HeaderFileContent += "\n#endif // %(file_include_name)s\n"%texts |
538 |
||
0 | 539 |
return fileContent,HeaderFileContent |
540 |
||
541 |
#------------------------------------------------------------------------------- |
|
542 |
# Main Function |
|
543 |
#------------------------------------------------------------------------------- |
|
544 |
||
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
545 |
def GenerateFile(filepath, node): |
188 | 546 |
try: |
547 |
headerfilepath = os.path.splitext(filepath)[0]+".h" |
|
245
d43ebbed895f
Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents:
235
diff
changeset
|
548 |
content, header = GenerateFileContent(node, os.path.split(headerfilepath)[1]) |
188 | 549 |
WriteFile(filepath, content) |
550 |
WriteFile(headerfilepath, header) |
|
551 |
return None |
|
552 |
except ValueError, message: |
|
553 |
return "Unable to Generate C File\n%s"%message |
|
554 |