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

Method dump_to_file

framework_lib/src/smart_battery.rs:1106–1131  ·  view source on GitHub ↗

Dump battery data to a file

(&self, ec: &CrosEc, path: &Path)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 3

read_passwordFunction · 0.85
collect_dataMethod · 0.80
write_to_fileMethod · 0.80

Tested by

no test coverage detected