From 84ad11e3108abf75c345bbd06b3d8701810ecb9f Mon Sep 17 00:00:00 2001 From: Mark Jessop Date: Sat, 17 Sep 2022 19:21:21 +0930 Subject: [PATCH] Send all custom fields via UDP broadcast, add baud rate and modulation details to sondehub uploader --- horusdemodlib/__init__.py | 2 +- horusdemodlib/horusudp.py | 5 +++++ horusdemodlib/sondehubamateur.py | 6 ++++++ horusdemodlib/uploader.py | 13 +++++++++++-- pyproject.toml | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/horusdemodlib/__init__.py b/horusdemodlib/__init__.py index 8879c6c..771bc6e 100755 --- a/horusdemodlib/__init__.py +++ b/horusdemodlib/__init__.py @@ -1 +1 @@ -__version__ = "0.3.7" +__version__ = "0.3.9" diff --git a/horusdemodlib/horusudp.py b/horusdemodlib/horusudp.py index bb6bbf9..579a062 100644 --- a/horusdemodlib/horusudp.py +++ b/horusdemodlib/horusudp.py @@ -53,6 +53,11 @@ def send_payload_summary(telemetry, port=55672, comment="HorusDemodLib"): if 'speed' in telemetry: packet['speed'] = telemetry['speed'] + # Add in any field names from the custom field section + if "custom_field_names" in telemetry: + for _custom_field_name in telemetry["custom_field_names"]: + if _custom_field_name in telemetry: + packet[_custom_field_name] = telemetry[_custom_field_name] # Set up our UDP socket _s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) diff --git a/horusdemodlib/sondehubamateur.py b/horusdemodlib/sondehubamateur.py index 8eabefd..f342394 100644 --- a/horusdemodlib/sondehubamateur.py +++ b/horusdemodlib/sondehubamateur.py @@ -213,6 +213,12 @@ def reformat_data(self, telemetry): if "modulation" in telemetry: _output["modulation"] = telemetry["modulation"] + if "modulation_detail" in telemetry: + _output["modulation_detail"] = telemetry["modulation_detail"] + + if "baud_rate" in telemetry: + _output["baud_rate"] = telemetry["baud_rate"] + # Add in any field names from the custom field section if "custom_field_names" in telemetry: for _custom_field_name in telemetry["custom_field_names"]: diff --git a/horusdemodlib/uploader.py b/horusdemodlib/uploader.py index d0168b8..31eae93 100644 --- a/horusdemodlib/uploader.py +++ b/horusdemodlib/uploader.py @@ -72,6 +72,7 @@ def main(): # parser.add_argument("--summary", type=int, default=-1, help="Override user.cfg UDP Summary output port. (NOT IMPLEMENTED)") parser.add_argument("--freq_hz", type=float, default=None, help="Receiver IQ centre frequency in Hz, used in determine the absolute frequency of a telemetry burst.") parser.add_argument("--freq_target_hz", type=float, default=None, help="Receiver 'target' frequency in Hz, used to add metadata to station position info.") + parser.add_argument("--baud_rate", type=int, default=None, help="Modulation baud rate (Hz), used to add additional metadata info.") parser.add_argument("-v", "--verbose", action="store_true", default=False, help="Verbose output (set logging level to DEBUG)") args = parser.parse_args() @@ -184,6 +185,10 @@ def main(): _decoded['f_centre'] = int(demod_stats.fest_mean) + int(args.freq_hz) habitat_uploader.last_freq_hz = _decoded['f_centre'] + # Add in baud rate, if provided. + if args.baud_rate: + _decoded['baud_rate'] = int(args.baud_rate) + # Send via UDP send_payload_summary(_decoded, port=user_config['summary_port']) @@ -229,11 +234,15 @@ def main(): _decoded['f_centre'] = int(demod_stats.fest_mean) + int(args.freq_hz) habitat_uploader.last_freq_hz = _decoded['f_centre'] + # Add in baud rate, if provided. + if args.baud_rate: + _decoded['baud_rate'] = int(args.baud_rate) + # Send via UDP send_payload_summary(_decoded, port=user_config['summary_port']) - # Upload to Habitat - habitat_uploader.add(_decoded['ukhas_str']+'\n') + # Do not upload Horus Binary packets to the Habitat endpoint. + # habitat_uploader.add(_decoded['ukhas_str']+'\n') # Upload the string to Sondehub Amateur sondehub_uploader.add(_decoded) diff --git a/pyproject.toml b/pyproject.toml index 5091a12..0ed422c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "horusdemodlib" -version = "0.3.7" +version = "0.3.9" description = "Project Horus HAB Telemetry Demodulators" authors = ["Mark Jessop"] license = "LGPL-2.1-or-later"