Skip to content

Commit 94b7e13

Browse files
Merge pull request #99 from FrameworkComputer/uefi-fixes
2 parents 4210e12 + 2b35aa9 commit 94b7e13

File tree

1 file changed

+18
-6
lines changed
  • framework_lib/src/chromium_ec

1 file changed

+18
-6
lines changed

framework_lib/src/chromium_ec/mod.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//! - `portio` - It uses raw port I/O. This works on UEFI and on Linux if the system isn't in lockdown mode (SecureBoot disabled).
99
//! - `windows` - It uses [DHowett's Windows driver](https://github.com/DHowett/FrameworkWindowsUtils)
1010
11+
use crate::os_specific;
1112
use crate::smbios;
1213
#[cfg(feature = "uefi")]
1314
use crate::uefi::shell_get_execution_break_flag;
@@ -287,14 +288,21 @@ impl CrosEc {
287288
loop {
288289
match cmd.send_command_vec(self) {
289290
Ok(data) => {
290-
// I think that means the buffer is empty
291+
// EC Buffer is empty. We can wait a bit and see if there's more
292+
// Can't run it too quickly, otherwise the commands might fail
291293
if data.is_empty() {
292-
return Ok(console);
294+
trace!("Empty EC response");
295+
println!("---");
296+
os_specific::sleep(1_000_000); // 1s
293297
}
294298

295-
let string = std::str::from_utf8(&data).unwrap();
296-
print!("{}", string);
297-
console.push_str(string);
299+
let utf8 = std::str::from_utf8(&data).unwrap();
300+
let ascii = utf8
301+
.replace(|c: char| !c.is_ascii(), "")
302+
.replace(|c: char| c == '\0', "");
303+
304+
print!("{}", ascii);
305+
console.push_str(ascii.as_str());
298306
}
299307
Err(err) => {
300308
println!("Err: {:?}", err);
@@ -318,7 +326,11 @@ impl CrosEc {
318326
subcmd: ConsoleReadSubCommand::ConsoleReadRecent as u8,
319327
}
320328
.send_command_vec(self)?;
321-
Ok(std::str::from_utf8(&data).unwrap().to_string())
329+
let utf8 = std::str::from_utf8(&data).unwrap();
330+
let ascii = utf8
331+
.replace(|c: char| !c.is_ascii(), "")
332+
.replace(|c: char| c == '\0', "");
333+
Ok(ascii)
322334
}
323335
}
324336

0 commit comments

Comments
 (0)