Requests recent console output from EC and constantly asks for more Prints the output and returns it when an error is encountered
(&self)
| 1566 | /// Requests recent console output from EC and constantly asks for more |
| 1567 | /// Prints the output and returns it when an error is encountered |
| 1568 | pub fn console_read(&self) -> EcResult<()> { |
| 1569 | EcRequestConsoleSnapshot {}.send_command(self)?; |
| 1570 | |
| 1571 | let mut cmd = EcRequestConsoleRead { |
| 1572 | subcmd: ConsoleReadSubCommand::ConsoleReadNext as u8, |
| 1573 | }; |
| 1574 | loop { |
| 1575 | match cmd.send_command_vec(self) { |
| 1576 | Ok(data) => { |
| 1577 | // EC Buffer is empty. That means we've read everything from the snapshot. |
| 1578 | // The windows crosecbus driver returns all NULL with a leading 0x01 instead of |
| 1579 | // an empty response. |
| 1580 | if data.is_empty() || data.iter().all(|x| *x == 0 || *x == 1) { |
| 1581 | debug!("Empty EC response. Stopping console read"); |
| 1582 | // Don't read too fast, wait 100ms before reading more |
| 1583 | os_specific::sleep(100_000); |
| 1584 | EcRequestConsoleSnapshot {}.send_command(self)?; |
| 1585 | cmd.subcmd = ConsoleReadSubCommand::ConsoleReadRecent as u8; |
| 1586 | continue; |
| 1587 | } |
| 1588 | |
| 1589 | let utf8 = std::str::from_utf8(&data).unwrap(); |
| 1590 | let full_ascii = utf8.replace(|c: char| !c.is_ascii(), ""); |
| 1591 | let ascii = full_ascii.replace(['\0'], ""); |
| 1592 | |
| 1593 | print!("{}", ascii); |
| 1594 | } |
| 1595 | Err(err) => { |
| 1596 | error!("Err: {:?}", err); |
| 1597 | return Err(err); |
| 1598 | } |
| 1599 | }; |
| 1600 | |
| 1601 | // Need to explicitly handle CTRL-C termination on UEFI Shell |
| 1602 | #[cfg(feature = "uefi")] |
| 1603 | if shell_get_execution_break_flag() { |
| 1604 | return Ok(()); |
| 1605 | } |
| 1606 | } |
| 1607 | } |
| 1608 | |
| 1609 | /// Read all of EC console buffer and return it |
| 1610 | pub fn console_read_one(&self) -> EcResult<String> { |
no test coverage detected