embassy-rs/embassy · error

DLC > 15

Error message

DLC > 15

What it means

FDCAN branch of `TxBufferElement::to_data_length` (DLC-to-byte-length conversion for transmitted events/buffers): a DLC above 15 is undefined and panics. As with the RX variant, this should be unreachable because DLC is a 4-bit field; hitting it means corrupted TX buffer contents or misaligned element reads.

Solutions

  1. Verify TX buffer/TX event FIFO offsets in the message RAM configuration.
  2. Only process TX event elements after the transmit-event interrupt signals a valid entry.
  3. Update embassy-stm32 to a version with corrected message RAM layout definitions for your chip.
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Calling `to_data_length` on a TX buffer element whose FDCAN-frame DLC field is > 15, typically via TX event FIFO processing after message RAM corruption or layout misconfiguration.

Common situations: Wrong message RAM offsets for the TX event FIFO; element read before hardware finished writing; concurrent access without proper synchronization.

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/8867ce2c182ee034. Report an issue: GitHub.

Appendix: source

Thrown at embassy-stm32/src/can/fd/message_ram/txbuffer_element.rs:356

    #[inline(always)]
    pub fn mm(&self) -> MM_R {
        MM_R::new(((self.bits[1] >> 24) & 0xFF) as u8)
    }
    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_event(&self) -> Event {
        let mm = self.mm().bits();
        let efc = self.efc().to_event_control();
        match efc {
            EventControl::DoNotStore => Event::NoEvent,
            EventControl::Store => Event::Event(mm),
        }
    }

View on GitHub (pinned to 463a07b963)