diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index 7d86b24ada..d3bbb922c0 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -138,12 +138,12 @@ typedef struct servoParam_t { int16_t min; // servo min int16_t max; // servo max int16_t middle; // servo middle - int8_t rate; // range [-125;+125] ; can be used to adjust a rate 0-125% and a direction - uint32_t reversedSources; // the direction of servo movement for each input source of the servo mixer, bit set=inverted + int8_t rate; // range [-125;+125] ; can be used to adjust a rate 0-125% and a direction uint8_t angleAtMin; // range [0;180] the measured angle in degrees from the middle when the servo is at the 'min' value. uint8_t angleAtMax; // range [0;180] the measured angle in degrees from the middle when the servo is at the 'max' value. int8_t forwardFromChannel; // RX channel index, 0 based. See CHANNEL_FORWARDING_DISABLED -} servoParam_t; + uint32_t reversedSources; // the direction of servo movement for each input source of the servo mixer, bit set=inverted +} __attribute__ ((__packed__)) servoParam_t; struct gimbalConfig_s; struct escAndServoConfig_s; diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index 927c3069f3..f9c0d4bb61 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -843,8 +843,8 @@ static bool processOutCommand(uint8_t cmdMSP) serialize8(currentProfile->servoConf[i].rate); serialize8(currentProfile->servoConf[i].angleAtMin); serialize8(currentProfile->servoConf[i].angleAtMax); - serialize32(currentProfile->servoConf[i].reversedSources); serialize8(currentProfile->servoConf[i].forwardFromChannel); + serialize32(currentProfile->servoConf[i].reversedSources); } break; case MSP_SERVO_MIX_RULES: @@ -1429,6 +1429,10 @@ static bool processInCommand(void) break; case MSP_SET_SERVO_CONFIGURATION: #ifdef USE_SERVOS + if (currentPort->dataSize != 1 + sizeof(servoParam_t)) { + headSerialError(0); + break; + } i = read8(); if (i >= MAX_SUPPORTED_SERVOS) { headSerialError(0); @@ -1439,8 +1443,8 @@ static bool processInCommand(void) currentProfile->servoConf[i].rate = read8(); currentProfile->servoConf[i].angleAtMin = read8(); currentProfile->servoConf[i].angleAtMax = read8(); - currentProfile->servoConf[i].reversedSources = read32(); currentProfile->servoConf[i].forwardFromChannel = read8(); + currentProfile->servoConf[i].reversedSources = read32(); } #endif break;