Update test_ltc_serial.py

handles dropframe
This commit is contained in:
Chris Frankland-Wright 2025-07-07 19:58:42 +01:00 committed by GitHub
parent 04d03b9cbd
commit fb233880d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,12 +1,14 @@
import serial import serial
import re import re
# Adjust this as needed # Adjust as needed
SERIAL_PORT = "/dev/ttyACM0" SERIAL_PORT = "/dev/ttyACM0"
BAUD_RATE = 115200 BAUD_RATE = 115200
# Case-insensitive pattern for: [LOCK] 10:00:00:00 | 25.00fps or FPS # Updated pattern to match drop-frame (;) and non-drop (:) timecode
ltc_pattern = re.compile(r"\[(LOCK|FREE)\]\s+(\d{2}:\d{2}:\d{2}:\d{2})\s+\|\s+([\d.]+fps)", re.IGNORECASE) ltc_pattern = re.compile(
r"\[(LOCK|FREE)\]\s+(\d{2}:\d{2}:\d{2}[:;]\d{2})\s+\|\s+([\d.]+fps)", re.IGNORECASE
)
def main(): def main():
print(f"🔌 Connecting to serial port: {SERIAL_PORT} @ {BAUD_RATE} baud") print(f"🔌 Connecting to serial port: {SERIAL_PORT} @ {BAUD_RATE} baud")
@ -18,7 +20,7 @@ def main():
match = ltc_pattern.match(line) match = ltc_pattern.match(line)
if match: if match:
status, timecode, framerate = match.groups() status, timecode, framerate = match.groups()
framerate = framerate.upper() # Standardise to FPS framerate = framerate.upper()
if status == "LOCK": if status == "LOCK":
print(f"🔒 {status:<4} | ⏱ {timecode} | 🎞 {framerate}") print(f"🔒 {status:<4} | ⏱ {timecode} | 🎞 {framerate}")
else: else: