write timestamp at front of each response

This commit is contained in:
2026-01-12 21:57:50 +00:00
parent e37553d0d7
commit 40536c8dca
2 changed files with 15 additions and 10 deletions
+14 -8
View File
@@ -131,18 +131,24 @@ impl Ecu<'_> {
buf).await;
info!("matches {}", handshake == b"\x02\x04\x00\xfa");
}
self.initialized_at = Some(Instant::now());
let now = Instant::now();
self.initialized_at = Some(now);
let ticks = now.as_ticks();
buf[0] = (ticks >> 56) as u8 & 0xff;
buf[1] = (ticks >> 48) as u8 & 0xff;
buf[2] = (ticks >> 40) as u8 & 0xff;
buf[3] = (ticks >> 32) as u8 & 0xff;
buf[4] = (ticks >> 24) as u8 & 0xff;
buf[5] = (ticks >> 16) as u8 & 0xff;
buf[6] = (ticks >> 8) as u8 & 0xff;
buf[7] = ticks as u8 & 0xff;
Self::chat(&mut uart, command, buf).await
let len = (Self::chat(&mut uart, command, &mut buf[8..]).await).len();
&buf[0..len+8]
}
pub async fn fetch_table<'a>(&mut self, n: u8, buf: &'a mut [u8]) -> &'a [u8] {
let r = self.run_command(&mut [0x72, 0x07, 0x72, n, 0, 0x14, 0x0], buf).await;
if r.len() > 5 {
&r[5..]
} else {
&[]
}
self.run_command(&mut [0x72, 0x07, 0x72, n, 0, 0x14, 0x0], buf).await
}
pub async fn poll(&mut self, callback: impl AsyncFn(Measure)) {
+1 -2
View File
@@ -116,8 +116,7 @@ pub async fn loop_udp_thing(stack : Stack<'_>, ecu: &mut Ecu<'_>) {
match subn.kind {
SubscriptionKind::Table(t, _s, _e) => {
let tbl = ecu.fetch_table(t, &mut buf).await;
let p = sock.send_to(tbl, sub.endpoint).await;
info!("sent {:?}", p);
sock.send_to(tbl, sub.endpoint).await;
}
}
subn.next_wake = now + subn.interval;