mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
tool/dump_tlv: pretty print tag name
This commit is contained in:
parent
fcd21607ce
commit
b50405356d
@ -21,6 +21,8 @@ def read_net_32(f):
|
||||
return -1
|
||||
return ord(a) << 24 | ord(b) << 16 | ord(c) << 8 | ord(d)
|
||||
|
||||
def format_tag(tag):
|
||||
return ''.join([ '%c' % i if (i > 0x20 and i < 128) else '.' for i in tag])
|
||||
|
||||
def as_hex(data):
|
||||
str_list = []
|
||||
@ -51,13 +53,13 @@ with open(infile, 'rb') as fin:
|
||||
pos += 8
|
||||
print("Valid .tlv file")
|
||||
while True:
|
||||
tag = read_net_32(fin)
|
||||
if tag < 0:
|
||||
tag = fin.read(4)
|
||||
if not tag:
|
||||
break
|
||||
pos += 4
|
||||
len = read_net_32(fin)
|
||||
pos += 4
|
||||
packet = fin.read(len)
|
||||
pos += len
|
||||
print('%04x: ' % tag + as_hex(packet))
|
||||
print("'%s' (%s): %s" % (format_tag(tag), as_hex(tag)[0:11], as_hex(packet)))
|
||||
print("Done")
|
||||
|
Loading…
x
Reference in New Issue
Block a user