Skip to content

Commit

Permalink
string conversion problem fix, there is a * in the size, e.g. 128*1, …
Browse files Browse the repository at this point in the history
…which could not be directly converted to an int (#58)
  • Loading branch information
kevindehecker authored and podhrmic committed Oct 5, 2017
1 parent caa581c commit 7ad636a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/generator/gen_messages_v1_0_c.py
Expand Up @@ -97,6 +97,9 @@ def generate_messages_h(directory, name, xml):
if name != 'stdout':
f.close()

def eval_int(expr):
import ast
return int(eval(compile(ast.parse(expr, mode='eval'), '<string>', 'eval')))
def copy_fixed_headers(directory, protocol_version):
'''copy the fixed protocol headers to the target directory'''
import shutil
Expand Down Expand Up @@ -153,7 +156,7 @@ def generate(output, xml):
else: # rely on arch capability to read or not
f.read_array_byte = '#define DL_%s_%s_length(_payload) _PPRZ_VAL_fixed_len_aligned(%d)\n' % (m.msg_name, f.field_name, int(f.array_length))
f.offset = offset
offset += int(f.length)
offset += eval_int(f.length)
f.dl_format = 'DL_FORMAT_ARRAY'
else:
f.offset = offset
Expand Down

0 comments on commit 7ad636a

Please sign in to comment.