Browse Source

Possible fix for pySerial API change in #32

kmpm 8 years ago
parent
commit
df716cc874
1 changed files with 7 additions and 1 deletions
  1. 7 1
      lib/uploader.py

+ 7 - 1
lib/uploader.py

@@ -46,12 +46,18 @@ class Uploader(object):
 
 
             # Wait for the string to be sent before switching baud
             # Wait for the string to be sent before switching baud
             time.sleep(0.1)
             time.sleep(0.1)
-            self._port.setBaudrate(baud)
+            self.set_baudrate(baud)
 
 
             # Get in sync again
             # Get in sync again
             sync()
             sync()
 
 
         self.line_number = 0
         self.line_number = 0
+    
+    def set_baudrate(self, baud):
+        try:
+            self._port.setBaudrate(baud)
+        except AttributeError:
+            self._port.baudrate = baud
 
 
     def expect(self, exp='> ', timeout=TIMEOUT):
     def expect(self, exp='> ', timeout=TIMEOUT):
         """will wait for exp to be returned from nodemcu or timeout"""
         """will wait for exp to be returned from nodemcu or timeout"""