Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To include timestamp field in the micrortps bridge messages. #8888

Merged
merged 1 commit into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions msg/templates/uorb_microcdr/msg.cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ from px_generate_uorb_topic_helper import * # this is in Tools/

uorb_struct = '%s_s'%spec.short_name
topic_name = spec.short_name

sorted_fields = sorted(spec.parsed_fields(), key=sizeof_field_type, reverse=True)
struct_size, padding_end_size = add_padding_bytes(sorted_fields, search_path)
topic_fields = ["uint64_t timestamp"]+["%s %s" % (convert_type(field.type), field.name) for field in sorted_fields]
}@

#include <px4_config.h>
Expand Down Expand Up @@ -102,9 +98,9 @@ def add_serialize_functions(fields, scope_name):
if (not field.is_header):
if (field.is_builtin):
if (not field.is_array):
print("\tserialize"+str(get_serialization_type_name(field.type))+"(input->"+scope_name+str(field.name)+", microCDRWriter);")
print(" serialize"+str(get_serialization_type_name(field.type))+"(input->"+scope_name+str(field.name)+", microCDRWriter);")
else:
print("\tserialize"+str(get_serialization_type_name(field.base_type))+"Array(input->"+scope_name+str(field.name)+", "+str(field.array_len)+", microCDRWriter);")
print(" serialize"+str(get_serialization_type_name(field.base_type))+"Array(input->"+scope_name+str(field.name)+", "+str(field.array_len)+", microCDRWriter);")
else:
name = field.name
children_fields = get_children_fields(field.base_type, search_path)
Expand All @@ -120,10 +116,10 @@ def add_deserialize_functions(fields, scope_name):
if (not field.is_header):
if (field.is_builtin):
if (not field.is_array):
print("\tdeserialize"+str(get_serialization_type_name(field.type))+"(&output->"+scope_name+str(field.name)+", microCDRReader);")
print(" deserialize"+str(get_serialization_type_name(field.type))+"(&output->"+scope_name+str(field.name)+", microCDRReader);")
else:
for i in range(field.array_len):
print("\tdeserialize"+str(get_serialization_type_name(field.base_type))+"(&output->"+scope_name+str(field.name)+ str('[%d]' %i) +", microCDRReader);")
print(" deserialize"+str(get_serialization_type_name(field.base_type))+"(&output->"+scope_name+str(field.name)+ str('[%d]' %i) +", microCDRReader);")
else:
name = field.name
children_fields = get_children_fields(field.base_type, search_path)
Expand Down Expand Up @@ -151,6 +147,7 @@ void serialize_@(topic_name)(const struct @(uorb_struct) *input, char *output, u

resetStaticMicroCDRForSerialize(microCDRWriter);

serializeUnsignedLong(input->timestamp, microCDRWriter);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be serializeUnsignedLongLong?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, is the correct one. Please, see the function prototype

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is no uint64_t type in IDL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, that's IDL. You're right then.

@add_code_to_serialize()

(*length) = microCDRWriter->m_microBuffer->m_serializedBuffer;
Expand All @@ -162,5 +159,6 @@ void deserialize_@(topic_name)(struct @(uorb_struct) *output, char *input, struc

resetStaticMicroCDRForDeserialize(microCDRReader);

deserializeUnsignedLong(&output->timestamp, microCDRReader);
@add_code_to_deserialize()
}
11 changes: 3 additions & 8 deletions msg/templates/urtps/msg.idl.template
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@
import genmsg.msgs
import gencpp
from px_generate_uorb_topic_helper import * # this is in Tools/

uorb_struct = '%s_s'%spec.short_name
topic_name = spec.short_name

sorted_fields = sorted(spec.parsed_fields(), key=sizeof_field_type, reverse=True)
struct_size, padding_end_size = add_padding_bytes(sorted_fields, search_path)
}@
@#################################################
@# Searching for serialize function per each field
Expand All @@ -61,9 +55,9 @@ def get_idl_type_name(field_type):
def add_msg_field(field):
if (not field.is_header):
if (not field.is_array):
print('\t' + str(get_idl_type_name(field.type)) + ' ' + field.name + ';')
print(" " + str(get_idl_type_name(field.type)) + ' ' + field.name + ';')
else:
print('\t' + str(get_idl_type_name(field.base_type)) + ' ' + field.name + '[' +str(field.array_len)+ '];')
print(" " + str(get_idl_type_name(field.base_type)) + ' ' + field.name + '[' +str(field.array_len)+ '];')

def add_msg_fields():
# sort fields (using a stable sort) as in the declaration of the type
Expand All @@ -76,5 +70,6 @@ def add_msg_fields():
@
struct @(spec.short_name)_
{
unsigned long long timestamp;
@add_msg_fields()
}; // struct @(spec.short_name)_