"""Sweep the tach via A's override: 800 -> 3500 -> 800 rpm, then override off. Usage: python tools/tach_ramp.py COM10 [step_rpm] [step_ms] Sends 'cfg override rpm N' lines over A's console; A pushes each as a CONFIG frame to B. Ctrl+C aborts and switches the override off. """ import sys import time import serial port = sys.argv[1] if len(sys.argv) > 1 else "COM10" step = int(sys.argv[2]) if len(sys.argv) > 2 else 50 dwell = (int(sys.argv[3]) if len(sys.argv) > 3 else 150) / 1000.0 s = serial.Serial(port, 115200, timeout=0.1) # Native-USB boards reset when the port opens - give A time to boot. time.sleep(4) s.reset_input_buffer() def send(cmd): s.write((cmd + "\n").encode()) s.flush() try: points = list(range(800, 3501, step)) + list(range(3500, 799, -step)) print("ramp: %d points, %d ms each (~%.0f s total)" % (len(points), dwell * 1000, len(points) * dwell)) for rpm in points: send("cfg override rpm %d" % rpm) time.sleep(dwell) finally: send("cfg override off") time.sleep(0.5) s.close() print("done, override off")