Skip to main content

pamoja_ds18b20_w1_slave_text

Function pamoja_ds18b20_w1_slave_text 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_ds18b20_w1_slave_text( bytes: *const u8, len: usize, out_text: *mut *mut PamojaString, ) -> PamojaStatus
Expand description

Renders the text the Linux kernel’s w1_therm driver serves for a scratchpad it read cleanly, the inverse of pamoja_ds18b20_parse_w1_slave: the nine bytes and the CRC the kernel computed with YES, then the bytes again with the temperature in millidegrees.

§Arguments

  • bytes - the nine scratchpad bytes, the ninth their CRC.
  • len - how many bytes; it must be nine.
  • out_text - receives the text.

§Returns

PamojaStatus::Ok with the text in out_text, which the caller releases with crate::pamoja_string_free; PamojaStatus::Codec when the CRC does not match, since the kernel only prints a clean read this way; or PamojaStatus::InvalidArgument for a null argument or a length other than nine.

§Safety

bytes must point to len readable bytes, and out_text must be a writable pointer or null.