From a893261e6de9130bee13f4133757bda9ccc5128a Mon Sep 17 00:00:00 2001 From: cTn Date: Sat, 9 Aug 2014 20:47:07 +0200 Subject: [PATCH] more strict --- js/protocols/stm32.js | 5 +++-- js/protocols/stm32usbdfu.js | 13 +++++++------ js/workers/hex_parser.js | 2 ++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/js/protocols/stm32.js b/js/protocols/stm32.js index 48f2b0f3..abfa1422 100644 --- a/js/protocols/stm32.js +++ b/js/protocols/stm32.js @@ -5,6 +5,7 @@ popular choices - 921600, 460800, 256000, 230400, 153600, 128000, 115200, 57600, 38400, 28800, 19200 */ +'use strict'; var STM32_protocol = function() { this.options = {}; @@ -449,7 +450,7 @@ STM32_protocol.prototype.upload_procedure = function(step) { var bytes_flashed = 0; var bytes_flashed_total = 0; // used for progress bar - function write() { + var write = function () { if (bytes_flashed < self.hex.data[flashing_block].bytes) { var bytes_to_write = ((bytes_flashed + 256) <= self.hex.data[flashing_block].bytes) ? 256 : (self.hex.data[flashing_block].bytes - bytes_flashed); @@ -530,7 +531,7 @@ STM32_protocol.prototype.upload_procedure = function(step) { self.verify_hex.push([]); } - function reading() { + var reading = function () { if (bytes_verified < self.hex.data[reading_block].bytes) { var bytes_to_read = ((bytes_verified + 256) <= self.hex.data[reading_block].bytes) ? 256 : (self.hex.data[reading_block].bytes - bytes_verified); diff --git a/js/protocols/stm32usbdfu.js b/js/protocols/stm32usbdfu.js index a63c2d0d..45bbd736 100644 --- a/js/protocols/stm32usbdfu.js +++ b/js/protocols/stm32usbdfu.js @@ -10,6 +10,7 @@ that being said, it seems that certain level of CLRSTATUS is required before running another type of operation for example switching from DNLOAD to UPLOAD, etc, clearning the state so device is in dfuIDLE is highly recommended. */ +'use strict'; var STM32DFU_protocol = function() { this.hex; // ref @@ -135,7 +136,7 @@ STM32DFU_protocol.prototype.resetDevice = function(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, { @@ -144,7 +145,7 @@ STM32DFU_protocol.prototype.controlTransfer = function(direction, request, value 'requestType': 'class', 'request': request, 'value': value, - 'index': interface, + 'index': _interface, 'length': length }, function(result) { if (result.resultCode) console.log(result.resultCode); @@ -168,7 +169,7 @@ STM32DFU_protocol.prototype.controlTransfer = function(direction, request, value 'requestType': 'class', 'request': request, 'value': value, - 'index': interface, + 'index': _interface, 'data': arrayBuf }, function(result) { if (result.resultCode) console.log(result.resultCode); @@ -296,7 +297,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) { // start self.loadAddress(address, write); - function write() { + var write = function () { if (bytes_flashed < self.hex.data[flashing_block].bytes) { var bytes_to_write = ((bytes_flashed + 2048) <= self.hex.data[flashing_block].bytes) ? 2048 : (self.hex.data[flashing_block].bytes - bytes_flashed); @@ -376,7 +377,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) { }); }); - function read() { + var read = function () { 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); @@ -452,7 +453,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) { self.loadAddress(address, leave); }); - function 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.upload_procedure(99); diff --git a/js/workers/hex_parser.js b/js/workers/hex_parser.js index bf23ae12..d75fd347 100644 --- a/js/workers/hex_parser.js +++ b/js/workers/hex_parser.js @@ -1,3 +1,5 @@ +'use strict'; + // input = string // result = if hex file is valid, result is an object // if hex file wasn't valid (crc check failed on any of the lines), result will be false