mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 16:25:19 +03:00
reboot procedure improvements
This commit is contained in:
parent
e711e5ba53
commit
8e9bded7a7
4 changed files with 50 additions and 3 deletions
|
@ -50,6 +50,23 @@ helper.mspQueue = (function (serial, MSP) {
|
|||
|
||||
privateScope.lockMethod = 'soft';
|
||||
|
||||
privateScope.queueLocked = false;
|
||||
|
||||
/**
|
||||
* Method locks queue
|
||||
* All future put requests will be rejected
|
||||
*/
|
||||
publicScope.lock = function () {
|
||||
privateScope.queueLocked = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Method unlocks queue making it possible to put new requests in it
|
||||
*/
|
||||
publicScope.unlock = function () {
|
||||
privateScope.queueLocked = false;
|
||||
};
|
||||
|
||||
publicScope.setLockMethod = function (method) {
|
||||
privateScope.lockMethod = method;
|
||||
};
|
||||
|
@ -80,6 +97,14 @@ helper.mspQueue = (function (serial, MSP) {
|
|||
|
||||
};
|
||||
|
||||
privateScope.getTimeout = function (code) {
|
||||
if (code == MSPCodes.MSP_SET_REBOOT || code == MSPCodes.MSP_EEPROM_WRITE) {
|
||||
return 5000;
|
||||
} else {
|
||||
return serial.getTimeout();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This method is periodically executed and moves MSP request
|
||||
* from a queue to serial port. This allows to throttle requests,
|
||||
|
@ -137,7 +162,7 @@ helper.mspQueue = (function (serial, MSP) {
|
|||
publicScope.put(request);
|
||||
}
|
||||
|
||||
}, serial.getTimeout());
|
||||
}, privateScope.getTimeout(request.code));
|
||||
|
||||
if (request.sentOn === null) {
|
||||
request.sentOn = new Date().getTime();
|
||||
|
@ -175,8 +200,19 @@ helper.mspQueue = (function (serial, MSP) {
|
|||
privateScope.queue = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Method puts new request into queue
|
||||
* @param {MspMessageClass} mspRequest
|
||||
* @returns {boolean} true on success, false when queue is locked
|
||||
*/
|
||||
publicScope.put = function (mspRequest) {
|
||||
|
||||
if (privateScope.queueLocked === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
privateScope.queue.push(mspRequest);
|
||||
return true;
|
||||
};
|
||||
|
||||
publicScope.getLength = function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue