File: srf.py

package info (click to toggle)
python-nmea2 1.19.0-3
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: python: 2,948; makefile: 3
file content (52 lines) | stat: -rw-r--r-- 1,248 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# SiRF

from ... import nmea


class SRF(nmea.ProprietarySentence):
    sentence_types = {}

    def __new__(_cls, manufacturer, data):
        name = manufacturer + data[0]
        cls = _cls.sentence_types.get(name, _cls)
        return super(SRF, cls).__new__(cls)

    def __init__(self, manufacturer, data):
        self.sentence_type = manufacturer + data[0]
        super(SRF, self).__init__(manufacturer, data)


class SRF103(SRF):
    fields = (
        ("Subtype", "subtype"),
        ('Sentence type', 'sentence'),
        # 00=GGA
        # 01=GLL
        # 02=GSA
        # 03=GSV
        # 04=RMC
        # 05=VTG
        ('Command', 'command'),
        # 0=Set
        # 1=Query
        ('Rate', 'rate'),
        ('Checksum', 'checksum'),
        # 0=No, 1=Yes
    )


class SRF100(SRF):
    fields = (
        ("Subtype", "subtype"),
        ('Protocol', 'protocol'),
        # 0 = SiRF Binary
        # 1 = NMEA
        ('Baud Rate', 'baud'),
        # 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200
        ('Data bits', 'databits'),
        # 8 (, 7 in NMEA)
        ('Stop bits', 'stopbits'),
        # 0, 1
        ('Parity', 'parity'),
        # 0, 1=Odd, 2=Even
    )