Improve MSP handling of servo configuration. Fixes backup of CJMCU

boards.
10.3.x-maintenance
Dominic Clifton 2015-05-07 22:47:32 +01:00
parent 244685c9a6
commit 0f95f4ec4c
1 changed files with 12 additions and 10 deletions

View File

@ -434,7 +434,8 @@ var MSP = {
case MSP_codes.MSP_SERVO_CONF:
SERVO_CONFIG = []; // empty the array as new data is coming in
for (var i = 0; i < 56; i += 7) {
if (data.byteLength % 7 == 0) {
for (var i = 0; i < data.byteLength; i += 7) {
var arr = {
'min': data.getInt16(i, 1),
'max': data.getInt16(i + 2, 1),
@ -444,6 +445,7 @@ var MSP = {
SERVO_CONFIG.push(arr);
}
}
break;
case MSP_codes.MSP_SET_RAW_RC:
break;
@ -688,7 +690,7 @@ var MSP = {
}
break;
case MSP_codes.MSP_CHANNEL_FORWARDING:
for (var i = 0; i < 8; i ++) {
for (var i = 0; i < data.byteLength && i < SERVO_CONFIG.length; i ++) {
var channelIndex = data.getUint8(i);
if (channelIndex < 255) {
SERVO_CONFIG[i].indexOfChannelToForward = channelIndex;