import serial import re # Adjust this as needed SERIAL_PORT = "/dev/ttyACM0" BAUD_RATE = 115200 # Case-insensitive pattern for: [LOCK] 10:00:00:00 | 25.00fps or FPS ltc_pattern = re.compile(r"\[(LOCK|FREE)\]\s+(\d{2}:\d{2}:\d{2}:\d{2})\s+\|\s+([\d.]+fps)", re.IGNORECASE) def main(): print(f"šŸ”Œ Connecting to serial port: {SERIAL_PORT} @ {BAUD_RATE} baud") try: with serial.Serial(SERIAL_PORT, BAUD_RATE, timeout=1) as ser: print("šŸ“” Listening for LTC messages...\n") while True: line = ser.readline().decode(errors='ignore').strip() match = ltc_pattern.match(line) if match: status, timecode, framerate = match.groups() framerate = framerate.upper() # Standardise to FPS if status == "LOCK": print(f"šŸ”’ {status:<4} | ā± {timecode} | šŸŽž {framerate}") else: print(f"🟔 {status:<4} | ā± {timecode} | šŸŽž {framerate}") else: if line: print(f"āš ļø Unrecognised line: {line}") except serial.SerialException as e: print(f"āŒ Serial error: {e}") except KeyboardInterrupt: print("\nšŸ›‘ Stopped by user.") if __name__ == "__main__": main()