-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stream comunication between JavaScript and guest OS #530
Comments
I finally made it, var emulator = new V86Starter({
...
uart1: true,
uart2: true,
uart3: true,
...
}); JavaScript → guest OS// JavaScript → guest OS
setInterval(() => {
console.log("send now!");
emulator.bus.send("serial1-input", 65);
}, 1000); stty raw < /dev/ttyS1
cat /dev/ttyS1 guest OS → JavaScriptstty raw < /dev/ttyS2
echo hello > /dev/ttyS2 emulator.add_listener("serial2-output-char", function(char)
{
console.log("outchar2", char);
});
|
I found this very, very useful. Thanks! |
I'm glad to hear that! |
This is very helpful, thank you for sharing! |
this is what I wanted. |
Small update about the serial port method: the emulator.add_listener("serial2-output-byte", function(byte)
{
console.log("outchar2", String.fromCharCode(byte));
}); Also you can use a var emulator = new V86({
...
virtio_console: true,
...
}); JavaScript → guest OS// JavaScript → guest OS
setInterval(() => {
console.log("send now!");
emulator.bus.send("virtio-console0-input-bytes", Uint8Array.from([65]));
}, 1000); stty raw < /dev/hvc0
microcom /dev/hvc0 guest OS → JavaScript// guest OS → JavaScript
emulator.add_listener("virtio-console1-output-bytes", function(bytes)
{
console.log("out", new TextDecoder("utf-8").decode(bytes));
}); stty raw < /dev/hvc1
echo hello > /dev/hvc1 |
Could you have a node.js server in the guest OS listening for inputs from the external Javascript? |
Currently, no, there is some implementation on a custom network stack: #1048 (reply in thread) UPD: Look at tcpip.js: #1197 and #1048 (comment) |
Hi, thank you so much for the fantastic project!
I'd like to comunicate or stream data between JavaScript and guest OS. I know
emulator.serial0_send()
and "serial0-output-line" event, using in the Lua intepreter, but the output might have noises.For example, when we have device files such as
/dev/jsread
and/dev/jswrite
, we can compress in a guest OS and use in JavaScript by usingcat /dev/jsread | gzip | /dev/jswrite
. You can also docat /dev/jsread | lua | /dev/jswrite
.Another my idea is to use named pipes (FIFO). I tried to use them, but unfortunelly they don't use
FS.prototype.Read
orFS.prototype.Write
, so I could not give or obtain data to the named pipe from JavaScript.Could you tell me how to comunicate between JavaScript and guest OS streamingly?
poor workaround
The script as follows create a large file
/root/myjsread
andemulator.fs9p.Read
is modified to give arbitrary data to guest OS from JavaScript.An example usage in a guest OS is as follows.
In my experiment, reading the
/root/myjsread
stopped arround 2^32 bytes.The text was updated successfully, but these errors were encountered: