changeset 1:c623f8832fd7

Tidy up, take cmd line args.
author darius@Inchoate
date Wed, 02 Sep 2009 13:24:44 +0930
parents 6503256a3fc4
children d6d9fba5464d
files test.py
diffstat 1 files changed, 12 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/test.py	Sun Feb 22 21:26:49 2009 +1030
+++ b/test.py	Wed Sep 02 13:24:44 2009 +0930
@@ -1,8 +1,13 @@
-import sirf
-import serial
+import serial, sirf, sys
+
 
 if __name__ == "__main__":
-    s = serial.Serial(port = '/dev/cuad0', baudrate = 9600)
+    if len(sys.argv) > 1:
+        port = sys.argv[1]
+    else:
+        port = '/dev/rfcomm1'
+        
+    s = serial.Serial(port = port, baudrate = 9600)
 
     s.setBaudrate(4800)
     s.flush()
@@ -12,15 +17,8 @@
     s.setBaudrate(9600)
     s.flush()
     
-    
-    s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00])))
-    s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00])))
-    s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00])))
-    s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00])))
-    s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00])))
-    s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00])))
-    s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00])))
-    s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00])))
     p = sirf.Parser()
-    while True:
-        print p.processstr(s.read(1000))
+
+    sirf.disablemsgs(s)
+    sirf.enablemsgs(s)
+    p.dumpmsgs(s)