Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce serial com port checks #159

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ gui = [
"PyQt6~=6.6",
]
test = [
"pyfakefs~=4.5",
"pyfakefs~=5.7",
"pytest~=8.3"
]

[project.urls]
Expand Down
27 changes: 3 additions & 24 deletions tmtccmd/com/ser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
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)

Check warning on line 83 in tmtccmd/com/ser_utils.py

View check run for this annotation

Codecov / codecov/patch

tmtccmd/com/ser_utils.py#L83

Added line #L83 was not covered by tests
if try_hint:
reconfig_com_port, com_port = __try_hint_handling(
json_cfg_path=json_cfg_path,
Expand All @@ -102,36 +102,15 @@
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

Check warning on line 113 in tmtccmd/com/ser_utils.py

View check run for this annotation

Codecov / codecov/patch

tmtccmd/com/ser_utils.py#L113

Added line #L113 was not covered by tests


def __try_hint_handling(
Expand Down
Loading