2024-04-02 15:25:21 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
import('./js/InstanceManager.mjs').then(module => {
|
|
|
|
const InstanceManager = module.default;
|
|
|
|
|
|
|
|
process.stdin.setRawMode(true);
|
|
|
|
process.stdin.resume();
|
|
|
|
process.stdin.setEncoding("utf8");
|
|
|
|
|
|
|
|
console.log("Now booting, please stand by ...");
|
|
|
|
|
|
|
|
const manager = new InstanceManager({ screen: false, term: false, spawnRoot: undefined });
|
|
|
|
manager.getInstanceByinstName("Host").then(result => {
|
|
|
|
const hostvm = result.vm;
|
|
|
|
|
2024-04-11 17:53:48 +00:00
|
|
|
hostvm.add_listener("emulator-started", () => {
|
2024-04-02 15:25:21 +00:00
|
|
|
process.stdout.write("Welcome to psl!");
|
2024-04-11 17:53:48 +00:00
|
|
|
hostvm.serial0_send("\n");
|
2024-04-02 15:25:21 +00:00
|
|
|
});
|
|
|
|
|
2024-04-11 17:53:48 +00:00
|
|
|
hostvm.add_listener("serial0-output-byte", (byte) => {
|
2024-04-02 15:25:21 +00:00
|
|
|
var chr = String.fromCharCode(byte);
|
|
|
|
if (chr <= "~") {
|
|
|
|
process.stdout.write(chr);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-04-11 17:53:48 +00:00
|
|
|
process.stdin.on("data", (c) => {
|
2024-04-02 15:25:21 +00:00
|
|
|
if (c === "\u0004") {
|
|
|
|
hostvm.stop();
|
|
|
|
process.stdin.pause();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hostvm.serial0_send(c);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}).catch(error => {
|
2024-04-11 17:53:48 +00:00
|
|
|
console.error(error);
|
2024-04-02 15:25:21 +00:00
|
|
|
throw Error("Error in getting host inastance, quitting");
|
|
|
|
});
|
|
|
|
}).catch(error => {
|
|
|
|
console.error('Error loading InstanceManager:', error);
|
|
|
|
});
|