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

Fix reset options #3932

Merged
merged 2 commits into from
May 6, 2024
Merged

Conversation

haslinghuis
Copy link
Member

@haslinghuis haslinghuis commented May 2, 2024

  • Resets the build options when switching flight controller using deep copy
  • Do not call FC.resetState() two times a second in portHandler
  • Fixes after connecting another FC after a build with local build retaining options:

image

image

@haslinghuis haslinghuis added this to the 11.0 milestone May 2, 2024
@haslinghuis haslinghuis self-assigned this May 2, 2024
Copy link

netlify bot commented May 2, 2024

Deploy Preview for origin-betaflight-app ready!

Name Link
🔨 Latest commit 3cae1c9
🔍 Latest deploy log https://app.netlify.com/sites/origin-betaflight-app/deploys/663915c591914f000800a6d0
😎 Deploy Preview https://deploy-preview-3932--origin-betaflight-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

This comment has been minimized.

@haslinghuis haslinghuis requested review from a team and McGiverGim May 3, 2024 18:47
@@ -796,6 +796,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
console.log("Fw git rev:", FC.CONFIG.gitRevision);

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
FC.CONFIG.buildOptions = [];
Copy link
Member

Choose a reason for hiding this comment

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

We have an INITIAL_CONFIG that I think does preciselly that:

const INITIAL_CONFIG = {
apiVersion: "0.0.0",
flightControllerIdentifier: '',
flightControllerVersion: '',
version: 0,
buildInfo: '',
buildKey: '',
buildOptions: [],
gitRevision: '',
multiType: 0,
msp_version: 0, // not specified using semantic versioning
capability: 0,
cycleTime: 0,
i2cError: 0,
cpuload: 0,
cpuTemp: 0,
activeSensors: 0,
mode: 0,
profile: 0,
uid: [0, 0, 0],
accelerometerTrims: [0, 0],
name: '', // present for backwards compatibility before MSP v1.45
craftName: '',
displayName: '', // present for backwards compatibility before MSP v1.45
pilotName: '',
pidProfileNames: ["", "", "", ""],
rateProfileNames: ["", "", "", ""],
numProfiles: 3,
rateProfile: 0,
boardType: 0,
armingDisableCount: 0,
armingDisableFlags: 0,
armingDisabled: false,
runawayTakeoffPreventionDisabled: false,
boardIdentifier: "",
boardVersion: 0,
targetCapabilities: 0,
targetName: "",
boardName: "",
manufacturerId: "",
signature: [],
mcuTypeId: 255,
configurationState: 0,
configStateFlag: 0,
sampleRateHz: 0,
configurationProblems: 0,
hardwareName: '',
};

It contains the buildOptions. Why it does not work?

Copy link
Member Author

Choose a reason for hiding this comment

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

resetState () {
// Using `Object.assign` instead of reassigning to
// trigger the updates on the Vue side
Object.assign(this.CONFIG, INITIAL_CONFIG);

buildOptions is not being reset here. This looks like the root cause. Need further investigation.

Copy link
Member Author

Choose a reason for hiding this comment

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

@McGiverGim

this.CONFIG.buildOptions is even retained when destroying the object and reassign with INITIAL_CONFIG instead of line 229. With this code this.CONFIG.buildOptions is not retaining previous values when switching FC.

this.CONFIG = null;
this.CONFIG = INITIAL_CONFIG;

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link

sonarqubecloud bot commented May 6, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

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

Copy link
Contributor

github-actions bot commented May 6, 2024

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

@haslinghuis haslinghuis requested a review from asizon May 6, 2024 17:51
Copy link
Member

@McGiverGim McGiverGim left a comment

Choose a reason for hiding this comment

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

Not tested, but looks good to me 👌

@haslinghuis haslinghuis merged commit 776a1f5 into betaflight:master May 6, 2024
11 of 12 checks passed
@haslinghuis haslinghuis deleted the fix-reset-options branch May 6, 2024 20:45
VitroidFPV pushed a commit to VitroidFPV/betaflight-configurator that referenced this pull request May 13, 2024
* Fix reset options

* Use deep copy
OGCJM11 pushed a commit to OGCJM11/betaflight-configurator that referenced this pull request Dec 28, 2024
* Fix reset options

* Use deep copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants