From 0ef0bc62809be652a263d1adbfefee0ce80cdec5 Mon Sep 17 00:00:00 2001 From: Jonathan Perret Date: Wed, 4 Dec 2024 23:54:23 +0100 Subject: [PATCH] Report an unknown carriage in simulation mode This avoids the UI showing a particular carriage type when it's irrelevant for simulation. --- .../python/main/ayab/engine/communication_mock.py | 15 +++++++++++++-- .../main/ayab/tests/test_communication_mock.py | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/python/main/ayab/engine/communication_mock.py b/src/main/python/main/ayab/engine/communication_mock.py index 33080304..837f132e 100644 --- a/src/main/python/main/ayab/engine/communication_mock.py +++ b/src/main/python/main/ayab/engine/communication_mock.py @@ -73,11 +73,22 @@ def req_info(self) -> None: self.rx_msg_list.append(cnfInfo) def req_init_API6(self, machine_val): - """Send machine type.""" + """Send machine type and initial state report""" cnfInit = bytes([Token.cnfInit.value, 0]) self.rx_msg_list.append(cnfInit) indState = bytes( - [Token.indState.value, 0, 1, 0xFF, 0xFF, 0xFF, 0xFF, 1, 0x00, 1] + [ + Token.indState.value, + 0, # success + 1, # fsm state + 0xFF, + 0xFF, # left sensor value + 0xFF, + 0xFF, # right sensor value + 0xFF, # carriage type (unknown) + 0, # position + 1, # direction + ] ) self.rx_msg_list.append(indState) diff --git a/src/main/python/main/ayab/tests/test_communication_mock.py b/src/main/python/main/ayab/tests/test_communication_mock.py index ffd8d66d..8bee5a86 100644 --- a/src/main/python/main/ayab/tests/test_communication_mock.py +++ b/src/main/python/main/ayab/tests/test_communication_mock.py @@ -73,7 +73,7 @@ def test_req_init_API6(self): assert bytes_read == expected_result # indState shall be sent automatically, also expected_result = ( - bytes([Token.indState.value, 0, 1, 0xFF, 0xFF, 0xFF, 0xFF, 1, 0, 1]), + bytes([Token.indState.value, 0, 1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 1]), Token.indState, 0, )