From 217909fe02482ac304f8959d3d5681d5543ecefa Mon Sep 17 00:00:00 2001 From: Mark Jessop Date: Sat, 24 Jul 2021 14:25:00 +0930 Subject: [PATCH] Add APRS callsign generation support for M20 sondes, matching dxlAPRS's weird-ass formatting. --- auto_rx/autorx/aprs.py | 3 ++- auto_rx/autorx/decode.py | 1 + auto_rx/autorx/utils.py | 10 ++++++++++ auto_rx/station.cfg.example | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/auto_rx/autorx/aprs.py b/auto_rx/autorx/aprs.py index f23a915..a5c0b2f 100644 --- a/auto_rx/autorx/aprs.py +++ b/auto_rx/autorx/aprs.py @@ -13,6 +13,7 @@ import traceback import socket from threading import Thread, Lock from . import __version__ as auto_rx_version +from .utils import strip_sonde_serial try: # Python 2 @@ -74,7 +75,7 @@ def telemetry_to_aprs_position( # Generate the comment field. _aprs_comment = aprs_comment _aprs_comment = _aprs_comment.replace("", _freq) - _aprs_comment = _aprs_comment.replace("", sonde_data["id"]) + _aprs_comment = _aprs_comment.replace("", strip_sonde_serial(sonde_data["id"])) _aprs_comment = _aprs_comment.replace("", "%.1fC" % sonde_data["temp"]) _aprs_comment = _aprs_comment.replace( "", "%.1fhPa" % sonde_data["pressure"] diff --git a/auto_rx/autorx/decode.py b/auto_rx/autorx/decode.py index a64b605..668420d 100644 --- a/auto_rx/autorx/decode.py +++ b/auto_rx/autorx/decode.py @@ -535,6 +535,7 @@ class SondeDecoder(object): # - Have dropped the low-leakage FIR filter (-F9) to save a bit of CPU # Have scaled back sample rate to 220 kHz to again save CPU. # mk2mod runs at ~90% CPU on a RPi 3, with rtl_fm using ~50% of another core. + # Update 2021-07-24: Updated version with speedups now taking 240 kHz BW and only using 50% of a core. decode_cmd = "%s %s-p %d -d %s %s-M raw -s 240k -f %d 2>/dev/null |" % ( self.sdr_fm, diff --git a/auto_rx/autorx/utils.py b/auto_rx/autorx/utils.py index 390943b..7994441 100644 --- a/auto_rx/autorx/utils.py +++ b/auto_rx/autorx/utils.py @@ -7,6 +7,7 @@ # from __future__ import division, print_function +import codecs import fcntl import logging import os @@ -255,6 +256,15 @@ def generate_aprs_id(sonde_data): # Use the generated id same as dxlAPRS _object_name = sonde_data["aprsid"] + elif "M20" in sonde_data["type"]: + # Generate the M20 ID based on the first two hex digits of the + # raw hexadecimal id, followed by the last decimal section. + # Why we do this and not just use the three hex bytes, nobody knows... + if 'rawid' in sonde_data: + _object_name = "ME" + sonde_data['rawid'].split('_')[1][:2] + sonde_data["id"].split("-")[-1] + else: + _object_name = None + elif "IMET" in sonde_data["type"]: # Use the last 5 characters of the unique ID we have generated. _object_name = "IMET" + sonde_data["id"][-5:] diff --git a/auto_rx/station.cfg.example b/auto_rx/station.cfg.example index c2aa301..bd0bc84 100644 --- a/auto_rx/station.cfg.example +++ b/auto_rx/station.cfg.example @@ -249,7 +249,7 @@ aprs_position_report = False # - Battery Voltage (e.g. 3.1V) # The default comment (below) is compatible with radiosondy.info's parsers, and should only be modified # if absolutely necessary. -aprs_custom_comment = Clb= t= h= p= Type= Radiosonde +aprs_custom_comment = Clb= t= h= p= Type= ser= Radiosonde ###########################