Fix crsf msp over telemetry

This commit is contained in:
Hans Christian Olaussen 2021-11-06 20:04:40 +01:00
parent 5d41f9830b
commit 7c12405fb8
1 changed files with 8 additions and 4 deletions

View File

@ -140,7 +140,11 @@ bool bufferCrsfMspFrame(uint8_t *frameStart, int frameLength)
bool handleCrsfMspFrameBuffer(uint8_t payloadSize, mspResponseFnPtr responseFn) bool handleCrsfMspFrameBuffer(uint8_t payloadSize, mspResponseFnPtr responseFn)
{ {
bool requestHandled = false; static bool replyPending = false;
if (replyPending) {
replyPending = sendMspReply(payloadSize, responseFn);
return replyPending;
}
if (!mspRxBuffer.len) { if (!mspRxBuffer.len) {
return false; return false;
} }
@ -148,17 +152,17 @@ bool handleCrsfMspFrameBuffer(uint8_t payloadSize, mspResponseFnPtr responseFn)
while (true) { while (true) {
const int mspFrameLength = mspRxBuffer.bytes[pos]; const int mspFrameLength = mspRxBuffer.bytes[pos];
if (handleMspFrame(&mspRxBuffer.bytes[CRSF_MSP_LENGTH_OFFSET + pos], mspFrameLength, NULL)) { if (handleMspFrame(&mspRxBuffer.bytes[CRSF_MSP_LENGTH_OFFSET + pos], mspFrameLength, NULL)) {
requestHandled |= sendMspReply(payloadSize, responseFn); replyPending |= sendMspReply(payloadSize, responseFn);
} }
pos += CRSF_MSP_LENGTH_OFFSET + mspFrameLength; pos += CRSF_MSP_LENGTH_OFFSET + mspFrameLength;
ATOMIC_BLOCK(NVIC_PRIO_SERIALUART1) { ATOMIC_BLOCK(NVIC_PRIO_SERIALUART1) {
if (pos >= mspRxBuffer.len) { if (pos >= mspRxBuffer.len) {
mspRxBuffer.len = 0; mspRxBuffer.len = 0;
return requestHandled; return replyPending;
} }
} }
} }
return requestHandled; return replyPending;
} }
#endif #endif