Skip to content

Commit

Permalink
log message if serial write reports that no bytes were written
Browse files Browse the repository at this point in the history
  • Loading branch information
tannermpeterson committed Jun 2, 2023
1 parent f341043 commit da5cabc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/mantarray_desktop_app/simulators/mc_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
12 changes: 10 additions & 2 deletions src/mantarray_desktop_app/sub_processes/mc_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(),
)
Expand Down

0 comments on commit da5cabc

Please sign in to comment.