1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-25 17:25:16 +03:00

Filter MSP Output while opening CLI

This commit is contained in:
Mark Haslinghuis 2021-03-31 23:28:54 +02:00
parent 9ece824971
commit 7340d9420b

View file

@ -5,6 +5,7 @@ TABS.cli = {
profileSwitchDelayMs: 100, profileSwitchDelayMs: 100,
outputHistory: "", outputHistory: "",
cliBuffer: "", cliBuffer: "",
startProcessing: false,
GUI: { GUI: {
snippetPreviewWindow: null, snippetPreviewWindow: null,
copyButton: null, copyButton: null,
@ -83,6 +84,7 @@ TABS.cli.initialize = function (callback) {
self.outputHistory = ""; self.outputHistory = "";
self.cliBuffer = ""; self.cliBuffer = "";
self.startProcessing = false;
const enterKeyCode = 13; const enterKeyCode = 13;
@ -400,9 +402,11 @@ TABS.cli.read = function (readInfo) {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
const currentChar = String.fromCharCode(data[i]); const currentChar = String.fromCharCode(data[i]);
const isCRLF = currentChar.charCodeAt() === lineFeedCode || currentChar.charCodeAt() === carriageReturnCode;
if (!CONFIGURATOR.cliValid) { if (!CONFIGURATOR.cliValid && (isCRLF || this.startProcessing)) {
// try to catch part of valid CLI enter message // try to catch part of valid CLI enter message (firmware message starts with CRLF)
this.startProcessing = true;
validateText += currentChar; validateText += currentChar;
writeToOutput(currentChar); writeToOutput(currentChar);
continue; continue;
@ -419,6 +423,7 @@ TABS.cli.read = function (readInfo) {
continue; continue;
} }
if (CONFIGURATOR.cliValid) {
switch (data[i]) { switch (data[i]) {
case lineFeedCode: case lineFeedCode:
if (GUI.operating_system === "Windows") { if (GUI.operating_system === "Windows") {
@ -446,6 +451,7 @@ TABS.cli.read = function (readInfo) {
default: default:
this.cliBuffer += currentChar; this.cliBuffer += currentChar;
} }
}
if (!CliAutoComplete.isBuilding()) { if (!CliAutoComplete.isBuilding()) {
// do not include the building dialog into the history // do not include the building dialog into the history