-
Notifications
You must be signed in to change notification settings - Fork 0
/
serial.html
85 lines (71 loc) · 1.97 KB
/
serial.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!doctype html>
<title>Serial example</title>
<script src="../build/libv86.js"></script>
<script>
"use strict";
window.onload = function()
{
var emulator = new V86Starter({
// Uncomment to see what's going on
//screen_container: document.getElementById("screen_container"),
bios: {
url: "../bios/seabios.bin",
},
vga_bios: {
url: "../bios/vgabios.bin",
},
cdrom: {
url: "../images/linux.iso",
},
autostart: true,
disable_keyboard: true,
});
// In this example we wait for output from the serial terminal, which
// should be running busybox. We log in as soon as a prompt appears and then
// retrieve a directory listing of the root directory
var data = "";
var stages = [
{
test: "login:",
send: "root\n",
},
{
test: "/root% ",
send: "ls -1 --color=never /\n",
},
{
test: "/root% ",
send: "lua -e 'print(3+4)'\n",
},
];
var stage = 0;
emulator.add_listener("serial0-output-char", function(char)
{
if(char === "\r")
{
return;
}
data += char;
document.getElementById("terminal").value += char;
var current = stages[stage];
if(!current)
{
return;
}
if(data.endsWith(current.test))
{
stage++;
emulator.serial0_send(current.send);
var log = "Sending: " + current.send.replace(/\n/g, "\\n") + "\n";
document.getElementById("log").value += log;
}
});
};
</script>
<textarea readonly rows=25 cols=60 id="log">Waiting for boot ...
</textarea>
<textarea readonly rows=25 cols=60 id="terminal"></textarea>
<div id="screen_container">
<div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
<canvas style="display: none"></canvas>
</div>