1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 08:15:22 +03:00

Revert "Implemented support for MSP jumbo frames, switched dataflash reading to be using jumbo frames."

This commit is contained in:
Michael Keller 2016-09-15 08:46:01 +12:00 committed by GitHub
parent 60cb7ab6be
commit af3a185c5a
6 changed files with 25 additions and 85 deletions

View file

@ -10,7 +10,6 @@ var MSP = {
message_buffer: null, message_buffer: null,
message_buffer_uint8_view: null, message_buffer_uint8_view: null,
message_checksum: 0, message_checksum: 0,
messageIsJumboFrame: false,
callbacks: [], callbacks: [],
packet_error: 0, packet_error: 0,
@ -19,8 +18,6 @@ var MSP = {
last_received_timestamp: null, last_received_timestamp: null,
listeners: [], listeners: [],
JUMBO_FRAME_SIZE_LIMIT: 255,
read: function (readInfo) { read: function (readInfo) {
var data = new Uint8Array(readInfo.data); var data = new Uint8Array(readInfo.data);
@ -53,12 +50,13 @@ var MSP = {
break; break;
case 3: case 3:
this.message_length_expected = data[i]; this.message_length_expected = data[i];
if (this.message_length_expected === this.JUMBO_FRAME_SIZE_LIMIT) {
this.messageIsJumboFrame = true;
}
this.message_checksum = data[i]; this.message_checksum = data[i];
// setup arraybuffer
this.message_buffer = new ArrayBuffer(this.message_length_expected);
this.message_buffer_uint8_view = new Uint8Array(this.message_buffer);
this.state++; this.state++;
break; break;
case 4: case 4:
@ -67,39 +65,13 @@ var MSP = {
if (this.message_length_expected > 0) { if (this.message_length_expected > 0) {
// process payload // process payload
if (this.messageIsJumboFrame) {
this.state++; this.state++;
} else {
this.state = this.state + 3;
}
} else { } else {
// no payload // no payload
this.state += 5; this.state += 2;
} }
break; break;
case 5: case 5: // payload
this.message_length_expected = data[i];
this.message_checksum ^= data[i];
this.state++;
break;
case 6:
this.message_length_expected = this.message_length_expected + 256 * data[i];
this.message_checksum ^= data[i];
this.state++;
break;
case 7:
// setup arraybuffer
this.message_buffer = new ArrayBuffer(this.message_length_expected);
this.message_buffer_uint8_view = new Uint8Array(this.message_buffer);
this.state++;
case 8: // payload
this.message_buffer_uint8_view[this.message_length_received] = data[i]; this.message_buffer_uint8_view[this.message_length_received] = data[i];
this.message_checksum ^= data[i]; this.message_checksum ^= data[i];
this.message_length_received++; this.message_length_received++;
@ -108,7 +80,7 @@ var MSP = {
this.state++; this.state++;
} }
break; break;
case 9: case 6:
if (this.message_checksum == data[i]) { if (this.message_checksum == data[i]) {
// message received, store dataview // message received, store dataview
this.dataView = new DataView(this.message_buffer, 0, this.message_length_expected); this.dataView = new DataView(this.message_buffer, 0, this.message_length_expected);
@ -120,7 +92,6 @@ var MSP = {
// Reset variables // Reset variables
this.message_length_received = 0; this.message_length_received = 0;
this.state = 0; this.state = 0;
this.messageIsJumboFrame = false;
this.notify(); this.notify();
break; break;

View file

@ -446,8 +446,6 @@ MspHelper.prototype.process_data = function(dataHandler) {
'115200', '115200',
'230400', '230400',
'250000', '250000',
'500000',
'1000000'
]; ];
if (semver.lt(CONFIG.apiVersion, "1.6.0")) { if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
SERIAL_CONFIG.ports = []; SERIAL_CONFIG.ports = [];
@ -1048,8 +1046,6 @@ MspHelper.prototype.crunch = function(code) {
'115200', '115200',
'230400', '230400',
'250000', '250000',
'500000',
'1000000'
]; //TODO, instead of lookuptable, this should be sent as uint32 ]; //TODO, instead of lookuptable, this should be sent as uint32
var serialPortFunctions = { var serialPortFunctions = {
'MSP': 0, 'MSP': 0,
@ -1209,29 +1205,17 @@ MspHelper.prototype.setRawRx = function(channels) {
* Send a request to read a block of data from the dataflash at the given address and pass that address and a dataview * Send a request to read a block of data from the dataflash at the given address and pass that address and a dataview
* 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).
*/ */
MspHelper.prototype.dataflashRead = function(address, blockSize, onDataCallback) { MspHelper.prototype.dataflashRead = function(address, onDataCallback) {
var outData = [address & 0xFF, (address >> 8) & 0xFF, (address >> 16) & 0xFF, (address >> 24) & 0xFF]; MSP.send_message(MSPCodes.MSP_DATAFLASH_READ, [address & 0xFF, (address >> 8) & 0xFF, (address >> 16) & 0xFF, (address >> 24) & 0xFF],
false, function(response) {
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
outData = outData.concat([blockSize & 0xFF, (blockSize >> 8) & 0xFF]);
}
MSP.send_message(MSPCodes.MSP_DATAFLASH_READ, outData, false, function(response) {
var chunkAddress = response.data.readU32(); var chunkAddress = response.data.readU32();
var headerSize = 4;
var dataSize = response.data.buffer.byteLength - headerSize;
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
headerSize = headerSize + 2;
dataSize = response.data.readU16();
}
// Verify that the address of the memory returned matches what the caller asked for // Verify that the address of the memory returned matches what the caller asked for
if (chunkAddress == address) { if (chunkAddress == address) {
/* Strip that address off the front of the reply and deliver it separately so the caller doesn't have to /* 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: * figure out the reply format:
*/ */
onDataCallback(address, new DataView(response.data.buffer, response.data.byteOffset + headerSize, dataSize)); onDataCallback(address, new DataView(response.data.buffer, response.data.byteOffset + 4, response.data.buffer.byteLength - 4));
} else { } else {
// Report error // Report error
onDataCallback(address, null); onDataCallback(address, null);

View file

@ -110,7 +110,7 @@ $(document).ready(function () {
$('input.auto_connect').prop('checked', true); $('input.auto_connect').prop('checked', true);
$('input.auto_connect, span.auto_connect').prop('title', chrome.i18n.getMessage('autoConnectEnabled')); $('input.auto_connect, span.auto_connect').prop('title', chrome.i18n.getMessage('autoConnectEnabled'));
$('select#baud').val(500000).prop('disabled', true); $('select#baud').val(115200).prop('disabled', true);
} else { } else {
// disabled by user // disabled by user
GUI.auto_connect = false; GUI.auto_connect = false;
@ -127,7 +127,7 @@ $(document).ready(function () {
if (GUI.auto_connect) { if (GUI.auto_connect) {
$('input.auto_connect, span.auto_connect').prop('title', chrome.i18n.getMessage('autoConnectEnabled')); $('input.auto_connect, span.auto_connect').prop('title', chrome.i18n.getMessage('autoConnectEnabled'));
$('select#baud').val(500000).prop('disabled', true); $('select#baud').val(115200).prop('disabled', true);
} else { } else {
$('input.auto_connect, span.auto_connect').prop('title', chrome.i18n.getMessage('autoConnectDisabled')); $('input.auto_connect, span.auto_connect').prop('title', chrome.i18n.getMessage('autoConnectDisabled'));

View file

@ -116,10 +116,7 @@
</div> </div>
<div class="dropdown dropdown-dark"> <div class="dropdown dropdown-dark">
<select class="dropdown-select" id="baud" title="Baud Rate"> <select class="dropdown-select" id="baud" title="Baud Rate">
<option value="1000000">1000000</option> <option value="115200" selected="selected">115200</option>
<option value="500000" selected="selected">500000</option>
<option value="250000">250000</option>
<option value="115200">115200</option>
<option value="57600">57600</option> <option value="57600">57600</option>
<option value="38400">38400</option> <option value="38400">38400</option>
<option value="28800">28800</option> <option value="28800">28800</option>

View file

@ -4,8 +4,7 @@ var
sdcardTimer; sdcardTimer;
TABS.onboard_logging = { TABS.onboard_logging = {
available: false, available: false
BLOCK_SIZE: 4096
}; };
TABS.onboard_logging.initialize = function (callback) { TABS.onboard_logging.initialize = function (callback) {
var var
@ -314,12 +313,7 @@ TABS.onboard_logging.initialize = function (callback) {
$(".dataflash-saving")[0].close(); $(".dataflash-saving")[0].close();
} }
function mark_saving_dialog_done(startTime, totalBytes) { function mark_saving_dialog_done() {
var totalTime = (new Date().getTime() - startTime) / 1000;
console.log('Received ' + totalBytes + ' bytes in ' + totalTime.toFixed(2) + 's ('
+ (totalBytes / totalTime / 1024).toFixed(2) + 'kB / s) with block size ' + self.BLOCK_SIZE + '.');
$(".dataflash-saving").addClass("done"); $(".dataflash-saving").addClass("done");
} }
@ -362,27 +356,26 @@ TABS.onboard_logging.initialize = function (callback) {
if (saveCancelled) { if (saveCancelled) {
dismiss_saving_dialog(); dismiss_saving_dialog();
} else { } else {
mark_saving_dialog_done(startTime, nextAddress); mark_saving_dialog_done();
} }
} else { } else {
mspHelper.dataflashRead(nextAddress, self.BLOCK_SIZE, onChunkRead); mspHelper.dataflashRead(nextAddress, onChunkRead);
} }
}; };
fileWriter.write(blob); fileWriter.write(blob);
} else { } else {
// A zero-byte block indicates end-of-file, so we're done // A zero-byte block indicates end-of-file, so we're done
mark_saving_dialog_done(startTime, nextAddress); mark_saving_dialog_done();
} }
} else { } else {
// There was an error with the received block (address didn't match the one we asked for), retry // There was an error with the received block (address didn't match the one we asked for), retry
mspHelper.dataflashRead(nextAddress, self.BLOCK_SIZE, onChunkRead); mspHelper.dataflashRead(nextAddress, onChunkRead);
} }
} }
var startTime = new Date().getTime();
// Fetch the initial block // Fetch the initial block
mspHelper.dataflashRead(nextAddress, self.BLOCK_SIZE, onChunkRead); mspHelper.dataflashRead(nextAddress, onChunkRead);
}); });
}); });
} }

View file

@ -39,12 +39,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
'19200', '19200',
'38400', '38400',
'57600', '57600',
'115200', '115200'
'230400',
'250000',
'500000',
'1000000'
]; ];
var gpsBaudRates = [ var gpsBaudRates = [