Skip to content

Commit

Permalink
fixes firmware-update-check timing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andySigler committed Jul 27, 2023
1 parent 50b249a commit 553d2ad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
17 changes: 13 additions & 4 deletions hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
TIP_LENGTH_OVERLAP = 10.5
TIP_LENGTH_LOOKUP = {50: 57.9, 200: 58.35, 1000: 95.6}

RESET_DELAY_SECONDS = 2


@dataclass
class CalibrationSquare:
Expand Down Expand Up @@ -128,6 +130,8 @@ async def update_firmware(
api: OT3API, force: bool = False, subsystems: Optional[List[SubSystem]] = None
) -> None:
"""Update firmware of OT3."""
if not api.is_simulator:
await asyncio.sleep(RESET_DELAY_SECONDS)
subsystems_on_boot = api.attached_subsystems
progress_tracker: Dict[SubSystem, List[int]] = {}

Expand All @@ -150,6 +154,14 @@ def _print_update_progress() -> None:
_print_update_progress()


async def reset_api(api: OT3API) -> None:
"""Reset OT3API."""
if not api.is_simulator:
await asyncio.sleep(RESET_DELAY_SECONDS)
await api.cache_instruments()
await api.refresh_positions()


async def build_async_ot3_hardware_api(
is_simulating: Optional[bool] = False,
use_defaults: Optional[bool] = True,
Expand Down Expand Up @@ -192,13 +204,10 @@ async def build_async_ot3_hardware_api(
print(e)
kwargs["use_usb_bus"] = False # type: ignore[assignment]
api = await builder(loop=loop, **kwargs) # type: ignore[arg-type]
if not is_simulating:
await asyncio.sleep(0.5)
if not is_simulating:
await update_firmware(api)
print(f"Firmware: v{api.fw_version}")
await api.cache_instruments()
await api.refresh_positions()
await reset_api(api)
return api


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Firmware Check."""
from asyncio import run, sleep
from asyncio import run
from typing import List

from opentrons.hardware_control.ot3api import OT3API
Expand All @@ -13,10 +13,12 @@
def _get_instrument_serial_number(api: OT3API, subsystem: SubSystem) -> str:
if subsystem == SubSystem.pipette_right:
_pip = api.hardware_pipettes[OT3Mount.RIGHT.to_mount()]
assert _pip
_pip_id = helpers_ot3.get_pipette_serial_ot3(_pip)
_id = f" ({_pip_id})"
elif subsystem == SubSystem.pipette_left:
_pip = api.hardware_pipettes[OT3Mount.LEFT.to_mount()]
assert _pip
_pip_id = helpers_ot3.get_pipette_serial_ot3(_pip)
_id = f" ({_pip_id})"
elif subsystem == SubSystem.gripper:
Expand All @@ -32,7 +34,6 @@ def _get_instrument_serial_number(api: OT3API, subsystem: SubSystem) -> str:
async def _main(simulate: bool, subsystems: List[SubSystem]) -> None:
api = await helpers_ot3.build_async_ot3_hardware_api(is_simulating=simulate)
while True:
await api.cache_instruments()
for subsys, state in api.attached_subsystems.items():
_id = _get_instrument_serial_number(api, subsys)
print(f" - v{state.current_fw_version}: {subsys.name}{_id}")
Expand All @@ -42,8 +43,7 @@ async def _main(simulate: bool, subsystems: List[SubSystem]) -> None:
print("done")
if api.is_simulator:
break
else:
await sleep(1)
await helpers_ot3.reset_api(api)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ def _listener(message: MessageDefinition, arb_id: ArbitrationId) -> None:
return test_pass


async def _main(test_config: TestConfig) -> None:
async def _main(test_config: TestConfig) -> None: # noqa: C901
global IDEAL_LABWARE_LOCATIONS
global CALIBRATED_LABWARE_LOCATIONS
global FINAL_TEST_RESULTS
Expand Down Expand Up @@ -1567,9 +1567,7 @@ async def _main(test_config: TestConfig) -> None:
arg_parser.add_argument(
"--slot-reservoir", type=int, default=DEFAULT_SLOT_RESERVOIR
)
arg_parser.add_argument(
"--slot-plate", type=int, default=DEFAULT_SLOT_PLATE
)
arg_parser.add_argument("--slot-plate", type=int, default=DEFAULT_SLOT_PLATE)
arg_parser.add_argument("--slot-fixture", type=int, default=DEFAULT_SLOT_FIXTURE)
arg_parser.add_argument("--slot-trash", type=int, default=DEFAULT_SLOT_TRASH)
arg_parser.add_argument("--simulate", action="store_true")
Expand Down

0 comments on commit 553d2ad

Please sign in to comment.