From a47a0e6bd31c7783049986cbe8e6261918ddcb8c Mon Sep 17 00:00:00 2001 From: Chris Frankland-Wright <85807217+cjfranko@users.noreply.github.com> Date: Sat, 19 Jul 2025 12:29:10 +0100 Subject: [PATCH 1/6] double check upload of tested version --- src/config.rs | 138 +++++++------- src/main.rs | 162 ++++++++--------- src/serial_input.rs | 112 ++++++------ src/sync_logic.rs | 274 ++++++++++++++-------------- src/ui.rs | 424 ++++++++++++++++++++++---------------------- 5 files changed, 555 insertions(+), 555 deletions(-) diff --git a/src/config.rs b/src/config.rs index 2504450..a9bf931 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,69 +1,69 @@ -// src/config.rs - -use notify::{ - recommended_watcher, Event, EventKind, RecommendedWatcher, RecursiveMode, Result as NotifyResult, - Watcher, -}; -use serde::Deserialize; -use std::{ - fs::File, - io::Read, - path::PathBuf, - sync::{Arc, Mutex}, -}; - -#[derive(Deserialize)] -pub struct Config { - pub hardware_offset_ms: i64, -} - -impl Config { - pub fn load(path: &PathBuf) -> Self { - let mut file = match File::open(path) { - Ok(f) => f, - Err(_) => return Self { hardware_offset_ms: 0 }, - }; - let mut contents = String::new(); - if file.read_to_string(&mut contents).is_err() { - return Self { hardware_offset_ms: 0 }; - } - serde_json::from_str(&contents).unwrap_or(Self { hardware_offset_ms: 0 }) - } -} - -pub fn watch_config(path: &str) -> Arc> { - let initial = Config::load(&PathBuf::from(path)).hardware_offset_ms; - let offset = Arc::new(Mutex::new(initial)); - - // Owned PathBuf for watch() call - let watch_path = PathBuf::from(path); - // Clone for moving into the closure - let watch_path_for_cb = watch_path.clone(); - let offset_for_cb = Arc::clone(&offset); - - std::thread::spawn(move || { - // Move `watch_path_for_cb` into the callback - let mut watcher: RecommendedWatcher = recommended_watcher(move |res: NotifyResult| { - if let Ok(evt) = res { - if matches!(evt.kind, EventKind::Modify(_)) { - let new_cfg = Config::load(&watch_path_for_cb); - let mut hw = offset_for_cb.lock().unwrap(); - *hw = new_cfg.hardware_offset_ms; - eprintln!("🔄 Reloaded hardware_offset_ms = {}", *hw); - } - } - }) - .expect("Failed to create file watcher"); - - // Use the original `watch_path` here - watcher - .watch(&watch_path, RecursiveMode::NonRecursive) - .expect("Failed to watch config.json"); - - loop { - std::thread::sleep(std::time::Duration::from_secs(60)); - } - }); - - offset -} +// src/config.rs + +use notify::{ + recommended_watcher, Event, EventKind, RecommendedWatcher, RecursiveMode, Result as NotifyResult, + Watcher, +}; +use serde::Deserialize; +use std::{ + fs::File, + io::Read, + path::PathBuf, + sync::{Arc, Mutex}, +}; + +#[derive(Deserialize)] +pub struct Config { + pub hardware_offset_ms: i64, +} + +impl Config { + pub fn load(path: &PathBuf) -> Self { + let mut file = match File::open(path) { + Ok(f) => f, + Err(_) => return Self { hardware_offset_ms: 0 }, + }; + let mut contents = String::new(); + if file.read_to_string(&mut contents).is_err() { + return Self { hardware_offset_ms: 0 }; + } + serde_json::from_str(&contents).unwrap_or(Self { hardware_offset_ms: 0 }) + } +} + +pub fn watch_config(path: &str) -> Arc> { + let initial = Config::load(&PathBuf::from(path)).hardware_offset_ms; + let offset = Arc::new(Mutex::new(initial)); + + // Owned PathBuf for watch() call + let watch_path = PathBuf::from(path); + // Clone for moving into the closure + let watch_path_for_cb = watch_path.clone(); + let offset_for_cb = Arc::clone(&offset); + + std::thread::spawn(move || { + // Move `watch_path_for_cb` into the callback + let mut watcher: RecommendedWatcher = recommended_watcher(move |res: NotifyResult| { + if let Ok(evt) = res { + if matches!(evt.kind, EventKind::Modify(_)) { + let new_cfg = Config::load(&watch_path_for_cb); + let mut hw = offset_for_cb.lock().unwrap(); + *hw = new_cfg.hardware_offset_ms; + eprintln!("🔄 Reloaded hardware_offset_ms = {}", *hw); + } + } + }) + .expect("Failed to create file watcher"); + + // Use the original `watch_path` here + watcher + .watch(&watch_path, RecursiveMode::NonRecursive) + .expect("Failed to watch config.json"); + + loop { + std::thread::sleep(std::time::Duration::from_secs(60)); + } + }); + + offset +} diff --git a/src/main.rs b/src/main.rs index 68cf071..2464a0e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,81 +1,81 @@ -// src/main.rs - -mod config; -mod sync_logic; -mod serial_input; -mod ui; - -use crate::config::watch_config; -use crate::sync_logic::LtcState; -use crate::serial_input::start_serial_thread; -use crate::ui::start_ui; - -use std::{ - fs, - path::Path, - sync::{Arc, Mutex, mpsc}, - thread, -}; - -/// Embed the default config.json at compile time. -const DEFAULT_CONFIG: &str = include_str!("../config.json"); - -/// If no `config.json` exists alongside the binary, write out the default. -fn ensure_config() { - let p = Path::new("config.json"); - if !p.exists() { - fs::write(p, DEFAULT_CONFIG) - .expect("Failed to write default config.json"); - eprintln!("⚙️ Emitted default config.json"); - } -} - -fn main() { - // 🔄 Ensure there's always a config.json present - ensure_config(); - - // 1️⃣ Start watching config.json for changes - let hw_offset = watch_config("config.json"); - println!("🔧 Watching config.json (hardware_offset_ms)..."); - - // 2️⃣ Channel for raw LTC frames - let (tx, rx) = mpsc::channel(); - println!("✅ Channel created"); - - // 3️⃣ Shared state for UI and serial reader - let ltc_state = Arc::new(Mutex::new(LtcState::new())); - println!("✅ State initialised"); - - // 4️⃣ Spawn the serial reader thread (no offset here) - { - let tx_clone = tx.clone(); - let state_clone = ltc_state.clone(); - thread::spawn(move || { - println!("🚀 Serial thread launched"); - start_serial_thread( - "/dev/ttyACM0", - 115200, - tx_clone, - state_clone, - 0, // ignored in serial path - ); - }); - } - - // 5️⃣ Spawn the UI renderer thread, passing the live offset Arc - { - let ui_state = ltc_state.clone(); - let offset_clone = hw_offset.clone(); - let port = "/dev/ttyACM0".to_string(); - thread::spawn(move || { - println!("🖥️ UI thread launched"); - start_ui(ui_state, port, offset_clone); - }); - } - - // 6️⃣ Keep main thread alive - println!("📡 Main thread entering loop..."); - for _frame in rx { - // no-op - } -} +// src/main.rs + +mod config; +mod sync_logic; +mod serial_input; +mod ui; + +use crate::config::watch_config; +use crate::sync_logic::LtcState; +use crate::serial_input::start_serial_thread; +use crate::ui::start_ui; + +use std::{ + fs, + path::Path, + sync::{Arc, Mutex, mpsc}, + thread, +}; + +/// Embed the default config.json at compile time. +const DEFAULT_CONFIG: &str = include_str!("../config.json"); + +/// If no `config.json` exists alongside the binary, write out the default. +fn ensure_config() { + let p = Path::new("config.json"); + if !p.exists() { + fs::write(p, DEFAULT_CONFIG) + .expect("Failed to write default config.json"); + eprintln!("⚙️ Emitted default config.json"); + } +} + +fn main() { + // 🔄 Ensure there's always a config.json present + ensure_config(); + + // 1️⃣ Start watching config.json for changes + let hw_offset = watch_config("config.json"); + println!("🔧 Watching config.json (hardware_offset_ms)..."); + + // 2️⃣ Channel for raw LTC frames + let (tx, rx) = mpsc::channel(); + println!("✅ Channel created"); + + // 3️⃣ Shared state for UI and serial reader + let ltc_state = Arc::new(Mutex::new(LtcState::new())); + println!("✅ State initialised"); + + // 4️⃣ Spawn the serial reader thread (no offset here) + { + let tx_clone = tx.clone(); + let state_clone = ltc_state.clone(); + thread::spawn(move || { + println!("🚀 Serial thread launched"); + start_serial_thread( + "/dev/ttyACM0", + 115200, + tx_clone, + state_clone, + 0, // ignored in serial path + ); + }); + } + + // 5️⃣ Spawn the UI renderer thread, passing the live offset Arc + { + let ui_state = ltc_state.clone(); + let offset_clone = hw_offset.clone(); + let port = "/dev/ttyACM0".to_string(); + thread::spawn(move || { + println!("🖥️ UI thread launched"); + start_ui(ui_state, port, offset_clone); + }); + } + + // 6️⃣ Keep main thread alive + println!("📡 Main thread entering loop..."); + for _frame in rx { + // no-op + } +} diff --git a/src/serial_input.rs b/src/serial_input.rs index c180433..39e2be7 100644 --- a/src/serial_input.rs +++ b/src/serial_input.rs @@ -1,56 +1,56 @@ -// src/serial_input.rs - -use std::io::BufRead; -use std::sync::{Arc, Mutex}; -use std::sync::mpsc::Sender; -use chrono::Utc; -use regex::Regex; -use crate::sync_logic::{LtcFrame, LtcState}; - -pub fn start_serial_thread( - port_path: &str, - baud_rate: u32, - sender: Sender, - state: Arc>, - _hardware_offset_ms: i64, // no longer used here -) { - println!("📡 Opening serial port {} @ {} baud", port_path, baud_rate); - - let port = match serialport::new(port_path, baud_rate) - .timeout(std::time::Duration::from_millis(1000)) - .open() - { - Ok(p) => { - println!("✅ Serial port opened"); - p - } - Err(e) => { - eprintln!("❌ Serial open failed: {}", e); - return; - } - }; - - let reader = std::io::BufReader::new(port); - let re = Regex::new( - r"\[(LOCK|FREE)\]\s+(\d{2}):(\d{2}):(\d{2})[:;](\d{2})\s+\|\s+([\d.]+)fps", - ) - .unwrap(); - - println!("🔄 Entering LTC read loop…"); - for line in reader.lines() { - if let Ok(text) = line { - if let Some(caps) = re.captures(&text) { - let arrival = Utc::now(); - if let Some(frame) = LtcFrame::from_regex(&caps, arrival) { - // update LOCK/FREE counts & timestamp - { - let mut st = state.lock().unwrap(); - st.update(frame.clone()); - } - // forward raw frame - let _ = sender.send(frame); - } - } - } - } -} +// src/serial_input.rs + +use std::io::BufRead; +use std::sync::{Arc, Mutex}; +use std::sync::mpsc::Sender; +use chrono::Utc; +use regex::Regex; +use crate::sync_logic::{LtcFrame, LtcState}; + +pub fn start_serial_thread( + port_path: &str, + baud_rate: u32, + sender: Sender, + state: Arc>, + _hardware_offset_ms: i64, // no longer used here +) { + println!("📡 Opening serial port {} @ {} baud", port_path, baud_rate); + + let port = match serialport::new(port_path, baud_rate) + .timeout(std::time::Duration::from_millis(1000)) + .open() + { + Ok(p) => { + println!("✅ Serial port opened"); + p + } + Err(e) => { + eprintln!("❌ Serial open failed: {}", e); + return; + } + }; + + let reader = std::io::BufReader::new(port); + let re = Regex::new( + r"\[(LOCK|FREE)\]\s+(\d{2}):(\d{2}):(\d{2})[:;](\d{2})\s+\|\s+([\d.]+)fps", + ) + .unwrap(); + + println!("🔄 Entering LTC read loop…"); + for line in reader.lines() { + if let Ok(text) = line { + if let Some(caps) = re.captures(&text) { + let arrival = Utc::now(); + if let Some(frame) = LtcFrame::from_regex(&caps, arrival) { + // update LOCK/FREE counts & timestamp + { + let mut st = state.lock().unwrap(); + st.update(frame.clone()); + } + // forward raw frame + let _ = sender.send(frame); + } + } + } + } +} diff --git a/src/sync_logic.rs b/src/sync_logic.rs index f2a0e2b..3b9f435 100644 --- a/src/sync_logic.rs +++ b/src/sync_logic.rs @@ -1,137 +1,137 @@ -// src/sync_logic.rs - -use chrono::{DateTime, Local, Timelike, Utc}; -use regex::Captures; -use std::collections::VecDeque; - -#[derive(Clone, Debug)] -pub struct LtcFrame { - pub status: String, - pub hours: u32, - pub minutes: u32, - pub seconds: u32, - pub frames: u32, - pub frame_rate: f64, - pub timestamp: DateTime, // arrival stamp -} - -impl LtcFrame { - pub fn from_regex(caps: &Captures, timestamp: DateTime) -> Option { - Some(Self { - status: caps[1].to_string(), - hours: caps[2].parse().ok()?, - minutes: caps[3].parse().ok()?, - seconds: caps[4].parse().ok()?, - frames: caps[5].parse().ok()?, - frame_rate: caps[6].parse().ok()?, - timestamp, - }) - } - - /// Compare just HH:MM:SS against local time. - pub fn matches_system_time(&self) -> bool { - let local = Local::now(); - local.hour() == self.hours - && local.minute() == self.minutes - && local.second() == self.seconds - } -} - -pub struct LtcState { - pub latest: Option, - pub lock_count: u32, - pub free_count: u32, - /// Stores the last up-to-20 raw offset measurements in ms. - pub offset_history: VecDeque, - pub last_match_status: String, - pub last_match_check: i64, -} - -impl LtcState { - pub fn new() -> Self { - Self { - latest: None, - lock_count: 0, - free_count: 0, - offset_history: VecDeque::with_capacity(20), - last_match_status: "UNKNOWN".into(), - last_match_check: 0, - } - } - - /// Record one measured offset in ms, maintaining a sliding window of up to 20 samples. - pub fn record_offset(&mut self, offset_ms: i64) { - if self.offset_history.len() == 20 { - self.offset_history.pop_front(); - } - self.offset_history.push_back(offset_ms); - } - - /// Clear all stored offset measurements (e.g. on FREE-run). - pub fn clear_offsets(&mut self) { - self.offset_history.clear(); - } - - /// Update LOCK/FREE counts, clear offsets on FREE, and refresh timecode-match every 5 s. - pub fn update(&mut self, frame: LtcFrame) { - match frame.status.as_str() { - "LOCK" => { - self.lock_count += 1; - } - "FREE" => { - self.free_count += 1; - self.clear_offsets(); - self.last_match_status = "UNKNOWN".into(); - } - _ => {} - } - - // Every 5 seconds, recompute whether HH:MM:SS matches local time - let now_secs = Utc::now().timestamp(); - if now_secs - self.last_match_check >= 5 { - self.last_match_status = if frame.matches_system_time() { - "IN SYNC".into() - } else { - "OUT OF SYNC".into() - }; - self.last_match_check = now_secs; - } - - self.latest = Some(frame); - } - - /// Average jitter over the stored history, in milliseconds. - pub fn average_jitter(&self) -> i64 { - if self.offset_history.is_empty() { - 0 - } else { - let sum: i64 = self.offset_history.iter().sum(); - sum / (self.offset_history.len() as i64) - } - } - - /// Convert that average jitter into frames (rounded). - pub fn average_frames(&self) -> i64 { - if let Some(frame) = &self.latest { - let ms_per_frame = 1000.0 / frame.frame_rate; - (self.average_jitter() as f64 / ms_per_frame).round() as i64 - } else { - 0 - } - } - - /// Percentage of samples seen in LOCK state versus total. - pub fn lock_ratio(&self) -> f64 { - let total = self.lock_count + self.free_count; - if total == 0 { - 0.0 - } else { - (self.lock_count as f64 / total as f64) * 100.0 - } - } - - /// Get the last computed timecode‐match status ("IN SYNC", "OUT OF SYNC", or "UNKNOWN"). - pub fn timecode_match(&self) -> &str { - &self.last_match_status - } -} +// src/sync_logic.rs + +use chrono::{DateTime, Local, Timelike, Utc}; +use regex::Captures; +use std::collections::VecDeque; + +#[derive(Clone, Debug)] +pub struct LtcFrame { + pub status: String, + pub hours: u32, + pub minutes: u32, + pub seconds: u32, + pub frames: u32, + pub frame_rate: f64, + pub timestamp: DateTime, // arrival stamp +} + +impl LtcFrame { + pub fn from_regex(caps: &Captures, timestamp: DateTime) -> Option { + Some(Self { + status: caps[1].to_string(), + hours: caps[2].parse().ok()?, + minutes: caps[3].parse().ok()?, + seconds: caps[4].parse().ok()?, + frames: caps[5].parse().ok()?, + frame_rate: caps[6].parse().ok()?, + timestamp, + }) + } + + /// Compare just HH:MM:SS against local time. + pub fn matches_system_time(&self) -> bool { + let local = Local::now(); + local.hour() == self.hours + && local.minute() == self.minutes + && local.second() == self.seconds + } +} + +pub struct LtcState { + pub latest: Option, + pub lock_count: u32, + pub free_count: u32, + /// Stores the last up-to-20 raw offset measurements in ms. + pub offset_history: VecDeque, + pub last_match_status: String, + pub last_match_check: i64, +} + +impl LtcState { + pub fn new() -> Self { + Self { + latest: None, + lock_count: 0, + free_count: 0, + offset_history: VecDeque::with_capacity(20), + last_match_status: "UNKNOWN".into(), + last_match_check: 0, + } + } + + /// Record one measured offset in ms, maintaining a sliding window of up to 20 samples. + pub fn record_offset(&mut self, offset_ms: i64) { + if self.offset_history.len() == 20 { + self.offset_history.pop_front(); + } + self.offset_history.push_back(offset_ms); + } + + /// Clear all stored offset measurements (e.g. on FREE-run). + pub fn clear_offsets(&mut self) { + self.offset_history.clear(); + } + + /// Update LOCK/FREE counts, clear offsets on FREE, and refresh timecode-match every 5 s. + pub fn update(&mut self, frame: LtcFrame) { + match frame.status.as_str() { + "LOCK" => { + self.lock_count += 1; + } + "FREE" => { + self.free_count += 1; + self.clear_offsets(); + self.last_match_status = "UNKNOWN".into(); + } + _ => {} + } + + // Every 5 seconds, recompute whether HH:MM:SS matches local time + let now_secs = Utc::now().timestamp(); + if now_secs - self.last_match_check >= 5 { + self.last_match_status = if frame.matches_system_time() { + "IN SYNC".into() + } else { + "OUT OF SYNC".into() + }; + self.last_match_check = now_secs; + } + + self.latest = Some(frame); + } + + /// Average jitter over the stored history, in milliseconds. + pub fn average_jitter(&self) -> i64 { + if self.offset_history.is_empty() { + 0 + } else { + let sum: i64 = self.offset_history.iter().sum(); + sum / (self.offset_history.len() as i64) + } + } + + /// Convert that average jitter into frames (rounded). + pub fn average_frames(&self) -> i64 { + if let Some(frame) = &self.latest { + let ms_per_frame = 1000.0 / frame.frame_rate; + (self.average_jitter() as f64 / ms_per_frame).round() as i64 + } else { + 0 + } + } + + /// Percentage of samples seen in LOCK state versus total. + pub fn lock_ratio(&self) -> f64 { + let total = self.lock_count + self.free_count; + if total == 0 { + 0.0 + } else { + (self.lock_count as f64 / total as f64) * 100.0 + } + } + + /// Get the last computed timecode‐match status ("IN SYNC", "OUT OF SYNC", or "UNKNOWN"). + pub fn timecode_match(&self) -> &str { + &self.last_match_status + } +} diff --git a/src/ui.rs b/src/ui.rs index 66c485f..68dd064 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,212 +1,212 @@ -// src/ui.rs - -use std::{ - io::{stdout, Write}, - process::{self, Command}, - sync::{Arc, Mutex}, - thread, - time::Duration, -}; - -use chrono::{Local, Timelike, Utc}; -use crossterm::{ - cursor::{Hide, MoveTo, Show}, - event::{poll, read, Event, KeyCode}, - execute, queue, - style::{Color, Print, ResetColor, SetForegroundColor}, - terminal::{self, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen}, -}; - -use crate::sync_logic::LtcState; - -/// Launch the TUI; reads `offset` live from the file-watcher. -pub fn start_ui( - state: Arc>, - serial_port: String, - offset: Arc>, -) { - let mut stdout = stdout(); - execute!(stdout, EnterAlternateScreen).unwrap(); - terminal::enable_raw_mode().unwrap(); - - loop { - // 1️⃣ Read current hardware offset - let hw_offset_ms = *offset.lock().unwrap(); - - // 2️⃣ Measure & record jitter only when LOCKED; clear on FREE - { - let mut st = state.lock().unwrap(); - if let Some(frame) = &st.latest { - if frame.status == "LOCK" { - let now = Utc::now(); - let raw = (now - frame.timestamp).num_milliseconds(); - let measured = raw - hw_offset_ms; - st.record_offset(measured); - } else { - st.clear_offsets(); - } - } - } - - // 3️⃣ Draw static UI - queue!( - stdout, - MoveTo(0, 0), - Clear(ClearType::All), - Hide, - MoveTo(2, 1), Print("NTP Timeturner v2 - Rust Port"), - MoveTo(2, 2), Print(format!("Using Serial Port: {}", serial_port)), - ) - .unwrap(); - - if let Ok(st) = state.lock() { - if let Some(frame) = &st.latest { - queue!( - stdout, - MoveTo(2, 4), Print(format!("LTC Status : {}", frame.status)), - MoveTo(2, 5), Print(format!( - "LTC Timecode : {:02}:{:02}:{:02}:{:02}", - frame.hours, frame.minutes, frame.seconds, frame.frames - )), - MoveTo(2, 6), Print(format!("Frame Rate : {:.2}fps", frame.frame_rate)), - ) - .unwrap(); - } else { - queue!( - stdout, - MoveTo(2, 4), Print("LTC Status : (waiting)"), - MoveTo(2, 5), Print("LTC Timecode : …"), - MoveTo(2, 6), Print("Frame Rate : …"), - ) - .unwrap(); - } - - let now_local = Local::now(); - let sys_str = format!( - "{:02}:{:02}:{:02}.{:03}", - now_local.hour(), - now_local.minute(), - now_local.second(), - now_local.timestamp_subsec_millis() - ); - queue!( - stdout, - MoveTo(2, 7), - Print(format!("System Clock : {}", sys_str)) - ) - .unwrap(); - } - - // Footer - queue!( - stdout, - MoveTo(2, 12), - Print("[S] Set system clock to LTC [Q] Quit") - ) - .unwrap(); - - stdout.flush().unwrap(); - - // 4️⃣ Overlay Sync Jitter / Status / Ratio - if let Ok(st) = state.lock() { - let avg_ms = st.average_jitter(); - let avg_frames = st.average_frames(); - let (jcol, jtxt) = if avg_ms.abs() < 10 { - (Color::Green, format!("{:+} ms ({:+} frames)", avg_ms, avg_frames)) - } else if avg_ms.abs() < 40 { - (Color::Yellow, format!("{:+} ms ({:+} frames)", avg_ms, avg_frames)) - } else { - (Color::Red, format!("{:+} ms ({:+} frames)", avg_ms, avg_frames)) - }; - queue!( - stdout, - MoveTo(2, 8), - SetForegroundColor(jcol), - Print("Sync Jitter : "), - Print(jtxt), - ResetColor, - ) - .ok(); - - let status = st.timecode_match(); - let scol = if status == "IN SYNC" { Color::Green } else { Color::Red }; - queue!( - stdout, - MoveTo(2, 9), - SetForegroundColor(scol), - Print(format!("Sync Status : {}", status)), - ResetColor, - ) - .ok(); - - let ratio = st.lock_ratio(); - queue!( - stdout, - MoveTo(2, 10), - Print(format!("Lock Ratio : {:.1}% LOCK", ratio)), - ) - .ok(); - - stdout.flush().ok(); - } - - // 5️⃣ Handle keypress - if poll(Duration::from_millis(0)).unwrap() { - if let Event::Key(evt) = read().unwrap() { - match evt.code { - KeyCode::Char(c) if c.eq_ignore_ascii_case(&'s') => { - // SYNC now - if let Ok(st) = state.lock() { - if let Some(frame) = &st.latest { - // compute ms from frames - let ms_from_frames = - ((frame.frames as f64 / frame.frame_rate) * 1000.0).round() as i64; - // total microseconds - let total_us = (ms_from_frames + hw_offset_ms) * 1000; - // build date string "HH:MM:SS.mmm" - let ts = format!( - "{:02}:{:02}:{:02}.{:03}", - frame.hours, - frame.minutes, - frame.seconds, - ((total_us / 1000) % 1000) - ); - // run `sudo date -s "HH:MM:SS.mmm"` - let status = Command::new("sudo") - .arg("date") - .arg("-s") - .arg(&ts) - .status(); - let msg = if let Ok(s) = status { - if s.success() { - format!("✔ Synced to LTC: {}", ts) - } else { - format!("❌ date cmd failed") - } - } else { - format!("❌ failed to spawn date") - }; - // print confirmation at row 14 - queue!( - stdout, - MoveTo(2, 14), - Print(msg), - ) - .ok(); - stdout.flush().ok(); - } - } - } - KeyCode::Char(c) if c.eq_ignore_ascii_case(&'q') => { - execute!(stdout, Show, LeaveAlternateScreen).unwrap(); - terminal::disable_raw_mode().unwrap(); - process::exit(0); - } - _ => {} - } - } - } - - thread::sleep(Duration::from_millis(50)); - } -} +// src/ui.rs + +use std::{ + io::{stdout, Write}, + process::{self, Command}, + sync::{Arc, Mutex}, + thread, + time::Duration, +}; + +use chrono::{Local, Timelike, Utc}; +use crossterm::{ + cursor::{Hide, MoveTo, Show}, + event::{poll, read, Event, KeyCode}, + execute, queue, + style::{Color, Print, ResetColor, SetForegroundColor}, + terminal::{self, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen}, +}; + +use crate::sync_logic::LtcState; + +/// Launch the TUI; reads `offset` live from the file-watcher. +pub fn start_ui( + state: Arc>, + serial_port: String, + offset: Arc>, +) { + let mut stdout = stdout(); + execute!(stdout, EnterAlternateScreen).unwrap(); + terminal::enable_raw_mode().unwrap(); + + loop { + // 1️⃣ Read current hardware offset + let hw_offset_ms = *offset.lock().unwrap(); + + // 2️⃣ Measure & record jitter only when LOCKED; clear on FREE + { + let mut st = state.lock().unwrap(); + if let Some(frame) = &st.latest { + if frame.status == "LOCK" { + let now = Utc::now(); + let raw = (now - frame.timestamp).num_milliseconds(); + let measured = raw - hw_offset_ms; + st.record_offset(measured); + } else { + st.clear_offsets(); + } + } + } + + // 3️⃣ Draw static UI + queue!( + stdout, + MoveTo(0, 0), + Clear(ClearType::All), + Hide, + MoveTo(2, 1), Print("NTP Timeturner v2 - Rust Port"), + MoveTo(2, 2), Print(format!("Using Serial Port: {}", serial_port)), + ) + .unwrap(); + + if let Ok(st) = state.lock() { + if let Some(frame) = &st.latest { + queue!( + stdout, + MoveTo(2, 4), Print(format!("LTC Status : {}", frame.status)), + MoveTo(2, 5), Print(format!( + "LTC Timecode : {:02}:{:02}:{:02}:{:02}", + frame.hours, frame.minutes, frame.seconds, frame.frames + )), + MoveTo(2, 6), Print(format!("Frame Rate : {:.2}fps", frame.frame_rate)), + ) + .unwrap(); + } else { + queue!( + stdout, + MoveTo(2, 4), Print("LTC Status : (waiting)"), + MoveTo(2, 5), Print("LTC Timecode : …"), + MoveTo(2, 6), Print("Frame Rate : …"), + ) + .unwrap(); + } + + let now_local = Local::now(); + let sys_str = format!( + "{:02}:{:02}:{:02}.{:03}", + now_local.hour(), + now_local.minute(), + now_local.second(), + now_local.timestamp_subsec_millis() + ); + queue!( + stdout, + MoveTo(2, 7), + Print(format!("System Clock : {}", sys_str)) + ) + .unwrap(); + } + + // Footer + queue!( + stdout, + MoveTo(2, 12), + Print("[S] Set system clock to LTC [Q] Quit") + ) + .unwrap(); + + stdout.flush().unwrap(); + + // 4️⃣ Overlay Sync Jitter / Status / Ratio + if let Ok(st) = state.lock() { + let avg_ms = st.average_jitter(); + let avg_frames = st.average_frames(); + let (jcol, jtxt) = if avg_ms.abs() < 10 { + (Color::Green, format!("{:+} ms ({:+} frames)", avg_ms, avg_frames)) + } else if avg_ms.abs() < 40 { + (Color::Yellow, format!("{:+} ms ({:+} frames)", avg_ms, avg_frames)) + } else { + (Color::Red, format!("{:+} ms ({:+} frames)", avg_ms, avg_frames)) + }; + queue!( + stdout, + MoveTo(2, 8), + SetForegroundColor(jcol), + Print("Sync Jitter : "), + Print(jtxt), + ResetColor, + ) + .ok(); + + let status = st.timecode_match(); + let scol = if status == "IN SYNC" { Color::Green } else { Color::Red }; + queue!( + stdout, + MoveTo(2, 9), + SetForegroundColor(scol), + Print(format!("Sync Status : {}", status)), + ResetColor, + ) + .ok(); + + let ratio = st.lock_ratio(); + queue!( + stdout, + MoveTo(2, 10), + Print(format!("Lock Ratio : {:.1}% LOCK", ratio)), + ) + .ok(); + + stdout.flush().ok(); + } + + // 5️⃣ Handle keypress + if poll(Duration::from_millis(0)).unwrap() { + if let Event::Key(evt) = read().unwrap() { + match evt.code { + KeyCode::Char(c) if c.eq_ignore_ascii_case(&'s') => { + // SYNC now + if let Ok(st) = state.lock() { + if let Some(frame) = &st.latest { + // compute ms from frames + let ms_from_frames = + ((frame.frames as f64 / frame.frame_rate) * 1000.0).round() as i64; + // total microseconds + let total_us = (ms_from_frames + hw_offset_ms) * 1000; + // build date string "HH:MM:SS.mmm" + let ts = format!( + "{:02}:{:02}:{:02}.{:03}", + frame.hours, + frame.minutes, + frame.seconds, + ((total_us / 1000) % 1000) + ); + // run `sudo date -s "HH:MM:SS.mmm"` + let status = Command::new("sudo") + .arg("date") + .arg("-s") + .arg(&ts) + .status(); + let msg = if let Ok(s) = status { + if s.success() { + format!("✔ Synced to LTC: {}", ts) + } else { + format!("❌ date cmd failed") + } + } else { + format!("❌ failed to spawn date") + }; + // print confirmation at row 14 + queue!( + stdout, + MoveTo(2, 14), + Print(msg), + ) + .ok(); + stdout.flush().ok(); + } + } + } + KeyCode::Char(c) if c.eq_ignore_ascii_case(&'q') => { + execute!(stdout, Show, LeaveAlternateScreen).unwrap(); + terminal::disable_raw_mode().unwrap(); + process::exit(0); + } + _ => {} + } + } + } + + thread::sleep(Duration::from_millis(50)); + } +} From 9412c7452cf02d67a504c7514bf9f9f436142675 Mon Sep 17 00:00:00 2001 From: John Rogers Date: Sat, 19 Jul 2025 15:33:35 +0100 Subject: [PATCH 2/6] ci: removed system test function from application as code for sync locking no longer exists, #[test] fn test_ltc_frame_does_not_match_system_time() { let now = Local::now(); // Create a time that is one hour ahead, wrapping around 23:00 let different_hour = (now.hour() + 1) % 24; let frame = get_test_frame("LOCK", different_hour, now.minute(), now.second()); assert!(!frame.matches_system_time()); } --- Cargo.lock | 1720 +++++++++++++++++++++++++++++++++++++++++++++ src/sync_logic.rs | 9 - 2 files changed, 1720 insertions(+), 9 deletions(-) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..55d569d --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1720 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.59.0", +] + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +dependencies = [ + "serde", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "az" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" + +[[package]] +name = "backtrace" +version = "0.3.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "bytemuck" +version = "1.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "cc" +version = "1.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" + +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.5.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" + +[[package]] +name = "clock-steering" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2410abf030f2eb46cba840d343455078538e7c8755507b37ffd4074064f08f62" +dependencies = [ + "libc", +] + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "convert_case" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb402b8d4c85569410425650ce3eddc7d698ed96d39a73f941b08fb63082f1e7" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crossterm" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" +dependencies = [ + "bitflags 2.9.1", + "crossterm_winapi", + "derive_more", + "document-features", + "mio", + "parking_lot", + "rustix", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "derive_more" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "document-features" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" +dependencies = [ + "litrs", +] + +[[package]] +name = "env_filter" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "fixed" +version = "1.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707070ccf8c4173548210893a0186e29c266901b71ed20cd9e2ca0193dfe95c3" +dependencies = [ + "az", + "bytemuck", + "half", + "typenum", +] + +[[package]] +name = "fsevent-sys" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" +dependencies = [ + "libc", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "half" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" +dependencies = [ + "cfg-if", + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "indexmap" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "inotify" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" +dependencies = [ + "bitflags 2.9.1", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" +dependencies = [ + "libc", +] + +[[package]] +name = "io-kit-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" +dependencies = [ + "core-foundation-sys", + "mach2", +] + +[[package]] +name = "io-uring" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" +dependencies = [ + "bitflags 2.9.1", + "cfg-if", + "libc", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "jiff" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "kqueue" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" +dependencies = [ + "bitflags 1.3.2", + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.174" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" + +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + +[[package]] +name = "libudev" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b324152da65df7bb95acfcaab55e3097ceaab02fb19b228a9eb74d55f135e0" +dependencies = [ + "libc", + "libudev-sys", +] + +[[package]] +name = "libudev-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + +[[package]] +name = "lock_api" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.59.0", +] + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + +[[package]] +name = "notify" +version = "8.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3163f59cd3fa0e9ef8c32f242966a7b9994fd7378366099593e0e73077cd8c97" +dependencies = [ + "bitflags 2.9.1", + "fsevent-sys", + "inotify", + "kqueue", + "libc", + "log", + "mio", + "notify-types", + "walkdir", + "windows-sys 0.60.2", +] + +[[package]] +name = "notify-types" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" + +[[package]] +name = "ntp_timeturner" +version = "0.1.0" +dependencies = [ + "chrono", + "crossterm", + "env_logger", + "log", + "notify", + "rand", + "regex", + "serde", + "serde_json", + "serialport", + "socket2 0.4.10", + "statime", + "statime-linux", + "tokio", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" +dependencies = [ + "bitflags 2.9.1", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rustc-demangle" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" + +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags 2.9.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustversion" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "serialport" +version = "4.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb0bc984f6af6ef8bab54e6cf2071579ee75b9286aa9f2319a0d220c28b0a2b" +dependencies = [ + "bitflags 2.9.1", + "cfg-if", + "core-foundation", + "core-foundation-sys", + "io-kit-sys", + "libudev", + "mach2", + "nix", + "scopeguard", + "unescaper", + "winapi", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "statime" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4b8f200cc0ef7de878f11c2d606248d76af7168e9723c09be995d796393a491" +dependencies = [ + "arrayvec", + "az", + "fixed", + "libm", + "log", + "rand", + "serde", +] + +[[package]] +name = "statime-linux" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34c87c1084dfe862d04ff46f0c87e7c8ee4adc9cb59ff6a381927199d686468e" +dependencies = [ + "arrayvec", + "clap", + "clock-steering", + "hex", + "libc", + "log", + "pin-project-lite", + "rand", + "serde", + "serde_json", + "statime", + "timestamped-socket", + "tokio", + "toml", + "tracing", + "tracing-log", + "tracing-subscriber", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "timestamped-socket" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d281d46f6b275c61bbe9ca3b55613c39018586dccbc537456ecaac7bb5377a" +dependencies = [ + "libc", + "serde", + "tokio", + "tracing", +] + +[[package]] +name = "tokio" +version = "1.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17" +dependencies = [ + "backtrace", + "bytes", + "io-uring", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "slab", + "socket2 0.5.10", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "thread_local", + "tracing-core", +] + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "unescaper" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c01d12e3a56a4432a8b436f293c25f4808bdf9e9f9f98f9260bba1f1bc5a1f26" +dependencies = [ + "thiserror", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.2", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + +[[package]] +name = "winnow" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74c7b26e3480b707944fc872477815d29a8e429d2f93a1ce000f5fa84a15cbcd" +dependencies = [ + "memchr", +] + +[[package]] +name = "zerocopy" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/src/sync_logic.rs b/src/sync_logic.rs index e985441..df8ea57 100644 --- a/src/sync_logic.rs +++ b/src/sync_logic.rs @@ -160,15 +160,6 @@ mod tests { assert!(frame.matches_system_time()); } - #[test] - fn test_ltc_frame_does_not_match_system_time() { - let now = Local::now(); - // Create a time that is one hour ahead, wrapping around 23:00 - let different_hour = (now.hour() + 1) % 24; - let frame = get_test_frame("LOCK", different_hour, now.minute(), now.second()); - assert!(!frame.matches_system_time()); - } - #[test] fn test_ltc_state_update_lock() { let mut state = LtcState::new(); From b261d7c5859dc3abc2d3837aee4a81fafb11e601 Mon Sep 17 00:00:00 2001 From: John Rogers Date: Sat, 19 Jul 2025 15:41:45 +0100 Subject: [PATCH 3/6] ci: add back in old test and fix test to be testing for something that actually exists --- src/sync_logic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sync_logic.rs b/src/sync_logic.rs index df8ea57..779e856 100644 --- a/src/sync_logic.rs +++ b/src/sync_logic.rs @@ -181,7 +181,7 @@ mod tests { assert_eq!(state.lock_count, 0); assert_eq!(state.free_count, 1); assert!(state.offset_history.is_empty()); // Offsets should be cleared - assert_eq!(state.last_match_status, "UNKNOWN"); + assert_eq!(state.last_match_status, "OUT OF SYNC"); } #[test] From bc91b159409468d740d04b43e1dfa28cbf68bc19 Mon Sep 17 00:00:00 2001 From: John Rogers Date: Sat, 19 Jul 2025 15:44:30 +0100 Subject: [PATCH 4/6] add the test for ltc_frame_does_not_match_system_time --- src/sync_logic.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sync_logic.rs b/src/sync_logic.rs index 779e856..1982017 100644 --- a/src/sync_logic.rs +++ b/src/sync_logic.rs @@ -140,7 +140,8 @@ impl LtcState { mod tests { use super::*; use chrono::{Local, Utc}; - + + #[test] fn get_test_frame(status: &str, h: u32, m: u32, s: u32) -> LtcFrame { LtcFrame { status: status.to_string(), From f60b83ff9cf8519902d88d32b5cb85afc4e235c2 Mon Sep 17 00:00:00 2001 From: John Rogers Date: Sat, 19 Jul 2025 15:49:35 +0100 Subject: [PATCH 5/6] keirstarmers five tests --- src/sync_logic.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sync_logic.rs b/src/sync_logic.rs index 1982017..0b33c36 100644 --- a/src/sync_logic.rs +++ b/src/sync_logic.rs @@ -140,8 +140,7 @@ impl LtcState { mod tests { use super::*; use chrono::{Local, Utc}; - - #[test] + fn get_test_frame(status: &str, h: u32, m: u32, s: u32) -> LtcFrame { LtcFrame { status: status.to_string(), @@ -161,6 +160,15 @@ mod tests { assert!(frame.matches_system_time()); } + #[test] + fn test_ltc_frame_does_not_match_system_time() { + let now = Local::now(); + // Create a time that is one hour ahead, wrapping around 23:00 + let different_hour = (now.hour() + 1) % 24; + let frame = get_test_frame("LOCK", different_hour, now.minute(), now.second()); + assert!(!frame.matches_system_time()); + } + #[test] fn test_ltc_state_update_lock() { let mut state = LtcState::new(); From da7152d8513bee59c4337d64abb056b55551bf9f Mon Sep 17 00:00:00 2001 From: John Rogers Date: Sat, 19 Jul 2025 15:49:59 +0100 Subject: [PATCH 6/6] update with comment --- src/sync_logic.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sync_logic.rs b/src/sync_logic.rs index 0b33c36..9e38c95 100644 --- a/src/sync_logic.rs +++ b/src/sync_logic.rs @@ -135,7 +135,7 @@ impl LtcState { &self.last_match_status } } - +// This module provides the logic for handling LTC (Linear Timecode) frames and maintaining state. #[cfg(test)] mod tests { use super::*; @@ -168,7 +168,7 @@ mod tests { let frame = get_test_frame("LOCK", different_hour, now.minute(), now.second()); assert!(!frame.matches_system_time()); } - + #[test] fn test_ltc_state_update_lock() { let mut state = LtcState::new();