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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

let option = data.readU16();
while (option) {
FC.CONFIG.buildOptions.push(option);
Expand Down