mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-21 07:15:15 +03:00
Merge pull request #1296 from mikeller/add_vcp_detection
Added auto-detection of VCP targets. Also added re-connecting after reboot for VCP targets.
This commit is contained in:
commit
0deb83a370
8 changed files with 71 additions and 135 deletions
44
src/js/fc.js
44
src/js/fc.js
|
@ -466,20 +466,6 @@ var FC = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
MCU_TYPES: {
|
|
||||||
0: "SIMULATOR",
|
|
||||||
1: "F103",
|
|
||||||
2: "F303",
|
|
||||||
3: "F40X",
|
|
||||||
4: "F411",
|
|
||||||
5: "F446",
|
|
||||||
6: "F722",
|
|
||||||
7: "F745",
|
|
||||||
8: "F746",
|
|
||||||
9: "F765",
|
|
||||||
255: "Unknown MCU",
|
|
||||||
},
|
|
||||||
|
|
||||||
getHardwareName: function () {
|
getHardwareName: function () {
|
||||||
let name;
|
let name;
|
||||||
if (CONFIG.targetName) {
|
if (CONFIG.targetName) {
|
||||||
|
@ -499,7 +485,37 @@ var FC = {
|
||||||
return name;
|
return name;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
MCU_TYPES: {
|
||||||
|
0: "SIMULATOR",
|
||||||
|
1: "F103",
|
||||||
|
2: "F303",
|
||||||
|
3: "F40X",
|
||||||
|
4: "F411",
|
||||||
|
5: "F446",
|
||||||
|
6: "F722",
|
||||||
|
7: "F745",
|
||||||
|
8: "F746",
|
||||||
|
9: "F765",
|
||||||
|
255: "Unknown MCU",
|
||||||
|
},
|
||||||
|
|
||||||
getMcuType: function () {
|
getMcuType: function () {
|
||||||
return FC.MCU_TYPES[CONFIG.mcuTypeId];
|
return FC.MCU_TYPES[CONFIG.mcuTypeId];
|
||||||
|
},
|
||||||
|
|
||||||
|
COMM_CAPABILITIES_FLAGS: {
|
||||||
|
HAS_VCP: 0x01,
|
||||||
|
HAS_SOFTSERIAL: 0x02,
|
||||||
|
},
|
||||||
|
|
||||||
|
boardHasVcp: function () {
|
||||||
|
var hasVcp = false;
|
||||||
|
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
|
||||||
|
hasVcp = (CONFIG.commCapabilities & FC.COMM_CAPABILITIES_FLAGS.HAS_VCP) !== 0;
|
||||||
|
} else {
|
||||||
|
hasVcp = BOARD.find_board_definition(CONFIG.boardIdentifier).vcp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return hasVcp;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -724,3 +724,23 @@ function update_dataflash_global() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reinitialiseConnection(originatorTab, callback) {
|
||||||
|
GUI.log(i18n.getMessage('deviceRebooting'));
|
||||||
|
|
||||||
|
if (FC.boardHasVcp()) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
||||||
|
setTimeout(function start_connection() {
|
||||||
|
$('a.connect').click();
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}, 2500);
|
||||||
|
} else {
|
||||||
|
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
||||||
|
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function() {
|
||||||
|
GUI.log(i18n.getMessage('deviceReady'));
|
||||||
|
originatorTab.initialize(false, $('#content').scrollTop());
|
||||||
|
});
|
||||||
|
}, 1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -291,24 +291,7 @@ TABS.cli.read = function (readInfo) {
|
||||||
CONFIGURATOR.cliActive = false;
|
CONFIGURATOR.cliActive = false;
|
||||||
CONFIGURATOR.cliValid = false;
|
CONFIGURATOR.cliValid = false;
|
||||||
GUI.log(i18n.getMessage('cliReboot'));
|
GUI.log(i18n.getMessage('cliReboot'));
|
||||||
GUI.log(i18n.getMessage('deviceRebooting'));
|
reinitialiseConnection(self);
|
||||||
|
|
||||||
if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
|
||||||
$('a.connect').click();
|
|
||||||
GUI.timeout_add('start_connection', function start_connection() {
|
|
||||||
$('a.connect').click();
|
|
||||||
}, 2500);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
|
||||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function () {
|
|
||||||
GUI.log(i18n.getMessage('deviceReady'));
|
|
||||||
if (!GUI.tab_switch_in_progress) {
|
|
||||||
$('#tabs ul.mode-connected .tab_setup a').click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -347,7 +330,10 @@ TABS.cli.send = function (line, callback) {
|
||||||
|
|
||||||
TABS.cli.cleanup = function (callback) {
|
TABS.cli.cleanup = function (callback) {
|
||||||
if (!(CONFIGURATOR.connectionValid && CONFIGURATOR.cliValid && CONFIGURATOR.cliActive)) {
|
if (!(CONFIGURATOR.connectionValid && CONFIGURATOR.cliValid && CONFIGURATOR.cliActive)) {
|
||||||
if (callback) callback();
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.send(getCliCommand('exit\r', this.cliBuffer), function (writeInfo) {
|
this.send(getCliCommand('exit\r', this.cliBuffer), function (writeInfo) {
|
||||||
|
@ -355,9 +341,10 @@ TABS.cli.cleanup = function (callback) {
|
||||||
// (another approach is however much more complicated):
|
// (another approach is however much more complicated):
|
||||||
// we can setup an interval asking for data lets say every 200ms, when data arrives, callback will be triggered and tab switched
|
// we can setup an interval asking for data lets say every 200ms, when data arrives, callback will be triggered and tab switched
|
||||||
// we could probably implement this someday
|
// we could probably implement this someday
|
||||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
reinitialiseConnection(self, function () {
|
||||||
if (callback) callback();
|
GUI.timeout_add('tab_change_callback', callback, 500);
|
||||||
}, 1000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
|
});
|
||||||
CONFIGURATOR.cliActive = false;
|
CONFIGURATOR.cliActive = false;
|
||||||
|
CONFIGURATOR.cliValid = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1194,29 +1194,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||||
|
reinitialiseConnection(self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function reinitialize() {
|
|
||||||
GUI.log(i18n.getMessage('deviceRebooting'));
|
|
||||||
|
|
||||||
if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
|
||||||
$('a.connect').click();
|
|
||||||
GUI.timeout_add('start_connection',function start_connection() {
|
|
||||||
$('a.connect').click();
|
|
||||||
},2500);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
|
||||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function() {
|
|
||||||
GUI.log(i18n.getMessage('deviceReady'));
|
|
||||||
TABS.configuration.initialize(false, $('#content').scrollTop());
|
|
||||||
});
|
|
||||||
},1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
save_serial_config();
|
save_serial_config();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -391,29 +391,11 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||||
|
reinitialiseConnection(self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function reinitialize() {
|
|
||||||
GUI.log(i18n.getMessage('deviceRebooting'));
|
|
||||||
|
|
||||||
if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
|
||||||
$('a.connect').click();
|
|
||||||
GUI.timeout_add('start_connection',function start_connection() {
|
|
||||||
$('a.connect').click();
|
|
||||||
},2500);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
|
||||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function() {
|
|
||||||
GUI.log(i18n.getMessage('deviceReady'));
|
|
||||||
TABS.failsafe.initialize(false, $('#content').scrollTop());
|
|
||||||
});
|
|
||||||
},1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, save_failssafe_config);
|
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, save_failssafe_config);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -50,29 +50,11 @@ TABS.onboard_logging.initialize = function (callback) {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||||
|
reinitialiseConnection(self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function reinitialize() {
|
|
||||||
GUI.log(i18n.getMessage('deviceRebooting'));
|
|
||||||
|
|
||||||
if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
|
||||||
$('a.connect').click();
|
|
||||||
GUI.timeout_add('start_connection',function start_connection() {
|
|
||||||
$('a.connect').click();
|
|
||||||
},2000);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
|
||||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function() {
|
|
||||||
GUI.log(i18n.getMessage('deviceReady'));
|
|
||||||
TABS.onboard_logging.initialize(false, $('#content').scrollTop());
|
|
||||||
});
|
|
||||||
},1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function load_html() {
|
function load_html() {
|
||||||
$('#content').load("./tabs/onboard_logging.html", function() {
|
$('#content').load("./tabs/onboard_logging.html", function() {
|
||||||
// translate to user-selected language
|
// translate to user-selected language
|
||||||
|
@ -424,7 +406,7 @@ TABS.onboard_logging.initialize = function (callback) {
|
||||||
|
|
||||||
function flash_save_begin() {
|
function flash_save_begin() {
|
||||||
if (GUI.connected_to) {
|
if (GUI.connected_to) {
|
||||||
if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) {
|
if (FC.boardHasVcp()) {
|
||||||
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
|
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
|
||||||
self.blockSize = self.VCP_BLOCK_SIZE;
|
self.blockSize = self.VCP_BLOCK_SIZE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -347,27 +347,10 @@ TABS.ports.initialize = function (callback, scrollPosition) {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, on_reboot_success_handler);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||||
|
reinitialiseConnection(self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function on_reboot_success_handler() {
|
|
||||||
GUI.log(i18n.getMessage('deviceRebooting'));
|
|
||||||
|
|
||||||
if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
|
||||||
$('a.connect').click();
|
|
||||||
GUI.timeout_add('start_connection',function start_connection() {
|
|
||||||
$('a.connect').click();
|
|
||||||
},2500);
|
|
||||||
} else {
|
|
||||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
|
||||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function() {
|
|
||||||
GUI.log(i18n.getMessage('deviceReady'));
|
|
||||||
TABS.ports.initialize(false, $('#content').scrollTop());
|
|
||||||
});
|
|
||||||
}, 1500); // seems to be just the right amount of delay to prevent data request timeouts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -304,7 +304,8 @@ TABS.transponder.initialize = function(callback, scrollPosition) {
|
||||||
GUI.log(i18n.getMessage('transponderEepromSaved'));
|
GUI.log(i18n.getMessage('transponderEepromSaved'));
|
||||||
if ( $(_this).hasClass('reboot') ) {
|
if ( $(_this).hasClass('reboot') ) {
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||||
|
reinitialiseConnection(self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -320,23 +321,6 @@ TABS.transponder.initialize = function(callback, scrollPosition) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function reinitialize() {
|
|
||||||
GUI.log(i18n.getMessage('deviceRebooting'));
|
|
||||||
if ( BOARD.find_board_definition(CONFIG.boardIdentifier).vcp ) {
|
|
||||||
$('a.connect').click();
|
|
||||||
GUI.timeout_add('start_connection', function start_connection() {
|
|
||||||
$('a.connect').click();
|
|
||||||
}, 2500);
|
|
||||||
} else {
|
|
||||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
|
||||||
MSP.send_message(MSPCodes.MSP_IDENT, false, false, function() {
|
|
||||||
GUI.log(i18n.getMessage('deviceReady'));
|
|
||||||
TABS.configuration.initialize(false, $('#content').scrollTop());
|
|
||||||
});
|
|
||||||
}, 1500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GUI.content_ready(callback);
|
GUI.content_ready(callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue