diff --git a/tabs/receiver.js b/tabs/receiver.js index 9e08e321..019c3465 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -326,8 +326,15 @@ TABS.receiver.initialize = function (callback) { maxWidth: windowWidth, maxHeight: windowHeight } }, function(createdWindow) { - // Give the window a callback it can use to access our MSP object to send to CF - createdWindow.contentWindow.setRawRx = MSP.setRawRx; + // Give the window a callback it can use to send the channels (otherwise it can't see those objects) + createdWindow.contentWindow.setRawRx = function(channels) { + if (CONFIGURATOR.connectionValid && GUI.active_tab != 'cli') { + MSP.setRawRx(channels); + return true; + } else { + return false; + } + } }); }); diff --git a/tabs/receiver_msp.js b/tabs/receiver_msp.js index 91fd9c24..2cb2c353 100644 --- a/tabs/receiver_msp.js +++ b/tabs/receiver_msp.js @@ -53,7 +53,10 @@ function transmitChannels() { } // Callback given to us by the window creator so we can have it send data over MSP for us: - window.setRawRx(channelValues); + if (!window.setRawRx(channelValues)) { + // MSP connection has gone away + chrome.app.window.current().close(); + } } function stickPortionToChannelValue(portion) { @@ -178,5 +181,5 @@ $(document).ready(function() { updateControlPositions(); - setInterval(transmitChannels, 100); + setInterval(transmitChannels, 50); }); \ No newline at end of file