embassy-rs/embassy · error

not implemented

Error message

not implemented

What it means

to_filter_element_config decodes the M_CAN filter's F0 event/action bits into a FilterElementConfig; the reserved/invalid encodings (0b000 and 0b111) fall through to unimplemented!. A message RAM filter element containing a reserved configuration value panics when decoded.

Solutions

  1. Only create filter elements with the supported action encodings (store fifo0/1, reject, priority variants)
  2. Initialize/zero message RAM filters so disabled filters are never decoded
  3. Change the fallthrough to return Option/Result or map 0b000 to a Disabled variant
  4. Validate filter configuration before writing it into message RAM

Example fix

// before
let cfg = element.to_filter_element_config(); // panics on 0b000/0b111
// after
let cfg = match raw_action {
    0b000 => FilterElementConfig::Disabled,
    other => element.to_filter_element_config_for(other),
};
Defensive patterns

Strategy: type-guard

Validate before calling

fn is_valid_action(bits: u8) -> bool { (0b001..=0b110).contains(&bits) }

Type guard

fn decode_filter_config(bits: u8) -> Option<FilterElementConfig> { matches!(bits, 0b001..=0b110).then(|| /* decode */) }

Try / catch

// treat decode as fallible in caller code; assume panic otherwise

Prevention

When it happens

Trigger: Reading a filter element from the FDCAN message RAM whose SFEC/EFEC field holds 0b000 (disable) or 0b111 (reserved) instead of the handled 0b001..0b110 values.

Common situations: Reading raw/uninitialized message RAM cells as filter elements, or manually crafted filter words with reserved action codes.

Related errors


AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10). Data as JSON: /api/errors/7ce1c0e6d86c1a9b. Report an issue: GitHub.

Appendix: source

Thrown at embassy-stm32/src/can/fd/message_ram/common.rs:131

            0b11 => FilterType::FilterDisabled,
            _ => unreachable!(),
        }
    }
}

#[doc = "Reader of field `(E|S)FEC`"]
pub type ESFEC_R = generic::R<u8, FilterElementConfig>;
impl ESFEC_R {
    pub fn to_filter_element_config(&self) -> FilterElementConfig {
        match self.bits() {
            0b000 => FilterElementConfig::DisableFilterElement,
            0b001 => FilterElementConfig::StoreInFifo0,
            0b010 => FilterElementConfig::StoreInFifo1,
            0b011 => FilterElementConfig::Reject,
            0b100 => FilterElementConfig::SetPriority,
            0b101 => FilterElementConfig::SetPriorityAndStoreInFifo0,
            0b110 => FilterElementConfig::SetPriorityAndStoreInFifo1,
            _ => unimplemented!(),
        }
    }
}

View on GitHub (pinned to 463a07b963)