""" Search the entire 286-byte and 989-byte packets for the ECG HR value (88). The ECG HR must be somewhere in the packet data. """ import struct with open("/home/prathiyuman/Prathiyuman/ContecMonitor/fiveparaminte-main/scratch/raw_contec_stream.bin", "rb") as f: stream = f.read() # Find all 286-byte packets with SpO2=98 at offset 264 # (indicating a time when the monitor was showing ECG=88, SpO2=98) packets = [] i = 0 while i < len(stream) - 8: if (stream[i + 2] == 0x04 or stream[i + 2] == 0x01) and stream[i + 3] == 0x46: pkt_len = struct.unpack_from(' 36: # Skip to around packet index 147 for off in range(8, l): if pkt[off] != 0: print(f" byte[{off}] = {pkt[off]} (0x{pkt[off]:02x})") break