From 27ff7161059498a2bd2654de1a20eb8d29cb0df7 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 18 Oct 2019 11:23:32 +0200 Subject: [PATCH] msg: don't implement print_message for fmu-v2 This saves about 3.4k of flash for fmu-v2. --- msg/CMakeLists.txt | 6 ++++++ msg/templates/uorb/msg.cpp.em | 6 ++++++ msg/tools/px_generate_uorb_topic_files.py | 11 +++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/msg/CMakeLists.txt b/msg/CMakeLists.txt index e112e116a96a..0542639650f3 100644 --- a/msg/CMakeLists.txt +++ b/msg/CMakeLists.txt @@ -177,6 +177,10 @@ foreach(msg_file ${msg_files}) list(APPEND uorb_sources ${msg_source_out_path}/${msg}.cpp) endforeach() +if (px4_constrained_flash_build) + set(added_arguments --constrained-flash) +endif() + # Generate uORB headers add_custom_command(OUTPUT ${uorb_headers} COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py @@ -187,6 +191,7 @@ add_custom_command(OUTPUT ${uorb_headers} -e templates/uorb -t ${CMAKE_CURRENT_BINARY_DIR}/tmp/headers -q + ${added_arguments} DEPENDS ${msg_files} templates/uorb/msg.h.em @@ -207,6 +212,7 @@ add_custom_command(OUTPUT ${uorb_sources} -e templates/uorb -t ${CMAKE_CURRENT_BINARY_DIR}/tmp/sources -q + ${added_arguments} DEPENDS ${msg_files} templates/uorb/msg.cpp.em diff --git a/msg/templates/uorb/msg.cpp.em b/msg/templates/uorb/msg.cpp.em index 8b0dfb7d6a63..02a8341049f1 100644 --- a/msg/templates/uorb/msg.cpp.em +++ b/msg/templates/uorb/msg.cpp.em @@ -15,6 +15,7 @@ @# - md5sum (String) MD5Sum of the .msg specification @# - search_path (dict) search paths for genmsg @# - topics (List of String) multi-topic names +@# - constrained_flash set to true if flash is constrained @# - ids (List) list of all RTPS msg ids @############################################### /**************************************************************************** @@ -82,9 +83,14 @@ ORB_DEFINE(@multi_topic, struct @uorb_struct, @(struct_size-padding_end_size), _ void print_message(const @uorb_struct& message) { +@[if constrained_flash] + (void)message; + PX4_INFO_RAW("Not implemented on flash constrained hardware\n"); +@[else] PX4_INFO_RAW(" @(uorb_struct)\n"); @[for field in sorted_fields]@ @( print_field(field) )@ @[end for]@ +@[end if]@ } diff --git a/msg/tools/px_generate_uorb_topic_files.py b/msg/tools/px_generate_uorb_topic_files.py index 47f45eed383b..aba2ab21554a 100755 --- a/msg/tools/px_generate_uorb_topic_files.py +++ b/msg/tools/px_generate_uorb_topic_files.py @@ -33,7 +33,7 @@ ############################################################################# """ -px_generate_uorb_topics.py +px_generate_uorb_topic_files.py Generates c/cpp header/source files for uorb topics from .msg (ROS syntax) message files """ @@ -85,6 +85,8 @@ TOPICS_TOKEN = '# TOPICS ' IDL_TEMPLATE_FILE = 'msg.idl.em' +CONSTRAINED_FLASH = False + class MsgScope: NONE = 0 @@ -156,7 +158,8 @@ def generate_output_from_file(format_idx, filename, outputdir, package, template "search_path": search_path, "msg_context": msg_context, "spec": spec, - "topics": topics + "topics": topics, + "constrained_flash": CONSTRAINED_FLASH } # Make sure output directory exists: @@ -511,11 +514,15 @@ def append_to_include_path(path_to_append, curr_include, package): parser.add_argument('-q', dest='quiet', default=False, action='store_true', help='string added as prefix to the output file ' ' name when converting directories') + parser.add_argument('--constrained-flash', dest='constrained_flash', default=False, action='store_true', + help='set to save flash space') args = parser.parse_args() if args.include_paths: append_to_include_path(args.include_paths, INCL_DEFAULT, args.package) + CONSTRAINED_FLASH = args.constrained_flash + if args.headers: generate_idx = 0 elif args.sources: