embassy-rs/embassy · error
Unknown value
Error message
Unknown value {} What it means
This From<u8> impl converts a raw register/code byte (e.g. a SPI-returned register address or value) into a typed enum (Register kind). When the byte does not match any known variant, the driver panics with "Unknown value" instead of returning an error. The library assumes all values arriving here come from the ADIN1110 chip and are in the documented range.
Solutions
- Verify the byte value against the ADIN1110 datasheet register map and use only documented codes.
- Check SPI wiring/CS polarity/mode (CPOL/CPHA) — a corrupted transfer can yield arbitrary bytes.
- Confirm you are using the correct driver for your chip (ADIN1110 vs ADIN2111); register maps differ.
- If a valid value is genuinely missing, patch the driver's match table or replace the panic with a Result-returning conversion.
Example fix
// before
let reg = Register::from(raw_byte); // panics on unknown
// after
let reg = match raw_byte {
0x90 => Register::RX_FSIZE,
0x91 => Register::RX,
_ => { defmt::warn!("unknown reg 0x{:x}", raw_byte); return Err(CtlError::BadRegister); }
}; Defensive patterns
Strategy: validation
Validate before calling
// Rust: validate the raw byte against the known register map before conversion
fn known_register(v: u8) -> bool {
matches!(v, 0x70..=0x73 | 0x90 | 0x91) // extend with full documented map
} Type guard
// Rust: fallible narrowing instead of panicking From
fn to_register(v: u8) -> Option<Register> {
Some(match v {
0x70 => Register::ADDR_MSK_LWR0,
0x71 => Register::ADDR_MSK_UPR0,
0x72 => Register::ADDR_MSK_LWR1,
0x73 => Register::ADDR_MSK_UPR1,
0x90 => Register::RX_FSIZE,
0x91 => Register::RX,
_ => return None,
})
} Try / catch
// Rust panics are not catchable in no_std; instead wrap all SPI reads so raw bytes never reach From unchecked: let reg = to_register(raw).ok_or_else(|| SpiError::UnknownRegister(raw))?;
Prevention
- Cross-check every register constant against the ADIN1110 datasheet table for your chip revision.
- Sanity-check SPI mode (0), CS polarity, and wiring when unexpected values appear.
- Never feed raw or user-supplied bytes into infallible enum From impls.
- Prefer patching the driver to TryFrom for defensive parsing of hardware responses.
When it happens
Trigger: Passing a byte to Register::from / the register-address conversion that is not one of the ADIN1110's defined register codes — e.g. reading a reserved register address, a garbled SPI frame, or constructing a register code from a constant not in the datasheet table.
Common situations: Typing a wrong register constant from an older datasheet revision; SPI bus corruption/miswiring producing out-of-range bytes; using this driver against a similar chip (ADIN2111 or other PHY) with different register map; accessing reserved vendor registers.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Invalid value
- ErevidIsZero
- Can only take the executor once
- DMA data error
- MCLK frequency < 9.5 MHz is not compatible with the TRNG
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/44c9d17f38e31f44.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-net-adin1110/src/regs.rs:82
0x0C => Self::IMASK0,
0x0D => Self::IMASK1,
0x20 => Self::MDIO_ACC,
0x21 => Self::MDIO_ACC_1,
0x30 => Self::TX_FSIZE,
0x31 => Self::TX,
0x32 => Self::TX_SPACE,
0x36 => Self::FIFO_CLR,
0x50 => Self::ADDR_FILT_UPR0,
0x51 => Self::ADDR_FILT_LWR0,
0x52 => Self::ADDR_FILT_UPR1,
0x53 => Self::ADDR_FILT_LWR1,
0x70 => Self::ADDR_MSK_LWR0,
0x71 => Self::ADDR_MSK_UPR0,
0x72 => Self::ADDR_MSK_LWR1,
0x73 => Self::ADDR_MSK_UPR1,
0x90 => Self::RX_FSIZE,
0x91 => Self::RX,
e => panic!("Unknown value {}", e),
}
}
}
// Register definitions
bitfield! {
/// Status0 Register bits
pub struct Status0(u32);
impl Debug;
u32;
/// Control Data Protection Error
pub cdpe, _ : 12;
/// Transmit Frame Check Squence Error
pub txfcse, _: 11;
/// Transmit Time Stamp Capture Available C
pub ttscac, _ : 10;
/// Transmit Time Stamp Capture Available B
pub ttscab, _ : 9;View on GitHub (pinned to 463a07b963)