embassy-rs/embassy · error

DLC > 15

Error message

DLC > 15

What it means

`RxFifoElement::to_data_length` converts a received DLC field back into a byte length. For FDCAN frames, DLC values are only defined up to 15 (64 bytes); a DLC read from message RAM above 15 is invalid hardware state, so the code panics. This should only occur if the message RAM was corrupted or interpreted wrongly.

Solutions

  1. Verify message RAM layout configuration (rx_fifo sizes/offsets) matches the chip's actual RAM map.
  2. Ensure the element is read only after the FIFO acknowledges a new frame (check RX FIFO fill/status flags).
  3. Update embassy-stm32 — older revisions had message RAM layout bugs.
Defensive patterns

Strategy: validation

Validate before calling

let dlc = element_hdr & 0xF; debug_assert!(dlc <= 15, "corrupted DLC field");

Prevention

When it happens

Trigger: Calling `to_data_length` on an RX FIFO element whose FDCAN-frame DLC field is > 15 — i.e. after message RAM corruption, wrong element layout/misalignment, or reading a stale/garbage element.

Common situations: Misconfigured message RAM sizes or element addresses in the driver configuration; races between reading the element and hardware overwriting it; incorrect FIFO index arithmetic.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at embassy-stm32/src/can/fd/message_ram/rxfifo_element.rs:104

    #[inline(always)]
    pub fn anmf(&self) -> ANMF_R {
        ANMF_R::new(((self.bits[1] >> 31) & 0x01) != 0)
    }
    pub fn to_data_length(&self) -> DataLength {
        let dlc = self.dlc().bits();
        let ff = self.fdf().frame_format();
        let len = if ff == FrameFormat::Fdcan {
            // See RM0433 Rev 7 Table 475. DLC coding
            match dlc {
                0..=8 => dlc,
                9 => 12,
                10 => 16,
                11 => 20,
                12 => 24,
                13 => 32,
                14 => 48,
                15 => 64,
                _ => panic!("DLC > 15"),
            }
        } else {
            match dlc {
                0..=8 => dlc,
                9..=15 => 8,
                _ => panic!("DLC > 15"),
            }
        };
        DataLength::new(len, ff)
    }
    pub fn to_filter_match(&self) -> FilterFrameMatch {
        if self.anmf().is_matching_frame() {
            FilterFrameMatch::DidMatch(self.fidx().bits())
        } else {
            FilterFrameMatch::DidNotMatch
        }
    }
}

View on GitHub (pinned to 463a07b963)