Print battery information interactively (prompts for unseal key)
(&self, ec: &CrosEc)
| 992 | |
| 993 | /// Print battery information interactively (prompts for unseal key) |
| 994 | pub fn dump_data(&self, ec: &CrosEc) -> EcResult<()> { |
| 995 | // Prompt for unseal key to access ManufacturerAccess data |
| 996 | print!("Enter unseal key in hex (e.g. 04143672), or press enter to skip: "); |
| 997 | io::stdout() |
| 998 | .flush() |
| 999 | .map_err(|e| EcError::DeviceError(format!("Failed to flush stdout: {}", e)))?; |
| 1000 | let input_text = read_password() |
| 1001 | .map_err(|e| EcError::DeviceError(format!("Failed to read key: {}", e)))?; |
| 1002 | let input_text = input_text.trim(); |
| 1003 | |
| 1004 | let unseal_key = if input_text.is_empty() { |
| 1005 | None |
| 1006 | } else { |
| 1007 | Some( |
| 1008 | u32::from_str_radix(input_text, 16) |
| 1009 | .map_err(|e| EcError::DeviceError(format!("Invalid key: {}", e)))?, |
| 1010 | ) |
| 1011 | }; |
| 1012 | |
| 1013 | let data = self.collect_data(ec, unseal_key)?; |
| 1014 | display_battery_data(&data); |
| 1015 | |
| 1016 | Ok(()) |
| 1017 | } |
| 1018 | |
| 1019 | /// Collect raw battery data into a struct (for dumping or analysis) |
| 1020 | #[allow(clippy::field_reassign_with_default)] |
no test coverage detected