mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 16:25:19 +03:00
retry on timeout mechanism
This commit is contained in:
parent
ba165a0f14
commit
9594880041
3 changed files with 31 additions and 2 deletions
18
js/msp.js
18
js/msp.js
|
@ -92,6 +92,7 @@ var MSP = {
|
|||
mspHelper.processData(this);
|
||||
} else {
|
||||
console.log('code: ' + this.code + ' - crc failed');
|
||||
console.log(data);
|
||||
|
||||
this.packet_error++;
|
||||
$('span.packet-error').html(this.packet_error);
|
||||
|
@ -109,10 +110,27 @@ var MSP = {
|
|||
this.last_received_timestamp = Date.now();
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {MSP} mspData
|
||||
*/
|
||||
putCallback: function (mspData) {
|
||||
MSP.callbacks.push(mspData);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} code
|
||||
*/
|
||||
removeCallback: function (code) {
|
||||
|
||||
for (var i in this.callbacks) {
|
||||
if (this.callbacks.hasOwnProperty(i) && this.callbacks[i].code == code) {
|
||||
clearTimeout(this.callbacks[i].timer);
|
||||
this.callbacks.splice(i, 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
send_message: function (code, data, callback_sent, callback_msp) {
|
||||
var bufferOut,
|
||||
bufView,
|
||||
|
|
|
@ -957,7 +957,7 @@ var mspHelper = (function (gui) {
|
|||
var callback = dataHandler.callbacks[i].callback;
|
||||
|
||||
// remove timeout
|
||||
clearInterval(dataHandler.callbacks[i].timer);
|
||||
clearTimeout(dataHandler.callbacks[i].timer);
|
||||
|
||||
// remove object from array
|
||||
dataHandler.callbacks.splice(i, 1);
|
||||
|
|
|
@ -40,7 +40,18 @@ helper.mspQueue = (function (serial, MSP) {
|
|||
*/
|
||||
privateScope.portInUse = true;
|
||||
|
||||
//TODO implement timeout scenario
|
||||
request.timer = setTimeout(function () {
|
||||
console.log('MSP data request timed-out: ' + request.code);
|
||||
/*
|
||||
* Remove current callback
|
||||
*/
|
||||
MSP.removeCallback(request.code);
|
||||
|
||||
/*
|
||||
* Create new entry in the queue
|
||||
*/
|
||||
publicScope.put(request);
|
||||
}, serial.getTimeout());
|
||||
|
||||
/*
|
||||
* Set receive callback here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue