From 0093a0df22ca5745b5d054e19830af04937cbc89 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Oct 2024 14:39:49 +0200 Subject: [PATCH] reduce serial com port checks --- CHANGELOG.md | 5 +++++ pyproject.toml | 3 ++- tmtccmd/com/ser_utils.py | 27 +++------------------------ 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48aebb85..9c5dbced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ Starting from v4.0.0, this project adheres to [Semantic Versioning](http://semve # [unreleased] +## Fixed + +- Removed serial port validity check, which does not work for something like symlinks created + with udev rules. + # [v8.0.2] 2024-08-27 ## Changed diff --git a/pyproject.toml b/pyproject.toml index c0bfdd43..23e20e67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,8 @@ gui = [ "PyQt6~=6.6", ] test = [ - "pyfakefs~=4.5", + "pyfakefs~=5.7", + "pytest~=8.3" ] [project.urls] diff --git a/tmtccmd/com/ser_utils.py b/tmtccmd/com/ser_utils.py index c96137a2..b75d31f0 100644 --- a/tmtccmd/com/ser_utils.py +++ b/tmtccmd/com/ser_utils.py @@ -80,7 +80,7 @@ def __det_com_port_with_json_file( json_obj = json.load(json_file) com_port = "" if not reconfig_com_port: - reconfig_com_port, try_hint, com_port = __try_com_port_load(json_obj=json_obj) + try_hint, com_port = __try_com_port_load(json_obj=json_obj) if try_hint: reconfig_com_port, com_port = __try_hint_handling( json_cfg_path=json_cfg_path, @@ -102,36 +102,15 @@ def __det_com_port_with_json_file( return com_port -def __try_com_port_load(json_obj) -> Tuple[bool, bool, str]: - reconfig_com_port = False +def __try_com_port_load(json_obj) -> Tuple[bool, str]: try_hint = False com_port = "" try: com_port = json_obj[JsonKeyNames.SERIAL_PORT.value] _LOGGER.info(f"Loaded serial port {com_port} from JSON configuration file") - if not check_port_validity(com_port): - while True: - _LOGGER.info( - "Serial port from configuration file not contained within serial" - " port list" - ) - reconfigure = input( - "Reconfigure serial port or try to determine from hint? " - "[r (reconfigure) / h (hint) / c(cancel)]: " - ) - if reconfigure.lower() in ["r"]: - reconfig_com_port = True - break - elif reconfigure.lower() in ["h"]: - try_hint = True - break - elif reconfigure.lower() in ["c"]: - return com_port - else: - continue except KeyError: try_hint = True - return reconfig_com_port, try_hint, com_port + return try_hint, com_port def __try_hint_handling(