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

Method read_string

framework_lib/src/smart_battery.rs:825–832  ·  view source on GitHub ↗
(&self, ec: &CrosEc, addr: u16)

Source from the content-addressed store, hash-verified

823 }
824
825 fn read_string(&self, ec: &CrosEc, addr: u16) -> EcResult<String> {
826 // SMBus strings are length-prefixed
827 let i2c_response = i2c_read(ec, self.i2c_port, self.i2c_addr >> 1, addr, 0x20)?;
828 i2c_response.is_successful()?;
829 // First byte is the returned string length
830 let str_bytes = &i2c_response.data[1..=(i2c_response.data[0] as usize)];
831 Ok(String::from_utf8_lossy(str_bytes).to_string())
832 }
833
834 /// Read a block of bytes with expected length
835 fn read_bytes(&self, ec: &CrosEc, addr: u16, len: u16) -> EcResult<Vec<u8>> {

Callers 1

collect_dataMethod · 0.80

Calls 2

i2c_readFunction · 0.85
is_successfulMethod · 0.80

Tested by

no test coverage detected