Skip to content

Commit

Permalink
The time elapsed since packet reception must be subtracted from the w…
Browse files Browse the repository at this point in the history
…all clock, not added.
  • Loading branch information
aMarcireau committed Apr 22, 2024
1 parent d8fb63d commit d4244a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d4244a4

Please sign in to comment.