use download_from_slice function

this closes #4
This commit is contained in:
2022-02-26 13:37:49 +01:00
parent 0108a54d8f
commit 2523cc8503
+1 -11
View File
@@ -64,17 +64,7 @@ pub fn flash_bin(binary: &[u8], d: &rusb::Device<GlobalContext>) -> Result<(), U
) )
.map_err(|e| UtilError::Dfu(e))?; .map_err(|e| UtilError::Dfu(e))?;
std::fs::write("target/out.bin", binary).map_err(|e| UtilError::File(e))?; dfu.download_from_slice(binary).unwrap();
dfu.download(
&mut std::fs::OpenOptions::new()
.read(true)
.open("target/out.bin")
.map_err(|e| UtilError::File(e))?,
std::fs::metadata("target/out.bin")
.map_err(|e| UtilError::File(e))?
.len() as u32,
)
.unwrap();
Ok(()) Ok(())
} }