Parcourir la source

Fix baudrate switching.

Lourens Rozema il y a 9 ans
Parent
commit
94050fe5f1
1 fichiers modifiés avec 9 ajouts et 2 suppressions
  1. 9 2
      nodemcu-uploader.py

+ 9 - 2
nodemcu-uploader.py

@@ -109,8 +109,15 @@ class Uploader:
 
         if baud != Uploader.BAUD:
             log.info('Changing communication to %s baud', baud)
-            self.exchange('uart.setup(0,%s,8,0,1,1)' % baud)
-            self._port.baudrate = baud
+            self.writeln('uart.setup(0,%s,8,0,1,1)' % baud)
+
+            # Wait for the string to be sent before switching baud
+            time.sleep(0.1)
+            self._port.setBaudrate(baud)
+
+            # Get in sync again
+            self.exchange('')
+            self.exchange('')
 
         self.line_number = 0