Default RTL gain of 35 and parser catches negative shifts generated by invalid packets.

This commit is contained in:
Nick Foster
2012-07-16 09:36:15 -07:00
parent 4750d20044
commit c2129e0eab
2 changed files with 10 additions and 2 deletions

View File

@@ -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):