embassy-rs/embassy · error

Standard Filter Slot Too High!

Error message

Standard Filter Slot Too High!

What it means

StandardFilterSlot::from is generated for slots 0..=27; any index outside that range panics with 'Standard Filter Slot Too High!'. This guards against addressing a standard CAN filter bank slot beyond the 28 entries the bxCAN/FDCAN standard filter list provides in embassy-stm32's fd filter module.

Solutions

  1. Clamp or validate filter slot indices to 0..=27 before constructing StandardFilterSlot
  2. Reduce the number of standard filters configured to at most 28, or move surplus filters to the extended filter bank
  3. Check loop bounds and configuration parsing so slot indices never exceed 27

Example fix

// before
let slot = StandardFilterSlot::from(idx); // idx may be >= 28
// after
assert!(idx < 28, "standard filter slot {} out of range 0..28", idx);
let slot = StandardFilterSlot::from(idx);
Defensive patterns

Strategy: validation

Validate before calling

// Rust
fn valid_standard_slot(idx: usize) -> Option<usize> {
    if idx < 28 { Some(idx) } else { None }
}

Type guard

// Rust
fn in_standard_slot_range(idx: usize) -> bool { idx <= 27 }

Try / catch

// Rust: validate before constructing; in debug builds an assert!(idx <= 27) before StandardFilterSlot::from(idx) surfaces bad loop bounds early.

Prevention

When it happens

Trigger: Constructing a StandardFilterSlot from a numeric index >= 28 (or negative, via an unhandled value) when configuring standard CAN ID filters, e.g. computing slot indices from a loop or config value that overruns the 28-slot table.

Common situations: Programmatically assigning filters to slots with an off-by-one loop bound; loading a filter count from configuration that exceeds 28; reusing extended-filter slot indices (up to a larger count) for standard filters.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at embassy-stm32/src/can/fd/filter.rs:273

            10 => StandardFilterSlot::_10,
            11 => StandardFilterSlot::_11,
            12 => StandardFilterSlot::_12,
            13 => StandardFilterSlot::_13,
            14 => StandardFilterSlot::_14,
            15 => StandardFilterSlot::_15,
            16 => StandardFilterSlot::_16,
            17 => StandardFilterSlot::_17,
            18 => StandardFilterSlot::_18,
            19 => StandardFilterSlot::_19,
            20 => StandardFilterSlot::_20,
            21 => StandardFilterSlot::_21,
            22 => StandardFilterSlot::_22,
            23 => StandardFilterSlot::_23,
            24 => StandardFilterSlot::_24,
            25 => StandardFilterSlot::_25,
            26 => StandardFilterSlot::_26,
            27 => StandardFilterSlot::_27,
            _ => panic!("Standard Filter Slot Too High!"),
        }
    }
}

/// Extended Filter Slot
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum ExtendedFilterSlot {
    /// 0
    _0 = 0,
    /// 1
    _1 = 1,
    /// 2
    _2 = 2,
    /// 3
    _3 = 3,
    /// 4
    _4 = 4,
    /// 5

View on GitHub (pinned to 463a07b963)