Explorar o código

gw: Reopen serial connection after resetting it.
Seems to more reliably flush the buffers on both Linux and Windows.

Keir Fraser %!s(int64=4) %!d(string=hai) anos
pai
achega
a28c52624b
Modificáronse 2 ficheiros con 2 adicións e 2 borrados
  1. 0 2
      scripts/greaseweazle/tools/util.py
  2. 2 0
      scripts/greaseweazle/usb.py

+ 0 - 2
scripts/greaseweazle/tools/util.py

@@ -185,8 +185,6 @@ def with_drive_selected(fn, usb, args, *_args, **_kwargs):
     except KeyboardInterrupt:
     except KeyboardInterrupt:
         print()
         print()
         usb.reset()
         usb.reset()
-        usb.ser.close()
-        usb.ser.open()
         raise
         raise
     finally:
     finally:
         usb.drive_motor(args.drive[1], False)
         usb.drive_motor(args.drive[1], False)

+ 2 - 0
scripts/greaseweazle/usb.py

@@ -191,6 +191,8 @@ class Unit:
         self.ser.baudrate = ControlCmd.ClearComms
         self.ser.baudrate = ControlCmd.ClearComms
         self.ser.baudrate = ControlCmd.Normal
         self.ser.baudrate = ControlCmd.Normal
         self.ser.reset_input_buffer()
         self.ser.reset_input_buffer()
+        self.ser.close()
+        self.ser.open()
 
 
 
 
     ## _send_cmd:
     ## _send_cmd: