Skip to content

Commit

Permalink
fix(api): Use specified port in tools (#4812)
Browse files Browse the repository at this point in the history
When we switched to apiv2 by default, we didn't go through and fix a specific
issue with write_pipette_memory: that it only respected the port argument in
apiv1. This commit fixes that (and removes some obsolete code).
  • Loading branch information
sfoster1 authored Jan 21, 2020
1 parent b867f96 commit 5351183
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions api/src/opentrons/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@


def connect_to_port(hardware):
parser = optparse.OptionParser(usage='usage: %prog [options] ')
parser.add_option(
"-p", "--p", dest="port", default='',
type='str', help='serial port of the smoothie'
)

options, _ = parser.parse_args(args=sys.argv, values=None)
if options.port:
hardware.connect(options.port)
else:
Expand All @@ -20,15 +14,22 @@ def connect_to_port(hardware):
driver = opentrons.drivers.smoothie_drivers.SimulatingDriver()

try:
if opentrons.config.feature_flags.use_protocol_api_v2():
api = opentrons.hardware_control.API
adapter = opentrons.hardware_control.adapters
hardware = adapter.SynchronousAdapter.build(
api.build_hardware_controller)
driver = hardware._backend._smoothie_driver
api = opentrons.hardware_control.API
adapter = opentrons.hardware_control.adapters
parser = optparse.OptionParser(usage='usage: %prog [options] ')
parser.add_option(
"-p", "--p", dest="port", default='',
type='str', help='serial port of the smoothie'
)

options, _ = parser.parse_args(args=sys.argv, values=None)
if options.port:
port = options.port
else:
hardware = opentrons.robot
connect_to_port(hardware)
driver = hardware._driver
port = None
hardware = adapter.SynchronousAdapter.build(
api.build_hardware_controller, port=port)
driver = hardware._backend._smoothie_driver
except AttributeError:
hardware = None
hardware = None # type: ignore
driver = None # type: ignore

0 comments on commit 5351183

Please sign in to comment.