diff options
Diffstat (limited to 'htdocs/app/serial-monitor/index.html')
| -rw-r--r-- | htdocs/app/serial-monitor/index.html | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/htdocs/app/serial-monitor/index.html b/htdocs/app/serial-monitor/index.html new file mode 100644 index 0000000..cdc8524 --- /dev/null +++ b/htdocs/app/serial-monitor/index.html | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
| 2 | <html> | ||
| 3 | <head> | ||
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
| 5 | <meta name="viewport" content = "height = device-height, width = 420, user-scalable = no" /> | ||
| 6 | <title>WebIOPi | Serial Monitor</title> | ||
| 7 | <script type="text/javascript" src="/webiopi.js"></script> | ||
| 8 | <script type="text/javascript"> | ||
| 9 | webiopi().ready(function() { | ||
| 10 | $("#inputText").keyup(function(event){ | ||
| 11 | if(event.keyCode == 13){ | ||
| 12 | sendData(); | ||
| 13 | } | ||
| 14 | }); | ||
| 15 | $.get("/devices/*", function(data) { | ||
| 16 | var devices = $("#devices"); | ||
| 17 | var added = false; | ||
| 18 | for (i in data) { | ||
| 19 | if (data[i].type=="Serial") { | ||
| 20 | added = true; | ||
| 21 | devices.append($("<option>" + data[i].name + "</option>")) | ||
| 22 | } | ||
| 23 | } | ||
| 24 | if (added) { | ||
| 25 | readData(); | ||
| 26 | } | ||
| 27 | }); | ||
| 28 | }); | ||
| 29 | |||
| 30 | function readData() { | ||
| 31 | webiopi().Serial($("#devices").val()).read(function(data) { | ||
| 32 | if (data.length > 0) { | ||
| 33 | var d = $("#output").text() + data; | ||
| 34 | $("#output").text(d); | ||
| 35 | } | ||
| 36 | }); | ||
| 37 | setTimeout(readData, 500); | ||
| 38 | } | ||
| 39 | |||
| 40 | function sendData() { | ||
| 41 | var data = $("#inputText").val() + "\n"; | ||
| 42 | webiopi().Serial($("#devices").val()).write(data); | ||
| 43 | $("#inputText").val(""); | ||
| 44 | } | ||
| 45 | |||
| 46 | function deviceChanged() { | ||
| 47 | $("#output").text(""); | ||
| 48 | } | ||
| 49 | |||
| 50 | </script> | ||
| 51 | <style type="text/css"> | ||
| 52 | #inputText { | ||
| 53 | width: 550px; | ||
| 54 | } | ||
| 55 | </style> | ||
| 56 | </head> | ||
| 57 | <body> | ||
| 58 | <h1>Serial Monitor</h1> | ||
| 59 | <span>Serial device : </span><select id="devices" onchange="deviceChanged()"></select><br/> | ||
| 60 | <span>Input : </span><br/> | ||
| 61 | <textarea id="output" rows="30" cols="100" disabled="disabled"></textarea><br/> | ||
| 62 | <span>Output : </span><input id="inputText" type="text"/> | ||
| 63 | </body> | ||
| 64 | </html> | ||
