Browse Source

systemcmds/topic_listener: use msg_files list from msg/

sbg
Daniel Agar 4 years ago
parent
commit
1eb3c59277
  1. 3
      msg/CMakeLists.txt
  2. 8
      src/systemcmds/topic_listener/CMakeLists.txt
  3. 25
      src/systemcmds/topic_listener/generate_listener.py

3
msg/CMakeLists.txt

@ -231,6 +231,9 @@ if (px4_constrained_flash_build) @@ -231,6 +231,9 @@ if (px4_constrained_flash_build)
set(added_arguments --constrained-flash)
endif()
# set parent scope msg_files for other modules to consume (eg topic_listener)
set(msg_files ${msg_files} PARENT_SCOPE)
# Generate uORB headers
add_custom_command(OUTPUT ${uorb_headers}
COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py

8
src/systemcmds/topic_listener/CMakeLists.txt

@ -32,16 +32,16 @@ @@ -32,16 +32,16 @@
############################################################################
add_custom_command(OUTPUT listener_generated.cpp
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_listener.py ${PX4_SOURCE_DIR} ${EXTERNAL_MODULES_LOCATION} > listener_generated.cpp
DEPENDS generate_listener.py uorb_msgs
)
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_listener.py ${PX4_SOURCE_DIR} ${msg_files} > listener_generated.cpp
DEPENDS generate_listener.py uorb_msgs
)
add_custom_target(generate_topic_listener
DEPENDS
listener_generated.cpp
generate_listener.py
uorb_msgs
)
)
px4_add_module(
MODULE systemcmds__topic_listener

25
src/systemcmds/topic_listener/generate_listener.py

@ -8,22 +8,29 @@ import re @@ -8,22 +8,29 @@ import re
# This script is run from Build/<target>_default.build/$(PX4_BASE)/Firmware/src/systemcmds/topic_listener
# argv[1] must be the full path of the top Firmware dir
# argv[2] (optional) is the full path to the EXTERNAL_MODULES_LOCATION
# argv[2] - argv[n] is the full list of msg files
raw_messages = glob.glob(sys.argv[1]+"/msg/*.msg")
if len(sys.argv) > 2:
external_raw_messages = glob.glob(sys.argv[2]+"/msg/*.msg")
raw_messages += external_raw_messages # Append the msgs defined in the EXTERNAL_MODULES_LOCATION to the normal msg list
messages = []
topics = []
message_elements = []
raw_messages = sys.argv[2:]
# large and not worth printing
raw_messages = [x for x in raw_messages if not any(exception in x for exception in ['qshell_req', 'ulog_stream', 'gps_inject_data', 'gps_dump'])]
messages = []
topics = []
message_elements = []
for index,m in enumerate(raw_messages):
topic_list = []
f = open(m,'r')
msg_path = sys.argv[1]+ '/msg/' + m
if os.path.isfile(msg_path):
# first try opening file in msg/ directory
f = open(msg_path,'r')
else:
# otherwise try opening directly (could be an external module msg)
f = open(m,'r')
for line in f.readlines():
items = re.split('\s+', line.strip())

Loading…
Cancel
Save