Skip to content
Browse files

Added a battery checking script

  • Loading branch information...
1 parent a103c8c commit d020268d3100353ee2964485fee770ce28adbcaf Hermes Conrad committed Apr 27, 2012
Showing with 31 additions and 0 deletions.
  1. +31 −0 Robotics/Drivers/Hermes/Firmware/batteryCheck.py
View
31 Robotics/Drivers/Hermes/Firmware/batteryCheck.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+import sys
+import serial
+import struct
+
+def main():
+ if(len(sys.argv) != 3):
+ print "Don't you mean..."
+ print "./batteryCheck.py /dev/ttyUSBn 9600"
+ return
+
+ port = sys.argv[1]
+ baud = sys.argv[2]
+
+ ser = serial.Serial(port, baud, timeout=1)
+
+ while(True):
+ byte = ser.read()
+ if(ord(byte) != 101):
+ continue
+
+ # we have a battery
+ vals = ser.read(4)
+ print "%.8f" % struct.unpack('f',vals)[0]
+ break
+
+ ser.close()
+
+
+if __name__ == "__main__":
+ main()

0 comments on commit d020268

Please sign in to comment.
Something went wrong with that request. Please try again.