diff --git a/src/main.rs b/src/main.rs index 3727ec7..46a5a05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2683,6 +2683,11 @@ async fn rfm_async_loop( let mut n_wkc0: u64 = 0; let mut last_wkick: Option = None; let mut rep_gen_done: u32 = 0; + // L0 watchdog: track PLC-echoed processed seq (SM3[8..15]) to detect + // reverse-path wedge (bSync=True illusion). Exit 42 for supervisor restart. + let mut echoed_seq: u64 = 0; + let mut last_echo_advance: Option = None; + let mut wd_logged: bool = false; while !STOP.load(Ordering::Relaxed) { if duration_sec > 0 && start.elapsed().as_secs() >= duration_sec { @@ -2855,6 +2860,15 @@ async fn rfm_async_loop( if rx_buf[..8] != prev_rx8 { prev_rx8.copy_from_slice(&rx_buf[..8]); n_fresh += 1; + // L0: read PLC-echoed processed seq + if rx_buf.len() >= 16 { + let es = u64::from_le_bytes(rx_buf[8..16].try_into().unwrap()); + if es != echoed_seq { + echoed_seq = es; + last_echo_advance = Some(Instant::now()); + wd_logged = false; + } + } { let p = (rt::now_ns() % 1_000_000) as i64; let mut adj = p; @@ -2958,6 +2972,26 @@ async fn rfm_async_loop( core::hint::spin_loop(); + // L0 watchdog check: reverse wedge = we wrote seq but PLC echo stopped advancing + if last_echo_advance.is_none() && start.elapsed().as_secs() > 5 { + last_echo_advance = Some(Instant::now()); // grace at startup + } + if let Some(t) = last_echo_advance { + if t.elapsed().as_millis() > 200 && tx_latest_seq > echoed_seq.wrapping_add(1) { + if echoed_seq == 0 { + // PLC echo never seen: old PLC config without aOut1[8..15] echo. + // Warn once, do not exit (not a wedge, just missing PLC feature). + if !wd_logged { + println!("WARN: PLC seq-echo not detected (activate new PLC config); watchdog passive"); + wd_logged = true; + } + } else { + println!("WEDGE: tx_seq={} echoed_seq={} stalled {}ms -> exit(42)", + tx_latest_seq, echoed_seq, t.elapsed().as_millis()); + std::process::exit(42); + } + } + } if last_report.elapsed() >= Duration::from_secs(10) { // SM 鎺㈤拡: 姣?绉掕 SM2/SM3 浣胯兘浣?+ SM2 缂撳啿, 鍖哄垎鍒嗛厤鏈敓鏁?vs 妗ヤ笉杞彂 if start.elapsed().as_secs() % 30 == 0 {