MCPcopy Index your code
hub / github.com/FrameworkComputer/framework-system / read_256_bytes

Function read_256_bytes

framework_lib/src/ccgx/binary.rs:119–134  ·  view source on GitHub ↗

Read 256 bytes starting from a particular row

(file_buffer: &[u8], row_no: u32, flash_row_size: usize)

Source from the content-addressed store, hash-verified

117
118/// Read 256 bytes starting from a particular row
119fn read_256_bytes(file_buffer: &[u8], row_no: u32, flash_row_size: usize) -> Option<Vec<u8>> {
120 let file_read_pointer = (row_no as usize) * flash_row_size;
121 let file_len = file_buffer.len();
122 // Try to read as much as we can
123 let read_len = if file_read_pointer + LARGE_ROW <= file_len {
124 LARGE_ROW
125 } else if file_read_pointer + SMALL_ROW <= file_len {
126 SMALL_ROW
127 } else {
128 // Overrunning the end of the file, this can happen if we read a
129 // CCG6 binary with CCG5 parameters, because the CCG5 flash_row_size
130 // is bigger.
131 return None;
132 };
133 Some(file_buffer[file_read_pointer..file_read_pointer + read_len].to_vec())
134}
135
136/// Read version information about FW based on a particular metadata offset
137///

Callers 2

read_metadataFunction · 0.85
read_versionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected