Skip to content

Commit

Permalink
gracefully exit gpio
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Jul 26, 2023
1 parent a95ae99 commit ef486d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
25 changes: 15 additions & 10 deletions hardware-testing/hardware_testing/gravimetric/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,19 @@ def _main(args: argparse.Namespace, _ctx: ProtocolContext) -> None:
deck_version="2",
extra_labware=custom_defs,
)
if args.tip == 0:
for tip in get_tip_volumes_for_qc(
args.pipette, args.channels, args.extra, args.photometric
):
hw = _ctx._core.get_hardware()
if not _ctx.is_simulating():
ui.alert_user_ready(f"Ready to run with {tip}ul tip?", hw)
args.tip = tip
try:
if args.tip == 0:
for tip in get_tip_volumes_for_qc(
args.pipette, args.channels, args.extra, args.photometric
):
hw = _ctx._core.get_hardware()
if not _ctx.is_simulating():
ui.alert_user_ready(f"Ready to run with {tip}ul tip?", hw)
args.tip = tip
_main(args, _ctx)
else:
_main(args, _ctx)
else:
_main(args, _ctx)
except Exception:
pass
finally:
_ctx._core.get_hardware()._backend.eeprom_driver._gpio.__del__()
1 change: 1 addition & 0 deletions hardware/opentrons_hardware/drivers/eeprom/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def close(self) -> bool:
logger.debug("Closing eeprom file descriptor")
os.close(self._eeprom_fd)
self._eeprom_fd = -1
self._gpio.__del__()
return True

def property_read(self, prop_ids: Optional[Set[PropId]] = None) -> Set[Property]:
Expand Down
8 changes: 8 additions & 0 deletions hardware/opentrons_hardware/drivers/gpio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ def __init__(self, consumer_name: Optional[str] = None) -> None:
self.deactivate_eeprom_wp()
sleep(1)

def __del__(self) -> None:
try:
self._estop_out_line.release()
self._nsync_out_line.release()
self._eeprom_wp_out_line.release()
except Exception:
pass

def activate_estop(self) -> None:
"""Assert the emergency stop, which will disable all motors."""
self._estop_out_line.set_value(0)
Expand Down

0 comments on commit ef486d4

Please sign in to comment.