diff --git a/src/mantarray_desktop_app/simulators/mc_simulator.py b/src/mantarray_desktop_app/simulators/mc_simulator.py index df674533..0efba861 100644 --- a/src/mantarray_desktop_app/simulators/mc_simulator.py +++ b/src/mantarray_desktop_app/simulators/mc_simulator.py @@ -815,8 +815,9 @@ def read_all(self) -> bytes: """Read all available bytes from the simulator.""" return self._read() - def write(self, input_item: bytes) -> None: + def write(self, input_item: bytes) -> int: self._input_queue.put_nowait(input_item) + return len(input_item) def _drain_all_queues(self) -> Dict[str, Any]: queue_items = { diff --git a/src/mantarray_desktop_app/sub_processes/mc_comm.py b/src/mantarray_desktop_app/sub_processes/mc_comm.py index 64bbc7d4..3b6d56c5 100644 --- a/src/mantarray_desktop_app/sub_processes/mc_comm.py +++ b/src/mantarray_desktop_app/sub_processes/mc_comm.py @@ -461,7 +461,15 @@ def _send_data_packet( board = self._board_connections[board_idx] if board is None: raise NotImplementedError("Board should not be None when sending a command to it") - board.write(data_packet) + + write_len = board.write(data_packet) + if write_len == 0: + put_log_message_into_queue( + logging.INFO, + "Serial data write reporting no bytes written", + self._board_queues[board_idx][1], + self.get_logging_level(), + ) def _commands_for_each_run_iteration(self) -> None: """Ordered actions to perform each iteration. @@ -1028,7 +1036,7 @@ def _handle_data_stream(self) -> None: except serial.SerialException as e: put_log_message_into_queue( logging.INFO, - f"Data read failed: {repr(e)}. Trying one more time", + f"Serial data read failed: {repr(e)}. Trying one more time", self._board_queues[board_idx][1], self.get_logging_level(), )