From: Neil Mayhew Date: Thu, 10 Dec 2020 03:14:15 +0000 (-0700) Subject: Fix v2 format decoding in btsnooz.py X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9fb790e6c8498b948411eae33530d9fe71316c91;p=android-x86%2Fsystem-bt.git Fix v2 format decoding in btsnooz.py The delta_time_ms field now seems to be 64 bits instead of 32. Without this change, dumps fail to decode and the script exits with a TypeError because type_to_hci encounters an unknown packet type. Bug: 175283029 Test: ./btsnooz.py bugreport-WXYZ.txt Tag: #refactor Sponsor: optedoblivion@ Change-Id: Ib893ee63abacf5335a4cbabb1dbdfc1702da77e6 --- diff --git a/tools/scripts/btsnooz.py b/tools/scripts/btsnooz.py index 5f68f01dd..95d59ce63 100755 --- a/tools/scripts/btsnooz.py +++ b/tools/scripts/btsnooz.py @@ -61,6 +61,7 @@ def type_to_hci(type): return '\x03' if type == TYPE_IN_EVT: return '\x04' + raise RuntimeError("type_to_hci: unknown type (0x{:02x})".format(type)) def decode_snooz(snooz): @@ -120,16 +121,16 @@ def decode_snooz_v2(decompressed, last_timestamp_ms): first_timestamp_ms = last_timestamp_ms + 0x00dcddb30f2f8000 offset = 0 while offset < len(decompressed): - length, packet_length, delta_time_ms, snooz_type = struct.unpack_from('=HHIb', decompressed, offset) - offset += 9 + length - 1 + length, packet_length, delta_time_ms, snooz_type = struct.unpack_from('=HHQb', decompressed, offset) + offset += 13 + length - 1 first_timestamp_ms -= delta_time_ms # Second pass does the actual writing out to stdout. offset = 0 while offset < len(decompressed): - length, packet_length, delta_time_ms, snooz_type = struct.unpack_from('=HHIb', decompressed, offset) + length, packet_length, delta_time_ms, snooz_type = struct.unpack_from('=HHQb', decompressed, offset) first_timestamp_ms += delta_time_ms - offset += 9 + offset += 13 sys.stdout.write(struct.pack('>II', packet_length, length)) sys.stdout.write(struct.pack('>II', type_to_direction(snooz_type), 0)) sys.stdout.write(struct.pack('>II', (first_timestamp_ms >> 32), (first_timestamp_ms & 0xFFFFFFFF)))