File: telemetry.py

package info (click to toggle)
python-aprslib 0.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: python: 2,973; makefile: 216
file content (25 lines) | stat: -rw-r--r-- 873 bytes parent folder | download
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
from aprslib.packets.base import APRSPacket

class TelemetryReport(APRSPacket):
    format = 'raw'
    telemetry = dict(seq=0,
                     vals=['0']*6)
    telemetry['vals'][5] = ['1']*8  # Replace io data with list of 8 values
    comment = ''

    def _serialize_body(self):
        # What do we do when len(digitalvalue) != 8?
        tempio = ''.join(self.telemetry['vals'][5])

        body = [
            str(self.telemetry['seq']).zfill(3),
            str(self.telemetry['vals'][0]).zfill(3),
            str(self.telemetry['vals'][1]).zfill(3),
            str(self.telemetry['vals'][2]).zfill(3),
            str(self.telemetry['vals'][3]).zfill(3),
            str(self.telemetry['vals'][4]).zfill(3),
            str(tempio),
            self.comment,
        ]
        # Add packet type to body joined by commas
        return 'T#' + ",".join(body)