mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
only fire recovery routine once if bus is not recoverable
This commit is contained in:
parent
619f9032be
commit
e20806c7a8
1 changed files with 30 additions and 26 deletions
14
js/serial.js
14
js/serial.js
|
@ -5,6 +5,7 @@ var serial = {
|
|||
bitrate: 0,
|
||||
bytes_received: 0,
|
||||
bytes_sent: 0,
|
||||
failed: 0,
|
||||
|
||||
transmitting: false,
|
||||
output_buffer: [],
|
||||
|
@ -18,6 +19,7 @@ var serial = {
|
|||
self.bitrate = connectionInfo.bitrate;
|
||||
self.bytes_received = 0;
|
||||
self.bytes_sent = 0;
|
||||
self.failed = 0;
|
||||
|
||||
self.onReceive.addListener(function log_bytes_received(info) {
|
||||
self.bytes_received += info.data.byteLength;
|
||||
|
@ -29,11 +31,15 @@ var serial = {
|
|||
|
||||
switch (info.error) {
|
||||
case 'system_error': // we might be able to recover from this one
|
||||
var crunch_status = function (info) {
|
||||
if (!self.failed++) {
|
||||
chrome.serial.setPaused(self.connectionId, false, function () {
|
||||
self.getInfo(function (info) {
|
||||
if (info) {
|
||||
if (!info.paused) {
|
||||
console.log('SERIAL: Connection recovered from last onReceiveError');
|
||||
googleAnalytics.sendException('Serial: onReceiveError - recovered', false);
|
||||
|
||||
self.failed = 0;
|
||||
} 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...');
|
||||
|
@ -50,11 +56,9 @@ var serial = {
|
|||
console.error(chrome.runtime.lastError.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chrome.serial.setPaused(self.connectionId, false, function () {
|
||||
self.getInfo(crunch_status);
|
||||
});
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'timeout':
|
||||
// TODO
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue