From fa63671ae99751a09e3ced9a265e864fc88fd030 Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Fri, 10 Mar 2017 01:14:22 -0800 Subject: [PATCH 01/11] Created custom telemetry packet report Modeled off of the PositionReport class, I created a TelemetryReport and used similar serialization to create a working packet that was uploaded to aprs.fi for testing. --- aprslib/packets/__init__.py | 1 + aprslib/packets/telemetry.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 aprslib/packets/telemetry.py diff --git a/aprslib/packets/__init__.py b/aprslib/packets/__init__.py index 19914e5..32b8a0c 100644 --- a/aprslib/packets/__init__.py +++ b/aprslib/packets/__init__.py @@ -1 +1,2 @@ from aprslib.packets.position import PositionReport +from aprslib.packets.telemetry import TelemetryReport diff --git a/aprslib/packets/telemetry.py b/aprslib/packets/telemetry.py new file mode 100644 index 0000000..d0504c4 --- /dev/null +++ b/aprslib/packets/telemetry.py @@ -0,0 +1,32 @@ +from aprslib.packets.base import APRSPacket + +class TelemetryReport(APRSPacket): + format = 'raw' + sequenceno = 0 + analog1 = 0 + analog2 = 0 + analog3 = 0 + analog4 = 0 + analog5 = 0 + digitalvalue = ['0']*8 + comment = '' + + def _serialize_body(self): + # What do we do when len(digitalvalue) != 8? + self.digitalvalue = ''.join(self.digitalvalue) + + body = [ + 'T#', # packet type + str(self.sequenceno).zfill(3), + str(self.analog1).zfill(3), + str(self.analog2).zfill(3), + str(self.analog3).zfill(3), + str(self.analog4).zfill(3), + str(self.analog5).zfill(3), + str(self.digitalvalue), + self.comment, + ] + tmpbody = ",".join(body) + + # remove static but erroneous comma between T# and sequenceno + return tmpbody[:2] + tmpbody[3:] From 7e4da837ad86826dea022fe0b0cd2e0d768b4d9b Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 11 Mar 2017 10:49:55 -0800 Subject: [PATCH 02/11] Initial commit with telemetry unit label support Committing initial code that supports the generation of an APRS unit/label string. This was testing by sending telemetry labels to APRS-IS and checked on aprs.fi. Not cleaned up yet. --- aprslib/packets/__init__.py | 1 + aprslib/packets/telemetryunitlabels.py | 43 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 aprslib/packets/telemetryunitlabels.py diff --git a/aprslib/packets/__init__.py b/aprslib/packets/__init__.py index 32b8a0c..79edfb9 100644 --- a/aprslib/packets/__init__.py +++ b/aprslib/packets/__init__.py @@ -1,2 +1,3 @@ from aprslib.packets.position import PositionReport from aprslib.packets.telemetry import TelemetryReport +from aprslib.packets.telemetryunitlabels import TelemetryUnitLabelsReport diff --git a/aprslib/packets/telemetryunitlabels.py b/aprslib/packets/telemetryunitlabels.py new file mode 100644 index 0000000..ffd4aa4 --- /dev/null +++ b/aprslib/packets/telemetryunitlabels.py @@ -0,0 +1,43 @@ +from aprslib.packets.base import APRSPacket + +class TelemetryUnitLabelsReport(APRSPacket): + format = 'raw' + telemetrystation = "N0CALL" + a1 = "BITS" + a2 = "BITS" + a3 = "BITS" + a4 = "BITS" + a5 = "BITS" + b1 = "EN" + b2 = "EN" + b3 = "EN" + b4 = "EN" + b5 = "EN" + b6 = "EN" + b7 = "EN" + b8 = "EN" + comment = '' + + def _serialize_body(self): + + body = [ + ':{0} :UNIT.'.format(self.telemetrystation), # packet type + self.a1, + self.a2, + self.a3, + self.a4, + self.a5, + self.b1, + self.b2, + self.b3, + self.b4, + self.b5, + self.b6, + self.b7, + self.b8, + ] + tmpbody = ",".join(body) + badcomma = tmpbody.index(",") + + # remove static but erroneous comma between UNIT. and a1 value + return tmpbody[:badcomma] + tmpbody[badcomma+1:] From f53d244ca2c5e218a2ad4cda5843c62aa7c588cf Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 11 Mar 2017 11:12:07 -0800 Subject: [PATCH 03/11] Removed unused comment and added comments Commented that the comma search at the end is due to the comma being able to change index due to a varying callsign length for the telemetry callsign. Also removed an unused comment variable. This code does NOT check for valid length of input data. --- aprslib/packets/telemetryunitlabels.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aprslib/packets/telemetryunitlabels.py b/aprslib/packets/telemetryunitlabels.py index ffd4aa4..f5bb2fb 100644 --- a/aprslib/packets/telemetryunitlabels.py +++ b/aprslib/packets/telemetryunitlabels.py @@ -16,7 +16,6 @@ class TelemetryUnitLabelsReport(APRSPacket): b6 = "EN" b7 = "EN" b8 = "EN" - comment = '' def _serialize_body(self): @@ -40,4 +39,5 @@ def _serialize_body(self): badcomma = tmpbody.index(",") # remove static but erroneous comma between UNIT. and a1 value + # Position can vary due to callsign return tmpbody[:badcomma] + tmpbody[badcomma+1:] From c6b87a14f5fdf74b1515b4e5273d986e4f4ab424 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 11 Mar 2017 21:09:06 -0800 Subject: [PATCH 04/11] Added telemetryparameters class to generate parameter string --- aprslib/packets/__init__.py | 1 + aprslib/packets/telemetryparameters.py | 43 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 aprslib/packets/telemetryparameters.py diff --git a/aprslib/packets/__init__.py b/aprslib/packets/__init__.py index 79edfb9..2ea2558 100644 --- a/aprslib/packets/__init__.py +++ b/aprslib/packets/__init__.py @@ -1,3 +1,4 @@ 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 diff --git a/aprslib/packets/telemetryparameters.py b/aprslib/packets/telemetryparameters.py new file mode 100644 index 0000000..c86ef4e --- /dev/null +++ b/aprslib/packets/telemetryparameters.py @@ -0,0 +1,43 @@ +from aprslib.packets.base import APRSPacket + +class TelemetryParametersReport(APRSPacket): + format = 'raw' + telemetrystation = "N0CALL" + a1 = "AN1" + a2 = "AN2" + a3 = "AN3" + a4 = "AN4" + a5 = "AN5" + b1 = "D1" + b2 = "D2" + b3 = "D3" + b4 = "D4" + b5 = "D5" + b6 = "D6" + b7 = "D7" + b8 = "D8" + + def _serialize_body(self): + + body = [ + ':{0} :PARM.'.format(self.telemetrystation), # packet type + self.a1, + self.a2, + self.a3, + self.a4, + self.a5, + self.b1, + self.b2, + self.b3, + self.b4, + self.b5, + self.b6, + self.b7, + self.b8, + ] + tmpbody = ",".join(body) + badcomma = tmpbody.index(",") + + # remove static but erroneous comma between PARM. and a1 value + # Position can vary due to callsign + return tmpbody[:badcomma] + tmpbody[badcomma+1:] From 8f0f72b5f8f31128c731ede2966730d5f980540b Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 11 Mar 2017 21:42:02 -0800 Subject: [PATCH 05/11] 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:] From f992ccfb841ec7dfa1cfea82ed858a3b026be789 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 11 Mar 2017 22:00:28 -0800 Subject: [PATCH 06/11] Changed test scaling a1b to 1.0 --- aprslib/packets/telemetryequations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aprslib/packets/telemetryequations.py b/aprslib/packets/telemetryequations.py index 1a2e6cf..0842415 100644 --- a/aprslib/packets/telemetryequations.py +++ b/aprslib/packets/telemetryequations.py @@ -4,7 +4,7 @@ class TelemetryEquationsReport(APRSPacket): format = 'raw' telemetrystation = "N0CALL" a1a = "0.0" - a1b = "9999.0" + a1b = "1.0" a1c = "0.0" a2a = "0.0" a2b = "1.0" From 5e7701144ffd165500e61df00515b5d89477072a Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 11 Mar 2017 22:15:05 -0800 Subject: [PATCH 07/11] Added TelemetrySenseProjectReport This function sends out only digital IO status telemetry as well as a project name that effectively describes what the APRS station is meant to do. --- aprslib/packets/__init__.py | 3 ++- aprslib/packets/telemetrysenseproject.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 aprslib/packets/telemetrysenseproject.py diff --git a/aprslib/packets/__init__.py b/aprslib/packets/__init__.py index 1a74d58..ae93ef7 100644 --- a/aprslib/packets/__init__.py +++ b/aprslib/packets/__init__.py @@ -2,4 +2,5 @@ from aprslib.packets.telemetry import TelemetryReport from aprslib.packets.telemetryunitlabels import TelemetryUnitLabelsReport from aprslib.packets.telemetryparameters import TelemetryParametersReport -from aprslib.packets.telemetryequations import TelemetryEquationsReport \ No newline at end of file +from aprslib.packets.telemetryequations import TelemetryEquationsReport +from aprslib.packets.telemetrysenseproject import TelemetrySenseProjectReport \ No newline at end of file diff --git a/aprslib/packets/telemetrysenseproject.py b/aprslib/packets/telemetrysenseproject.py new file mode 100644 index 0000000..224ada7 --- /dev/null +++ b/aprslib/packets/telemetrysenseproject.py @@ -0,0 +1,23 @@ +from aprslib.packets.base import APRSPacket + +class TelemetrySenseProjectReport(APRSPacket): + format = 'raw' + telemetrystation = "N0CALL" + digitalvalue = ['0']*8 + project = '' + + def _serialize_body(self): + # What do we do when len(digitalvalue) != 8? + self.digitalvalue = ''.join(self.digitalvalue) + + body = [ + ':{0} :BITS.'.format(self.telemetrystation), # packet type + str(self.digitalvalue), + self.project, + ] + tmpbody = ",".join(body) + badcomma = tmpbody.index(",") + + # remove static but erroneous comma between BITS. and digitalvalue + # Position can vary due to callsign + return tmpbody[:badcomma] + tmpbody[badcomma + 1:] From 5bc2eda3b4d71b1da05034ddc72edf5e0b153179 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 12 Mar 2017 23:29:54 -0700 Subject: [PATCH 08/11] Revert "Merge branch 'faradayrfcustombitprojectname' into faradayrfcustom" This reverts commit 798b2efbe30c8608387c3972499b2f32c4884f06, reversing changes made to 9853c1d2af0f1c7baac7ae0517245a93982fe14d. --- aprslib/packets/__init__.py | 4 -- aprslib/packets/telemetryequations.py | 47 ------------------------ aprslib/packets/telemetryparameters.py | 43 ---------------------- aprslib/packets/telemetrysenseproject.py | 23 ------------ aprslib/packets/telemetryunitlabels.py | 43 ---------------------- 5 files changed, 160 deletions(-) delete mode 100644 aprslib/packets/telemetryequations.py delete mode 100644 aprslib/packets/telemetryparameters.py delete mode 100644 aprslib/packets/telemetrysenseproject.py delete mode 100644 aprslib/packets/telemetryunitlabels.py diff --git a/aprslib/packets/__init__.py b/aprslib/packets/__init__.py index ae93ef7..32b8a0c 100644 --- a/aprslib/packets/__init__.py +++ b/aprslib/packets/__init__.py @@ -1,6 +1,2 @@ from aprslib.packets.position import PositionReport from aprslib.packets.telemetry import TelemetryReport -from aprslib.packets.telemetryunitlabels import TelemetryUnitLabelsReport -from aprslib.packets.telemetryparameters import TelemetryParametersReport -from aprslib.packets.telemetryequations import TelemetryEquationsReport -from aprslib.packets.telemetrysenseproject import TelemetrySenseProjectReport \ No newline at end of file diff --git a/aprslib/packets/telemetryequations.py b/aprslib/packets/telemetryequations.py deleted file mode 100644 index 0842415..0000000 --- a/aprslib/packets/telemetryequations.py +++ /dev/null @@ -1,47 +0,0 @@ -from aprslib.packets.base import APRSPacket - -class TelemetryEquationsReport(APRSPacket): - format = 'raw' - telemetrystation = "N0CALL" - a1a = "0.0" - a1b = "1.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:] diff --git a/aprslib/packets/telemetryparameters.py b/aprslib/packets/telemetryparameters.py deleted file mode 100644 index c86ef4e..0000000 --- a/aprslib/packets/telemetryparameters.py +++ /dev/null @@ -1,43 +0,0 @@ -from aprslib.packets.base import APRSPacket - -class TelemetryParametersReport(APRSPacket): - format = 'raw' - telemetrystation = "N0CALL" - a1 = "AN1" - a2 = "AN2" - a3 = "AN3" - a4 = "AN4" - a5 = "AN5" - b1 = "D1" - b2 = "D2" - b3 = "D3" - b4 = "D4" - b5 = "D5" - b6 = "D6" - b7 = "D7" - b8 = "D8" - - def _serialize_body(self): - - body = [ - ':{0} :PARM.'.format(self.telemetrystation), # packet type - self.a1, - self.a2, - self.a3, - self.a4, - self.a5, - self.b1, - self.b2, - self.b3, - self.b4, - self.b5, - self.b6, - self.b7, - self.b8, - ] - tmpbody = ",".join(body) - badcomma = tmpbody.index(",") - - # remove static but erroneous comma between PARM. and a1 value - # Position can vary due to callsign - return tmpbody[:badcomma] + tmpbody[badcomma+1:] diff --git a/aprslib/packets/telemetrysenseproject.py b/aprslib/packets/telemetrysenseproject.py deleted file mode 100644 index 224ada7..0000000 --- a/aprslib/packets/telemetrysenseproject.py +++ /dev/null @@ -1,23 +0,0 @@ -from aprslib.packets.base import APRSPacket - -class TelemetrySenseProjectReport(APRSPacket): - format = 'raw' - telemetrystation = "N0CALL" - digitalvalue = ['0']*8 - project = '' - - def _serialize_body(self): - # What do we do when len(digitalvalue) != 8? - self.digitalvalue = ''.join(self.digitalvalue) - - body = [ - ':{0} :BITS.'.format(self.telemetrystation), # packet type - str(self.digitalvalue), - self.project, - ] - tmpbody = ",".join(body) - badcomma = tmpbody.index(",") - - # remove static but erroneous comma between BITS. and digitalvalue - # Position can vary due to callsign - return tmpbody[:badcomma] + tmpbody[badcomma + 1:] diff --git a/aprslib/packets/telemetryunitlabels.py b/aprslib/packets/telemetryunitlabels.py deleted file mode 100644 index f5bb2fb..0000000 --- a/aprslib/packets/telemetryunitlabels.py +++ /dev/null @@ -1,43 +0,0 @@ -from aprslib.packets.base import APRSPacket - -class TelemetryUnitLabelsReport(APRSPacket): - format = 'raw' - telemetrystation = "N0CALL" - a1 = "BITS" - a2 = "BITS" - a3 = "BITS" - a4 = "BITS" - a5 = "BITS" - b1 = "EN" - b2 = "EN" - b3 = "EN" - b4 = "EN" - b5 = "EN" - b6 = "EN" - b7 = "EN" - b8 = "EN" - - def _serialize_body(self): - - body = [ - ':{0} :UNIT.'.format(self.telemetrystation), # packet type - self.a1, - self.a2, - self.a3, - self.a4, - self.a5, - self.b1, - self.b2, - self.b3, - self.b4, - self.b5, - self.b6, - self.b7, - self.b8, - ] - tmpbody = ",".join(body) - badcomma = tmpbody.index(",") - - # remove static but erroneous comma between UNIT. and a1 value - # Position can vary due to callsign - return tmpbody[:badcomma] + tmpbody[badcomma+1:] From aa3b1bb165035fc812aeceb639806b992767a8d0 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 12 Mar 2017 23:49:20 -0700 Subject: [PATCH 09/11] Updated telemetry value methodology Per @rossengeorgiev comments on #27 I now use a dictionary with lists to hold telemetry similar to how aprslib holds telemetry when parsed from comments. --- aprslib/packets/telemetry.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/aprslib/packets/telemetry.py b/aprslib/packets/telemetry.py index d0504c4..ff519b9 100644 --- a/aprslib/packets/telemetry.py +++ b/aprslib/packets/telemetry.py @@ -2,28 +2,24 @@ class TelemetryReport(APRSPacket): format = 'raw' - sequenceno = 0 - analog1 = 0 - analog2 = 0 - analog3 = 0 - analog4 = 0 - analog5 = 0 - digitalvalue = ['0']*8 + telemetry = dict(seq=0, + vals=['0']*6) + telemetry['vals'][5] = ['1']*8 comment = '' def _serialize_body(self): # What do we do when len(digitalvalue) != 8? - self.digitalvalue = ''.join(self.digitalvalue) + tempio = ''.join(self.telemetry['vals'][5]) body = [ 'T#', # packet type - str(self.sequenceno).zfill(3), - str(self.analog1).zfill(3), - str(self.analog2).zfill(3), - str(self.analog3).zfill(3), - str(self.analog4).zfill(3), - str(self.analog5).zfill(3), - str(self.digitalvalue), + 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, ] tmpbody = ",".join(body) From e890fe8e3a79a6cd9b70b452ae18ac30299ca8a4 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 12 Mar 2017 23:54:46 -0700 Subject: [PATCH 10/11] Update return statement Much more simple method of only having data in body be joined by commas and tacking that onto a packet type indicator to avoid having to remove a comma later. This was suggested in comments on #27. --- aprslib/packets/telemetry.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/aprslib/packets/telemetry.py b/aprslib/packets/telemetry.py index ff519b9..ca2fb38 100644 --- a/aprslib/packets/telemetry.py +++ b/aprslib/packets/telemetry.py @@ -12,7 +12,6 @@ def _serialize_body(self): tempio = ''.join(self.telemetry['vals'][5]) body = [ - 'T#', # packet type str(self.telemetry['seq']).zfill(3), str(self.telemetry['vals'][0]).zfill(3), str(self.telemetry['vals'][1]).zfill(3), @@ -22,7 +21,5 @@ def _serialize_body(self): str(tempio), self.comment, ] - tmpbody = ",".join(body) - - # remove static but erroneous comma between T# and sequenceno - return tmpbody[:2] + tmpbody[3:] + # Add packet type to body joined by commas + return 'T#' + ",".join(body) From b5b45b3c0965e3a94eaf3e65eaf03f9eee99d9d8 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Mon, 13 Mar 2017 00:03:52 -0700 Subject: [PATCH 11/11] Commented on io value update After creating a value list I update the last item to itself be a list of items. This is so it may hold binary data for IO. --- aprslib/packets/telemetry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aprslib/packets/telemetry.py b/aprslib/packets/telemetry.py index ca2fb38..65e5505 100644 --- a/aprslib/packets/telemetry.py +++ b/aprslib/packets/telemetry.py @@ -4,7 +4,7 @@ class TelemetryReport(APRSPacket): format = 'raw' telemetry = dict(seq=0, vals=['0']*6) - telemetry['vals'][5] = ['1']*8 + telemetry['vals'][5] = ['1']*8 # Replace io data with list of 8 values comment = '' def _serialize_body(self):