From fb795285ca99d2c7d66a0771b4859e1fa5967da1 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 24 Jul 2023 14:16:33 +0200 Subject: Add decode_gps.py experiment --- python/experiments/decode_gps.py | 23 +++++++++++++++++++++++ python/igate.py | 5 ++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 python/experiments/decode_gps.py diff --git a/python/experiments/decode_gps.py b/python/experiments/decode_gps.py new file mode 100755 index 0000000..da7904a --- /dev/null +++ b/python/experiments/decode_gps.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +import struct +from math import pow + +EXAMPLE_MSG = b"<\xff\x01HB9EGM-7>APLRT1,WIDE1-1:!/7%=6P\')8[I#Q" + +def decodeEncodedGPS(packet): + """Returns a string with decoded latitude and longitude, or raises ValueError""" + ix = packet.index(b":!/") + gps_packet = packet[ix+3:] + encoded_latitude = gps_packet[:4] + encoded_longitude = gps_packet[4:8] + + (y1, y2, y3, y4) = struct.unpack("APLRG1,qAC:={LATITUDE}L{LONGITUDE}&{COMMENT}" + packet = f"{CALLSIGN}>{APRS_DEVICEID},qAC:={LATITUDE}L{LONGITUDE}&{COMMENT}" try: send_frame_to_aprs_is(packet.encode()) except Exception as ex: -- cgit v1.2.3