Mercurial > ~darius > hgwebdir.cgi > sirf
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test.py Sun Feb 22 21:26:49 2009 +1030 @@ -0,0 +1,26 @@ +import sirf +import serial + +if __name__ == "__main__": + s = serial.Serial(port = '/dev/cuad0', baudrate = 9600) + + s.setBaudrate(4800) + s.flush() + # Switch to SiRF and 9600 baud + s.write(sirf.nmea2sirf) + s.flush() + 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))