Skip to content

Commit 31c0e19

Browse files
committed
enable stdio and fix stdout flushing
1 parent 1780a6a commit 31c0e19

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

library/std/src/sys/pal/vexos/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub mod os;
1515
pub mod pipe;
1616
#[path = "../unsupported/process.rs"]
1717
pub mod process;
18-
#[path = "../unsupported/stdio.rs"]
1918
pub mod stdio;
2019
#[path = "../unsupported/thread.rs"]
2120
pub mod thread;
@@ -63,7 +62,9 @@ pub extern "C" fn __rust_abort() -> ! {
6362

6463
pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
6564

66-
pub unsafe fn cleanup() {}
65+
pub unsafe fn cleanup() {
66+
stdio::
67+
}
6768

6869
pub fn unsupported<T>() -> crate::io::Result<T> {
6970
Err(unsupported_err())

library/std/src/sys/pal/vexos/stdio.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ impl io::Write for Stdout {
5252

5353
fn flush(&mut self) -> io::Result<()> {
5454
unsafe {
55-
vex_sdk::vexTasksRun();
55+
while (vex_sdk::vexSerialWriteFree(STDIO_CHANNEL) as usize) != STDOUT_BUF_SIZE {
56+
vex_sdk::vexTasksRun();
57+
}
5658
}
5759

5860
Ok(())
@@ -75,7 +77,8 @@ impl io::Write for Stderr {
7577
}
7678
}
7779

78-
pub const STDIN_BUF_SIZE: usize = 0;
80+
pub const STDIN_BUF_SIZE: usize = 4096;
81+
const STDOUT_BUF_SIZE: usize = 2048;
7982

8083
pub fn is_ebadf(_err: &io::Error) -> bool {
8184
true

0 commit comments

Comments
 (0)