Fix CRC errors in msp responses caused by double calling of
headSerialReply(). Ensure system is not reset while MSP response is being transmitted.
This commit is contained in:
parent
5b2659c92c
commit
a48a848890
|
@ -208,8 +208,8 @@ const char *boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
||||||
|
|
||||||
// FIXME - Provided for backwards compatibility with configurator code until configurator is updated.
|
// FIXME - Provided for backwards compatibility with configurator code until configurator is updated.
|
||||||
// DEPRECATED - DO NOT USE "MSP_CONFIG" and MSP_SET_CONFIG. In Cleanflight, isolated commands already exist and should be used instead.
|
// DEPRECATED - DO NOT USE "MSP_CONFIG" and MSP_SET_CONFIG. In Cleanflight, isolated commands already exist and should be used instead.
|
||||||
#define MSP_CONFIG 66 //out message baseflight-specific settings that aren't covered elsewhere
|
#define MSP_CONFIG 66 //out message baseflight-specific settings that aren't covered elsewhere
|
||||||
#define MSP_SET_CONFIG 67 //in message baseflight-specific settings save
|
#define MSP_SET_CONFIG 67 //in message baseflight-specific settings save
|
||||||
|
|
||||||
#define MSP_REBOOT 68 //in message reboot settings
|
#define MSP_REBOOT 68 //in message reboot settings
|
||||||
|
|
||||||
|
@ -1302,31 +1302,26 @@ static bool processInCommand(void)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case MSP_SET_FEATURE:
|
case MSP_SET_FEATURE:
|
||||||
headSerialReply(0);
|
|
||||||
featureClearAll();
|
featureClearAll();
|
||||||
featureSet(read32()); // features bitmap
|
featureSet(read32()); // features bitmap
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_SET_BOARD_ALIGNMENT:
|
case MSP_SET_BOARD_ALIGNMENT:
|
||||||
headSerialReply(0);
|
|
||||||
masterConfig.boardAlignment.rollDegrees = read16();
|
masterConfig.boardAlignment.rollDegrees = read16();
|
||||||
masterConfig.boardAlignment.pitchDegrees = read16();
|
masterConfig.boardAlignment.pitchDegrees = read16();
|
||||||
masterConfig.boardAlignment.yawDegrees = read16();
|
masterConfig.boardAlignment.yawDegrees = read16();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_SET_CURRENT_METER_CONFIG:
|
case MSP_SET_CURRENT_METER_CONFIG:
|
||||||
headSerialReply(0);
|
|
||||||
masterConfig.batteryConfig.currentMeterScale = read16();
|
masterConfig.batteryConfig.currentMeterScale = read16();
|
||||||
masterConfig.batteryConfig.currentMeterOffset = read16();
|
masterConfig.batteryConfig.currentMeterOffset = read16();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_SET_MIXER:
|
case MSP_SET_MIXER:
|
||||||
headSerialReply(0);
|
|
||||||
masterConfig.mixerConfiguration = read8();
|
masterConfig.mixerConfiguration = read8();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_SET_RX_CONFIG:
|
case MSP_SET_RX_CONFIG:
|
||||||
headSerialReply(0);
|
|
||||||
masterConfig.rxConfig.serialrx_provider = read8();
|
masterConfig.rxConfig.serialrx_provider = read8();
|
||||||
masterConfig.rxConfig.maxcheck = read16();
|
masterConfig.rxConfig.maxcheck = read16();
|
||||||
masterConfig.rxConfig.midrc = read16();
|
masterConfig.rxConfig.midrc = read16();
|
||||||
|
@ -1335,20 +1330,16 @@ static bool processInCommand(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_SET_RSSI_CONFIG:
|
case MSP_SET_RSSI_CONFIG:
|
||||||
headSerialReply(0);
|
|
||||||
masterConfig.rxConfig.rssi_channel = read8();
|
masterConfig.rxConfig.rssi_channel = read8();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case MSP_SET_RX_MAP:
|
case MSP_SET_RX_MAP:
|
||||||
headSerialReply(0);
|
|
||||||
for (i = 0; i < MAX_MAPPABLE_RX_INPUTS; i++) {
|
for (i = 0; i < MAX_MAPPABLE_RX_INPUTS; i++) {
|
||||||
masterConfig.rxConfig.rcmap[i] = read8();
|
masterConfig.rxConfig.rcmap[i] = read8();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_SET_CONFIG:
|
case MSP_SET_CONFIG:
|
||||||
headSerialReply(0);
|
|
||||||
|
|
||||||
masterConfig.mixerConfiguration = read8(); // multitype
|
masterConfig.mixerConfiguration = read8(); // multitype
|
||||||
|
|
||||||
|
@ -1367,7 +1358,6 @@ static bool processInCommand(void)
|
||||||
|
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
case MSP_SET_LED_COLORS:
|
case MSP_SET_LED_COLORS:
|
||||||
headSerialReply(0);
|
|
||||||
for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) {
|
for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) {
|
||||||
hsvColor_t *color = &masterConfig.colors[i];
|
hsvColor_t *color = &masterConfig.colors[i];
|
||||||
color->h = read16();
|
color->h = read16();
|
||||||
|
@ -1377,7 +1367,6 @@ static bool processInCommand(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_SET_LED_STRIP_CONFIG:
|
case MSP_SET_LED_STRIP_CONFIG:
|
||||||
headSerialReply(MAX_LED_STRIP_LENGTH * 6);
|
|
||||||
for (i = 0; i < MAX_LED_STRIP_LENGTH; i++) {
|
for (i = 0; i < MAX_LED_STRIP_LENGTH; i++) {
|
||||||
ledConfig_t *ledConfig = &masterConfig.ledConfigs[i];
|
ledConfig_t *ledConfig = &masterConfig.ledConfigs[i];
|
||||||
uint16_t mask;
|
uint16_t mask;
|
||||||
|
@ -1398,7 +1387,6 @@ static bool processInCommand(void)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case MSP_REBOOT:
|
case MSP_REBOOT:
|
||||||
headSerialReply(0);
|
|
||||||
isRebootScheduled = true;
|
isRebootScheduled = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1477,6 +1465,10 @@ void mspProcess(void)
|
||||||
mspProcessPort();
|
mspProcessPort();
|
||||||
|
|
||||||
if (isRebootScheduled) {
|
if (isRebootScheduled) {
|
||||||
|
// pause a little while to allow response to be sent
|
||||||
|
while (!isSerialTransmitBufferEmpty(candidatePort->port)) {
|
||||||
|
delay(50);
|
||||||
|
}
|
||||||
systemReset();
|
systemReset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue