1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-24 16:55:29 +03:00

WIP bigger refactor of LED Config

Currently crashes when reading/writing led configuration.
This commit is contained in:
Marcelo Bezerra 2022-11-08 17:37:38 +01:00
parent fae79547f2
commit 2e96599146
4 changed files with 85 additions and 47 deletions

View file

@ -1051,7 +1051,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
case MSP_LED_STRIP_CONFIG:
for (int i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[i];
sbufWriteU32(dst, *ledConfig);
sbufWriteDataSafe(dst, ledConfig, sizeof(ledConfig_t));
}
break;
@ -2677,13 +2677,13 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
break;
case MSP_SET_LED_STRIP_CONFIG:
if (dataSize == 5) {
if (dataSize == (1 + sizeof(ledConfig_t))) {
tmp_u8 = sbufReadU8(src);
if (tmp_u8 >= LED_MAX_STRIP_LENGTH || dataSize != (1 + 4)) {
if (tmp_u8 >= LED_MAX_STRIP_LENGTH) {
return MSP_RESULT_ERROR;
}
ledConfig_t *ledConfig = &ledStripConfigMutable()->ledConfigs[tmp_u8];
*ledConfig = sbufReadU32(src);
sbufReadDataSafe(src, ledConfig, sizeof(ledConfig_t));
reevaluateLedConfig();
} else
return MSP_RESULT_ERROR;