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:
parent
0baad91237
commit
343cb15e61
2 changed files with 36 additions and 19 deletions
39
js/serial.js
39
js/serial.js
|
@ -3,7 +3,6 @@ var serial = {
|
|||
bitrate: 0,
|
||||
bytes_received: 0,
|
||||
bytes_sent: 0,
|
||||
connectionRecovered: 0,
|
||||
|
||||
transmitting: false,
|
||||
output_buffer: [],
|
||||
|
@ -26,18 +25,22 @@ var serial = {
|
|||
console.error(info);
|
||||
ga_tracker.sendEvent('Error', 'Serial', info.error);
|
||||
|
||||
// valid conditions are 'disconnected', 'timeout', 'device_lost', 'system_error'
|
||||
if (info.error == 'system_error') {
|
||||
// we might be able to recover from this one
|
||||
chrome.serial.setPaused(self.connectionId, false, function() {
|
||||
console.log('SERIAL: Connection unpause after onReceiveError triggered');
|
||||
self.connectionRecovered++;
|
||||
});
|
||||
switch (info.error) {
|
||||
case 'system_error': // we might be able to recover from this one
|
||||
chrome.serial.setPaused(self.connectionId, false, get_status);
|
||||
|
||||
function get_status() {
|
||||
self.getInfo(crunch_status);
|
||||
}
|
||||
|
||||
if (self.connectionRecovered >= 10) {
|
||||
console.log('SERIAL: Connection recovery failed, disconnecting');
|
||||
function crunch_status(info) {
|
||||
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...');
|
||||
ga_tracker.sendEvent('Error', 'Serial', 'unrecoverable');
|
||||
|
||||
if ($('a.connect').hasClass('active')) {
|
||||
$('a.connect').click();
|
||||
|
@ -45,6 +48,18 @@ var serial = {
|
|||
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);
|
||||
|
@ -83,7 +98,6 @@ var serial = {
|
|||
|
||||
self.connectionId = -1;
|
||||
self.bitrate = 0;
|
||||
self.connectionRecovered = 0;
|
||||
|
||||
if (callback) callback(result);
|
||||
});
|
||||
|
@ -98,6 +112,9 @@ var serial = {
|
|||
callback(devices);
|
||||
});
|
||||
},
|
||||
getInfo: function(callback) {
|
||||
chrome.serial.getInfo(this.connectionId, callback);
|
||||
},
|
||||
setControlSignals: function(signals, callback) {
|
||||
chrome.serial.setControlSignals(this.connectionId, signals, callback);
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"minimum_chrome_version": "33",
|
||||
"version": "0.44.3",
|
||||
"version": "0.44.4",
|
||||
|
||||
"author": "cTn",
|
||||
"name": "Baseflight - Configurator",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue