From b63e85ad30c356c832862dcca5375a9b14bf2e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Tue, 19 Mar 2024 10:53:08 -0300 Subject: [PATCH] controller: Download file locally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/controller.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/controller.rs b/src/controller.rs index 02b716c..4a0ea91 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -202,7 +202,7 @@ impl Controller { file: OpenOptions::new() .write(true) .create(true) - .open("/tmp/potato2") + .open(status.path.split('/').last().unwrap()) .unwrap(), })); @@ -216,7 +216,7 @@ impl Controller { payload.data[2], payload.data[3], ]); - println!("0x{:x?}", crc); + println!("crc: 0x{:x?}", crc); exit(0); } } @@ -277,15 +277,16 @@ impl Controller { progress.finish(); } - self.waiting = false; - self.status = None; - // Lets get the crc let mut buffer = Vec::new(); - let mut file = std::fs::File::open("/tmp/potato2").unwrap(); + let mut file = std::fs::File::open(status.path.split('/').last().unwrap()).unwrap(); file.read_to_end(&mut buffer).unwrap(); let crc = mavlink_crc32(&buffer); - println!("{:08x}", crc); + println!("calculated crc: 0x{:08x}", crc); + + self.status = None; + self.waiting = false; + return None; } }