more strict

10.3.x-maintenance
cTn 2014-08-09 20:47:07 +02:00
parent f16b3a479a
commit fc0fff017e
3 changed files with 12 additions and 8 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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