fix style

10.3.x-maintenance
cTn 2014-08-14 17:00:32 +02:00
parent d7810e1bb6
commit cc8e53205d
4 changed files with 84 additions and 82 deletions

View File

@ -193,8 +193,9 @@ function configuration_upload() {
// should be reworked in the future, so the same code won't be cloned over !!!
// PID section
var PID_buffer_out = new Array();
var PID_buffer_needle = 0;
var PID_buffer_out = new Array(),
PID_buffer_needle = 0;
for (var i = 0; i < PIDs.length; i++) {
switch (i) {
case 0:
@ -220,6 +221,7 @@ function configuration_upload() {
PID_buffer_out[PID_buffer_needle + 2] = parseInt(PIDs[i][2] * 1000);
break;
}
PID_buffer_needle += 3;
}
@ -243,9 +245,9 @@ function configuration_upload() {
function aux() {
// AUX section
var AUX_val_buffer_out = new Array();
var AUX_val_buffer_out = new Array(),
needle = 0;
var needle = 0;
for (var i = 0; i < AUX_CONFIG_values.length; i++) {
AUX_val_buffer_out[needle++] = lowByte(AUX_CONFIG_values[i]);
AUX_val_buffer_out[needle++] = highByte(AUX_CONFIG_values[i]);

View File

@ -7,7 +7,7 @@
*/
'use strict';
var STM32_protocol = function() {
var STM32_protocol = function () {
this.options = {};
this.hex; // ref
this.verify_hex;
@ -47,7 +47,7 @@ var STM32_protocol = function() {
};
// no input parameters
STM32_protocol.prototype.connect = function(port, baud, hex, options) {
STM32_protocol.prototype.connect = function (port, baud, hex, options) {
var self = this;
self.hex = hex;
@ -69,7 +69,7 @@ STM32_protocol.prototype.connect = function(port, baud, hex, options) {
}
if (self.options.no_reboot) {
serial.connect(port, {bitrate: baud, parityBit: 'even', stopBits: 'one'}, function(openInfo) {
serial.connect(port, {bitrate: baud, parityBit: 'even', stopBits: 'one'}, function (openInfo) {
if (openInfo) {
// we are connected, disabling connect button in the UI
GUI.connect_lock = true;
@ -80,7 +80,7 @@ STM32_protocol.prototype.connect = function(port, baud, hex, options) {
}
});
} else {
serial.connect(port, {bitrate: self.options.reboot_baud}, function(openInfo) {
serial.connect(port, {bitrate: self.options.reboot_baud}, function (openInfo) {
if (openInfo) {
console.log('Sending ascii "R" to reboot');
@ -92,10 +92,10 @@ STM32_protocol.prototype.connect = function(port, baud, hex, options) {
bufferView[0] = 0x52;
serial.send(bufferOut, function() {
serial.disconnect(function(result) {
serial.send(bufferOut, function () {
serial.disconnect(function (result) {
if (result) {
serial.connect(port, {bitrate: baud, parityBit: 'even', stopBits: 'one'}, function(openInfo) {
serial.connect(port, {bitrate: baud, parityBit: 'even', stopBits: 'one'}, function (openInfo) {
if (openInfo) {
self.initialize();
} else {
@ -115,7 +115,7 @@ STM32_protocol.prototype.connect = function(port, baud, hex, options) {
};
// initialize certain variables and start timers that oversee the communication
STM32_protocol.prototype.initialize = function() {
STM32_protocol.prototype.initialize = function () {
var self = this;
// reset and set some variables before we start
@ -130,11 +130,11 @@ STM32_protocol.prototype.initialize = function() {
self.progress_bar_e.val(0);
self.progress_bar_e.removeClass('valid invalid');
serial.onReceive.addListener(function(info) {
serial.onReceive.addListener(function (info) {
self.read(info);
});
GUI.interval_add('STM32_timeout', function() {
GUI.interval_add('STM32_timeout', function () {
if (self.upload_process_alive) { // process is running
self.upload_process_alive = false;
} else {
@ -155,7 +155,7 @@ STM32_protocol.prototype.initialize = function() {
// no input parameters
// this method should be executed every 1 ms via interval timer
STM32_protocol.prototype.read = function(readInfo) {
STM32_protocol.prototype.read = function (readInfo) {
// routine that fills the buffer
var data = new Uint8Array(readInfo.data);
@ -175,7 +175,7 @@ STM32_protocol.prototype.read = function(readInfo) {
};
// we should always try to consume all "proper" available data while using retrieve
STM32_protocol.prototype.retrieve = function(n_bytes, callback) {
STM32_protocol.prototype.retrieve = function (n_bytes, callback) {
if (this.receive_buffer.length >= n_bytes) {
// data that we need are there, process immediately
var data = this.receive_buffer.slice(0, n_bytes);
@ -192,7 +192,7 @@ STM32_protocol.prototype.retrieve = function(n_bytes, callback) {
// Array = array of bytes that will be send over serial
// bytes_to_read = received bytes necessary to trigger read_callback
// callback = function that will be executed after received bytes = bytes_to_read
STM32_protocol.prototype.send = function(Array, bytes_to_read, callback) {
STM32_protocol.prototype.send = function (Array, bytes_to_read, callback) {
// flip flag
this.upload_process_alive = true;
@ -210,13 +210,13 @@ STM32_protocol.prototype.send = function(Array, bytes_to_read, callback) {
this.receive_buffer = [];
// send over the actual data
serial.send(bufferOut, function(writeInfo) {});
serial.send(bufferOut, function (writeInfo) {});
};
// val = single byte to be verified
// data = response of n bytes from mcu (array)
// result = true/false
STM32_protocol.prototype.verify_response = function(val, data) {
STM32_protocol.prototype.verify_response = function (val, data) {
if (val != data[0]) {
console.log('STM32 Communication failed, wrong response, expected: ' + val + ' received: ' + data[0]);
GUI.log('STM32 Communication <span style="color: red">failed</span>, wrong response, expected: ' + val + ' received: ' + data[0]);
@ -232,7 +232,7 @@ STM32_protocol.prototype.verify_response = function(val, data) {
// input = 16 bit value
// result = true/false
STM32_protocol.prototype.verify_chip_signature = function(signature) {
STM32_protocol.prototype.verify_chip_signature = function (signature) {
switch (signature) {
case 0x412: // not tested
console.log('Chip recognized as F1 Low-density');
@ -307,7 +307,7 @@ STM32_protocol.prototype.verify_chip_signature = function(signature) {
// first_array = usually hex_to_flash array
// second_array = usually verify_hex array
// result = true/false
STM32_protocol.prototype.verify_flash = function(first_array, second_array) {
STM32_protocol.prototype.verify_flash = function (first_array, second_array) {
for (var i = 0; i < first_array.length; i++) {
if (first_array[i] != second_array[i]) {
console.log('Verification failed on byte: ' + i + ' expected: 0x' + first_array[i].toString(16) + ' received: 0x' + second_array[i].toString(16));
@ -321,7 +321,7 @@ STM32_protocol.prototype.verify_flash = function(first_array, second_array) {
};
// step = value depending on current state of upload_procedure
STM32_protocol.prototype.upload_procedure = function(step) {
STM32_protocol.prototype.upload_procedure = function (step) {
var self = this;
switch (step) {
@ -330,8 +330,8 @@ STM32_protocol.prototype.upload_procedure = function(step) {
GUI.log('Contacting bootloader ...');
var send_counter = 0;
GUI.interval_add('stm32_initialize_mcu', function() { // 200 ms interval (just in case mcu was already initialized), we need to break the 2 bytes command requirement
self.send([0x7F], 1, function(reply) {
GUI.interval_add('stm32_initialize_mcu', function () { // 200 ms interval (just in case mcu was already initialized), we need to break the 2 bytes command requirement
self.send([0x7F], 1, function (reply) {
if (reply[0] == 0x7F || reply[0] == self.status.ACK || reply[0] == self.status.NACK) {
GUI.interval_remove('stm32_initialize_mcu');
console.log('STM32 - Serial interface initialized on the MCU side');
@ -361,9 +361,9 @@ STM32_protocol.prototype.upload_procedure = function(step) {
break;
case 2:
// get version of the bootloader and supported commands
self.send([self.command.get, 0xFF], 2, function(data) { // 0x00 ^ 0xFF
self.send([self.command.get, 0xFF], 2, function (data) { // 0x00 ^ 0xFF
if (self.verify_response(self.status.ACK, data)) {
self.retrieve(data[1] + 1 + 1, function(data) { // data[1] = number of bytes that will follow [ 1 except current and ACKs]
self.retrieve(data[1] + 1 + 1, function (data) { // data[1] = number of bytes that will follow [ 1 except current and ACKs]
console.log('STM32 - Bootloader version: ' + (parseInt(data[0].toString(16)) / 10).toFixed(1)); // convert dec to hex, hex to dec and add floating point
// proceed to next step
@ -374,9 +374,9 @@ STM32_protocol.prototype.upload_procedure = function(step) {
break;
case 3:
// get ID (device signature)
self.send([self.command.get_ID, 0xFD], 2, function(data) { // 0x01 ^ 0xFF
self.send([self.command.get_ID, 0xFD], 2, function (data) { // 0x01 ^ 0xFF
if (self.verify_response(self.status.ACK, data)) {
self.retrieve(data[1] + 1 + 1, function(data) { // data[1] = number of bytes that will follow [ 1 (N = 1 for STM32), except for current byte and ACKs]
self.retrieve(data[1] + 1 + 1, function (data) { // data[1] = number of bytes that will follow [ 1 (N = 1 for STM32), except for current byte and ACKs]
var signature = (data[0] << 8) | data[1];
console.log('STM32 - Signature: 0x' + signature.toString(16)); // signature in hex representation
@ -398,9 +398,9 @@ STM32_protocol.prototype.upload_procedure = function(step) {
if (self.options.erase_chip) {
console.log('Executing global chip erase');
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
self.send([self.command.erase, 0xBC], 1, function (reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
self.send([0xFF, 0x00], 1, function(reply) {
self.send([0xFF, 0x00], 1, function (reply) {
if (self.verify_response(self.status.ACK, reply)) {
console.log('Erasing: done');
// proceed to next step
@ -412,7 +412,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
} else {
console.log('Executing local erase (only needed pages)');
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
self.send([self.command.erase, 0xBC], 1, function (reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
// the bootloader receives one byte that contains N, the number of pages to be erased 1
var max_address = self.hex.data[self.hex.data.length - 1].address + self.hex.data[self.hex.data.length - 1].bytes - 0x8000000;
@ -427,7 +427,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
}
buff.push(checksum);
self.send(buff, 1, function(reply) {
self.send(buff, 1, function (reply) {
if (self.verify_response(self.status.ACK, reply)) {
console.log('Erasing: done');
// proceed to next step
@ -456,13 +456,13 @@ STM32_protocol.prototype.upload_procedure = function(step) {
// console.log('STM32 - Writing to: 0x' + address.toString(16) + ', ' + bytes_to_write + ' bytes');
self.send([self.command.write_memory, 0xCE], 1, function(reply) { // 0x31 ^ 0xFF
self.send([self.command.write_memory, 0xCE], 1, function (reply) { // 0x31 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
// address needs to be transmitted as 32 bit integer, we need to bit shift each byte out and then calculate address checksum
var address_arr = [(address >> 24), (address >> 16), (address >> 8), address];
var address_checksum = address_arr[0] ^ address_arr[1] ^ address_arr[2] ^ address_arr[3];
self.send([address_arr[0], address_arr[1], address_arr[2], address_arr[3], address_checksum], 1, function(reply) { // write start address + checksum
self.send([address_arr[0], address_arr[1], address_arr[2], address_arr[3], address_checksum], 1, function (reply) { // write start address + checksum
if (self.verify_response(self.status.ACK, reply)) {
var array_out = new Array(bytes_to_write + 2); // 2 byte overhead [N, ...., checksum]
array_out[0] = bytes_to_write - 1; // number of bytes to be written (to write 128 bytes, N must be 127, to write 256 bytes, N must be 255)
@ -479,7 +479,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
address += bytes_to_write;
bytes_flashed_total += bytes_to_write;
self.send(array_out, 1, function(reply) {
self.send(array_out, 1, function (reply) {
if (self.verify_response(self.status.ACK, reply)) {
// update progress bar
self.progress_bar_e.val(bytes_flashed_total / (self.hex.bytes_total * 2) * 100);
@ -537,18 +537,18 @@ STM32_protocol.prototype.upload_procedure = function(step) {
// console.log('STM32 - Reading from: 0x' + address.toString(16) + ', ' + bytes_to_read + ' bytes');
self.send([self.command.read_memory, 0xEE], 1, function(reply) { // 0x11 ^ 0xFF
self.send([self.command.read_memory, 0xEE], 1, function (reply) { // 0x11 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
var address_arr = [(address >> 24), (address >> 16), (address >> 8), address];
var address_checksum = address_arr[0] ^ address_arr[1] ^ address_arr[2] ^ address_arr[3];
self.send([address_arr[0], address_arr[1], address_arr[2], address_arr[3], address_checksum], 1, function(reply) { // read start address + checksum
self.send([address_arr[0], address_arr[1], address_arr[2], address_arr[3], address_checksum], 1, function (reply) { // read start address + checksum
if (self.verify_response(self.status.ACK, reply)) {
var bytes_to_read_n = bytes_to_read - 1;
self.send([bytes_to_read_n, (~bytes_to_read_n) & 0xFF], 1, function(reply) { // bytes to be read + checksum XOR(complement of bytes_to_read_n)
self.send([bytes_to_read_n, (~bytes_to_read_n) & 0xFF], 1, function (reply) { // bytes to be read + checksum XOR(complement of bytes_to_read_n)
if (self.verify_response(self.status.ACK, reply)) {
self.retrieve(bytes_to_read, function(data) {
self.retrieve(bytes_to_read, function (data) {
for (var i = 0; i < data.length; i++) {
self.verify_hex[reading_block].push(data[i]);
}
@ -621,13 +621,13 @@ STM32_protocol.prototype.upload_procedure = function(step) {
// memory address = 4 bytes, 1st high byte, 4th low byte, 5th byte = checksum XOR(byte 1, byte 2, byte 3, byte 4)
console.log('Sending GO command: 0x8000000');
self.send([self.command.go, 0xDE], 1, function(reply) { // 0x21 ^ 0xFF
self.send([self.command.go, 0xDE], 1, function (reply) { // 0x21 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
var gt_address = 0x8000000;
var address = [(gt_address >> 24), (gt_address >> 16), (gt_address >> 8), gt_address];
var address_checksum = address[0] ^ address[1] ^ address[2] ^ address[3];
self.send([address[0], address[1], address[2], address[3], address_checksum], 1, function(reply) {
self.send([address[0], address[1], address[2], address[3], address_checksum], 1, function (reply) {
if (self.verify_response(self.status.ACK, reply)) {
// disconnect
self.upload_procedure(99);
@ -643,7 +643,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
console.log('Script finished after: ' + (microtime() - self.upload_time_start).toFixed(4) + ' seconds');
// close connection
serial.disconnect(function(result) {
serial.disconnect(function (result) {
if (result) { // All went as expected
} else { // Something went wrong
}

View File

@ -12,7 +12,7 @@
*/
'use strict';
var STM32DFU_protocol = function() {
var STM32DFU_protocol = function () {
this.hex; // ref
this.verify_hex;
@ -62,7 +62,7 @@ var STM32DFU_protocol = function() {
};
};
STM32DFU_protocol.prototype.connect = function(device, hex) {
STM32DFU_protocol.prototype.connect = function (device, hex) {
var self = this;
self.hex = hex;
@ -75,7 +75,7 @@ STM32DFU_protocol.prototype.connect = function(device, hex) {
self.progress_bar_e.val(0);
self.progress_bar_e.removeClass('valid invalid');
chrome.usb.getDevices(device, function(result) {
chrome.usb.getDevices(device, function (result) {
if (result.length) {
console.log('USB DFU detected with ID: ' + result[0].device);
@ -87,10 +87,10 @@ STM32DFU_protocol.prototype.connect = function(device, hex) {
});
};
STM32DFU_protocol.prototype.openDevice = function(device) {
STM32DFU_protocol.prototype.openDevice = function (device) {
var self = this;
chrome.usb.openDevice(device, function(handle) {
chrome.usb.openDevice(device, function (handle) {
self.handle = handle;
console.log('Device opened with Handle ID: ' + handle.handle);
@ -98,7 +98,7 @@ STM32DFU_protocol.prototype.openDevice = function(device) {
});
};
STM32DFU_protocol.prototype.closeDevice = function() {
STM32DFU_protocol.prototype.closeDevice = function () {
var self = this;
chrome.usb.closeDevice(this.handle, function closed() {
@ -108,7 +108,7 @@ STM32DFU_protocol.prototype.closeDevice = function() {
});
};
STM32DFU_protocol.prototype.claimInterface = function(interfaceNumber) {
STM32DFU_protocol.prototype.claimInterface = function (interfaceNumber) {
var self = this;
chrome.usb.claimInterface(this.handle, interfaceNumber, function claimed() {
@ -118,7 +118,7 @@ STM32DFU_protocol.prototype.claimInterface = function(interfaceNumber) {
});
};
STM32DFU_protocol.prototype.releaseInterface = function(interfaceNumber) {
STM32DFU_protocol.prototype.releaseInterface = function (interfaceNumber) {
var self = this;
chrome.usb.releaseInterface(this.handle, interfaceNumber, function released() {
@ -128,15 +128,15 @@ STM32DFU_protocol.prototype.releaseInterface = function(interfaceNumber) {
});
};
STM32DFU_protocol.prototype.resetDevice = function(callback) {
chrome.usb.resetDevice(this.handle, function(result) {
STM32DFU_protocol.prototype.resetDevice = function (callback) {
chrome.usb.resetDevice(this.handle, function (result) {
console.log('Reset Device: ' + result);
if (callback) callback();
});
};
STM32DFU_protocol.prototype.controlTransfer = function(direction, request, value, _interface, length, data, callback) {
STM32DFU_protocol.prototype.controlTransfer = function (direction, request, value, _interface, length, data, callback) {
if (direction == 'in') {
// data is ignored
chrome.usb.controlTransfer(this.handle, {
@ -147,7 +147,7 @@ STM32DFU_protocol.prototype.controlTransfer = function(direction, request, value
'value': value,
'index': _interface,
'length': length
}, function(result) {
}, function (result) {
if (result.resultCode) console.log(result.resultCode);
var buf = new Uint8Array(result.data);
@ -171,7 +171,7 @@ STM32DFU_protocol.prototype.controlTransfer = function(direction, request, value
'value': value,
'index': _interface,
'data': arrayBuf
}, function(result) {
}, function (result) {
if (result.resultCode) console.log(result.resultCode);
callback(result);
@ -180,11 +180,11 @@ STM32DFU_protocol.prototype.controlTransfer = function(direction, request, value
};
// routine calling DFU_CLRSTATUS until device is in dfuIDLE state
STM32DFU_protocol.prototype.clearStatus = function(callback) {
STM32DFU_protocol.prototype.clearStatus = function (callback) {
var self = this;
function check_status() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
if (data[4] == self.state.dfuIDLE) {
callback(data);
} else {
@ -202,16 +202,16 @@ STM32DFU_protocol.prototype.clearStatus = function(callback) {
check_status();
};
STM32DFU_protocol.prototype.loadAddress = function(address, callback) {
STM32DFU_protocol.prototype.loadAddress = function (address, callback) {
var self = this;
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x21, address, (address >> 8), (address >> 16), (address >> 24)], function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x21, address, (address >> 8), (address >> 16), (address >> 24)], function () {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
if (data[4] == self.state.dfuDNBUSY) {
var delay = data[1] | (data[2] << 8) | (data[3] << 16);
setTimeout(function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
setTimeout(function () {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
if (data[4] == self.state.dfuDNLOAD_IDLE) {
callback(data);
} else {
@ -231,7 +231,7 @@ STM32DFU_protocol.prototype.loadAddress = function(address, callback) {
// first_array = usually hex_to_flash array
// second_array = usually verify_hex array
// result = true/false
STM32DFU_protocol.prototype.verify_flash = function(first_array, second_array) {
STM32DFU_protocol.prototype.verify_flash = function (first_array, second_array) {
for (var i = 0; i < first_array.length; i++) {
if (first_array[i] != second_array[i]) {
console.log('Verification failed on byte: ' + i + ' expected: 0x' + first_array[i].toString(16) + ' received: 0x' + second_array[i].toString(16));
@ -244,12 +244,12 @@ STM32DFU_protocol.prototype.verify_flash = function(first_array, second_array) {
return true;
};
STM32DFU_protocol.prototype.upload_procedure = function(step) {
STM32DFU_protocol.prototype.upload_procedure = function (step) {
var self = this;
switch (step) {
case 1:
self.clearStatus(function() {
self.clearStatus(function () {
self.upload_procedure(2);
});
break;
@ -258,13 +258,13 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
console.log('Executing global chip erase');
GUI.log('Erasing ...');
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x41], function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x41], function () {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
if (data[4] == self.state.dfuDNBUSY) { // completely normal
var delay = data[1] | (data[2] << 8) | (data[3] << 16);
setTimeout(function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
setTimeout(function () {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
if (data[4] == self.state.dfuDNLOAD_IDLE) {
self.upload_procedure(4);
} else {
@ -307,13 +307,13 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
bytes_flashed += bytes_to_write;
bytes_flashed_total += bytes_to_write;
self.controlTransfer('out', self.request.DNLOAD, wBlockNum++, 0, 0, data_to_flash, function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
self.controlTransfer('out', self.request.DNLOAD, wBlockNum++, 0, 0, data_to_flash, function () {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
if (data[4] == self.state.dfuDNBUSY) {
var delay = data[1] | (data[2] << 8) | (data[3] << 16);
setTimeout(function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
setTimeout(function () {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
if (data[4] == self.state.dfuDNLOAD_IDLE) {
// update progress bar
self.progress_bar_e.val(bytes_flashed_total / (self.hex.bytes_total * 2) * 100);
@ -371,8 +371,8 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
}
// start
self.clearStatus(function() {
self.loadAddress(address, function() {
self.clearStatus(function () {
self.loadAddress(address, function () {
self.clearStatus(read);
});
});
@ -381,7 +381,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
if (bytes_verified < self.hex.data[reading_block].bytes) {
var bytes_to_read = ((bytes_verified + 2048) <= self.hex.data[reading_block].bytes) ? 2048 : (self.hex.data[reading_block].bytes - bytes_verified);
self.controlTransfer('in', self.request.UPLOAD, wBlockNum++, 0, bytes_to_read, 0, function(data, code) {
self.controlTransfer('in', self.request.UPLOAD, wBlockNum++, 0, bytes_to_read, 0, function (data, code) {
for (var i = 0; i < data.length; i++) {
self.verify_hex[reading_block].push(data[i]);
}
@ -405,8 +405,8 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
bytes_verified = 0;
wBlockNum = 2;
self.clearStatus(function() {
self.loadAddress(address, function() {
self.clearStatus(function () {
self.loadAddress(address, function () {
self.clearStatus(read);
});
});
@ -449,13 +449,13 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
// jump to application code
var address = self.hex.data[0].address;
self.clearStatus(function() {
self.clearStatus(function () {
self.loadAddress(address, leave);
});
var leave = function () {
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, 0, function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, 0, function () {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
self.upload_procedure(99);
});
});

View File

@ -61,7 +61,7 @@ $(document).ready(function () {
// auto-connect
chrome.storage.local.get('auto_connect', function (result) {
if (!result.auto_connect || result.auto_connect) {
if (result.auto_connect === 'undefined' || result.auto_connect) {
// default or enabled by user
GUI.auto_connect = true;