import struct def read_u16_le(data: bytes, offset: int) -> int: if offset + 2 > len(data): return None return struct.unpack_from(' float: if offset + 4 > len(data): return None return struct.unpack_from(' 8192: consumed += 1 continue if consumed + pkt_len <= len(stream): packets.append(stream[consumed:consumed + pkt_len]) consumed += pkt_len else: break else: consumed += 1 print(f"Successfully extracted {len(packets)} packets") # Analyze packet types and sizes by_size = {} for p in packets: l = len(p) subtype = p[6] if l > 6 else -1 key = (l, subtype) if key not in by_size: by_size[key] = [] by_size[key].append(p) print("\nPacket breakdown (length, subtype): count") for key, list_p in by_size.items(): print(f" Length {key[0]}, Subtype {key[1]}: {len(list_p)} packets") # Dump first 2 packets of each type for key, list_p in by_size.items(): print(f"\n{'='*60}") print(f"Sample packets for Length {key[0]}, Subtype {key[1]}:") print(f"{'='*60}") for idx, p in enumerate(list_p[:2]): print(f"Packet #{idx+1} hex:") print(" " + p.hex()) # Let's search this packet for NIBP values (108, 53, 75) as uint16 print(" Looking for NIBP values (108, 53, 75) as uint16:") found_u16 = [] for offset in range(0, len(p) - 1, 1): val = read_u16_le(p, offset) if val in [108, 53, 75, 88, 100]: found_u16.append(f"offset {offset}: {val}") if found_u16: print(" uint16 matches: " + ", ".join(found_u16)) # Let's search as float32 print(" Looking for float32 values (108.0, 53.0, 75.0, 88.0, 100.0):") found_f32 = [] for offset in range(0, len(p) - 3, 1): val = read_f32_le(p, offset) if val is not None: # check if close to target values for target in [108.0, 53.0, 75.0, 88.0, 100.0]: if abs(val - target) < 0.1: found_f32.append(f"offset {offset}: {val:.1f}") if found_f32: print(" float32 matches: " + ", ".join(found_f32))