Skip to content

Commit

Permalink
reset usb device on error
Browse files Browse the repository at this point in the history
  • Loading branch information
blawar committed Nov 25, 2022
1 parent cf3ac28 commit a9b6f4a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nut/Usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def getDevice():
time.sleep(1)

def daemon():
dev = None
global status
Watcher.start()
while True:
Expand All @@ -195,4 +196,9 @@ def is_in_ep(ep): return usb.util.endpoint_direction(ep.bEndpointAddress) == usb
poll_commands(in_ep, out_ep)
except BaseException as e:
Print.error('usb exception: ' + str(e))

try:
dev.reset()
except:
pass
time.sleep(1)

0 comments on commit a9b6f4a

Please sign in to comment.