From d4244a40e82bca955dedeeac0976fb81131f98ce Mon Sep 17 00:00:00 2001 From: Alexandre Marcireau Date: Tue, 23 Apr 2024 09:55:34 +1000 Subject: [PATCH] The time elapsed since packet reception must be subtracted from the wall clock, not added. --- python/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/src/lib.rs b/python/src/lib.rs index 6535aa9..76b7bd5 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -247,12 +247,15 @@ impl Device { }; let duration_since_epoch = std::time::SystemTime::now() .duration_since(std::time::SystemTime::UNIX_EPOCH) - .unwrap_or(std::time::Duration::from_secs(0)); + .unwrap_or(std::time::Duration::new(0, 0)); Ok(( duration_since_epoch.as_secs_f64(), status.map(|status| { ( - (status.instant.elapsed() + duration_since_epoch).as_secs_f64(), + (duration_since_epoch + .checked_sub(status.instant.elapsed()) + .unwrap_or(std::time::Duration::new(0, 0))) + .as_secs_f64(), status.backlog, status.raw_packets, status.clutch_engaged,