mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-16 21:05:28 +03:00
Fix the 0.63.0 serial port configuration migration code.
This commit is contained in:
parent
9ee66994b0
commit
2e5acfc1bd
1 changed files with 56 additions and 47 deletions
|
@ -8,7 +8,8 @@ function configuration_backup(callback) {
|
||||||
|
|
||||||
var configuration = {
|
var configuration = {
|
||||||
'generatedBy': chrome.runtime.getManifest().version,
|
'generatedBy': chrome.runtime.getManifest().version,
|
||||||
'profiles': []
|
'profiles': [],
|
||||||
|
'apiVersion': CONFIG.apiVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
MSP.send_message(MSP_codes.MSP_STATUS, false, false, function () {
|
MSP.send_message(MSP_codes.MSP_STATUS, false, false, function () {
|
||||||
|
@ -240,11 +241,9 @@ function configuration_restore(callback) {
|
||||||
// validate
|
// validate
|
||||||
if (typeof configuration.generatedBy !== 'undefined' && compareVersions(configuration.generatedBy, CONFIGURATOR.backupFileMinVersionAccepted)) {
|
if (typeof configuration.generatedBy !== 'undefined' && compareVersions(configuration.generatedBy, CONFIGURATOR.backupFileMinVersionAccepted)) {
|
||||||
|
|
||||||
if (configuration.generatedBy != chrome.runtime.getManifest().version) {
|
if (!migrate(configuration)) {
|
||||||
if (!migrate(configuration)) {
|
GUI.log(chrome.i18n.getMessage('backupFileUnmigratable'));
|
||||||
GUI.log(chrome.i18n.getMessage('backupFileUnmigratable'));
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration_upload(configuration, callback);
|
configuration_upload(configuration, callback);
|
||||||
|
@ -262,6 +261,9 @@ function configuration_restore(callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
function compareVersions(generated, required) {
|
function compareVersions(generated, required) {
|
||||||
|
if (generated == undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var a = generated.split('.'),
|
var a = generated.split('.'),
|
||||||
b = required.split('.');
|
b = required.split('.');
|
||||||
|
|
||||||
|
@ -344,46 +346,6 @@ function configuration_restore(callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Serial configuation redesigned
|
|
||||||
var ports = [];
|
|
||||||
for (var portIndex = 0; portIndex < configuration.SERIAL_CONFIG.ports.length; portIndex++) {
|
|
||||||
var oldPort = configuration.SERIAL_CONFIG.ports[portIndex];
|
|
||||||
|
|
||||||
var newPort = {
|
|
||||||
identifier: oldPort.identifier,
|
|
||||||
functionMask: 0,
|
|
||||||
msp_baudrate: configuration.SERIAL_CONFIG.mspBaudRate,
|
|
||||||
gps_baudrate: configuration.SERIAL_CONFIG.gpsBaudRate,
|
|
||||||
telemetry_baudrate: 0, // auto
|
|
||||||
blackbox_baudrate: 5, // 115200
|
|
||||||
};
|
|
||||||
|
|
||||||
switch(oldPort.scenario) {
|
|
||||||
case 1: // MSP, CLI, TELEMETRY, SMARTPORT TELEMETRY, GPS-PASSTHROUGH
|
|
||||||
case 5: // MSP, CLI, GPS-PASSTHROUGH
|
|
||||||
case 8: // MSP ONLY
|
|
||||||
newPort.functionMask = 1; // FUCNTION_MSP
|
|
||||||
break;
|
|
||||||
case 2: // GPS
|
|
||||||
newPort.functionMask = 2; // FUNCTION_GPS
|
|
||||||
break;
|
|
||||||
case 3: // RX_SERIAL
|
|
||||||
newPort.functionMask = 64; // FUNCTION_RX_SERIAL
|
|
||||||
break;
|
|
||||||
case 10: // BLACKBOX ONLY
|
|
||||||
newPort.functionMask = 128; // FUNCTION_BLACKBOX
|
|
||||||
break;
|
|
||||||
case 11: // MSP, CLI, BLACKBOX, GPS-PASSTHROUGH
|
|
||||||
newPort.functionMask = 1 + 128; // FUNCTION_BLACKBOX
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ports.push(newPort);
|
|
||||||
}
|
|
||||||
configuration.SERIAL_CONFIG = {
|
|
||||||
ports: ports
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var profileIndex = 0; profileIndex < 3; profileIndex++) {
|
for (var profileIndex = 0; profileIndex < 3; profileIndex++) {
|
||||||
var RC = configuration.profiles[profileIndex].RC;
|
var RC = configuration.profiles[profileIndex].RC;
|
||||||
// TPA breakpoint was added
|
// TPA breakpoint was added
|
||||||
|
@ -401,7 +363,54 @@ function configuration_restore(callback) {
|
||||||
appliedMigrationsCount++;
|
appliedMigrationsCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.log(chrome.i18n.getMessage('configMigrationSuccessful', [appliedMigrationsCount]));
|
if (compareVersions(migratedVersion, '0.63.0') && !compareVersions(configuration.apiVersion, '1.7')) {
|
||||||
|
// Serial configuation redesigned, 0.63.0 saves old and new configurations.
|
||||||
|
var ports = [];
|
||||||
|
for (var portIndex = 0; portIndex < configuration.SERIAL_CONFIG.ports.length; portIndex++) {
|
||||||
|
var oldPort = configuration.SERIAL_CONFIG.ports[portIndex];
|
||||||
|
|
||||||
|
var newPort = {
|
||||||
|
identifier: oldPort.identifier,
|
||||||
|
functions: [],
|
||||||
|
msp_baudrate: String(configuration.SERIAL_CONFIG.mspBaudRate),
|
||||||
|
gps_baudrate: String(configuration.SERIAL_CONFIG.gpsBaudRate),
|
||||||
|
telemetry_baudrate: 'AUTO',
|
||||||
|
blackbox_baudrate: '115200',
|
||||||
|
};
|
||||||
|
|
||||||
|
switch(oldPort.scenario) {
|
||||||
|
case 1: // MSP, CLI, TELEMETRY, SMARTPORT TELEMETRY, GPS-PASSTHROUGH
|
||||||
|
case 5: // MSP, CLI, GPS-PASSTHROUGH
|
||||||
|
case 8: // MSP ONLY
|
||||||
|
newPort.functions.push('MSP');
|
||||||
|
break;
|
||||||
|
case 2: // GPS
|
||||||
|
newPort.functions.push('GPS');
|
||||||
|
break;
|
||||||
|
case 3: // RX_SERIAL
|
||||||
|
newPort.functions.push('RX_SERIAL');
|
||||||
|
break;
|
||||||
|
case 10: // BLACKBOX ONLY
|
||||||
|
newPort.functions.push('BLACKBOX');
|
||||||
|
break;
|
||||||
|
case 11: // MSP, CLI, BLACKBOX, GPS-PASSTHROUGH
|
||||||
|
newPort.functions.push('MSP');
|
||||||
|
newPort.functions.push('BLACKBOX');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ports.push(newPort);
|
||||||
|
}
|
||||||
|
configuration.SERIAL_CONFIG = {
|
||||||
|
ports: ports
|
||||||
|
};
|
||||||
|
|
||||||
|
appliedMigrationsCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appliedMigrationsCount > 0) {
|
||||||
|
GUI.log(chrome.i18n.getMessage('configMigrationSuccessful', [appliedMigrationsCount]));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue