Skip to content

Commit ebac51a

Browse files
committed
Read UART for console input.
1 parent 0fda2b0 commit ebac51a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ mod fs;
1818
mod program;
1919
mod vgaconsole;
2020

21+
pub use config::Config as OsConfig;
22+
2123
// ===========================================================================
2224
// Global Variables
2325
// ===========================================================================
@@ -344,6 +346,25 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
344346
println!("Failed to get HID events: {:?}", e);
345347
}
346348
}
349+
if let Some((uart_dev, _serial_conf)) = menu.context.config.get_serial_console() {
350+
loop {
351+
let mut buffer = [0u8; 8];
352+
let wrapper = neotron_common_bios::ApiBuffer::new(&mut buffer);
353+
match (api.serial_read)(uart_dev, wrapper, neotron_common_bios::Option::None) {
354+
neotron_common_bios::Result::Ok(n) if n == 0 => {
355+
break;
356+
}
357+
neotron_common_bios::Result::Ok(n) => {
358+
for b in &buffer[0..n] {
359+
menu.input_byte(*b);
360+
}
361+
}
362+
_ => {
363+
break;
364+
}
365+
}
366+
}
367+
}
347368
(api.power_idle)();
348369
}
349370
}

0 commit comments

Comments
 (0)