pub fn read_patch(text: &str, into: &mut [u32; 386]) -> Result<(), PatchError>Expand description
Reads a patch from the form Semtech ships it in.
The patch arrives as a C array of 32-bit words, written without leading zeros, so a word is between one and eight characters long. That is read here rather than converted first, so the file a board’s vendor ships is the file that is loaded.
§Arguments
text- the file’s contents.into- where the words are put.
§Returns
Nothing, with into filled.
§Errors
PatchError::WrongCount when the text does not hold exactly PRAM_WORDS words. A
short count means the file is truncated or is not a patch, and a long one means it is
something else, so neither is loaded.
§Examples
use pamoja_radios::sx1302::sx1261::{read_patch, PRAM_WORDS};
let mut text = String::from("const uint32_t pram[] = {\n");
for _ in 0..PRAM_WORDS {
text.push_str("0x337fe1,\n");
}
text.push_str("};\n");
let mut patch = [0u32; PRAM_WORDS];
read_patch(&text, &mut patch).expect("that is a patch of the right length");
assert_eq!(patch[0], 0x337fe1);