2017-06-21 00:00:20 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<link rel="stylesheet" href="dygraph.css">
|
|
|
|
<title>Get data ADC</title>
|
|
|
|
<script type="text/javascript" src="dygraph.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2017-07-29 19:11:18 +00:00
|
|
|
<h3 style="width:800px; text-align: center;">Read ADC RTL8711AM/RTL8195AM</h3>
|
2017-06-21 00:00:20 +00:00
|
|
|
<div id="div_g" style="width:800px; height:400px;"></div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var data = [];
|
|
|
|
var g = new Dygraph(document.getElementById("div_g"), data,
|
2017-07-29 19:11:18 +00:00
|
|
|
{ drawPoints: true,
|
|
|
|
showRangeSelector: true,
|
|
|
|
showRoller: true, labels: ['X', 'U']});
|
|
|
|
|
2017-06-21 00:00:20 +00:00
|
|
|
var oldblkid = 0;
|
|
|
|
var rdnextflg = false;
|
|
|
|
var cur_idx = 0;
|
|
|
|
ws = new WebSocket('ws://rtl871x0/web.cgi');
|
|
|
|
ws.binaryType = 'arraybuffer';
|
2018-03-04 15:23:47 +00:00
|
|
|
ws.onopen = function(){ws.send('adc*');ws.send('adc*')};
|
2017-06-21 00:00:20 +00:00
|
|
|
ws.onmessage = function (event) {
|
|
|
|
if(event.data instanceof ArrayBuffer) {
|
|
|
|
var wordarray = new Uint16Array(event.data);
|
|
|
|
if(wordarray.length > 2) {
|
|
|
|
var blksz = wordarray[0];
|
|
|
|
if(wordarray.length == blksz + 2) {
|
|
|
|
var blkid = wordarray[1];
|
|
|
|
if(rdnextflg) {
|
|
|
|
cur_idx += (blkid - oldblkid) & 0xFFFF;
|
|
|
|
} else rdnextflg = true;
|
|
|
|
oldblkid = blkid + blksz;
|
|
|
|
for (var i = 2; i < wordarray.length; i++) {
|
2017-07-29 19:11:18 +00:00
|
|
|
if(cur_idx > 10000 ) data.shift();
|
2017-06-21 00:00:20 +00:00
|
|
|
data.push([cur_idx++, wordarray[i]]);
|
|
|
|
}
|
|
|
|
g.updateOptions({'file':data});
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 19:11:18 +00:00
|
|
|
if(cur_idx < 10000 ) ws.send("adc");
|
2017-06-21 00:00:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body></html>
|