DFU detection and port UI DFU option injection

10.3.x-maintenance
cTn 2014-06-08 20:10:07 +02:00
parent a0582fd79f
commit b5a1015610
4 changed files with 31 additions and 5 deletions

View File

@ -131,10 +131,27 @@ port_handler.prototype.check = function() {
self.initial_ports = current_ports; self.initial_ports = current_ports;
} }
check_usb_devices();
});
function check_usb_devices() {
chrome.usb.getDevices(usbDevices.STM32DFU, function(result) {
if (result.length) {
if (!$("div#port-picker .port select [value='DFU']").length) {
$('div#port-picker .port select').append('<option value="DFU">DFU</option>');
$('div#port-picker .port select').val('DFU');
}
} else {
if ($("div#port-picker .port select [value='DFU']").length) {
$("div#port-picker .port select [value='DFU']").remove();
}
}
self.main_timeout_reference = setTimeout(function() { self.main_timeout_reference = setTimeout(function() {
self.check(); self.check();
}, 250); }, 250);
}); });
}
}; };
port_handler.prototype.update_port_select = function(ports) { port_handler.prototype.update_port_select = function(ports) {

View File

@ -10,7 +10,7 @@ $(document).ready(function() {
var selected_port = String($('div#port-picker .port select').val()); var selected_port = String($('div#port-picker .port select').val());
var selected_baud = parseInt($('div#port-picker #baud').val()); var selected_baud = parseInt($('div#port-picker #baud').val());
if (selected_port != '0') { if (selected_port != '0' && selected_port != 'DFU') {
if (!clicks) { if (!clicks) {
console.log('Connecting to: ' + selected_port); console.log('Connecting to: ' + selected_port);
GUI.connecting_to = selected_port; GUI.connecting_to = selected_port;

View File

@ -55,6 +55,11 @@ var STM32DFU_protocol = function() {
}; };
}; };
STM32DFU_protocol.prototype.connect = function(hex) {
var self = this;
self.hex = hex;
};
STM32DFU_protocol.prototype.openDevice = function(callback) { STM32DFU_protocol.prototype.openDevice = function(callback) {
}; };

View File

@ -103,7 +103,11 @@ function tab_initialize_firmware_flasher() {
if (!$(this).hasClass('locked')) { if (!$(this).hasClass('locked')) {
if (!GUI.connect_lock) { // button disabled while flashing is in progress if (!GUI.connect_lock) { // button disabled while flashing is in progress
if (parsed_hex != false) { if (parsed_hex != false) {
if (String($('div#port-picker .port select').val()) != 'DFU') {
STM32.connect(parsed_hex); STM32.connect(parsed_hex);
} else {
STM32DFU.connect(parsed_hex);
}
} else { } else {
STM32.GUI_status(chrome.i18n.getMessage('firmwareFlasherFirmwareNotLoaded')); STM32.GUI_status(chrome.i18n.getMessage('firmwareFlasherFirmwareNotLoaded'));
} }