From 1e99f0de6c86b2d062db157ad49973af4b75490b Mon Sep 17 00:00:00 2001 From: Martin Shetty <1972005+martukas@users.noreply.github.com> Date: Mon, 3 Oct 2022 23:53:04 -0700 Subject: [PATCH] some restructuring of debug libs; updates #1303 --- .gitignore | 4 +- software/common/common.sh | 2 +- software/controller/controller.sh | 11 +- software/controller/platformio/README.md | 47 +-- software/utils/debug/debug.sh | 39 ++ software/utils/debug/debug_cli.py | 24 +- software/utils/debug/debug_lib/__init__.py | 0 .../debug/{ => debug_lib}/controller_debug.py | 18 +- .../debug/{ => debug_lib}/debug_types.py | 0 .../utils/debug/{ => debug_lib}/test_data.py | 8 +- .../debug/{ => debug_lib}/test_scenario.py | 0 .../utils/debug/{ => debug_lib}/var_info.py | 2 +- software/utils/debug/unit_test.py | 0 .../util/protocols/network_protocol_pb2.py | 369 ------------------ software/utils/debug/util/serial_detect.py | 16 +- 15 files changed, 86 insertions(+), 454 deletions(-) create mode 100755 software/utils/debug/debug.sh create mode 100644 software/utils/debug/debug_lib/__init__.py rename software/utils/debug/{ => debug_lib}/controller_debug.py (98%) rename software/utils/debug/{ => debug_lib}/debug_types.py (100%) rename software/utils/debug/{ => debug_lib}/test_data.py (99%) rename software/utils/debug/{ => debug_lib}/test_scenario.py (100%) rename software/utils/debug/{ => debug_lib}/var_info.py (99%) mode change 100644 => 100755 software/utils/debug/unit_test.py delete mode 100644 software/utils/debug/util/protocols/network_protocol_pb2.py diff --git a/.gitignore b/.gitignore index 85989a961..0f7182b9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ #network protocol output files software/common/generated_libs/protocols/*.c software/common/generated_libs/protocols/*.h -software/utils/debug/lib/protocols/* software/gui/src/protocols/*.cc software/gui/src/protocols/*.h +software/utils/debug/protocols/* build/ build_autotests/ @@ -58,5 +58,5 @@ fp-info-cache *-cache.lib #performance test data +local_data/ test_data/ -device_list.* diff --git a/software/common/common.sh b/software/common/common.sh index 92c925439..6807ef4ec 100755 --- a/software/common/common.sh +++ b/software/common/common.sh @@ -126,7 +126,7 @@ update_platformio() { generate_network_protocols() { PROTOCOLS_DIR=generated_libs/protocols - PYTHON_LIB_PATH=../utils/debug/lib/protocols + PYTHON_LIB_PATH=../utils/debug/protocols GUI_LIB_PATH=../gui/src/protocols NANOPB_PATH=$(pip3 show nanopb | awk '{ if($1 == "Location:") print $2}')/nanopb/generator diff --git a/software/controller/controller.sh b/software/controller/controller.sh index d0ccec17a..89a2369bb 100755 --- a/software/controller/controller.sh +++ b/software/controller/controller.sh @@ -84,6 +84,9 @@ The following options are available: unit Builds and runs unit tests only (and generates coverage reports) - run specific unit test, may include wildcards, i.e. '*debug*' [-o] - open coverage report in browser when done + integrate Run integration tests + all [delay_time] - run all integration tests, pause for [delay time] in between + [parameters...] - run specific integration test with parameters cov_upload Upload coverage reports to Codecov server help/-h Display this help info EOF @@ -235,7 +238,7 @@ print_device_info() { if [ ! -z "$SN" ] then echo "SN has been defined in environment, will be deploying to the following device:" - ../utils/debug/debug_cli.py -c "devices find $SN" + ../utils/debug/debug.sh -c "device find $SN" fi } @@ -243,7 +246,7 @@ print_device_info() { # prints ST-Link serial number by defined alias get_hla_serial() { device_alias="$1" - ../utils/debug/debug_cli.py -c "devices find $device_alias h" + ../utils/debug/debug.sh -c "device find $device_alias h" } # build @@ -483,7 +486,7 @@ elif [ "$1" == "run" ]; then elif [ "$1" == "debug" ]; then shift pushd ../utils/debug - ./debug_cli.py "$@" + ./debug.sh "$@" popd exit $EXIT_SUCCESS @@ -512,7 +515,7 @@ elif [ "$1" == "integrate" ]; then # DEVICES # ########### elif [ "$1" == "devices" ]; then - ../utils/debug/debug_cli.py -c "devices list" + ../utils/debug/debug.sh -c "device list" exit $EXIT_SUCCESS ################ diff --git a/software/controller/platformio/README.md b/software/controller/platformio/README.md index c5874e769..2492e6b7b 100644 --- a/software/controller/platformio/README.md +++ b/software/controller/platformio/README.md @@ -4,35 +4,24 @@ The [build_config](build_config) directory contains the build configuration. What follows is the configuration for the deployment scripts. -## Deployment script - -By default, controller software and integration tests will deploy to any one STM32 that is hooked up to your machine. - -The [deploy.sh](deploy.sh) script provides a convenient way to deploy to multiple connected STM devices, -addressing them by user-defined aliases. In order for this to work, you need to modify the Platformio's STLink script, -find out the serial number of your Nucleo and add it to the list of aliases. - -The script provides its own help on syntax. - -The script is also used by integration test tools, so it is a good idea to configure it correctly. - -The script is further abstracted by the [../controller.sh](../controller.sh) utility, which will deploy the default -release firmware to the controller with simplified syntax. - ## Modifying STLink script -For the above script to work, a file in your local platformio configuration found here: +In order to deploy to multiple STM32 devices on the same system, a file in your local platformio configuration found here: `$HOME/.platformio/packages/tool-openocd/scripts/interface/stlink.cfg` must be replaced with the [`stlink.cfg`](stlink.cfg) provided here. -> TODO: make a script to patch or replace this file +This patching is now handled by running `controller.sh patch_ocd`. This solution is based on a post on the platformio forums [here](https://community.platformio.org/t/choosing-stlink-v2-programmer/10716). The post is rather old, so the TCL syntax had to be modified to make it work. -## Finding your Nucleo's serial number +### Finding your Nucleo's serial number + +Association of STM32 HLA serial number to prototype alias ID is now managed by the python and bash utility scripts. Use `./controller.sh devices` or use the `device` command in the debug interface for more details. The manifest is maintained on Google Drive in a spreadsheet under `Testing`. + +The following are instructions for how to do this manually. To deploy to a particular STM32 boards connected to your system, first find out the serial numbers of your connected Nucleos. @@ -43,29 +32,9 @@ E: ID_SERIAL_SHORT=066FFF303435554157105014 E: ID_SERIAL_SHORT=066BFF303435554157104916 ``` -On Windows, you can use the STLink utility provided by ST Micro. The serial number shows up in the log when you connect. -Possibly you might need to use this to update the firmware too. Close the utility after you have what you need. +On Windows, you can use the STLink utility provided by ST Micro. The serial number shows up in the log when you connect. Possibly you might need to use this to update the firmware too. Close the utility after you have what you need. With the STLink script modified, you can now deploy firmware like this: ``` SERIAL=066BFF303435554157104916 TEST=TEST_IDLE pio run -e integration-test -t upload ``` - -However, this can get tedious, so we recommend... - -## Making an alias - -The [device_lookup_table.txt](device_lookup_table.txt) file contains a list of aliases. - -The list will look something like this: -``` -ALIAS NUCLEO_SERIAL COMMENT -p1 0668FF303435554157122853 Pizza #1 at Edwin's Workshop -p3 0668FF303435554157105440 Pizza #3 at Martin's farm -``` - -For the first column, make a unique label, hopefully similar to whatever designation has been agreed to by the team. -The second column is the serial number obtained by the magic above, and lastly you can have some nice description. - -**PLEASE COMMIT CHANGES** after adding your Nucleo to the list. This will help keep things consistently documented as -we test software on various prototypes. diff --git a/software/utils/debug/debug.sh b/software/utils/debug/debug.sh new file mode 100755 index 000000000..b357961eb --- /dev/null +++ b/software/utils/debug/debug.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Copyright 2020-2022, RespiraWorks +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Fail if any command fails +set -e +set -o pipefail + +# Print each command as it executes +if [ -n "$VERBOSE" ]; then + set -o xtrace +fi + +pushd () { + command pushd "$@" > /dev/null +} + +popd () { + command popd > /dev/null +} + +# This script should work no matter where you call it from. +MY_PATH="$(dirname "$0")" + +pushd $MY_PATH +PYTHONPATH=$MY_PATH ./debug_cli.py "${@:1}" +popd diff --git a/software/utils/debug/debug_cli.py b/software/utils/debug/debug_cli.py index 6747b6737..085d57c7e 100755 --- a/software/utils/debug/debug_cli.py +++ b/software/utils/debug/debug_cli.py @@ -29,15 +29,15 @@ import os import shlex import traceback -from util.colors import * -from util.error import Error -from util.serial_detect import DeviceScanner -from controller_debug import ControllerDebugInterface, MODE_BOOT -from var_info import VAR_ACCESS_READ_ONLY, VAR_ACCESS_WRITE, VAR_FLOAT_ARRAY import numpy as np import matplotlib.pyplot as plt -import test_data from pathlib import Path +from util.colors import * +from util.error import Error +from util.serial_detect import DeviceScanner +from debug_lib.controller_debug import ControllerDebugInterface, MODE_BOOT +from debug_lib.var_info import VAR_ACCESS_READ_ONLY, VAR_ACCESS_WRITE, VAR_FLOAT_ARRAY +import debug_lib.test_data import debug_funcs @@ -82,7 +82,7 @@ def __init__(self, connect_to): super(CmdLine, self).__init__() self.scripts_directory = "scripts" self.test_scenarios_dir = Path("test_scenarios").absolute().resolve() - self.test_data_dir = Path("../../../test_data").absolute().resolve() + self.test_data_dir = Path("../../../local_data/test_data").absolute().resolve() self.interface = ControllerDebugInterface() self.maybe_connect(connect_to) @@ -191,27 +191,27 @@ def maybe_connect(self, alias_or_port): print(f"Attempting to connect to: {selected.print()}") self.interface.connect(selected.port) - def do_devices(self, line): + def do_device(self, line): """This command manages the connection of the debug interface to the ventilator controller If ventilator USB cable is unplugged, the CLI prompt should update to reflect this on the next loop (blank line or failed command). You may also start the debugger without a plugged in device. Use one of the following commands to reconnect. - devices list + device list searches and lists available STM32 devices on the serial bus - devices off + device off disconnect if connected - devices find [h/p/c] + device find [h/p/c] print information for specific device alias - string must match alias as defined in manifest h - print HLA serial number only p - print port only c - print configuration only - devices connect + device connect connect to device, where is one of: - `auto` find port of and connect to plugged in device, must be only one - alias, as definded in device manifest diff --git a/software/utils/debug/debug_lib/__init__.py b/software/utils/debug/debug_lib/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/software/utils/debug/controller_debug.py b/software/utils/debug/debug_lib/controller_debug.py similarity index 98% rename from software/utils/debug/controller_debug.py rename to software/utils/debug/debug_lib/controller_debug.py index b9fe301a6..1ba32eb92 100755 --- a/software/utils/debug/controller_debug.py +++ b/software/utils/debug/debug_lib/controller_debug.py @@ -20,17 +20,17 @@ """ +import debug_lib.debug_types +import debug_lib.var_info +from debug_lib.test_scenario import TestScenario +from debug_lib.test_data import * +from util.error import Error +from util.colors import red, orange import serial import threading import time -import debug_types -import var_info import fnmatch -from util.error import Error -import test_scenario -from test_data import * from pathlib import Path -from util.colors import red, orange # TODO: Import constants from proto instead! @@ -327,11 +327,11 @@ def tests_import(self, file_name): if not in_file.is_file(): raise Error(f"Input file does not exist {file_name}") elif in_file.suffix == ".csv": - imported_scenarios = test_scenario.TestScenario.from_csv( + imported_scenarios = TestScenario.from_csv( in_file, self.variable_metadata.keys() ) elif in_file.suffix == ".json": - imported_scenarios = test_scenario.TestScenario.from_json(in_file) + imported_scenarios = TestScenario.from_json(in_file) else: raise Error(f"Unknown file format `{in_file.suffix}`") if bool(set(imported_scenarios.keys()) & set(self.scenarios.keys())): @@ -403,7 +403,7 @@ def test_run(self, name): return test def trace_save(self, scenario_name="manual_trace"): - test = TestData(test_scenario.TestScenario()) + test = TestData(TestScenario()) # get data self.save_test_data(test) diff --git a/software/utils/debug/debug_types.py b/software/utils/debug/debug_lib/debug_types.py similarity index 100% rename from software/utils/debug/debug_types.py rename to software/utils/debug/debug_lib/debug_types.py diff --git a/software/utils/debug/test_data.py b/software/utils/debug/debug_lib/test_data.py similarity index 99% rename from software/utils/debug/test_data.py rename to software/utils/debug/debug_lib/test_data.py index 18b56462d..4d3756691 100755 --- a/software/utils/debug/test_data.py +++ b/software/utils/debug/debug_lib/test_data.py @@ -20,16 +20,16 @@ """ +from debug_lib.test_scenario import TestScenario +from util.colors import red import datetime -from test_scenario import TestScenario -from typing import Dict, List -from datetime import datetime import matplotlib.pyplot as plt import dateutil.parser import json import platform import git -from util.colors import red +from typing import Dict, List +from datetime import datetime from pathlib import Path diff --git a/software/utils/debug/test_scenario.py b/software/utils/debug/debug_lib/test_scenario.py similarity index 100% rename from software/utils/debug/test_scenario.py rename to software/utils/debug/debug_lib/test_scenario.py diff --git a/software/utils/debug/var_info.py b/software/utils/debug/debug_lib/var_info.py similarity index 99% rename from software/utils/debug/var_info.py rename to software/utils/debug/debug_lib/var_info.py index 0838bb31d..7814b2d18 100755 --- a/software/utils/debug/var_info.py +++ b/software/utils/debug/debug_lib/var_info.py @@ -20,7 +20,7 @@ """ -import debug_types +import debug_lib.debug_types from util.error import Error # TODO: Import constants from proto instead! diff --git a/software/utils/debug/unit_test.py b/software/utils/debug/unit_test.py old mode 100644 new mode 100755 diff --git a/software/utils/debug/util/protocols/network_protocol_pb2.py b/software/utils/debug/util/protocols/network_protocol_pb2.py deleted file mode 100644 index 6015949df..000000000 --- a/software/utils/debug/util/protocols/network_protocol_pb2.py +++ /dev/null @@ -1,369 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: network_protocol.proto - -from google.protobuf.internal import enum_type_wrapper -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor.FileDescriptor( - name='network_protocol.proto', - package='', - syntax='proto2', - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x16network_protocol.proto\"C\n\tGuiStatus\x12\x11\n\tuptime_ms\x18\x01 \x02(\x04\x12#\n\x0e\x64\x65sired_params\x18\x02 \x02(\x0b\x32\x0b.VentParams\"\xa6\x01\n\x10\x43ontrollerStatus\x12\x11\n\tuptime_ms\x18\x01 \x02(\x04\x12\"\n\ractive_params\x18\x02 \x02(\x0b\x32\x0b.VentParams\x12&\n\x0fsensor_readings\x18\x03 \x02(\x0b\x32\r.SensorsProto\x12 \n\x18pressure_setpoint_cm_h2o\x18\x05 \x02(\x02\x12\x11\n\tfan_power\x18\x06 \x02(\x02\"\xe6\x01\n\nVentParams\x12\x17\n\x04mode\x18\x01 \x02(\x0e\x32\t.VentMode\x12\x13\n\x0bpeep_cm_h2o\x18\x03 \x02(\r\x12\x17\n\x0f\x62reaths_per_min\x18\x04 \x02(\r\x12\x12\n\npip_cm_h2o\x18\x05 \x02(\r\x12$\n\x1cinspiratory_expiratory_ratio\x18\x06 \x02(\x02\x12\"\n\x1ainspiratory_trigger_cm_h2o\x18\x08 \x02(\r\x12%\n\x1d\x65xpiratory_trigger_ml_per_min\x18\t \x02(\r\x12\x0c\n\x04\x66io2\x18\n \x02(\x02\"\xeb\x01\n\x0cSensorsProto\x12\x1f\n\x17patient_pressure_cm_h2o\x18\x01 \x02(\x02\x12\x11\n\tvolume_ml\x18\x02 \x02(\x02\x12\x17\n\x0f\x66low_ml_per_min\x18\x03 \x02(\x02\x12#\n\x1binflow_pressure_diff_cm_h2o\x18\x04 \x02(\x02\x12$\n\x1coutflow_pressure_diff_cm_h2o\x18\x05 \x02(\x02\x12\x11\n\tbreath_id\x18\x06 \x02(\x04\x12\"\n\x1a\x66low_correction_ml_per_min\x18\x07 \x02(\x02\x12\x0c\n\x04\x66io2\x18\x08 \x02(\x02*[\n\x08VentMode\x12\x07\n\x03OFF\x10\x00\x12\x14\n\x10PRESSURE_CONTROL\x10\x01\x12\x13\n\x0fPRESSURE_ASSIST\x10\x02\x12\x1b\n\x17HIGH_FLOW_NASAL_CANNULA\x10\x03' -) - -_VENTMODE = _descriptor.EnumDescriptor( - name='VentMode', - full_name='VentMode', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='OFF', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='PRESSURE_CONTROL', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='PRESSURE_ASSIST', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='HIGH_FLOW_NASAL_CANNULA', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=735, - serialized_end=826, -) -_sym_db.RegisterEnumDescriptor(_VENTMODE) - -VentMode = enum_type_wrapper.EnumTypeWrapper(_VENTMODE) -OFF = 0 -PRESSURE_CONTROL = 1 -PRESSURE_ASSIST = 2 -HIGH_FLOW_NASAL_CANNULA = 3 - - - -_GUISTATUS = _descriptor.Descriptor( - name='GuiStatus', - full_name='GuiStatus', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='uptime_ms', full_name='GuiStatus.uptime_ms', index=0, - number=1, type=4, cpp_type=4, label=2, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='desired_params', full_name='GuiStatus.desired_params', index=1, - number=2, type=11, cpp_type=10, label=2, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto2', - extension_ranges=[], - oneofs=[ - ], - serialized_start=26, - serialized_end=93, -) - - -_CONTROLLERSTATUS = _descriptor.Descriptor( - name='ControllerStatus', - full_name='ControllerStatus', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='uptime_ms', full_name='ControllerStatus.uptime_ms', index=0, - number=1, type=4, cpp_type=4, label=2, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='active_params', full_name='ControllerStatus.active_params', index=1, - number=2, type=11, cpp_type=10, label=2, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='sensor_readings', full_name='ControllerStatus.sensor_readings', index=2, - number=3, type=11, cpp_type=10, label=2, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='pressure_setpoint_cm_h2o', full_name='ControllerStatus.pressure_setpoint_cm_h2o', index=3, - number=5, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='fan_power', full_name='ControllerStatus.fan_power', index=4, - number=6, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto2', - extension_ranges=[], - oneofs=[ - ], - serialized_start=96, - serialized_end=262, -) - - -_VENTPARAMS = _descriptor.Descriptor( - name='VentParams', - full_name='VentParams', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='mode', full_name='VentParams.mode', index=0, - number=1, type=14, cpp_type=8, label=2, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='peep_cm_h2o', full_name='VentParams.peep_cm_h2o', index=1, - number=3, type=13, cpp_type=3, label=2, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='breaths_per_min', full_name='VentParams.breaths_per_min', index=2, - number=4, type=13, cpp_type=3, label=2, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='pip_cm_h2o', full_name='VentParams.pip_cm_h2o', index=3, - number=5, type=13, cpp_type=3, label=2, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='inspiratory_expiratory_ratio', full_name='VentParams.inspiratory_expiratory_ratio', index=4, - number=6, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='inspiratory_trigger_cm_h2o', full_name='VentParams.inspiratory_trigger_cm_h2o', index=5, - number=8, type=13, cpp_type=3, label=2, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='expiratory_trigger_ml_per_min', full_name='VentParams.expiratory_trigger_ml_per_min', index=6, - number=9, type=13, cpp_type=3, label=2, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='fio2', full_name='VentParams.fio2', index=7, - number=10, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto2', - extension_ranges=[], - oneofs=[ - ], - serialized_start=265, - serialized_end=495, -) - - -_SENSORSPROTO = _descriptor.Descriptor( - name='SensorsProto', - full_name='SensorsProto', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='patient_pressure_cm_h2o', full_name='SensorsProto.patient_pressure_cm_h2o', index=0, - number=1, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='volume_ml', full_name='SensorsProto.volume_ml', index=1, - number=2, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='flow_ml_per_min', full_name='SensorsProto.flow_ml_per_min', index=2, - number=3, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='inflow_pressure_diff_cm_h2o', full_name='SensorsProto.inflow_pressure_diff_cm_h2o', index=3, - number=4, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='outflow_pressure_diff_cm_h2o', full_name='SensorsProto.outflow_pressure_diff_cm_h2o', index=4, - number=5, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='breath_id', full_name='SensorsProto.breath_id', index=5, - number=6, type=4, cpp_type=4, label=2, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='flow_correction_ml_per_min', full_name='SensorsProto.flow_correction_ml_per_min', index=6, - number=7, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='fio2', full_name='SensorsProto.fio2', index=7, - number=8, type=2, cpp_type=6, label=2, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto2', - extension_ranges=[], - oneofs=[ - ], - serialized_start=498, - serialized_end=733, -) - -_GUISTATUS.fields_by_name['desired_params'].message_type = _VENTPARAMS -_CONTROLLERSTATUS.fields_by_name['active_params'].message_type = _VENTPARAMS -_CONTROLLERSTATUS.fields_by_name['sensor_readings'].message_type = _SENSORSPROTO -_VENTPARAMS.fields_by_name['mode'].enum_type = _VENTMODE -DESCRIPTOR.message_types_by_name['GuiStatus'] = _GUISTATUS -DESCRIPTOR.message_types_by_name['ControllerStatus'] = _CONTROLLERSTATUS -DESCRIPTOR.message_types_by_name['VentParams'] = _VENTPARAMS -DESCRIPTOR.message_types_by_name['SensorsProto'] = _SENSORSPROTO -DESCRIPTOR.enum_types_by_name['VentMode'] = _VENTMODE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -GuiStatus = _reflection.GeneratedProtocolMessageType('GuiStatus', (_message.Message,), { - 'DESCRIPTOR' : _GUISTATUS, - '__module__' : 'network_protocol_pb2' - # @@protoc_insertion_point(class_scope:GuiStatus) - }) -_sym_db.RegisterMessage(GuiStatus) - -ControllerStatus = _reflection.GeneratedProtocolMessageType('ControllerStatus', (_message.Message,), { - 'DESCRIPTOR' : _CONTROLLERSTATUS, - '__module__' : 'network_protocol_pb2' - # @@protoc_insertion_point(class_scope:ControllerStatus) - }) -_sym_db.RegisterMessage(ControllerStatus) - -VentParams = _reflection.GeneratedProtocolMessageType('VentParams', (_message.Message,), { - 'DESCRIPTOR' : _VENTPARAMS, - '__module__' : 'network_protocol_pb2' - # @@protoc_insertion_point(class_scope:VentParams) - }) -_sym_db.RegisterMessage(VentParams) - -SensorsProto = _reflection.GeneratedProtocolMessageType('SensorsProto', (_message.Message,), { - 'DESCRIPTOR' : _SENSORSPROTO, - '__module__' : 'network_protocol_pb2' - # @@protoc_insertion_point(class_scope:SensorsProto) - }) -_sym_db.RegisterMessage(SensorsProto) - - -# @@protoc_insertion_point(module_scope) diff --git a/software/utils/debug/util/serial_detect.py b/software/utils/debug/util/serial_detect.py index cfe0b7fa7..de321b082 100755 --- a/software/utils/debug/util/serial_detect.py +++ b/software/utils/debug/util/serial_detect.py @@ -135,21 +135,11 @@ def find(self, port): def auto_select(self): if not self.manifest: - print( - red( - "Could not auto-detect serial port; " - "platformio device list did not yield any STM32 devices." - ) - ) + print(red("Could not auto-select: no devices connected.")) return None if len(self.manifest) > 1: - print( - red( - "Could not auto-detect serial port; " - "platformio device list yielded multiple STM32 devices:\n" - f"{self.list_devices()}" - ) - ) + print(red("Could not auto-select: multiple devices connected.")) + print(self.list_devices()) return None return self.manifest[0]