1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-14 11:59:51 +03:00

another experimental fix for serial "system_error"

This commit is contained in:
cTn 2014-07-01 12:48:20 +02:00
parent 0baad91237
commit 343cb15e61
2 changed files with 36 additions and 19 deletions

View file

@ -3,7 +3,6 @@ var serial = {
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: [],
@ -26,18 +25,22 @@ var serial = {
console.error(info); console.error(info);
ga_tracker.sendEvent('Error', 'Serial', info.error); ga_tracker.sendEvent('Error', 'Serial', info.error);
// valid conditions are 'disconnected', 'timeout', 'device_lost', 'system_error' switch (info.error) {
if (info.error == 'system_error') { case 'system_error': // we might be able to recover from this one
// we might be able to recover from this one chrome.serial.setPaused(self.connectionId, false, get_status);
chrome.serial.setPaused(self.connectionId, false, function() {
console.log('SERIAL: Connection unpause after onReceiveError triggered'); function get_status() {
self.connectionRecovered++; self.getInfo(crunch_status);
});
} }
if (self.connectionRecovered >= 10) { function crunch_status(info) {
console.log('SERIAL: Connection recovery failed, disconnecting'); if (!info.paused) {
console.log('SERIAL: Connection recovered from last onReceiveError');
ga_tracker.sendEvent('Error', 'Serial', 'recovered');
} else {
console.log('SERIAL: Connection did not recover from last onReceiveError, disconnecting');
GUI.log('Unrecoverable <span style="color: red">failure</span> of serial connection, disconnecting...'); GUI.log('Unrecoverable <span style="color: red">failure</span> of serial connection, disconnecting...');
ga_tracker.sendEvent('Error', 'Serial', 'unrecoverable');
if ($('a.connect').hasClass('active')) { if ($('a.connect').hasClass('active')) {
$('a.connect').click(); $('a.connect').click();
@ -45,6 +48,18 @@ var serial = {
self.disconnect(); self.disconnect();
} }
} }
}
break;
case 'timeout':
// TODO
break;
case 'device_lost':
// TODO
break;
case 'disconnected':
// TODO
break;
}
}); });
console.log('SERIAL: Connection opened with ID: ' + connectionInfo.connectionId + ', Baud: ' + connectionInfo.bitrate); console.log('SERIAL: Connection opened with ID: ' + connectionInfo.connectionId + ', Baud: ' + connectionInfo.bitrate);
@ -83,7 +98,6 @@ var serial = {
self.connectionId = -1; self.connectionId = -1;
self.bitrate = 0; self.bitrate = 0;
self.connectionRecovered = 0;
if (callback) callback(result); if (callback) callback(result);
}); });
@ -98,6 +112,9 @@ var serial = {
callback(devices); callback(devices);
}); });
}, },
getInfo: function(callback) {
chrome.serial.getInfo(this.connectionId, callback);
},
setControlSignals: function(signals, callback) { setControlSignals: function(signals, callback) {
chrome.serial.setControlSignals(this.connectionId, signals, callback); chrome.serial.setControlSignals(this.connectionId, signals, callback);
}, },

View file

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