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.
This commit is contained in:
@ -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"
|
||||
|
@ -9,6 +9,7 @@ license.workspace = true
|
||||
|
||||
[features]
|
||||
comms = []
|
||||
single-packet-msgs = []
|
||||
usb = ["embassy-usb"]
|
||||
stm32 = ["embassy-stm32", "physical/stm32"]
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user