mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-03 23:47:08 +00:00
Fix TypeError. Do not call ord() with embty byte object.
This commit is contained in:
parent
d54424c330
commit
1b466dbe99
@ -5,27 +5,30 @@
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def read_net_32(f):
|
||||
a = f.read(1)
|
||||
if a == '':
|
||||
if not a:
|
||||
return -1
|
||||
b = f.read(1)
|
||||
if b == '':
|
||||
if not b:
|
||||
return -1
|
||||
c = f.read(1)
|
||||
if c == '':
|
||||
if not c:
|
||||
return -1
|
||||
d = f.read(1)
|
||||
if d == '':
|
||||
if not d:
|
||||
return -1
|
||||
return ord(a) << 24 | ord(b) << 16 | ord(c) << 8 | ord(d)
|
||||
|
||||
|
||||
def as_hex(data):
|
||||
str_list = []
|
||||
for byte in data:
|
||||
str_list.append("{0:02x} ".format(byte))
|
||||
return ''.join(str_list)
|
||||
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print('Dump TLV file')
|
||||
print('Copyright 2017, BlueKitchen GmbH')
|
||||
@ -37,7 +40,6 @@ infile = sys.argv[1]
|
||||
|
||||
with open(infile, 'rb') as fin:
|
||||
pos = 0
|
||||
try:
|
||||
# check header
|
||||
magic_0 = read_net_32(fin)
|
||||
magic_1 = read_net_32(fin)
|
||||
@ -59,6 +61,3 @@ with open (infile, 'rb') as fin:
|
||||
pos += len
|
||||
print('%04x: ' % tag + as_hex(packet))
|
||||
print("Done")
|
||||
|
||||
except TypeError:
|
||||
print ("Error parsing tlv at offset %u (%x)." % (pos, pos))
|
||||
|
Loading…
Reference in New Issue
Block a user