From b8a7275c6c5d4aacbce9f5eec52aeee44a12631f Mon Sep 17 00:00:00 2001 From: Tanner Peterson Date: Wed, 15 Apr 2026 16:59:43 -0500 Subject: [PATCH] only set stim schedule mode when connecting to an instrument that is in online mode --- .../src/controller/subsystems/instrument_comm.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/controller/src/controller/subsystems/instrument_comm.py b/controller/src/controller/subsystems/instrument_comm.py index 1708c73..3afe018 100644 --- a/controller/src/controller/subsystems/instrument_comm.py +++ b/controller/src/controller/subsystems/instrument_comm.py @@ -210,8 +210,7 @@ async def _setup(self) -> None: await self._send_data_packet(SerialCommPacketTypes.HANDSHAKE) # register magic word to sync with data stream before starting other tasks await self._register_magic_word() - # now that the magic word is registered, set the stim schedule mode to standard and get metadata - await self._set_to_standard_stim_schedule_mode() + # now that the magic word is registered get metadata await self._prompt_instrument_for_metadata() logger.info("Instrument ready") @@ -722,12 +721,17 @@ async def _process_command_response(self, packet_type: int, response_data: bytes case "check_connection_status": prev_command_info["status"] = response_data[0] self._system_in_offline_mode = response_data[0] == InstrumentConnectionStatuses.OFFLINE - if self._system_in_offline_mode: - self._offline_state_change.set() - logger.info( f"Instrument running in {'offline' if self._system_in_offline_mode else 'online'} mode at time of connection" ) + + if self._system_in_offline_mode: + self._offline_state_change.set() + # stim can only be run in standard schedule mode while offline, so if the instrument is + # in offline mode then the state should be known + else: + # otherwise need to set stim schedule mode to a known state + await self._set_to_standard_stim_schedule_mode() case "end_offline_mode": prev_command_info |= parse_end_offline_mode_bytes(response_data) # need to get sub wells before sending response