diff --git a/js/boards.js b/js/boards.js index ca8a632c..6c6070c3 100644 --- a/js/boards.js +++ b/js/boards.js @@ -72,6 +72,10 @@ var BOARD_DEFINITIONS = [ name: "Omnibus F4", identifier: "OBF4", vcp: true + }, { + name: "Omnibus F4 Pro", + identifier: "OBSD", + vcp: true } ]; diff --git a/js/msp.js b/js/msp.js index 464176c5..457f5050 100644 --- a/js/msp.js +++ b/js/msp.js @@ -205,6 +205,13 @@ var MSP = { message.onFinish = callback_msp; message.onSend = callback_sent; + /* + * In case of MSP_REBOOT special procedure is required + */ + if (code == MSPCodes.MSP_SET_REBOOT || code == MSPCodes.MSP_EEPROM_WRITE) { + message.retryCounter = 10; + } + helper.mspQueue.put(message); return true; diff --git a/js/serial.js b/js/serial.js index c23f0faf..8d44e284 100644 --- a/js/serial.js +++ b/js/serial.js @@ -300,9 +300,9 @@ var serial = { */ getTimeout: function () { if (serial.bitrate >= 57600) { - return 1000; - } else { return 1500; + } else { + return 2500; } } diff --git a/js/serial_queue.js b/js/serial_queue.js index fe648744..a033f076 100644 --- a/js/serial_queue.js +++ b/js/serial_queue.js @@ -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 () {