1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-22 15:55:28 +03:00

Support large MSP_DATAFLASH_READ payloads

This commit is contained in:
Konstantin Sharlaimov (DigitalEntity) 2017-08-27 23:41:39 +10:00
parent 42e6941edd
commit 57da32d30b
2 changed files with 50 additions and 28 deletions

View file

@ -9145,21 +9145,32 @@ var mspHelper = (function (gui) {
* of the returned data to the given callback (or null for the data if an error occured). * of the returned data to the given callback (or null for the data if an error occured).
*/ */
self.dataflashRead = function (address, onDataCallback) { self.dataflashRead = function (address, onDataCallback) {
MSP.send_message(MSPCodes.MSP_DATAFLASH_READ, [address & 0xFF, (address >> 8) & 0xFF, (address >> 16) & 0xFF, (address >> 24) & 0xFF], var buffer = [];
false, function (response) { buffer.push(address & 0xFF);
var chunkAddress = response.data.getUint32(0, 1); buffer.push((address >> 8) & 0xFF);
buffer.push((address >> 16) & 0xFF);
buffer.push((address >> 24) & 0xFF);
// Verify that the address of the memory returned matches what the caller asked for // For API > 2.0.0 we support requesting payload size - request 4KiB and let firmware decide what actual size to send
if (chunkAddress == address) { if (CONFIG.apiVersion && semver.gte(CONFIG.apiVersion, "2.0.0")) {
/* Strip that address off the front of the reply and deliver it separately so the caller doesn't have to buffer.push(lowByte(4096));
* figure out the reply format: buffer.push(highByte(4096));
*/ }
onDataCallback(address, new DataView(response.data.buffer, response.data.byteOffset + 4, response.data.buffer.byteLength - 4));
} else { MSP.send_message(MSPCodes.MSP_DATAFLASH_READ, buffer, false, function (response) {
// Report error var chunkAddress = response.data.getUint32(0, 1);
onDataCallback(address, null);
} // Verify that the address of the memory returned matches what the caller asked for
}); if (chunkAddress == address) {
/* Strip that address off the front of the reply and deliver it separately so the caller doesn't have to
* figure out the reply format:
*/
onDataCallback(address, new DataView(response.data.buffer, response.data.byteOffset + 4, response.data.buffer.byteLength - 4));
} else {
// Report error
onDataCallback(address, null);
}
});
}; };
self.sendRxFailConfig = function (onCompleteCallback) { self.sendRxFailConfig = function (onCompleteCallback) {

View file

@ -1592,21 +1592,32 @@ var mspHelper = (function (gui) {
* of the returned data to the given callback (or null for the data if an error occured). * of the returned data to the given callback (or null for the data if an error occured).
*/ */
self.dataflashRead = function (address, onDataCallback) { self.dataflashRead = function (address, onDataCallback) {
MSP.send_message(MSPCodes.MSP_DATAFLASH_READ, [address & 0xFF, (address >> 8) & 0xFF, (address >> 16) & 0xFF, (address >> 24) & 0xFF], var buffer = [];
false, function (response) { buffer.push(address & 0xFF);
var chunkAddress = response.data.getUint32(0, 1); buffer.push((address >> 8) & 0xFF);
buffer.push((address >> 16) & 0xFF);
buffer.push((address >> 24) & 0xFF);
// Verify that the address of the memory returned matches what the caller asked for // For API > 2.0.0 we support requesting payload size - request 4KiB and let firmware decide what actual size to send
if (chunkAddress == address) { if (CONFIG.apiVersion && semver.gte(CONFIG.apiVersion, "2.0.0")) {
/* Strip that address off the front of the reply and deliver it separately so the caller doesn't have to buffer.push(lowByte(4096));
* figure out the reply format: buffer.push(highByte(4096));
*/ }
onDataCallback(address, new DataView(response.data.buffer, response.data.byteOffset + 4, response.data.buffer.byteLength - 4));
} else { MSP.send_message(MSPCodes.MSP_DATAFLASH_READ, buffer, false, function (response) {
// Report error var chunkAddress = response.data.getUint32(0, 1);
onDataCallback(address, null);
} // Verify that the address of the memory returned matches what the caller asked for
}); if (chunkAddress == address) {
/* Strip that address off the front of the reply and deliver it separately so the caller doesn't have to
* figure out the reply format:
*/
onDataCallback(address, new DataView(response.data.buffer, response.data.byteOffset + 4, response.data.buffer.byteLength - 4));
} else {
// Report error
onDataCallback(address, null);
}
});
}; };
self.sendRxFailConfig = function (onCompleteCallback) { self.sendRxFailConfig = function (onCompleteCallback) {