annotate test.py @ 4:2fde8c382dae

SiRF uses a 15 bit checksum, see section 1-2
author Daniel O'Connor <darius@dons.net.au>
date Wed, 20 Jun 2012 16:48:55 +0930
parents 387e6e928567
children f3547b32c7c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
1 import serial, sirf, sys
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
2
3
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
3 # Copyright (c) 2009
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
4 # Daniel O'Connor <darius@dons.net.au>. All rights reserved.
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
5 #
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
6 # Redistribution and use in source and binary forms, with or without
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
7 # modification, are permitted provided that the following conditions
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
8 # are met:
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
9 # 1. Redistributions of source code must retain the above copyright
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
10 # notice, this list of conditions and the following disclaimer.
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
11 # 2. Redistributions in binary form must reproduce the above copyright
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
12 # notice, this list of conditions and the following disclaimer in the
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
13 # documentation and/or other materials provided with the distribution.
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
14 #
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
15 # THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
18 # ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
387e6e928567 Add 2 clause BSDL.
Daniel O'Connor <darius@dons.net.au>
parents: 1
diff changeset
25 # SUCH DAMAGE.
0
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
26
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
27 if __name__ == "__main__":
1
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
28 if len(sys.argv) > 1:
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
29 port = sys.argv[1]
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
30 else:
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
31 port = '/dev/rfcomm1'
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
32
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
33 s = serial.Serial(port = port, baudrate = 9600)
0
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
34
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
35 s.setBaudrate(4800)
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
36 s.flush()
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
37 # Switch to SiRF and 9600 baud
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
38 s.write(sirf.nmea2sirf)
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
39 s.flush()
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
40 s.setBaudrate(9600)
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
41 s.flush()
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
42
6503256a3fc4 Prototype code for parsing SiRF messages.
darius@Inchoate
parents:
diff changeset
43 p = sirf.Parser()
1
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
44
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
45 sirf.disablemsgs(s)
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
46 sirf.enablemsgs(s)
c623f8832fd7 Tidy up, take cmd line args.
darius@Inchoate
parents: 0
diff changeset
47 p.dumpmsgs(s)