{"record":{"id":"44c9d17f38e31f44","repo":"embassy-rs/embassy","slug":"unknown-value","errorCode":null,"errorMessage":"Unknown value {}","messagePattern":"Unknown value (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-net-adin1110/src/regs.rs","lineNumber":82,"sourceCode":"            0x0C => Self::IMASK0,\n            0x0D => Self::IMASK1,\n            0x20 => Self::MDIO_ACC,\n            0x21 => Self::MDIO_ACC_1,\n            0x30 => Self::TX_FSIZE,\n            0x31 => Self::TX,\n            0x32 => Self::TX_SPACE,\n            0x36 => Self::FIFO_CLR,\n            0x50 => Self::ADDR_FILT_UPR0,\n            0x51 => Self::ADDR_FILT_LWR0,\n            0x52 => Self::ADDR_FILT_UPR1,\n            0x53 => Self::ADDR_FILT_LWR1,\n            0x70 => Self::ADDR_MSK_LWR0,\n            0x71 => Self::ADDR_MSK_UPR0,\n            0x72 => Self::ADDR_MSK_LWR1,\n            0x73 => Self::ADDR_MSK_UPR1,\n            0x90 => Self::RX_FSIZE,\n            0x91 => Self::RX,\n            e => panic!(\"Unknown value {}\", e),\n        }\n    }\n}\n\n// Register definitions\nbitfield! {\n    /// Status0 Register bits\n    pub struct Status0(u32);\n    impl Debug;\n    u32;\n    /// Control Data Protection Error\n    pub cdpe, _ : 12;\n    /// Transmit Frame Check Squence Error\n    pub txfcse, _: 11;\n    /// Transmit Time Stamp Capture Available C\n    pub ttscac, _ : 10;\n    /// Transmit Time Stamp Capture Available B\n    pub ttscab, _ : 9;","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-net-adin1110/src/regs.rs#L64-L100","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet reg = Register::from(raw_byte); // panics on unknown\n// after\nlet reg = match raw_byte {\n    0x90 => Register::RX_FSIZE,\n    0x91 => Register::RX,\n    _ => { defmt::warn!(\"unknown reg 0x{:x}\", raw_byte); return Err(CtlError::BadRegister); }\n};","handlingStrategy":"validation","validationCode":"// Rust: validate the raw byte against the known register map before conversion\nfn known_register(v: u8) -> bool {\n    matches!(v, 0x70..=0x73 | 0x90 | 0x91) // extend with full documented map\n}","typeGuard":"// Rust: fallible narrowing instead of panicking From\nfn to_register(v: u8) -> Option<Register> {\n    Some(match v {\n        0x70 => Register::ADDR_MSK_LWR0,\n        0x71 => Register::ADDR_MSK_UPR0,\n        0x72 => Register::ADDR_MSK_LWR1,\n        0x73 => Register::ADDR_MSK_UPR1,\n        0x90 => Register::RX_FSIZE,\n        0x91 => Register::RX,\n        _ => return None,\n    })\n}","tryCatchPattern":"// Rust panics are not catchable in no_std; instead wrap all SPI reads so raw bytes never reach From unchecked:\nlet reg = to_register(raw).ok_or_else(|| SpiError::UnknownRegister(raw))?;","preventionTips":["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."],"tags":["embedded","rust","ethernet","register-map","panic"],"backgroundTag":"invalid-enum-value","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}