From 8f0f72b5f8f31128c731ede2966730d5f980540b Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 11 Mar 2017 21:42:02 -0800 Subject: [PATCH] Added APRS equations packet support TelemetryEquationsReport will generate a string of equation parameters to scale telemetry data to. --- aprslib/packets/__init__.py | 3 +- aprslib/packets/telemetryequations.py | 47 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 aprslib/packets/telemetryequations.py diff --git a/aprslib/packets/__init__.py b/aprslib/packets/__init__.py index 2ea2558..1a74d58 100644 --- a/aprslib/packets/__init__.py +++ b/aprslib/packets/__init__.py @@ -1,4 +1,5 @@ from aprslib.packets.position import PositionReport from aprslib.packets.telemetry import TelemetryReport from aprslib.packets.telemetryunitlabels import TelemetryUnitLabelsReport -from aprslib.packets.telemetryparameters import TelemetryParametersReport \ No newline at end of file +from aprslib.packets.telemetryparameters import TelemetryParametersReport +from aprslib.packets.telemetryequations import TelemetryEquationsReport \ No newline at end of file diff --git a/aprslib/packets/telemetryequations.py b/aprslib/packets/telemetryequations.py new file mode 100644 index 0000000..1a2e6cf --- /dev/null +++ b/aprslib/packets/telemetryequations.py @@ -0,0 +1,47 @@ +from aprslib.packets.base import APRSPacket + +class TelemetryEquationsReport(APRSPacket): + format = 'raw' + telemetrystation = "N0CALL" + a1a = "0.0" + a1b = "9999.0" + a1c = "0.0" + a2a = "0.0" + a2b = "1.0" + a2c = "0.0" + a3a = "0.0" + a3b = "1.0" + a3c = "0.0" + a4a = "0.0" + a4b = "1.0" + a4c = "0.0" + a5a = "0.0" + a5b = "1.0" + a5c = "0.0" + + def _serialize_body(self): + + body = [ + ':{0} :EQNS.'.format(self.telemetrystation), # packet type + self.a1a, + self.a1b, + self.a1c, + self.a2a, + self.a2b, + self.a2c, + self.a3a, + self.a3b, + self.a3c, + self.a4a, + self.a4b, + self.a4c, + self.a5a, + self.a5b, + self.a5c, + ] + tmpbody = ",".join(body) + badcomma = tmpbody.index(",") + + # remove static but erroneous comma between EQNS. and a1 value + # Position can vary due to callsign + return tmpbody[:badcomma] + tmpbody[badcomma+1:]