@@ -446,6 +446,8 @@ MspHelper.prototype.process_data = function(dataHandler) {
446446 '115200' ,
447447 '230400' ,
448448 '250000' ,
449+ '500000' ,
450+ '1000000'
449451 ] ;
450452 if ( semver . lt ( CONFIG . apiVersion , "1.6.0" ) ) {
451453 SERIAL_CONFIG . ports = [ ] ;
@@ -1046,6 +1048,8 @@ MspHelper.prototype.crunch = function(code) {
10461048 '115200' ,
10471049 '230400' ,
10481050 '250000' ,
1051+ '500000' ,
1052+ '1000000'
10491053 ] ; //TODO, instead of lookuptable, this should be sent as uint32
10501054 var serialPortFunctions = {
10511055 'MSP' : 0 ,
@@ -1205,17 +1209,29 @@ MspHelper.prototype.setRawRx = function(channels) {
12051209 * Send a request to read a block of data from the dataflash at the given address and pass that address and a dataview
12061210 * of the returned data to the given callback (or null for the data if an error occured).
12071211 */
1208- MspHelper . prototype . dataflashRead = function ( address , onDataCallback ) {
1209- MSP . send_message ( MSPCodes . MSP_DATAFLASH_READ , [ address & 0xFF , ( address >> 8 ) & 0xFF , ( address >> 16 ) & 0xFF , ( address >> 24 ) & 0xFF ] ,
1210- false , function ( response ) {
1212+ MspHelper . prototype . dataflashRead = function ( address , blockSize , onDataCallback ) {
1213+ var outData = [ address & 0xFF , ( address >> 8 ) & 0xFF , ( address >> 16 ) & 0xFF , ( address >> 24 ) & 0xFF ] ;
1214+
1215+ if ( semver . gte ( CONFIG . flightControllerVersion , "3.1.0" ) ) {
1216+ outData = outData . concat ( [ blockSize & 0xFF , ( blockSize >> 8 ) & 0xFF ] ) ;
1217+ }
1218+
1219+ MSP . send_message ( MSPCodes . MSP_DATAFLASH_READ , outData , false , function ( response ) {
12111220 var chunkAddress = response . data . readU32 ( ) ;
1212-
1221+
1222+ var headerSize = 4 ;
1223+ var dataSize = response . data . buffer . byteLength - headerSize ;
1224+ if ( semver . gte ( CONFIG . flightControllerVersion , "3.1.0" ) ) {
1225+ headerSize = headerSize + 2 ;
1226+ dataSize = response . data . readU16 ( ) ;
1227+ }
1228+
12131229 // Verify that the address of the memory returned matches what the caller asked for
12141230 if ( chunkAddress == address ) {
12151231 /* Strip that address off the front of the reply and deliver it separately so the caller doesn't have to
12161232 * figure out the reply format:
12171233 */
1218- onDataCallback ( address , new DataView ( response . data . buffer , response . data . byteOffset + 4 , response . data . buffer . byteLength - 4 ) ) ;
1234+ onDataCallback ( address , new DataView ( response . data . buffer , response . data . byteOffset + headerSize , dataSize ) ) ;
12191235 } else {
12201236 // Report error
12211237 onDataCallback ( address , null ) ;
0 commit comments