mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 00:35:26 +03:00
parent
acd92a40d3
commit
697943b512
2 changed files with 10 additions and 8 deletions
|
@ -47,7 +47,8 @@ const serial = {
|
||||||
self.connectionType = 'serial';
|
self.connectionType = 'serial';
|
||||||
|
|
||||||
chrome.serial.connect(path, options, function (connectionInfo) {
|
chrome.serial.connect(path, options, function (connectionInfo) {
|
||||||
if (connectionInfo && !self.openCanceled && !checkChromeRuntimeError()) {
|
self.failed = checkChromeRuntimeError();
|
||||||
|
if (connectionInfo && !self.openCanceled && !self.failed) {
|
||||||
self.connected = true;
|
self.connected = true;
|
||||||
self.connectionId = connectionInfo.connectionId;
|
self.connectionId = connectionInfo.connectionId;
|
||||||
self.bitrate = connectionInfo.bitrate;
|
self.bitrate = connectionInfo.bitrate;
|
||||||
|
@ -65,6 +66,7 @@ const serial = {
|
||||||
if (!self.failed++) {
|
if (!self.failed++) {
|
||||||
chrome.serial.setPaused(self.connectionId, false, function () {
|
chrome.serial.setPaused(self.connectionId, false, function () {
|
||||||
self.getInfo(function (getInfo) {
|
self.getInfo(function (getInfo) {
|
||||||
|
checkChromeRuntimeError();
|
||||||
if (getInfo) {
|
if (getInfo) {
|
||||||
if (!getInfo.paused) {
|
if (!getInfo.paused) {
|
||||||
console.log(`${self.connectionType}: connection recovered from last onReceiveError`);
|
console.log(`${self.connectionType}: connection recovered from last onReceiveError`);
|
||||||
|
@ -74,8 +76,6 @@ const serial = {
|
||||||
gui_log(i18n.getMessage('serialUnrecoverable'));
|
gui_log(i18n.getMessage('serialUnrecoverable'));
|
||||||
self.errorHandler(getInfo.error, 'receive');
|
self.errorHandler(getInfo.error, 'receive');
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
checkChromeRuntimeError();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -87,13 +87,14 @@ const serial = {
|
||||||
self.error = info.error;
|
self.error = info.error;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
chrome.serial.setPaused(info.connectionId, false, function() {
|
chrome.serial.setPaused(info.connectionId, false, function() {
|
||||||
self.getInfo(function (_info) {
|
checkChromeRuntimeError();
|
||||||
if (_info) {
|
self.getInfo(function (getInfo) {
|
||||||
if (_info.paused) {
|
if (getInfo) {
|
||||||
|
if (getInfo.paused) {
|
||||||
// assume unrecoverable, disconnect
|
// assume unrecoverable, disconnect
|
||||||
console.log(`${self.connectionType}: connection did not recover from ${self.error} condition, disconnecting`);
|
console.log(`${self.connectionType}: connection did not recover from ${self.error} condition, disconnecting`);
|
||||||
gui_log(i18n.getMessage('serialUnrecoverable'));
|
gui_log(i18n.getMessage('serialUnrecoverable'));
|
||||||
self.errorHandler(_info.error, 'receive');
|
self.errorHandler(getInfo.error, 'receive');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log(`${self.connectionType}: connection recovered from ${self.error} condition`);
|
console.log(`${self.connectionType}: connection recovered from ${self.error} condition`);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
import { mixerList } from "../model";
|
import { mixerList } from "../model";
|
||||||
import CONFIGURATOR from "../data_storage";
|
import CONFIGURATOR from "../data_storage";
|
||||||
|
import { gui_log } from "../gui_log";
|
||||||
|
|
||||||
export function millitime() {
|
export function millitime() {
|
||||||
return new Date().getTime();
|
return new Date().getTime();
|
||||||
|
@ -39,7 +40,7 @@ export function isInt(n) {
|
||||||
export function checkChromeRuntimeError() {
|
export function checkChromeRuntimeError() {
|
||||||
if (chrome.runtime.lastError) {
|
if (chrome.runtime.lastError) {
|
||||||
console.error(`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${new Error().stack}`);
|
console.error(`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${new Error().stack}`);
|
||||||
|
gui_log(`Chrome API Error: ${chrome.runtime.lastError.message}.`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue