Added timeouts to sends in movement.rs
This commit is contained in:
parent
5f3f5e63b2
commit
ce049b81d2
|
@ -1,7 +1,7 @@
|
||||||
use embassy_stm32::adc::Adc;
|
use embassy_stm32::adc::Adc;
|
||||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::peripherals;
|
use embassy_stm32::peripherals;
|
||||||
use embassy_time::{Delay, Duration, Timer};
|
use embassy_time::{Delay, Duration, Timer, with_timeout};
|
||||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
||||||
use embassy_util::channel::mpmc::{Receiver, Sender};
|
use embassy_util::channel::mpmc::{Receiver, Sender};
|
||||||
use embassy_util::{select, Either};
|
use embassy_util::{select, Either};
|
||||||
|
@ -110,9 +110,10 @@ pub async fn movement_task(
|
||||||
down_pin.set_low();
|
down_pin.set_low();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send with timeouts to prevent blocking if display or usb task are blocked.
|
||||||
join(
|
join(
|
||||||
pos_sender.send(rotor_state.actual_pos),
|
with_timeout(Duration::from_millis(100), pos_sender.send(rotor_state.actual_pos)),
|
||||||
state_sender.send(rotor_state),
|
with_timeout(Duration::from_millis(100), state_sender.send(rotor_state)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue