From 0475c1b9f5e95ccaf64305e683675892f6b5c5e9 Mon Sep 17 00:00:00 2001 From: Jonathan Diamond Date: Tue, 4 Feb 2025 10:58:28 -0800 Subject: [PATCH] [config_tool] Support read/apply the ProfilingMask configuration parameter. --- bin/config_tool.py | 30 ++++++++++++++++++++++++++++++ requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/bin/config_tool.py b/bin/config_tool.py index f5d63ed..b941038 100755 --- a/bin/config_tool.py +++ b/bin/config_tool.py @@ -152,6 +152,28 @@ def _str_to_tick_direction(tick_direction_str): return _tick_direction_map.get(tick_direction_str, TickDirection.OFF) +# A bit mask used to select a set of profilers to enable: +# SYSTEM = 1 << 0 +# COUNTERS = 1 << 1 +# EXECUTIONS = 1 << 2 +# EXECUTION_STATS = 1 << 3 +# PIPELINES = 1 << 4 +# By default enable all profiling besides EXECUTIONS. +_profile_level_map = { + "off": 0, + "on": 0b11011, + "detailed": 0b11111 +} + + +def _args_to_profile_level(cls, args, config_interface): + if args.value.isdigit(): + mask_val = int(args.value) + else: + mask_val = _profile_level_map.get(args.value, 0) + return ProfilingMask(mask_val) + + _iono_delay_model_map = { "auto": IonoDelayModel.AUTO, "off": IonoDelayModel.OFF, @@ -434,6 +456,8 @@ def _str_to_socket_type(key): 'watchdog_enabled': {'format': WatchdogTimerEnabled, 'arg_parse': _args_to_bool}, 'user_device_id': {'format': UserDeviceID, 'arg_parse': _args_to_id}, + 'profiling_enabled': {'format': ProfilingMask, 'arg_parse': _args_to_profile_level}, + 'uart1_baud': {'format': Uart1BaudConfig, 'arg_parse': _args_to_int_gen('baud_rate')}, 'uart2_baud': {'format': Uart2BaudConfig, 'arg_parse': _args_to_int_gen('baud_rate')}, 'uart1_diagnostics_enabled': {'format': Uart1DiagnosticMessagesEnabled, 'arg_parse': _args_to_bool}, @@ -1418,6 +1442,12 @@ def main(): help='The scale factor to convert from wheel encoder ticks to distance ' '(in meters/tick).') + help = 'Configure system profiling support.' + param_parser.add_parser('profiling_enabled', help=help, description=help) + profiling_enabled_parser = apply_param_parser.add_parser('profiling_enabled', help=help, description=help) + profiling_enabled_parser.add_argument('value', help='Sets profiling which profiling features are enabled.', + choices=_profile_level_map.keys()) + # config_tool.py apply -- output interface/stream control help = 'Configure the UART1 serial baud rate.' param_parser.add_parser('uart1_baud', help=help, description=help) diff --git a/requirements.txt b/requirements.txt index 39e89b6..bb0e30a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ argparse-formatter>=1.4 colorama>=0.4.4 construct~=2.10.67 deepdiff>=8.0.1 -fusion-engine-client==1.24.0rc2 +fusion-engine-client==1.24.0rc3 pynmea2~=1.18.0 pyserial~=3.5 urllib3>=1.21.1 diff --git a/setup.py b/setup.py index b5ee6ff..e33d201 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ "colorama>=0.4.4", "construct~=2.10.67", "deepdiff>=8.0.1", - "fusion-engine-client==1.24.0rc2", + "fusion-engine-client==1.24.0rc3", "psutil>=5.9.4", "pynmea2~=1.18.0", "pyserial~=3.5",