MCPcopy Create free account
hub / github.com/FrameworkComputer/framework-system / read_block

Method read_block

framework_lib/src/smart_battery.rs:849–854  ·  view source on GitHub ↗

Read a block of bytes, returning whatever length the device provides

(&self, ec: &CrosEc, addr: u16, max_len: u16)

Source from the content-addressed store, hash-verified

847
848 /// Read a block of bytes, returning whatever length the device provides
849 fn read_block(&self, ec: &CrosEc, addr: u16, max_len: u16) -> EcResult<Vec<u8>> {
850 let i2c_response = i2c_read(ec, self.i2c_port, self.i2c_addr >> 1, addr, max_len + 1)?;
851 i2c_response.is_successful()?;
852 let actual_len = i2c_response.data[0] as usize;
853 Ok(i2c_response.data[1..=actual_len].to_vec())
854 }
855
856 /// Raw I2C read without SMBus block length prefix handling
857 fn read_raw(&self, ec: &CrosEc, addr: u16, len: u16) -> EcResult<Vec<u8>> {

Callers 2

mac_readMethod · 0.80
collect_dataMethod · 0.80

Calls 2

i2c_readFunction · 0.85
is_successfulMethod · 0.80

Tested by

no test coverage detected