Forces logging off during ZMODEM uploads

With logging on, the Rust logger trace messages do indeed cause the
sender to abort near the beginning of the upload.

Change-Id: I9ed150db1ad557034d1aefcc99385d771be3edd5
GitOrigin-RevId: 3815d6b21db1dc4978b19fc9b4307007d03e4b12
This commit is contained in:
Matt Harvey
2021-09-27 15:03:10 -07:00
committed by Sam Leffler
parent c26d79fff8
commit 97fccf9c95

View File

@@ -3,6 +3,7 @@ use alloc::vec::Vec;
use crc::crc32;
use crc::Hasher32;
use log;
use zmodem;
@@ -45,6 +46,14 @@ impl io::Write for Upload {
/// Receives using ZMODEM and wraps the result as an Upload.
pub fn rz<R: io::BufRead, W: io::Write>(r: R, w: W) -> Result<Upload, io::Error> {
let mut upload = Upload::new();
// Turn off logging, since it goes to the UART and will cause the sender to
// abort.
let prior_log_level = log::max_level();
log::set_max_level(log::LevelFilter::Off);
zmodem::recv::recv(r, w, &mut upload)?;
log::set_max_level(prior_log_level);
Ok(upload)
}