add downlink format check

This commit is contained in:
Junzi Sun 2019-06-06 11:46:44 +02:00
parent 57ad40ec57
commit 24806f7e88

View File

@ -6,6 +6,7 @@ import os
import sys import sys
import socket import socket
import time import time
import pyModeS as pms
from threading import Thread from threading import Thread
import traceback import traceback
@ -138,8 +139,12 @@ class BaseClient(Thread):
# Other message tupe # Other message tupe
continue continue
if len(msg) not in [14, 28]: df = pms.df(msg)
# incomplete message
# skip incomplete message
if df in [0, 4, 5, 11] and len(msg) != 14:
continue
if df in [16, 17, 18, 19, 20, 21, 24] and len(msg) != 28:
continue continue
messages.append([msg, ts]) messages.append([msg, ts])
@ -271,10 +276,10 @@ class BaseClient(Thread):
time.sleep(0.001) time.sleep(0.001)
except Exception as e: except Exception as e:
# Provides the user an option to supply the environment # Provides the user an option to supply the environment
# variable PYMODES_DEBUG to halt the execution # variable PYMODES_DEBUG to halt the execution
# for debugging purposes # for debugging purposes
debug_intent = os.environ.get('PYMODES_DEBUG', None) debug_intent = os.environ.get('PYMODES_DEBUG', 'false')
if debug_intent.lower() == 'true': if debug_intent.lower() == 'true':
traceback.print_exc() traceback.print_exc()
sys.exit() sys.exit()