adjust can to hopefull work better
This commit is contained in:
@@ -251,12 +251,12 @@ async fn main(spawner: Spawner) {
|
|||||||
|
|
||||||
// Improve CAN robustness for longer cables:
|
// Improve CAN robustness for longer cables:
|
||||||
// 1. Enable Automatic Bus-Off Management (ABOM)
|
// 1. Enable Automatic Bus-Off Management (ABOM)
|
||||||
// 2. Ensure No Automatic Retransmission (NART) is DISABLED (i.e. we WANT retransmission)
|
// 2. Disable Automatic Retransmission (NART) as we send regular measurements anyway
|
||||||
// 3. Enable Receive FIFO Overwrite Mode (RFLM = 0, default)
|
// 3. Enable Receive FIFO Overwrite Mode (RFLM = 0, default)
|
||||||
// 4. Increase Resync Jump Width (SJW) if possible by patching BTIMR
|
// 4. Increase Resync Jump Width (SJW) if possible by patching BTIMR
|
||||||
hal::pac::CAN1.ctlr().modify(|w| {
|
hal::pac::CAN1.ctlr().modify(|w| {
|
||||||
w.set_abom(true);
|
w.set_abom(false);
|
||||||
w.set_nart(false); // HAL default is usually false, but let's be explicit
|
w.set_nart(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// SJW is bits 24-25 of BTIMR. HAL sets it to 0 (SJW=1).
|
// SJW is bits 24-25 of BTIMR. HAL sets it to 0 (SJW=1).
|
||||||
|
|||||||
@@ -367,11 +367,13 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
|
|||||||
let config = self.twai_config.take().expect("twai config not set");
|
let config = self.twai_config.take().expect("twai config not set");
|
||||||
let mut twai = config.into_async().start();
|
let mut twai = config.into_async().start();
|
||||||
|
|
||||||
let res = (async {
|
|
||||||
if twai.is_bus_off() {
|
if twai.is_bus_off() {
|
||||||
bail!("Bus offline after start");
|
info!("Bus offline after start, attempting recovery");
|
||||||
|
// Re-start to initiate recovery
|
||||||
|
twai = twai.stop().start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let res = (async {
|
||||||
Timer::after_millis(10).await;
|
Timer::after_millis(10).await;
|
||||||
|
|
||||||
let mut moistures = Moistures::default();
|
let mut moistures = Moistures::default();
|
||||||
@@ -395,11 +397,13 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
|
|||||||
let config = self.twai_config.take().expect("twai config not set");
|
let config = self.twai_config.take().expect("twai config not set");
|
||||||
let mut twai = config.into_async().start();
|
let mut twai = config.into_async().start();
|
||||||
|
|
||||||
let res = (async {
|
|
||||||
if twai.is_bus_off() {
|
if twai.is_bus_off() {
|
||||||
bail!("Bus offline after start");
|
info!("Bus offline after start, attempting recovery");
|
||||||
|
// Re-start to initiate recovery
|
||||||
|
twai = twai.stop().start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let res = (async {
|
||||||
Timer::after_millis(1000).await;
|
Timer::after_millis(1000).await;
|
||||||
info!("Sending info messages now");
|
info!("Sending info messages now");
|
||||||
// Send a few test messages per potential sensor node
|
// Send a few test messages per potential sensor node
|
||||||
|
|||||||
Reference in New Issue
Block a user