Skip to main content

write_error

Function write_error 

Source
fn write_error<HalError>(
    tx_buf: &mut [u8],
    err: &CryptoServiceError<HalError>,
) -> usize
where HalError: Debug,
Expand description

Map a [CryptoServiceError] into a status + payload and write it.

Driver-level failures are split into two cases:

  • [AteccErrorKind::Chip]: the chip itself returned a non-zero status byte. Surface that as [ResponseStatus::AteccChipError] (0x05) with the raw chip status byte in payload[0]. Lets the host translate to ParseError, ExecutionError, etc., for triage.
  • Anything else (HAL nack, wake failure, CRC mismatch, timeout, …): surface as [ResponseStatus::AteccCommunicationError] (0x04) with a one-byte sub-code in payload[0] derived from [AteccErrorKind::as_sub_code].