From 477d385a483a2095d556699dbf2888f90305db73 Mon Sep 17 00:00:00 2001 From: vegano1 Date: Tue, 6 Aug 2024 11:56:27 -0400 Subject: [PATCH] cleaning up --- .../hardware_control/backends/ot3controller.py | 6 +++--- api/src/opentrons/hardware_control/module_control.py | 4 ++-- .../hardware_control/modules/absorbance_reader.py | 1 + api/src/opentrons/hardware_control/modules/update.py | 12 ++++++++---- api/src/opentrons/hardware_control/poller.py | 5 ----- .../drivers/absorbance_reader/test_driver.py | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/api/src/opentrons/hardware_control/backends/ot3controller.py b/api/src/opentrons/hardware_control/backends/ot3controller.py index 386e6a36159..430b08d946a 100644 --- a/api/src/opentrons/hardware_control/backends/ot3controller.py +++ b/api/src/opentrons/hardware_control/backends/ot3controller.py @@ -494,9 +494,9 @@ def update_feature_flags(self, feature_flags: HardwareFeatureFlags) -> None: async def update_motor_status(self) -> None: """Retreieve motor and encoder status and position from all present nodes""" motor_nodes = self._motor_nodes() - assert len(motor_nodes) - response = await get_motor_position(self._messenger, motor_nodes) - self._handle_motor_status_response(response) + if motor_nodes: + response = await get_motor_position(self._messenger, motor_nodes) + self._handle_motor_status_response(response) async def update_motor_estimation(self, axes: Sequence[Axis]) -> None: """Update motor position estimation for commanded nodes, and update cache of data.""" diff --git a/api/src/opentrons/hardware_control/module_control.py b/api/src/opentrons/hardware_control/module_control.py index 5d9b33b66fc..a24ef20e34a 100644 --- a/api/src/opentrons/hardware_control/module_control.py +++ b/api/src/opentrons/hardware_control/module_control.py @@ -127,8 +127,8 @@ async def unregister_modules( for mod in mods_at_ports: for attached_mod in self.available_modules: if ( - attached_mod.port == mod.port - and attached_mod.serial_number == mod.serial + attached_mod.serial_number == mod.serial + or attached_mod.port == mod.port ): removed_modules.append(attached_mod) diff --git a/api/src/opentrons/hardware_control/modules/absorbance_reader.py b/api/src/opentrons/hardware_control/modules/absorbance_reader.py index d95bd70b5fa..2f7a2b0ea7f 100644 --- a/api/src/opentrons/hardware_control/modules/absorbance_reader.py +++ b/api/src/opentrons/hardware_control/modules/absorbance_reader.py @@ -295,6 +295,7 @@ async def update_device(self, firmware_file_path: str) -> Tuple[bool, str]: log.debug(f"Updating {self.name}: {self.port} with {firmware_file_path}") self._updating = True success, res = await self._driver.update_firmware(firmware_file_path) + self._device_info = await self._driver.get_device_info() await self._poller.start() self._updating = False return success, res diff --git a/api/src/opentrons/hardware_control/modules/update.py b/api/src/opentrons/hardware_control/modules/update.py index f6fd83d0300..07983569035 100644 --- a/api/src/opentrons/hardware_control/modules/update.py +++ b/api/src/opentrons/hardware_control/modules/update.py @@ -141,7 +141,8 @@ async def upload_via_avrdude( "-b{}".format(BAUDRATE), "-D", "-Uflash:w:{}:i".format(firmware_file_path), - **kwargs, + stdout=kwargs["stdout"], + stderr=kwargs["stderr"], ) await proc.wait() @@ -193,8 +194,9 @@ async def upload_via_bossa( "--offset=0x2000", f"{firmware_file_path}", ] - - proc = await asyncio.create_subprocess_exec(*bossa_args, **kwargs) + proc = await asyncio.create_subprocess_exec( + *bossa_args, stdout=kwargs["stdout"], stderr=kwargs["stderr"] + ) stdout, stderr = await proc.communicate() res = stdout.decode() if "Verify successful" in res: @@ -233,7 +235,9 @@ async def upload_via_dfu( f"-D{firmware_file_path}", "-R", ] - proc = await asyncio.create_subprocess_exec(*dfu_args, **kwargs) + proc = await asyncio.create_subprocess_exec( + *dfu_args, stdout=kwargs["stdout"], stderr=kwargs["stderr"] + ) stdout, stderr = await proc.communicate() res = stdout.decode() diff --git a/api/src/opentrons/hardware_control/poller.py b/api/src/opentrons/hardware_control/poller.py index f0dc4c2dfc2..05fd5b18c72 100644 --- a/api/src/opentrons/hardware_control/poller.py +++ b/api/src/opentrons/hardware_control/poller.py @@ -36,10 +36,6 @@ def __init__(self, reader: Reader, interval: float) -> None: self._poll_waiters: List["asyncio.Future[None]"] = [] self._poll_forever_task: Optional["asyncio.Task[None]"] = None - @property - def is_running(self) -> bool: - return self._poll_forever_task is not None - async def start(self) -> None: assert self._poll_forever_task is None, "Poller already started" self._poll_forever_task = asyncio.create_task(self._poll_forever()) @@ -56,7 +52,6 @@ async def stop(self) -> None: await asyncio.gather(task, return_exceptions=True) for waiter in self._poll_waiters: waiter.cancel(msg="Module was removed") - self._poll_forever_task = None async def wait_next_poll(self) -> None: """Wait for the next poll to complete. diff --git a/api/tests/opentrons/drivers/absorbance_reader/test_driver.py b/api/tests/opentrons/drivers/absorbance_reader/test_driver.py index ecda705fa3e..230a4ee5d31 100644 --- a/api/tests/opentrons/drivers/absorbance_reader/test_driver.py +++ b/api/tests/opentrons/drivers/absorbance_reader/test_driver.py @@ -60,7 +60,7 @@ async def test_driver_connect_disconnect( mock_interface.byonoy_open_device.assert_called_once() assert await driver.is_connected() - assert driver._connection.verify_device_handle() + assert driver._connection._verify_device_handle() assert driver._connection._device_handle == 1 mock_interface.byonoy_free_device.return_value = MockErrorCode.BYONOY_ERROR_NO_ERROR