From 1dce6aa810952b74477ea7424aea95415acd9c42 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 23 Dec 2018 14:55:42 +0100 Subject: [PATCH] Uplink demodulation: Error handling if frame type not found --- uplink/demodulate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/uplink/demodulate.py b/uplink/demodulate.py index 77cd9ea..38cefd2 100755 --- a/uplink/demodulate.py +++ b/uplink/demodulate.py @@ -205,6 +205,12 @@ def hammingDistance(str1, str2): min_hammdist_ftype = ftype best_ftype = int(min_hammdist_ftype, 2) + + if not best_ftype in PACKETLEN_BY_FTYPE: + print("[Frame " + str(count) + "]: Frame type 0x{:03x} not found, ignoring".format(int(ftype, 2))) + print("[Frame " + str(count) + "]: Raw bitstring is " + bitstring) + continue + packetlen = PACKETLEN_BY_FTYPE[best_ftype] print("[Frame " + str(count) + "]: Frame Type is 0x{:03x}".format(best_ftype) + ", Packet Length " + str(packetlen) + " bytes")