Read a block of bytes with expected length
(&self, ec: &CrosEc, addr: u16, len: u16)
| 833 | |
| 834 | /// Read a block of bytes with expected length |
| 835 | fn read_bytes(&self, ec: &CrosEc, addr: u16, len: u16) -> EcResult<Vec<u8>> { |
| 836 | let i2c_response = i2c_read(ec, self.i2c_port, self.i2c_addr >> 1, addr, len + 1)?; |
| 837 | i2c_response.is_successful()?; |
| 838 | let actual_len = i2c_response.data[0]; |
| 839 | if actual_len != len as u8 { |
| 840 | return Err(EcError::DeviceError(format!( |
| 841 | "Expected {} bytes but got {} from register 0x{:02X}", |
| 842 | len, actual_len, addr |
| 843 | ))); |
| 844 | } |
| 845 | Ok(i2c_response.data[1..].to_vec()) |
| 846 | } |
| 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>> { |
no test coverage detected