Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Fix handling of MSP_SERVO and MSP_MOTOR. Previously the code assumed
Browse files Browse the repository at this point in the history
there was always 8 servos and 8 motors.
  • Loading branch information
hydra committed Jun 1, 2015
1 parent 774fcf5 commit 8d39b3f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions js/msp.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,18 @@ var MSP = {
SENSOR_DATA.magnetometer[2] = data.getInt16(16, 1) / 1090;
break;
case MSP_codes.MSP_SERVO:
var servoCount = message_length / 2;
var needle = 0;
for (var i = 0; i < 8; i++) {
for (var i = 0; i < servoCount; i++) {
SERVO_DATA[i] = data.getUint16(needle, 1);

needle += 2;
}
break;
case MSP_codes.MSP_MOTOR:
var motorCount = message_length / 2;
var needle = 0;
for (var i = 0; i < 8; i++) {
for (var i = 0; i < motorCount; i++) {
MOTOR_DATA[i] = data.getUint16(needle, 1);

needle += 2;
Expand Down

0 comments on commit 8d39b3f

Please sign in to comment.