eculocate

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 40536c8dcae395d519f9785baa5139e86ee610e3
parent e37553d0d75509d2eb7bdc83ab0a8bfe938dc66f
Author: Daniel Barlow <dan@telent.net>
Date:   Mon, 12 Jan 2026 21:57:50 +0000

write timestamp at front of each response

Diffstat:
Mecu-esp32/src/ecu.rs | 24+++++++++++++++---------
Mecu-esp32/src/streamer.rs | 3+--
2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/ecu-esp32/src/ecu.rs b/ecu-esp32/src/ecu.rs @@ -131,18 +131,24 @@ impl Ecu<'_> { buf).await; info!("matches {}", handshake == b"\x02\x04\x00\xfa"); } - self.initialized_at = Some(Instant::now()); - - Self::chat(&mut uart, command, buf).await + 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; + + 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)) { diff --git a/ecu-esp32/src/streamer.rs b/ecu-esp32/src/streamer.rs @@ -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;