aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/stm32/src/bin/can.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/stm32/src/bin/can.rs b/tests/stm32/src/bin/can.rs
index 93253ab84..8737ca8ee 100644
--- a/tests/stm32/src/bin/can.rs
+++ b/tests/stm32/src/bin/can.rs
@@ -67,15 +67,25 @@ async fn main(_spawner: Spawner) {
67 let tx_ts = Instant::now(); 67 let tx_ts = Instant::now();
68 can.write(&tx_frame).await; 68 can.write(&tx_frame).await;
69 69
70 info!("Receiving frame...");
71 let envelope = can.read().await.unwrap(); 70 let envelope = can.read().await.unwrap();
71 info!("Frame received!");
72 72
73 info!("loopback time {}", envelope.ts); 73 info!("loopback time {}", envelope.ts);
74 info!("loopback frame {=u8}", envelope.frame.data().unwrap()[0]); 74 info!("loopback frame {=u8}", envelope.frame.data().unwrap()[0]);
75 75
76 // Theoretical minimum latency is 55us, actual is usually ~80us
77 let latency = envelope.ts.saturating_duration_since(tx_ts); 76 let latency = envelope.ts.saturating_duration_since(tx_ts);
78 assert!(Duration::from_micros(50) < latency && latency < Duration::from_micros(100)); 77 info!("loopback latency {} us", latency.as_micros());
78
79 // Theoretical minimum latency is 55us, actual is usually ~80us
80 const MIN_LATENCY: Duration = Duration::from_micros(50);
81 const MAX_LATENCY: Duration = Duration::from_micros(150);
82 assert!(
83 MIN_LATENCY < latency && latency < MAX_LATENCY,
84 "{} < {} < {}",
85 MIN_LATENCY,
86 latency,
87 MAX_LATENCY
88 );
79 89
80 i += 1; 90 i += 1;
81 if i > 10 { 91 if i > 10 {