mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
more strict
This commit is contained in:
parent
f16b3a479a
commit
fc0fff017e
3 changed files with 12 additions and 8 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
popular choices - 921600, 460800, 256000, 230400, 153600, 128000, 115200, 57600, 38400, 28800, 19200
|
popular choices - 921600, 460800, 256000, 230400, 153600, 128000, 115200, 57600, 38400, 28800, 19200
|
||||||
*/
|
*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var STM32_protocol = function() {
|
var STM32_protocol = function() {
|
||||||
this.options = {};
|
this.options = {};
|
||||||
|
@ -449,7 +450,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
|
||||||
var bytes_flashed = 0;
|
var bytes_flashed = 0;
|
||||||
var bytes_flashed_total = 0; // used for progress bar
|
var bytes_flashed_total = 0; // used for progress bar
|
||||||
|
|
||||||
function write() {
|
var write = function () {
|
||||||
if (bytes_flashed < self.hex.data[flashing_block].bytes) {
|
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);
|
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([]);
|
self.verify_hex.push([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function reading() {
|
var reading = function () {
|
||||||
if (bytes_verified < self.hex.data[reading_block].bytes) {
|
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);
|
var bytes_to_read = ((bytes_verified + 256) <= self.hex.data[reading_block].bytes) ? 256 : (self.hex.data[reading_block].bytes - bytes_verified);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
that being said, it seems that certain level of CLRSTATUS is required before running another type of operation for
|
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.
|
example switching from DNLOAD to UPLOAD, etc, clearning the state so device is in dfuIDLE is highly recommended.
|
||||||
*/
|
*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var STM32DFU_protocol = function() {
|
var STM32DFU_protocol = function() {
|
||||||
this.hex; // ref
|
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') {
|
if (direction == 'in') {
|
||||||
// data is ignored
|
// data is ignored
|
||||||
chrome.usb.controlTransfer(this.handle, {
|
chrome.usb.controlTransfer(this.handle, {
|
||||||
|
@ -144,7 +145,7 @@ STM32DFU_protocol.prototype.controlTransfer = function(direction, request, value
|
||||||
'requestType': 'class',
|
'requestType': 'class',
|
||||||
'request': request,
|
'request': request,
|
||||||
'value': value,
|
'value': value,
|
||||||
'index': interface,
|
'index': _interface,
|
||||||
'length': length
|
'length': length
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
if (result.resultCode) console.log(result.resultCode);
|
if (result.resultCode) console.log(result.resultCode);
|
||||||
|
@ -168,7 +169,7 @@ STM32DFU_protocol.prototype.controlTransfer = function(direction, request, value
|
||||||
'requestType': 'class',
|
'requestType': 'class',
|
||||||
'request': request,
|
'request': request,
|
||||||
'value': value,
|
'value': value,
|
||||||
'index': interface,
|
'index': _interface,
|
||||||
'data': arrayBuf
|
'data': arrayBuf
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
if (result.resultCode) console.log(result.resultCode);
|
if (result.resultCode) console.log(result.resultCode);
|
||||||
|
@ -296,7 +297,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
|
||||||
// start
|
// start
|
||||||
self.loadAddress(address, write);
|
self.loadAddress(address, write);
|
||||||
|
|
||||||
function write() {
|
var write = function () {
|
||||||
if (bytes_flashed < self.hex.data[flashing_block].bytes) {
|
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);
|
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) {
|
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);
|
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);
|
self.loadAddress(address, leave);
|
||||||
});
|
});
|
||||||
|
|
||||||
function leave() {
|
var leave = function () {
|
||||||
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, 0, 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('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
|
||||||
self.upload_procedure(99);
|
self.upload_procedure(99);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
// input = string
|
// input = string
|
||||||
// result = if hex file is valid, result is an object
|
// 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
|
// if hex file wasn't valid (crc check failed on any of the lines), result will be false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue