Skip to content

Commit

Permalink
Release interface and re-attach kernel drivers when closing port
Browse files Browse the repository at this point in the history
This allows the OS to reuse the FTDI after using the port via pyftdi.
  • Loading branch information
tavip committed Mar 24, 2018
1 parent fa8534f commit 488be84
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pyftdi/ftdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,12 @@ def close(self):
if self.usb_dev:
self.set_bitmode(0, Ftdi.BITMODE_RESET)
self.set_latency_timer(self.LATENCY_MAX)
self.usb_dev._ctx.managed_release_interface(self.usb_dev,
self.index - 1)
try:
self.usb_dev.attach_kernel_driver(self.index - 1)
except (NotImplementedError, usb.core.USBError):
pass
UsbTools.release_device(self.usb_dev)
self.usb_dev = None

Expand Down

0 comments on commit 488be84

Please sign in to comment.