Put keyboard and screen into a PTY and start a PTY tester program
This commit is contained in:
parent
8ca0f25f7f
commit
598318ecf5
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -88,7 +88,6 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"syslog_msg_ipc",
|
"syslog_msg_ipc",
|
||||||
"syslog_rpc",
|
"syslog_rpc",
|
||||||
"unicode_reader",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -274,22 +273,6 @@ version = "1.0.13"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-segmentation"
|
|
||||||
version = "1.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode_reader"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d68d43b506d20b459657e0f0fe3bf0fdbac65b61cbcc2bff842fc6614a8dc179"
|
|
||||||
dependencies = [
|
|
||||||
"smallvec",
|
|
||||||
"unicode-segmentation",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
|
@ -6,4 +6,3 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
syslog_msg_ipc = { version = "0.1.0", path = "../syslog/syslog_msg_ipc" }
|
syslog_msg_ipc = { version = "0.1.0", path = "../syslog/syslog_msg_ipc" }
|
||||||
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
|
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
|
||||||
unicode_reader = "1.0.2"
|
|
||||||
|
45
src/main.rs
45
src/main.rs
@ -1,7 +1,11 @@
|
|||||||
use std::{fs::File, io::{BufReader, Write}, os::mikros::{ipc, syscalls}, process::Command};
|
use std::{
|
||||||
|
fs::File,
|
||||||
|
io::{Read, Write},
|
||||||
|
os::mikros::{ipc, syscalls},
|
||||||
|
process::Command,
|
||||||
|
};
|
||||||
|
|
||||||
use syslog_rpc::Message;
|
use syslog_rpc::Message;
|
||||||
use unicode_reader::CodePoints;
|
|
||||||
|
|
||||||
struct SyslogMessageHandler {
|
struct SyslogMessageHandler {
|
||||||
registered_devices: Vec<String>,
|
registered_devices: Vec<String>,
|
||||||
@ -48,32 +52,29 @@ fn main() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
Command::new("/bin/ps2").spawn().unwrap();
|
Command::new("/bin/ps2").spawn().unwrap();
|
||||||
|
|
||||||
|
syslog_client
|
||||||
|
.send_text_message("init_phase2", "Starting PTY server")
|
||||||
|
.unwrap();
|
||||||
|
Command::new("/bin/pty_server").spawn().unwrap();
|
||||||
|
|
||||||
let mut msg_handler = SyslogMessageHandler::new();
|
let mut msg_handler = SyslogMessageHandler::new();
|
||||||
while !msg_handler
|
while !msg_handler.registered_devices.iter().any(|x| x == "kbd") {
|
||||||
.registered_devices
|
|
||||||
.iter()
|
|
||||||
.any(|x| x == "kbd")
|
|
||||||
{
|
|
||||||
msg_handler.process_messages();
|
msg_handler.process_messages();
|
||||||
}
|
}
|
||||||
|
|
||||||
let kbd = BufReader::new(File::open("/dev/kbd").unwrap());
|
let mut kbd = File::open("/dev/kbd").unwrap();
|
||||||
let mut display = File::open("/dev/bga0").unwrap();
|
let mut display = File::open("/dev/bga0").unwrap();
|
||||||
|
|
||||||
let mut line_buf = String::new();
|
let mut pty = File::open("/dev/ptmx").unwrap();
|
||||||
|
|
||||||
for ch in CodePoints::from(kbd) {
|
Command::new("/bin/pts_tester").spawn().unwrap();
|
||||||
let Ok(ch) = ch else {
|
|
||||||
continue;
|
let mut kbd_buf = [0u8; 512];
|
||||||
};
|
let mut pty_buf = [0u8; 512];
|
||||||
write!(display, "{}", ch).unwrap();
|
loop {
|
||||||
if ch == '\n' {
|
let kbd_len = kbd.read(&mut kbd_buf).unwrap();
|
||||||
println!("Got line: {:?}", &line_buf);
|
let pty_len = pty.read(&mut pty_buf).unwrap();
|
||||||
line_buf.clear();
|
pty.write_all(&kbd_buf[..kbd_len]).unwrap();
|
||||||
} else if ch == '\u{8}' {
|
display.write_all(&pty_buf[..pty_len]).unwrap();
|
||||||
line_buf.pop();
|
|
||||||
} else {
|
|
||||||
line_buf.push(ch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user