diff service/garageArduino/garageArduino.py @ 44:55b68d1e8212

opening usb apparently causes an arduino restart now, so i have to wait for that to pass before beginning communications Ignore-this: 9f34e8914c6bbe3fb54b2c8f5ed01804
author drewp@bigasterisk.com
date Sat, 29 Dec 2012 04:54:54 -0800
parents 62b3bb861e35
children 69b214997213
line wrap: on
line diff
--- a/service/garageArduino/garageArduino.py	Sun Dec 02 16:58:45 2012 -0800
+++ b/service/garageArduino/garageArduino.py	Sat Dec 29 04:54:54 2012 -0800
@@ -35,7 +35,9 @@
 class ArduinoGarage(object):
     def __init__(self, port='/dev/ttyACM0'):
         self.ser = LoggingSerial(port=port, baudrate=115200, timeout=1)
+        time.sleep(2)  # wait for a arduino reset to pass
         self.ser.flush()
+        self.ping()
 
     def ping(self):
         self.ser.write("\x60\x00\x00")
@@ -223,6 +225,7 @@
                 newData = ard.poll()
             except ValueError, e:
                 print e
+                os.abort()
             else:
                 self.lastPollTime = now
                 self.lastValues = newData # for other data besides the blinks