mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-16 12:55:13 +03:00
hardware roundtrip
This commit is contained in:
parent
019fb3e851
commit
e76612a4cc
5 changed files with 25 additions and 33 deletions
34
js/msp.js
34
js/msp.js
|
@ -185,42 +185,12 @@ var MSP = {
|
|||
'callback': (callback_msp) ? callback_msp : false,
|
||||
'onSend': callback_sent,
|
||||
'timer': false,
|
||||
'created': new Date().getTime()
|
||||
'created': new Date().getTime(),
|
||||
'sentOn': null
|
||||
};
|
||||
|
||||
helper.mspQueue.put(obj);
|
||||
|
||||
// var requestExists = false;
|
||||
// for (i = 0; i < MSP.callbacks.length; i++) {
|
||||
// if (i < MSP.callbacks.length) {
|
||||
// if (MSP.callbacks[i].code == code) {
|
||||
// // request already exist, we will just attach
|
||||
// requestExists = true;
|
||||
// break;
|
||||
// }
|
||||
// } else {
|
||||
// console.log("Callback index error: "+ i);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!requestExists) {
|
||||
// obj.timer = setInterval(function () {
|
||||
// console.log('MSP data request timed-out: ' + code);
|
||||
//
|
||||
// serial.send(bufferOut, false);
|
||||
// }, serial.getTimeout()); // we should be able to define timeout in the future
|
||||
// }
|
||||
|
||||
// MSP.callbacks.push(obj);
|
||||
|
||||
// always send messages with data payload (even when there is a message already in the queue)
|
||||
// if (data || !requestExists) {
|
||||
// serial.send(bufferOut, function (sendInfo) {
|
||||
// if (sendInfo.bytesSent == bufferOut.byteLength) {
|
||||
// if (callback_sent) callback_sent();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
return true;
|
||||
},
|
||||
promise: function(code, data) {
|
||||
|
|
|
@ -967,6 +967,7 @@ var mspHelper = (function (gui) {
|
|||
*/
|
||||
if (dataHandler.callbacks[i]) {
|
||||
helper.mspQueue.putRoundtrip(new Date().getTime() - dataHandler.callbacks[i].created);
|
||||
helper.mspQueue.putHardwareRoundtrip(new Date().getTime() - dataHandler.callbacks[i].sentOn);
|
||||
}
|
||||
|
||||
// fire callback
|
||||
|
|
|
@ -330,6 +330,7 @@ function onConnect() {
|
|||
helper.interval.add('msp-load-update', function () {
|
||||
$('#msp-load').text("MSP load: " + helper.mspQueue.getLoad().toFixed(2));
|
||||
$('#msp-roundtrip').text("MSP round trip: " + helper.mspQueue.getRoundtrip().toFixed(0));
|
||||
$('#hardware-roundtrip').text("HW round trip: " + helper.mspQueue.getHardwareRoundtrip().toFixed(0));
|
||||
}, 100);
|
||||
|
||||
helper.interval.add('global_data_refresh', helper.periodicStatusUpdater.run, helper.periodicStatusUpdater.getUpdateInterval(serial.bitrate), false);
|
||||
|
|
|
@ -38,10 +38,11 @@ helper.mspQueue = (function (serial, MSP) {
|
|||
var publicScope = {},
|
||||
privateScope = {};
|
||||
|
||||
privateScope.handlerFrequency = 200;
|
||||
privateScope.handlerFrequency = 100;
|
||||
|
||||
privateScope.loadAverage = new walkingAverageClass(privateScope.handlerFrequency);
|
||||
privateScope.roundtripAverage = new walkingAverageClass(50);
|
||||
privateScope.hardwareRoundtripAverage = new walkingAverageClass(50);
|
||||
|
||||
privateScope.queue = [];
|
||||
|
||||
|
@ -91,6 +92,10 @@ helper.mspQueue = (function (serial, MSP) {
|
|||
publicScope.put(request);
|
||||
}, serial.getTimeout());
|
||||
|
||||
if (request.sentOn === null) {
|
||||
request.sentOn = new Date().getTime();
|
||||
}
|
||||
|
||||
/*
|
||||
* Set receive callback here
|
||||
*/
|
||||
|
@ -153,6 +158,18 @@ helper.mspQueue = (function (serial, MSP) {
|
|||
privateScope.roundtripAverage.put(number);
|
||||
};
|
||||
|
||||
publicScope.getHardwareRoundtrip = function () {
|
||||
return privateScope.hardwareRoundtripAverage.getAverage();
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {number} number
|
||||
*/
|
||||
publicScope.putHardwareRoundtrip = function (number) {
|
||||
privateScope.hardwareRoundtripAverage.put(number);
|
||||
};
|
||||
|
||||
setInterval(publicScope.executor, Math.round(1000 / privateScope.handlerFrequency));
|
||||
|
||||
return publicScope;
|
||||
|
|
|
@ -278,6 +278,9 @@
|
|||
<div>
|
||||
<span id="msp-roundtrip"> </span>
|
||||
</div>
|
||||
<div>
|
||||
<span id="hardware-roundtrip"> </span>
|
||||
</div>
|
||||
<div class="version">
|
||||
<!-- configuration version generated here -->
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue