mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 19:32:36 +08:00
Fixes for manual bridge generation
Fix for some forgot .cxx extensions Fix for 'print' python 2 3 compatibility Fix for topic ID type change
This commit is contained in:
committed by
Lorenz Meier
parent
c05ea542d9
commit
c5e2745a19
@@ -84,18 +84,18 @@ ORB_DEFINE(@multi_topic, struct @uorb_struct, @(struct_size-padding_end_size),
|
||||
@{
|
||||
|
||||
def print_info(field):
|
||||
print "type: ", field.type, "name: ", field.name, "base_type: ", \
|
||||
print("type: ", field.type, "name: ", field.name, "base_type: ", \
|
||||
field.base_type, "field.is_array:", ('0', '1')[field.is_array], " array_len: ", field.array_len, \
|
||||
"is_builtin:", ('0', '1')[field.is_builtin], "is_header:", ('0', '1')[field.is_header]
|
||||
"is_builtin:", ('0', '1')[field.is_builtin], "is_header:", ('0', '1')[field.is_header])
|
||||
|
||||
def print_level_info(fields):
|
||||
for field in fields:
|
||||
print_info(field)
|
||||
if (not field.is_builtin):
|
||||
print "\n"
|
||||
print("\n")
|
||||
children_fields = get_children_fields(field.base_type, search_path)
|
||||
print_level_info(children_fields)
|
||||
print "\n"
|
||||
print("\n")
|
||||
|
||||
def walk_through_parsed_fields():
|
||||
print_level_info(spec.parsed_fields())
|
||||
@@ -111,9 +111,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("\tserialize"+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("\tserialize"+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)
|
||||
@@ -129,10 +129,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("\tdeserialize"+str(get_serialization_type_name(field.type))+"(&output->"+scope_name+str(field.name)+", microCDRReader);")
|
||||
else:
|
||||
for i in xrange(field.array_len):
|
||||
print "\tdeserialize"+str(get_serialization_type_name(field.base_type))+"(&output->"+scope_name+str(field.name)+ str('[%d]' %i) +", microCDRReader);"
|
||||
print("\tdeserialize"+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)
|
||||
|
||||
@@ -83,7 +83,7 @@ bool RtpsTopics::init()
|
||||
}
|
||||
|
||||
@[if send_topics]@
|
||||
void RtpsTopics::publish(char topic_ID, char data_buffer[], size_t len)
|
||||
void RtpsTopics::publish(uint8_t topic_ID, char data_buffer[], size_t len)
|
||||
{
|
||||
switch (topic_ID)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ void RtpsTopics::publish(char topic_ID, char data_buffer[], size_t len)
|
||||
@[end if]@
|
||||
@[if recv_topics]@
|
||||
|
||||
bool RtpsTopics::hasMsg(char *topic_ID)
|
||||
bool RtpsTopics::hasMsg(uint8_t *topic_ID)
|
||||
{
|
||||
if (nullptr == topic_ID) return false;
|
||||
|
||||
@@ -134,7 +134,7 @@ bool RtpsTopics::hasMsg(char *topic_ID)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RtpsTopics::getMsg(const char topic_ID, eprosima::fastcdr::Cdr &scdr)
|
||||
bool RtpsTopics::getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr)
|
||||
{
|
||||
bool ret = false;
|
||||
switch (topic_ID)
|
||||
|
||||
@@ -64,11 +64,11 @@ class RtpsTopics {
|
||||
public:
|
||||
bool init();
|
||||
@[if send_topics]@
|
||||
void publish(char topic_ID, char data_buffer[], size_t len);
|
||||
void publish(uint8_t topic_ID, char data_buffer[], size_t len);
|
||||
@[end if]@
|
||||
@[if recv_topics]@
|
||||
bool hasMsg(char *topic_ID);
|
||||
bool getMsg(const char topic_ID, eprosima::fastcdr::Cdr &scdr);
|
||||
bool hasMsg(uint8_t *topic_ID);
|
||||
bool getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr);
|
||||
@[end if]@
|
||||
|
||||
private:
|
||||
|
||||
@@ -229,7 +229,7 @@ int main(int argc, char** argv)
|
||||
int received = 0, loop = 0;
|
||||
int length = 0, total_read = 0;
|
||||
bool receiving = false;
|
||||
char topic_ID = 255;
|
||||
uint8_t topic_ID = 255;
|
||||
std::chrono::time_point<std::chrono::steady_clock> start, end;
|
||||
@[end if]@
|
||||
|
||||
|
||||
@@ -61,9 +61,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('\t' + 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('\t' + 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
|
||||
|
||||
Reference in New Issue
Block a user