From c2129e0eab7af92cbc2e6177bcc25742412ed8ef Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 16 Jul 2012 09:36:15 -0700 Subject: [PATCH] Default RTL gain of 35 and parser catches negative shifts generated by invalid packets. --- apps/uhd_modes.py | 3 ++- python/modes_parse.py | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/uhd_modes.py b/apps/uhd_modes.py index 6f271c7..2650bf1 100755 --- a/apps/uhd_modes.py +++ b/apps/uhd_modes.py @@ -29,6 +29,7 @@ from string import split, join import air_modes import gnuradio.gr.gr_threading as _threading import csv +from air_modes.modes_exceptions import * class top_block_runner(_threading.Thread): def __init__(self, tb): @@ -87,7 +88,7 @@ class adsb_rx_block (gr.top_block): self.u.set_gain_mode(0) #manual gain mode if options.gain is None: - options.gain = 49 + options.gain = 34 self.u.set_gain(options.gain) print "Gain is %i" % self.u.get_gain() diff --git a/python/modes_parse.py b/python/modes_parse.py index f1c3b61..3af9486 100644 --- a/python/modes_parse.py +++ b/python/modes_parse.py @@ -77,9 +77,16 @@ class data_field: def get_bits(self, *args): startbit = args[0] num = args[1] - bits = (self.data \ + try: + bits = (self.data \ >> (self.get_numbits() - startbit - num + self.offset)) \ & ((1 << num) - 1) + #the exception handler catches instances when you try to shift more than + #the number of bits. this can happen when a garbage packet gets through + #which reports itself as a short packet but of type long. + #TODO: should find more productive way to throw this out + except ValueError: + bits = 0 return bits class bds09_reply(data_field):