mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
final push for phase 1
This commit is contained in:
parent
c9d0bf0937
commit
007f8ffd7d
1 changed files with 32 additions and 25 deletions
|
|
@ -50,15 +50,15 @@ def run_curses(stdscr):
|
||||||
|
|
||||||
serial_port = find_serial_port()
|
serial_port = find_serial_port()
|
||||||
if not serial_port:
|
if not serial_port:
|
||||||
stdscr.addstr(0, 0, "❌ Could not find Teensy serial port (ACM/USB).")
|
stdscr.addstr(0, 0, "Could not find Teensy serial port (ACM/USB).")
|
||||||
stdscr.refresh()
|
stdscr.refresh()
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ser = serial.Serial(serial_port, BAUD_RATE, timeout=1)
|
ser = serial.Serial(serial_port, BAUD_RATE, timeout=0.1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
stdscr.addstr(0, 0, f"❌ Failed to open {serial_port}: {e}")
|
stdscr.addstr(0, 0, f"Failed to open {serial_port}: {e}")
|
||||||
stdscr.refresh()
|
stdscr.refresh()
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
return
|
return
|
||||||
|
|
@ -72,10 +72,15 @@ def run_curses(stdscr):
|
||||||
sync_requested = False
|
sync_requested = False
|
||||||
syncing = False
|
syncing = False
|
||||||
|
|
||||||
|
read_buffer = ""
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
now = get_system_time()
|
now = get_system_time()
|
||||||
line = ser.readline().decode(errors='ignore').strip()
|
try:
|
||||||
if line:
|
data = ser.read(128).decode(errors='ignore')
|
||||||
|
read_buffer += data
|
||||||
|
while '\n' in read_buffer:
|
||||||
|
line, read_buffer = read_buffer.split('\n', 1)
|
||||||
parsed = parse_ltc_line(line)
|
parsed = parse_ltc_line(line)
|
||||||
if parsed:
|
if parsed:
|
||||||
status, tc_str, fps = parsed
|
status, tc_str, fps = parsed
|
||||||
|
|
@ -97,6 +102,8 @@ def run_curses(stdscr):
|
||||||
sync_feedback = f"[ERR] Failed to sync: {e}"
|
sync_feedback = f"[ERR] Failed to sync: {e}"
|
||||||
sync_requested = False
|
sync_requested = False
|
||||||
syncing = False
|
syncing = False
|
||||||
|
except Exception as e:
|
||||||
|
pass # ignore serial read errors
|
||||||
|
|
||||||
if last_ltc_dt:
|
if last_ltc_dt:
|
||||||
sys_time = now.replace(microsecond=0)
|
sys_time = now.replace(microsecond=0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue