1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-23 08:15:19 +03:00

flush msp queue on disconnect

This commit is contained in:
Pawel Spychalski (DzikuVx) 2017-01-20 15:42:17 +01:00
parent 72d85ad354
commit ce3678950d
2 changed files with 18 additions and 7 deletions

View file

@ -104,12 +104,16 @@ $(document).ready(function () {
helper.interval.killAll(['global_data_refresh']);
GUI.tab_switch_cleanup();
GUI.tab_switch_in_progress = false;
CONFIGURATOR.connectionValid = false;
GUI.connected_to = false;
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
/*
* Flush
*/
helper.mspQueue.flush();
serial.disconnect(onClosed);
GUI.connected_to = false;
CONFIGURATOR.connectionValid = false;
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
MSP.disconnect_cleanup();
PortUsage.reset();

View file

@ -24,7 +24,10 @@ helper.mspQueue = (function (serial, MSP) {
*/
publicScope.executor = function () {
if (privateScope.portInUse) {
/*
* if port is blocked or there is no connection, do not process the queue
*/
if (privateScope.portInUse || !CONFIGURATOR.connectionValid) {
return false;
}
@ -37,13 +40,13 @@ helper.mspQueue = (function (serial, MSP) {
*/
privateScope.portInUse = true;
//TODO implement timeout scenario
/*
* Set receive callback here
*/
MSP.putCallback(request);
//TODO implement timeout scenario
/*
* Send data to serial port
*/
@ -65,6 +68,10 @@ helper.mspQueue = (function (serial, MSP) {
return privateScope.queue.shift();
};
publicScope.flush = function () {
privateScope.queue = [];
};
publicScope.freeSerialPort = function () {
privateScope.portInUse = false;
};