mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 20:35:19 +03:00
make the validation pass on hexes with holes
This commit is contained in:
parent
be9cd9f606
commit
7bdd43fd1c
1 changed files with 34 additions and 29 deletions
|
@ -143,7 +143,7 @@ STM32DFU_protocol.prototype.controlTransfer = function(direction, request, value
|
||||||
if (result.resultCode) console.log(result.resultCode);
|
if (result.resultCode) console.log(result.resultCode);
|
||||||
|
|
||||||
var buf = new Uint8Array(result.data);
|
var buf = new Uint8Array(result.data);
|
||||||
callback(buf);
|
callback(buf, result.resultCode);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// length is ignored
|
// length is ignored
|
||||||
|
@ -345,9 +345,13 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_read_address() {
|
function load_read_address() {
|
||||||
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('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('out', self.request.DNLOAD, 0, 0, 0, [0x21, address, (address >> 8), (address >> 16), (address >> 24)], function(result) { // problem on this call !!
|
||||||
|
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);
|
var delay = data[1] | (data[2] << 8) | (data[3] << 16);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
@ -359,33 +363,34 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, delay);
|
}, delay);
|
||||||
|
} else if (data[4] == self.state.dfuUPLOAD_IDLE) {
|
||||||
|
read();
|
||||||
} else {
|
} else {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}, delay);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear_status() {
|
function clear_status() {
|
||||||
self.controlTransfer('out', self.request.CLRSTATUS, 0, 0, 0, 0, function() {
|
|
||||||
self.controlTransfer('out', self.request.CLRSTATUS, 0, 0, 0, 0, function() {
|
self.controlTransfer('out', self.request.CLRSTATUS, 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) {
|
||||||
if (data[4] == self.state.dfuIDLE) {
|
if (data[4] == self.state.dfuIDLE) {
|
||||||
read();
|
read();
|
||||||
} else {
|
} else {
|
||||||
// throw some error
|
clear_status();
|
||||||
console.log(data);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function read() {
|
function read() {
|
||||||
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);
|
||||||
|
|
||||||
self.controlTransfer('in', self.request.UPLOAD, wBlockNum++, 0, bytes_to_read, 0, function(data) {
|
self.controlTransfer('in', self.request.UPLOAD, wBlockNum++, 0, bytes_to_read, 0, function(data, code) {
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
self.verify_hex[reading_block].push(data[i]);
|
self.verify_hex[reading_block].push(data[i]);
|
||||||
}
|
}
|
||||||
|
@ -407,7 +412,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
|
||||||
|
|
||||||
address = self.hex.data[reading_block].address;
|
address = self.hex.data[reading_block].address;
|
||||||
bytes_verified = 0;
|
bytes_verified = 0;
|
||||||
wBlockNum = 2;
|
//wBlockNum = 2;
|
||||||
|
|
||||||
load_read_address();
|
load_read_address();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue