"""One-off: expert rhythm (1.bin) piece mode ends after the piece window; press fretboard only (no pick) after it stops -> must restart (trigger=fret + PITCH).""" import os import sys import time sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import rtt_pitch_reg_test as R def main() -> int: R.import_deps() jlink = R.connect_jlink("AT32F403AC") # same default as rtt_pitch_reg_test try: cb = R.find_rtt_control_block(jlink) if cb is None: print("FAIL: RTT CB not found") return 1 print(f"RTT CB @ 0x{cb:08X}", flush=True) jlink.rtt_start(cb) R.wait_rtt_ready(jlink) sess = R.RttSession(jlink) sess.pump(0.3) sess.cmd("log clear", 0.3) sess.cmd("tone bin1 0", 1.2) # expert + rhythm 1.bin (piece 0..1920ms) sess.cmd("tone start", 0.8) # pick start, piece plays then stops print(">> playing window (piece ~2s) ...", flush=True) sess.pump(4.0) # wait until piece ended, PlayTick frozen base = len(sess.lines) sess.cmd("chord key 0", 0.4) sess.cmd("chord key 8", 0.2) # fretboard only, no pick sess.pump(3.0) # capture restart new = sess.lines[base:] joined = "\n".join(new) trig = [l for l in new if "trigger=fret" in l] change = [l for l in new if "expert/fret change" in l] pitch = [l for l in new if "[PITCH] on" in l] print("---- full session ----", flush=True) for l in sess.lines: print(l, flush=True) print("---- captured after fret-only press ----", flush=True) for l in new: print(l, flush=True) print("---- verdict ----", flush=True) handled = trig or change if handled and pitch: path = "restart" if trig else "note_on-change" print(f"PASS fret-only continue: path={path}, PITCH on x{len(pitch)}") return 0 print("FAIL: no handler log or no pitch") return 1 finally: try: sess.cmd("chord key 23", 0.3) # stop band, leave device quiet sess.pump(0.3) except Exception: pass jlink.close() if __name__ == "__main__": raise SystemExit(main())