1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 01:05:27 +03:00

track bus recovery so it wouldn't fall into infinite loop, experimental fix

This commit is contained in:
cTn 2014-07-01 04:13:33 +02:00
parent c342ad5997
commit 0baad91237
2 changed files with 22 additions and 8 deletions

View file

@ -1,8 +1,9 @@
var serial = { var serial = {
connectionId: -1, connectionId: -1,
bitrate: 0, bitrate: 0,
bytes_received: 0, bytes_received: 0,
bytes_sent: 0, bytes_sent: 0,
connectionRecovered: 0,
transmitting: false, transmitting: false,
output_buffer: [], output_buffer: [],
@ -30,17 +31,29 @@ var serial = {
// we might be able to recover from this one // we might be able to recover from this one
chrome.serial.setPaused(self.connectionId, false, function() { chrome.serial.setPaused(self.connectionId, false, function() {
console.log('SERIAL: Connection unpause after onReceiveError triggered'); console.log('SERIAL: Connection unpause after onReceiveError triggered');
self.connectionRecovered++;
}); });
} }
if (self.connectionRecovered >= 10) {
console.log('SERIAL: Connection recovery failed, disconnecting');
GUI.log('Unrecoverable <span style="color: red">failure</span> of serial connection, disconnecting...');
if ($('a.connect').hasClass('active')) {
$('a.connect').click();
} else {
self.disconnect();
}
}
}); });
console.log('SERIAL: Connection opened with ID: ' + connectionInfo.connectionId + ', Baud: ' + connectionInfo.bitrate); console.log('SERIAL: Connection opened with ID: ' + connectionInfo.connectionId + ', Baud: ' + connectionInfo.bitrate);
callback(connectionInfo); if (callback) callback(connectionInfo);
} else { } else {
console.log('SERIAL: Failed to open serial port'); console.log('SERIAL: Failed to open serial port');
ga_tracker.sendEvent('Error', 'Serial', 'FailedToOpen'); ga_tracker.sendEvent('Error', 'Serial', 'FailedToOpen');
callback(false); if (callback) callback(false);
} }
}); });
}, },
@ -70,8 +83,9 @@ var serial = {
self.connectionId = -1; self.connectionId = -1;
self.bitrate = 0; self.bitrate = 0;
self.connectionRecovered = 0;
callback(result); if (callback) callback(result);
}); });
}, },
getDevices: function(callback) { getDevices: function(callback) {

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"minimum_chrome_version": "33", "minimum_chrome_version": "33",
"version": "0.44.2", "version": "0.44.3",
"author": "cTn", "author": "cTn",
"name": "Baseflight - Configurator", "name": "Baseflight - Configurator",