22 lines
720 B
Python
22 lines
720 B
Python
with open("/home/prathiyuman/Prathiyuman/ContecMonitor/fiveparaminte-main/scratch/raw_contec_stream.bin", "rb") as f:
|
|
stream = f.read()
|
|
|
|
packets = []
|
|
i = 0
|
|
while i < len(stream) - 4:
|
|
b0, b1, b2, b3 = stream[i], stream[i+1], stream[i+2], stream[i+3]
|
|
if b3 == 0x46:
|
|
pkt_len = b0 | (b1 << 8)
|
|
if pkt_len == 989 and i + pkt_len <= len(stream):
|
|
packets.append(stream[i:i + pkt_len])
|
|
i += max(pkt_len, 4)
|
|
else:
|
|
i += 1
|
|
|
|
if packets:
|
|
pkt = packets[-1]
|
|
print("Last 100 bytes of 989-byte packet:")
|
|
for off in range(889, 989, 2):
|
|
val = pkt[off] | (pkt[off+1] << 8)
|
|
print(f" Offset {off}: hex={pkt[off]:02x} {pkt[off+1]:02x} -> u16 LE = {val}")
|