Skip to content

Commit

Permalink
Parsing also patch and dirty fields of cnfInfo message (#550)
Browse files Browse the repository at this point in the history
* Parsing also patch and dirty fields of cnfInfo message

* Fix linting error

* Add suffix to firmware information
  • Loading branch information
dl1com authored Jul 24, 2023
1 parent 215a61a commit 5eb8494
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/python/ayab/engine/communication_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 6 additions & 1 deletion src/main/python/ayab/engine/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion src/main/python/ayab/tests/test_communication_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5eb8494

Please sign in to comment.