diff --git a/apollo_fpga/__init__.py b/apollo_fpga/__init__.py index 29bd19b..76fb450 100644 --- a/apollo_fpga/__init__.py +++ b/apollo_fpga/__init__.py @@ -91,13 +91,16 @@ class ApolloDebugger: backend = None - - def __init__(self, force_offline=False, device=None): - """ Sets up a connection to the debugger. """ + def __init__(self, force_offline=False, device=None, ids=None, stub_ids=None): + """Set up a connection to the debugger.""" + if ids is None: + ids = self.APOLLO_USB_IDS + if stub_ids is None: + stub_ids = self.LUNA_USB_IDS # Try to create a connection to our Apollo debug firmware. if device is None: - device = self._find_device(self.APOLLO_USB_IDS, custom_match=self._device_has_apollo_id) + device = self._find_device(ids, custom_match=self._device_has_apollo_id) # If Apollo VID/PID is not found, try to find a gateware VID/PID with a valid Apollo stub # interface. If found, request the gateware to liberate the USB port. In devices with a @@ -105,7 +108,7 @@ def __init__(self, force_offline=False, device=None): if device is None: # First, find the candidate device... - fpga_device = self._find_device(self.LUNA_USB_IDS, custom_match=self._device_has_stub_iface) + fpga_device = self._find_device(stub_ids, custom_match=self._device_has_stub_iface) if fpga_device is None: raise DebuggerNotFound("No Apollo debugger or stub interface found.") elif not force_offline: @@ -118,7 +121,7 @@ def __init__(self, force_offline=False, device=None): raise DebuggerNotFound(f"Handoff request failed: {e.strerror}") # Wait for Apollo to enumerate and try again - device = self._find_device(self.APOLLO_USB_IDS, custom_match=self._device_has_apollo_id, timeout=5000) + device = self._find_device(ids, custom_match=self._device_has_apollo_id, timeout=5000) if device is None: raise DebuggerNotFound("Handoff was requested, but Apollo debugger not found.")