Skip to content

Commit

Permalink
Fix: reatach kernel driver after releasing controller device. Fixes #188
Browse files Browse the repository at this point in the history
  • Loading branch information
kozec committed Mar 29, 2017
1 parent fbd6645 commit 7205b82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scc/drivers/sc_dongle.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def close(self):
# Called when dongle is removed
for c in self._controllers.values():
self.daemon.remove_controller(c)
self._controllers = []
self._controllers = {}
USBDevice.close(self)


Expand Down
7 changes: 4 additions & 3 deletions scc/drivers/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def unclaim(self):
for number in self._claimed:
try:
self.handle.releaseInterface(number)
self.handle.attachKernelDriver(number)
except usb1.USBErrorNoDevice, e:
# Safe to ignore, happens when USB is removed
pass
Expand All @@ -157,12 +158,12 @@ def unclaim(self):

def close(self):
""" Called after device is disconnected """
self.unclaim()
try:
self.handle.close()
self.unclaim()
except: pass
try:
self.device.close()
self.handle.resetDevice()
self.handle.close()
except: pass


Expand Down

0 comments on commit 7205b82

Please sign in to comment.