#!/usr/bin/env python3
import struct

with open('/Users/admin/workspace/jyq/mcubin/mcu_app.bin', 'rb') as f:
    d = f.read()

# Common baud rates as 32-bit LE
bauds = [9600, 14400, 19200, 38400, 57600, 115200, 230400, 460800, 921600]
for b in bauds:
    packed = struct.pack('<I', b)
    idx = 0
    while True:
        idx = d.find(packed, idx)
        if idx < 0:
            break
        ctx = d[max(0,idx-8):idx+20]
        print(f'Found {b} at offset 0x{idx:04X}: {ctx.hex()}')
        idx += 1

# Also try 16-bit versions
bauds16 = [9600, 14400, 19200, 38400, 57600, 115200, 230400, 460800, 921600]
for b in bauds16:
    packed = struct.pack('<H', b)
    idx = 0
    while True:
        idx = d.find(packed, idx)
        if idx < 0:
            break
        ctx = d[max(0,idx-8):idx+16]
        print(f'Found {b}(16bit) at offset 0x{idx:04X}: {ctx.hex()}')
        idx += 1
