From 403df6f5f42c8a66e0a35aa24a0bcd533e86f261 Mon Sep 17 00:00:00 2001 From: Zachary Sunforge Date: Tue, 2 Jul 2024 15:32:20 -0700 Subject: [PATCH] Added feature flag for single packet messages so we can have an optimized version when we don't need to check data over multiple packets. --- Cargo.toml | 2 +- node/Cargo.toml | 1 + node/src/stm32/usb.rs | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 539eb74..f2d2a45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ ] [workspace.package] -version = "0.3.2" +version = "0.3.3" edition = "2021" repository = "https://git.bfpower.io/BFPOWER/physical" readme = "README.md" diff --git a/node/Cargo.toml b/node/Cargo.toml index 1e67d5a..520b5d8 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -9,6 +9,7 @@ license.workspace = true [features] comms = [] +single-packet-msgs = [] usb = ["embassy-usb"] stm32 = ["embassy-stm32", "physical/stm32"] diff --git a/node/src/stm32/usb.rs b/node/src/stm32/usb.rs index 1099716..d2f767f 100644 --- a/node/src/stm32/usb.rs +++ b/node/src/stm32/usb.rs @@ -18,11 +18,17 @@ impl comms::Sender for TypedInterIn { } impl comms::Receiver for TypedInterOut { + #[cfg(feature = "single-packet-msgs")] async fn receive(&mut self, buffer: &mut [u8]) -> Result<(), comms::Reset> { - // This should be OK because all our messages are smaller than a single packet. + // This is OK when all our messages are smaller than a single packet. self.read(buffer) .await .map(|_| ()) .map_err(|_| comms::Reset) } + + #[cfg(not(feature = "single-packet-msgs"))] + async fn receive(&mut self, buffer: &mut [u8]) -> Result<(), comms::Reset> { + todo!("Decide if we want a general purpose multi-packet message receive") + } }