Poll PTY and keyboard when there is no data
This commit is contained in:
parent
598318ecf5
commit
6e9938c5fc
39
Cargo.lock
generated
39
Cargo.lock
generated
@ -22,6 +22,9 @@ name = "bitflags"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
@ -59,6 +62,16 @@ version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
|
||||
|
||||
[[package]]
|
||||
name = "file_rpc"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"parking_lot",
|
||||
"postcard",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.2.1"
|
||||
@ -86,6 +99,7 @@ dependencies = [
|
||||
name = "init_phase2"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"file_rpc",
|
||||
"syslog_msg_ipc",
|
||||
"syslog_rpc",
|
||||
]
|
||||
@ -139,9 +153,21 @@ dependencies = [
|
||||
"embedded-io 0.4.0",
|
||||
"embedded-io 0.6.1",
|
||||
"heapless",
|
||||
"postcard-derive",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "postcard-derive"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0239fa9c1d225d4b7eb69925c25c5e082307a141e470573fbbe3a817ce6a7a37"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.86"
|
||||
@ -207,7 +233,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.77",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -231,6 +257,17 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.77"
|
||||
|
@ -4,5 +4,6 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
file_rpc = { version = "0.1.0", path = "../file_rpc" }
|
||||
syslog_msg_ipc = { version = "0.1.0", path = "../syslog/syslog_msg_ipc" }
|
||||
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
|
||||
|
16
src/main.rs
16
src/main.rs
@ -1,10 +1,11 @@
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{Read, Write},
|
||||
os::mikros::{ipc, syscalls},
|
||||
os::mikros::{fs::FileExt, ipc, syscalls},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use file_rpc::{PendingPoll, PollEvents};
|
||||
use syslog_rpc::Message;
|
||||
|
||||
struct SyslogMessageHandler {
|
||||
@ -71,9 +72,22 @@ fn main() {
|
||||
|
||||
let mut kbd_buf = [0u8; 512];
|
||||
let mut pty_buf = [0u8; 512];
|
||||
|
||||
let (kbd_pid, kbd_fd) = kbd.get_pid_fd();
|
||||
let (pty_pid, pty_fd) = pty.get_pid_fd();
|
||||
|
||||
let kbd_pid_client = file_rpc::Client::new(kbd_pid);
|
||||
let pty_pid_client = file_rpc::Client::new(pty_pid);
|
||||
|
||||
loop {
|
||||
let kbd_len = kbd.read(&mut kbd_buf).unwrap();
|
||||
let pty_len = pty.read(&mut pty_buf).unwrap();
|
||||
if kbd_len == 0 && pty_len == 0 {
|
||||
let kbd_poll = kbd_pid_client.poll(kbd_fd, PollEvents::POLLIN);
|
||||
let pty_poll = pty_pid_client.poll(pty_fd, PollEvents::POLLIN);
|
||||
PendingPoll::get_list_result(&[kbd_poll, pty_poll]);
|
||||
continue;
|
||||
}
|
||||
pty.write_all(&kbd_buf[..kbd_len]).unwrap();
|
||||
display.write_all(&pty_buf[..pty_len]).unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user