Merge pull request #115 from sherlockflight/development

Fix endianness of board version read
10.3.x-maintenance
Dominic Clifton 2015-02-26 20:44:56 +00:00
commit 84e88e17bf
3 changed files with 42 additions and 23 deletions

View File

@ -887,6 +887,9 @@
"dataflashButtonEraseCancel": {
"message": "Cancel"
},
"dataflashFileWriteFailed": {
"message": "Failed to write to the file you selected, are the permissions on that folder okay?"
},
"firmwareFlasherReleaseSummaryHead": {
"message": "Release info"
},

View File

@ -548,7 +548,7 @@ var MSP = {
identifier += String.fromCharCode(data.getUint8(offset));
}
CONFIG.boardIdentifier = identifier;
CONFIG.boardVersion = data.getUint16(offset);
CONFIG.boardVersion = data.getUint16(offset, 1);
offset+=2;
break;

View File

@ -139,7 +139,8 @@ TABS.dataflash.initialize = function (callback) {
show_saving_dialog();
function onChunkRead(chunkAddress, chunkDataView) {
// If we didn't get a zero-byte chunk (indicating end-of-file), request more
if (chunkDataView != null) {
// Did we receive any data?
if (chunkDataView.byteLength > 0) {
nextAddress += chunkDataView.byteLength;
@ -148,8 +149,7 @@ TABS.dataflash.initialize = function (callback) {
var
blob = new Blob([chunkDataView]);
fileWriter.write(blob);
fileWriter.onwriteend = function(e) {
if (saveCancelled || nextAddress >= maxBytes) {
if (saveCancelled) {
dismiss_saving_dialog();
@ -159,11 +159,20 @@ TABS.dataflash.initialize = function (callback) {
} else {
MSP.dataflashRead(nextAddress, onChunkRead);
}
};
fileWriter.write(blob);
} else {
// A zero-byte block indicates end-of-file, so we're done
mark_saving_dialog_done();
}
} else {
// There was an error with the received block (address didn't match the one we asked for), retry
MSP.dataflashRead(nextAddress, onChunkRead);
}
}
// Fetch the initial block
MSP.dataflashRead(nextAddress, onChunkRead);
});
}
@ -178,8 +187,14 @@ TABS.dataflash.initialize = function (callback) {
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: filename,
accepts: [{extensions: ['TXT']}]}, function(fileEntry) {
if (!fileEntry) {
console.log('No file selected');
var error = chrome.runtime.lastError;
if (error) {
console.error(error.message);
if (error.message != "User cancelled") {
GUI.log(chrome.i18n.getMessage('dataflashFileWriteFailed'));
}
return;
}
@ -199,6 +214,7 @@ TABS.dataflash.initialize = function (callback) {
}, function (e) {
// File is not readable or does not exist!
console.error(e);
GUI.log(chrome.i18n.getMessage('dataflashFileWriteFailed'));
});
});
}