From 5eb8494ef1d4ad9ff4dd91bc560bc5bb4e74552a Mon Sep 17 00:00:00 2001 From: dl1com <1631996+dl1com@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:58:34 +0200 Subject: [PATCH] Parsing also patch and dirty fields of cnfInfo message (#550) * Parsing also patch and dirty fields of cnfInfo message * Fix linting error * Add suffix to firmware information --- src/main/python/ayab/engine/communication_mock.py | 4 ++-- src/main/python/ayab/engine/control.py | 7 ++++++- src/main/python/ayab/tests/test_communication_mock.py | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/python/ayab/engine/communication_mock.py b/src/main/python/ayab/engine/communication_mock.py index 748327c3..10fdd61b 100644 --- a/src/main/python/ayab/engine/communication_mock.py +++ b/src/main/python/ayab/engine/communication_mock.py @@ -66,8 +66,8 @@ def open_serial(self, portname=None) -> bool: return True def req_info(self) -> None: - """Send a request for API version information.""" - cnfInfo = bytes([Token.cnfInfo.value, 6, 1, 0]) # APIv6, FWv1.0 + """Send a request for API version information""" + cnfInfo = bytes([Token.cnfInfo.value, 6, 1, 0, 0, 109, 111, 99, 107, 0]) # APIv6, FW v1.0.0-mock self.rx_msg_list.append(cnfInfo) def req_init_API6(self, machine_val): diff --git a/src/main/python/ayab/engine/control.py b/src/main/python/ayab/engine/control.py index 260677bd..4ab61ceb 100644 --- a/src/main/python/ayab/engine/control.py +++ b/src/main/python/ayab/engine/control.py @@ -132,7 +132,12 @@ def __log_cnfInfo(self, msg): api = msg[1] log = "API v" + str(api) if api >= 5: - log += ", FW v" + str(msg[2]) + "." + str(msg[3]) + log += ", FW v" + str(msg[2]) + "." + str(msg[3]) + "." + str(msg[4]) + suffix = msg[5:21] + suffix_null_index = suffix.find(0) + suffix = suffix[:suffix_null_index+1].decode() + if len(suffix) > 1: + log += "-" + suffix self.logger.info(log) def cnf_line_API6(self, line_number): diff --git a/src/main/python/ayab/tests/test_communication_mock.py b/src/main/python/ayab/tests/test_communication_mock.py index 84c3fc76..03ede7e5 100644 --- a/src/main/python/ayab/tests/test_communication_mock.py +++ b/src/main/python/ayab/tests/test_communication_mock.py @@ -50,8 +50,9 @@ def test_req_start_API6(self): assert bytes_read == expected_result def test_req_info(self): + # expecting 1.0.0-mock expected_result = (bytes([Token.cnfInfo.value, 6, 1, - 0]), Token.cnfInfo, 6) + 0, 0, 109, 111, 99, 107, 0]), Token.cnfInfo, 6) self.comm_dummy.req_info() bytes_read = self.comm_dummy.update_API6() assert bytes_read == expected_result