mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
assert over the type of the 'timestamp' field
This commit is contained in:
parent
e6bd9bdeeb
commit
7c7602873e
@ -118,14 +118,21 @@ def generate_output_from_file(format_idx, filename, outputdir, templatedir, incl
|
||||
msg_context = genmsg.msg_loader.MsgContext.create_default()
|
||||
full_type_name = genmsg.gentools.compute_full_type_name(PACKAGE, os.path.basename(filename))
|
||||
spec = genmsg.msg_loader.load_msg_from_file(msg_context, filename, full_type_name)
|
||||
field_name_list = []
|
||||
field_name_and_type = {}
|
||||
for field in spec.parsed_fields():
|
||||
field_name_list.append(field.name)
|
||||
field_name_and_type.update({field.name:field.type})
|
||||
# assert if the timestamp field exists
|
||||
try:
|
||||
assert 'timestamp' in field_name_list
|
||||
assert 'timestamp' in field_name_and_type
|
||||
except AssertionError:
|
||||
print("[ERROR] uORB topic files generator:\n\tgenerate_output_from_file:\tNo 'timestamp' field found in " + spec.short_name + " msg definition!")
|
||||
exit(1)
|
||||
# assert if the timestamp field is of type uint64
|
||||
try:
|
||||
assert field_name_and_type.get('timestamp') == 'uint64'
|
||||
except AssertionError:
|
||||
print("[ERROR] uORB topic files generator:\n\tgenerate_output_from_file:\t'timestamp' field in " + spec.short_name + " msg definition is not of type uint64 but rather of type " + field_name_and_type.get('timestamp') + "!")
|
||||
exit(1)
|
||||
topics = get_multi_topics(filename)
|
||||
if includepath:
|
||||
search_path = genmsg.command_line.includepath_to_dict(includepath)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user