annotate test.py @ 0:6503256a3fc4

Prototype code for parsing SiRF messages. Seems to work, but needs fleshing out for actual use.
author darius@Inchoate
date Sun, 22 Feb 2009 21:26:49 +1030
parents
children c623f8832fd7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
1 import sirf
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
2 import serial
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
3
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
4 if __name__ == "__main__":
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
5 s = serial.Serial(port = '/dev/cuad0', baudrate = 9600)
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
6
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
7 s.setBaudrate(4800)
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
8 s.flush()
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
9 # Switch to SiRF and 9600 baud
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
10 s.write(sirf.nmea2sirf)
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
11 s.flush()
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
12 s.setBaudrate(9600)
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
13 s.flush()
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
14
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
15
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
16 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00])))
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
17 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00])))
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
18 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00])))
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
19 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00])))
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
20 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00])))
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
21 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00])))
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
22 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00])))
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
23 s.write(sirf.Parser.OrdLsttoStr(sirf.Parser.Encap([0xa6, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00])))
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
24 p = sirf.Parser()
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
25 while True:
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
26 print p.processstr(s.read(1000))