File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -296,16 +296,18 @@ def ctrl_transfer(
296296 async def setup (self ):
297297 """Initialize the USB connection to the machine."""
298298
299+ if self .dev is not None :
300+ # previous setup did not properly finish,
301+ # or we are re-initializing the device.
302+ logger .warning ("USB device already connected. Closing previous connection." )
303+ await self .stop ()
304+
299305 if not USE_USB :
300306 raise RuntimeError (
301307 "USB is not enabled. Please install pyusb and libusb. "
302308 "https://docs.pylabrobot.org/installation.html"
303309 )
304310
305- if self .dev is not None :
306- logging .warning ("Already initialized. Please call stop() first." )
307- return
308-
309311 logger .info ("Finding USB device..." )
310312
311313 devices = self .get_available_devices ()
You can’t perform that action at this time.
0 commit comments