double check upload of tested version

This commit is contained in:
Chris Frankland-Wright 2025-07-19 12:29:10 +01:00 committed by GitHub
parent bd2111d77a
commit a47a0e6bd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 555 additions and 555 deletions

View file

@ -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<LtcFrame>,
state: Arc<Mutex<LtcState>>,
_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<LtcFrame>,
state: Arc<Mutex<LtcState>>,
_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);
}
}
}
}
}