From bb1dcbe4a12d14738be3c2d49cc5583fb9e9f965 Mon Sep 17 00:00:00 2001 From: Blizzard Finnegan Date: Wed, 21 Jun 2023 13:24:23 -0400 Subject: [PATCH] Fix saving so that data can be re-imported --- src/device.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/device.rs b/src/device.rs index 0d60284..c016f88 100755 --- a/src/device.rs +++ b/src/device.rs @@ -7,6 +7,7 @@ const REBOOTS_SECTION: &str = "Reboots"; const BP_SECTION: &str = "Successful BP tests"; const TEMP_SECTION: &str = "Successful temp tests"; const OUTPUT_FOLDER: &str = "output/"; +const SECTION_SEPARATOR: &str = ": "; const UNINITIALISED_SERIAL: &str = "uninitialised"; const SERIAL_HEADER: &str = "DtCtrlCfgDeviceSerialNum"; #[derive(PartialEq,Debug)] @@ -63,7 +64,7 @@ impl Device{ for line in file_lines { if line.len() > 0{ log::trace!("{:?}",line); - let section_and_data:Vec<&str> = line.split(": ").collect(); + let section_and_data:Vec<&str> = line.split(SECTION_SEPARATOR).collect(); let section:&str = section_and_data[0]; let possible_value:Result = section_and_data[1].trim().parse::(); match possible_value{ @@ -327,12 +328,15 @@ impl Device{ if let Some(ref mut file_name) = self.output_file{ log::debug!("Writing to file!"); let mut output_data = REBOOTS_SECTION.to_string(); + output_data.push_str(SECTION_SEPARATOR); output_data.push_str(&self.reboots.to_string()); output_data.push_str("\n"); output_data.push_str(BP_SECTION); + output_data.push_str(SECTION_SEPARATOR); output_data.push_str(&self.bps.to_string()); output_data.push_str("\n"); output_data.push_str(TEMP_SECTION); + output_data.push_str(SECTION_SEPARATOR); log::trace!("Current temps: [{}]",self.temps); log::trace!("Initial temps: [{}]",self.init_temps); let saved_temps = (self.temps - self.init_temps) + self.temp_offset;