Re-implementation of rustbootd's ecat_el6695_* examples as a single binary with fixes found in review and on hardware: - DC-follow PLL hardened against period-2 hunting: slew-limited anchor (+/-50us/cycle), bistable-trap snap re-anchor, re-prime on stale deadline - drift-free absolute-grid ticker mode; probe mode for timestamp forensics - bounded-memory online stats (histograms), graceful SIGINT/SIGTERM shutdown with full report, error-streak abort - timestamp plausibility filter comparing against the previous raw sample (avoids the deadlock after a startup outlier) - XFC scope waveform options: --el2202 (with --el2202-dual), --el2262, --el1252 latch timestamp readback with per-channel edge statistics - register access unified in regs.rs: named bit constants everywhere, read-modify-write for enable/activation bytes - vendored patched ethercrab 0.7.1 (sdo_write_complete, send_raw_coe) Verified on J1900 (PREEMPT_RT 6.6.135): 600k cycles/600s exact 1 kHz, tx/rx zero errors, phase_err p50=164us std=5us; EL2202<->EL1252 loopback edge interval mean 2000.24us std=24.65us.
46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
//! A weird looking test, but it just makes sure the EtherCrab init routines are `Send`.
|
|
|
|
use core::future::Future;
|
|
use ethercrab::{MainDevice, MainDeviceConfig, PduStorage, Timeouts, std::ethercat_now};
|
|
use std::{sync::Arc, time::Duration};
|
|
|
|
#[test]
|
|
fn init_must_be_send() {
|
|
fn spawn<'a, F, T>(_fut: F) -> Result<(), ()>
|
|
where
|
|
F: Future<Output = T> + Send + 'a,
|
|
T: 'a,
|
|
{
|
|
// Don't bother running the future - this is just a compile test
|
|
Ok(())
|
|
}
|
|
|
|
let _ = spawn(init());
|
|
}
|
|
|
|
const MAX_SUBDEVICES: usize = 16;
|
|
const MAX_PDU_DATA: usize = 1100;
|
|
const MAX_FRAMES: usize = 16;
|
|
const PDI_LEN: usize = 64;
|
|
|
|
static PDU_STORAGE: PduStorage<MAX_FRAMES, MAX_PDU_DATA> = PduStorage::new();
|
|
|
|
async fn init() {
|
|
let (_tx, _rx, pdu_loop) = PDU_STORAGE.try_split().expect("can only split once");
|
|
|
|
let maindevice = Arc::new(MainDevice::new(
|
|
pdu_loop,
|
|
Timeouts {
|
|
wait_loop_delay: Duration::from_millis(2),
|
|
mailbox_response: Duration::from_millis(1000),
|
|
..Default::default()
|
|
},
|
|
MainDeviceConfig::default(),
|
|
));
|
|
|
|
let _group = maindevice
|
|
.init_single_group::<MAX_SUBDEVICES, PDI_LEN>(ethercat_now)
|
|
.await
|
|
.expect("Init");
|
|
}
|