mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
Update test_ltc_serial.py
handles dropframe
This commit is contained in:
parent
04d03b9cbd
commit
fb233880d1
1 changed files with 6 additions and 4 deletions
|
|
@ -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:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue