mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
Update test_ltc_serial.py
This commit is contained in:
parent
8abf2a81bf
commit
04d03b9cbd
1 changed files with 5 additions and 4 deletions
|
|
@ -5,8 +5,8 @@ import re
|
||||||
SERIAL_PORT = "/dev/ttyACM0"
|
SERIAL_PORT = "/dev/ttyACM0"
|
||||||
BAUD_RATE = 115200
|
BAUD_RATE = 115200
|
||||||
|
|
||||||
# Regex pattern to match: [LOCK] 10:00:00:00 | 24.00FPS
|
# 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)")
|
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,10 +18,11 @@ 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
|
||||||
if status == "LOCK":
|
if status == "LOCK":
|
||||||
print(f"🔒 {status} | ⏱ {timecode} | 🎞 {framerate}")
|
print(f"🔒 {status:<4} | ⏱ {timecode} | 🎞 {framerate}")
|
||||||
else:
|
else:
|
||||||
print(f"🟡 {status} | ⏱ {timecode} | 🎞 {framerate}")
|
print(f"🟡 {status:<4} | ⏱ {timecode} | 🎞 {framerate}")
|
||||||
else:
|
else:
|
||||||
if line:
|
if line:
|
||||||
print(f"⚠️ Unrecognised line: {line}")
|
print(f"⚠️ Unrecognised line: {line}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue