Skip to content
Snippets Groups Projects
Commit 28521ea7 authored by TSC21's avatar TSC21 Committed by Beat Küng
Browse files

move parse_yaml_msg_id_file() definition to generate_microRTPS_bridge.py

parent a50fed1b
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,11 @@ import px_generate_uorb_topic_helper
import subprocess
import glob
import errno
try:
import yaml
except ImportError:
raise ImportError(
"Failed to import yaml. You may need to install it with 'sudo pip install pyyaml'")
def get_absolute_path(arg_parse_dir):
......@@ -63,6 +68,20 @@ def get_absolute_path(arg_parse_dir):
return dir
def parse_yaml_msg_id_file(yaml_file):
"""
Parses a yaml file into a dict
"""
try:
with open(yaml_file, 'r') as f:
return yaml.load(f)
except OSError as e:
if e.errno == errno.ENOENT:
raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), yaml_file)
else:
raise
default_client_out = get_absolute_path(
"src/modules/micrortps_bridge/micrortps_client")
default_agent_out = get_absolute_path(
......@@ -186,8 +205,7 @@ if agent and os.path.isdir(os.path.join(agent_out_dir, "idl")):
uorb_templates_dir = os.path.join(msg_folder, args.uorb_templates)
urtps_templates_dir = os.path.join(msg_folder, args.urtps_templates)
# parse yaml file into a map of ids
rtps_ids = px_generate_uorb_topic_helper.parse_yaml_msg_id_file(
os.path.join(msg_folder, args.yaml_file))
rtps_ids = parse_yaml_msg_id_file(os.path.join(msg_folder, args.yaml_file))
uRTPS_CLIENT_TEMPL_FILE = 'microRTPS_client.cpp.template'
......
......@@ -41,11 +41,6 @@ precompiled and thus message generation will be much faster
import os
import errno
try:
import yaml
except ImportError:
raise ImportError(
"Failed to import yaml. You may need to install it with 'sudo pip install pyyaml")
import genmsg.msgs
import gencpp
......@@ -351,21 +346,6 @@ def print_field_def(field):
print('\t%s%s%s %s%s;%s' % (type_prefix, type_px4, type_appendix, field.name,
array_size, comment))
def parse_yaml_msg_id_file(yaml_file):
"""
Parses a yaml file into a dict
"""
try:
with open(yaml_file, 'r') as f:
return yaml.load(f)
except OSError as e:
if e.errno == errno.ENOENT:
raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), yaml_file)
else:
raise
def rtps_message_id(msg_id_map, message):
"""
Get RTPS ID of uORB message
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment