puter/incubator/x86emu/www/main.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

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;
hostvm.add_listener("emulator-started", () => {
2024-04-02 15:25:21 +00:00
process.stdout.write("Welcome to psl!");
hostvm.serial0_send("\n");
2024-04-02 15:25:21 +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);
}
});
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 => {
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);
});