Mercurial > ~darius > hgwebdir.cgi > sirf
comparison test.py @ 1:c623f8832fd7
Tidy up, take cmd line args.
author | darius@Inchoate |
---|---|
date | Wed, 02 Sep 2009 13:24:44 +0930 |
parents | 6503256a3fc4 |
children | 387e6e928567 |
comparison
equal
deleted
inserted
replaced
0:6503256a3fc4 | 1:c623f8832fd7 |
---|---|
1 import sirf | 1 import serial, sirf, sys |
2 import serial | 2 |
3 | 3 |
4 if __name__ == "__main__": | 4 if __name__ == "__main__": |
5 s = serial.Serial(port = '/dev/cuad0', baudrate = 9600) | 5 if len(sys.argv) > 1: |
6 port = sys.argv[1] | |
7 else: | |
8 port = '/dev/rfcomm1' | |
9 | |
10 s = serial.Serial(port = port, baudrate = 9600) | |
6 | 11 |
7 s.setBaudrate(4800) | 12 s.setBaudrate(4800) |
8 s.flush() | 13 s.flush() |
9 # Switch to SiRF and 9600 baud | 14 # Switch to SiRF and 9600 baud |
10 s.write(sirf.nmea2sirf) | 15 s.write(sirf.nmea2sirf) |
11 s.flush() | 16 s.flush() |
12 s.setBaudrate(9600) | 17 s.setBaudrate(9600) |
13 s.flush() | 18 s.flush() |
14 | 19 |
15 | |
16 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00]))) | |
17 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00]))) | |
18 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00]))) | |
19 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00]))) | |
20 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00]))) | |
21 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00]))) | |
22 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00]))) | |
23 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00]))) | |
24 p = sirf.Parser() | 20 p = sirf.Parser() |
25 while True: | 21 |
26 print p.processstr(s.read(1000)) | 22 sirf.disablemsgs(s) |
23 sirf.enablemsgs(s) | |
24 p.dumpmsgs(s) |