Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presets: ignore CLI error messages caused by resetting defaults #3635

Closed

Conversation

limonspb
Copy link
Member

@limonspb limonspb commented Nov 17, 2023

this PR is mainly for BF 4.4 where resetting to defaults causes CLI errors.
This problem makes the CLI dialog to show up every time the user hit "save" on the presets tab, or loads a backup.
The solution is to ignore errors that's popping right after resetting to defaults.

While working, i also noticed a bug that presets CLI messages timeout are being ignored.

This comment has been minimized.

Copy link

sonarcloud bot commented Nov 17, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
5.4% 5.4% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Copy link
Contributor

Do you want to test this code? Here you have an automated build:
Betaflight-Configurator-Android
Betaflight-Configurator-Linux
Betaflight-Configurator-macOS
Betaflight-Configurator-Windows
WARNING: It may be unstable and result in corrupted configurations or data loss. Use only for testing!

haslinghuis
haslinghuis previously approved these changes Nov 17, 2023
@blckmn
Copy link
Member

blckmn commented Nov 17, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> FAIL
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> PASS
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> FAIL
  • assigned to an approver -> FAIL
  • approver count at least three -> FAIL

@nerdCopter
Copy link
Member

  • Please explain why is it a problem? errors are useful to show changes that might otherwise be hidden/ignored.
  • or maybe i cannot reproduce the same errors that you wish to avoid. Can provide a diff for me to test from?
  • and where i should expect to view any errors. (e.g. setup>reset, presets>save, CLI>defaults nosave)

@limonspb
Copy link
Member Author

  • Please explain why is it a problem? errors are useful to show changes that might otherwise be hidden/ignored.
  • or maybe i cannot reproduce the same errors that you wish to avoid. Can provide a diff for me to test from?
  • and where i should expect to view any errors. (e.g. setup>reset, presets>save, CLI>defaults nosave)

I can reproduce pretty much on any FC.

  1. Flash betaflight 4.4 (not 4.5)
  2. Open CLI, type "defaults nosave"
  3. See errors.

Same errors will pop when you load backup on presets tab.

They appear when 4.4 build doesn't include, for example, baro, or camera control, but the config file for the board has it. For example foxeer F7 v1-V4
image-19

@@ -72,7 +73,7 @@ export default class CliEngine
}

close(callback) {
this.send(this.getCliCommand('exit\r', ""), function () { //this.cliBuffer
this.send(this.getCliCommand('exit\r', ""), function () { //this._cliBuffer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unused.

Suggested change
this.send(this.getCliCommand('exit\r', ""), function () { //this._cliBuffer
this.send(this.getCliCommand('exit\r', ""), function () {

Comment on lines 161 to +169
if (text.startsWith("###ERROR")) {
this.writeToOutput(`<span class="error_message">${text}</span><br>`);
this._cliErrorsCount++;
if (this._lastCommandIsDefaults) {
this.writeToOutput(`<span class="warning_message">${text}</span><br>`);
} else {
this.writeToOutput(`<span class="error_message">${text}</span><br>`);
this._cliErrorsCount++;
}
} else {
this._lastCommandIsDefaults = text.toLowerCase().includes(CliEngine.s_outputResetting);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is plain text used for logging and the actual logic here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get the question

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So instead of sending something like this

{
  type: 'error',
  message: '###ERROR some error message',
}

we have plain string which is used for display and hope that this value is formatted correctly when we do the logic. Like the meaning of the message is not separate from display.

Like, if for example this would be localised at some point, wouldn't ###ERROR become ###BŁAD in polish

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see yeah, it could be improved. This part is straight copy-paste from CLI tab.

@haslinghuis haslinghuis dismissed their stale review November 21, 2023 12:07

I've also now found some errors in presets for 4.5 - so I don't think it's a good idea to mask them.

@limonspb
Copy link
Member Author

limonspb commented Nov 24, 2023

@haslinghuis it's not masking all errors, just the ones coming right after "defaults nosave". If presets got errors, they still be shown.

@haslinghuis
Copy link
Member

@limonspb we should rather fix the underlying problem in firmware and look at each error (as we still can see the errors in cli).

@limonspb
Copy link
Member Author

limonspb commented Nov 25, 2023

@limonspb we should rather fix the underlying problem in firmware and look at each error (as we still can see the errors in cli).

I wish it was possible for 4.4
4.5 has it fixed already somehow.

But 4.4 had this problem since the beginning. I think it's because default config might have some commands like camera control, that might not be included in the actual firmware build.

@haslinghuis haslinghuis removed this from the 10.10.0 milestone Dec 5, 2023
@limonspb limonspb closed this Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants