From a9b6f4aa39a09b546df0cc321b21a09946a0703a Mon Sep 17 00:00:00 2001 From: Blake Warner Date: Thu, 24 Nov 2022 20:17:02 -0500 Subject: [PATCH] reset usb device on error --- nut/Usb.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nut/Usb.py b/nut/Usb.py index f522b8ec0..11c76a45a 100644 --- a/nut/Usb.py +++ b/nut/Usb.py @@ -169,6 +169,7 @@ def getDevice(): time.sleep(1) def daemon(): + dev = None global status Watcher.start() while True: @@ -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)