From e9018111be1e3ad13124d0e4bb38f56957740dfe Mon Sep 17 00:00:00 2001 From: Paul Zinselmeyer Date: Fri, 3 May 2024 17:26:32 +0200 Subject: [PATCH] fix rx loop bug --- canome/src/bus.rs | 10 +++++----- canome/src/can.rs | 21 +-------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/canome/src/bus.rs b/canome/src/bus.rs index 4a04049..6fcb422 100644 --- a/canome/src/bus.rs +++ b/canome/src/bus.rs @@ -50,11 +50,11 @@ pub trait BusBehaviour { impl> BusBehaviour for &T { fn get(&self, id: ::ID) -> Option<::Data> { - self.get(id) + (*self).get(id) } fn register_waker(&self, id: ::ID, waker: &Waker) { - self.register_waker(id, waker) + (*self).register_waker(id, waker) } fn publish( @@ -62,15 +62,15 @@ impl> BusBehaviour for &T { id: ::ID, value: ::Data, ) -> Result<(), BusError> { - self.publish(id, value) + (*self).publish(id, value) } fn publish_local(&self, id: &::ID, value: ::Data) { - self.publish_local(id, value) + (*self).publish_local(id, value) } fn request(&self, id: ::ID) -> Result<(), BusError> { - self.request(id) + (*self).request(id) } } diff --git a/canome/src/can.rs b/canome/src/can.rs index 80a6cb9..ca79d61 100644 --- a/canome/src/can.rs +++ b/canome/src/can.rs @@ -46,26 +46,7 @@ impl BusBackend for BxCanBus { } } -impl Default for BxCanBus { - fn default() -> Self { - Self { - tx_queue: MpMcQueue::new(), - on_publish: &Self::empty_hook, - } - } -} - impl BxCanBus { - pub const fn new() -> Self { - Self { - tx_queue: MpMcQueue::new(), - on_publish: &Self::empty_hook, - } - } - - #[inline] - fn empty_hook(&self) {} - pub const fn new_with_hook(on_publish: &'static (dyn Fn(&Self) + Send + Sync)) -> Self { Self { tx_queue: MpMcQueue::new(), @@ -118,7 +99,7 @@ impl BxCanBus { } } Err(nb::Error::WouldBlock) => break, - Err(nb::Error::Other(_)) => {} + Err(nb::Error::Other(_)) => break, } }