Dump battery data to a file
(&self, ec: &CrosEc, path: &Path)
| 1104 | |
| 1105 | /// Dump battery data to a file |
| 1106 | pub fn dump_to_file(&self, ec: &CrosEc, path: &Path) -> EcResult<()> { |
| 1107 | // Prompt for unseal key |
| 1108 | print!("Enter unseal key in hex (e.g. 04143672), or press enter to skip: "); |
| 1109 | io::stdout() |
| 1110 | .flush() |
| 1111 | .map_err(|e| EcError::DeviceError(format!("Failed to flush stdout: {}", e)))?; |
| 1112 | let input_text = read_password() |
| 1113 | .map_err(|e| EcError::DeviceError(format!("Failed to read key: {}", e)))?; |
| 1114 | let input_text = input_text.trim(); |
| 1115 | |
| 1116 | let unseal_key = if input_text.is_empty() { |
| 1117 | None |
| 1118 | } else { |
| 1119 | Some( |
| 1120 | u32::from_str_radix(input_text, 16) |
| 1121 | .map_err(|e| EcError::DeviceError(format!("Invalid key: {}", e)))?, |
| 1122 | ) |
| 1123 | }; |
| 1124 | |
| 1125 | let data = self.collect_data(ec, unseal_key)?; |
| 1126 | data.write_to_file(path) |
| 1127 | .map_err(|e| EcError::DeviceError(format!("Failed to write file: {}", e)))?; |
| 1128 | |
| 1129 | println!("Battery data saved to {}", path.display()); |
| 1130 | Ok(()) |
| 1131 | } |
| 1132 | } |
| 1133 | |
| 1134 | /// Determine if the battery is bq40z50-R3 based on available data. |
nothing calls this directly
no test coverage detected