add a default handler for serial errors (disconnect) (#1522)
add a default handler for serial errors (disconnect)10.7.0-preview
commit
e1af1fbd52
|
@ -306,6 +306,13 @@
|
|||
"message": "Show Log"
|
||||
},
|
||||
|
||||
"serialErrorFrameError": {
|
||||
"message": "Serial connection error: bad framing"
|
||||
},
|
||||
"serialErrorParityError": {
|
||||
"message": "Serial connection error: bad parity"
|
||||
},
|
||||
|
||||
"serialPortOpened": {
|
||||
"message": "Serial port <span class=\"message-positive\">successfully</span> opened with ID: $1"
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var serial = {
|
||||
connected: false,
|
||||
connected: false,
|
||||
connectionId: false,
|
||||
openRequested: false,
|
||||
openCanceled: false,
|
||||
|
@ -39,7 +39,7 @@ var serial = {
|
|||
}
|
||||
|
||||
if (connectionInfo && !self.openCanceled) {
|
||||
self.connected = true;
|
||||
self.connected = true;
|
||||
self.connectionId = connectionInfo.connectionId;
|
||||
self.bitrate = connectionInfo.bitrate;
|
||||
self.bytesReceived = 0;
|
||||
|
@ -52,8 +52,6 @@ var serial = {
|
|||
});
|
||||
|
||||
self.onReceiveError.addListener(function watch_for_on_receive_errors(info) {
|
||||
console.error(info);
|
||||
|
||||
switch (info.error) {
|
||||
case 'system_error': // we might be able to recover from this one
|
||||
if (!self.failed++) {
|
||||
|
@ -84,8 +82,6 @@ var serial = {
|
|||
}
|
||||
break;
|
||||
|
||||
//case 'break':
|
||||
// This occurs on F1 boards with old firmware during reboot
|
||||
case 'overrun':
|
||||
// wait 50 ms and attempt recovery
|
||||
self.error = info.error;
|
||||
|
@ -114,11 +110,18 @@ var serial = {
|
|||
break;
|
||||
|
||||
case 'timeout':
|
||||
// TODO
|
||||
// No data has been received for receiveTimeout milliseconds.
|
||||
// We will do nothing.
|
||||
break;
|
||||
|
||||
case 'frame_error':
|
||||
case 'parity_error':
|
||||
GUI.log(i18n.getMessage('serialError' + inflection.camelize(info.error)));
|
||||
case 'break': // This seems to be the error that is thrown under NW.js in Windows when the device reboots after typing 'exit' in CLI
|
||||
case 'disconnected':
|
||||
case 'device_lost':
|
||||
default:
|
||||
console.log("serial disconnecting: " + info.error);
|
||||
CONFIG.armingDisabled = false;
|
||||
CONFIG.runawayTakeoffPreventionDisabled = false;
|
||||
|
||||
|
@ -128,10 +131,6 @@ var serial = {
|
|||
self.disconnect();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'disconnected':
|
||||
// TODO
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue