From 24806f7e888ecaa3a83ff99068cb88903e775bbb Mon Sep 17 00:00:00 2001 From: Junzi Sun Date: Thu, 6 Jun 2019 11:46:44 +0200 Subject: [PATCH] add downlink format check --- pyModeS/extra/tcpclient.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pyModeS/extra/tcpclient.py b/pyModeS/extra/tcpclient.py index e8d15d0..75f91ef 100644 --- a/pyModeS/extra/tcpclient.py +++ b/pyModeS/extra/tcpclient.py @@ -6,6 +6,7 @@ import os import sys import socket import time +import pyModeS as pms from threading import Thread import traceback @@ -138,8 +139,12 @@ class BaseClient(Thread): # Other message tupe continue - if len(msg) not in [14, 28]: - # incomplete message + df = pms.df(msg) + + # 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 messages.append([msg, ts]) @@ -271,10 +276,10 @@ class BaseClient(Thread): time.sleep(0.001) 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 # for debugging purposes - debug_intent = os.environ.get('PYMODES_DEBUG', None) + debug_intent = os.environ.get('PYMODES_DEBUG', 'false') if debug_intent.lower() == 'true': traceback.print_exc() sys.exit()