1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

fixed problem msp send error when serial port buffer full

This commit is contained in:
ligenxxxx 2020-12-16 11:47:12 +08:00
parent d89a5c8713
commit fbfbf189c1

View file

@ -312,6 +312,7 @@ static int mspSerialEncode(mspPort_t *msp, mspPacket_t *packet, mspVersion_e msp
uint8_t checksum;
int hdrLen = 3;
int crcLen = 0;
int ret = 0;
#define V1_CHECKSUM_STARTPOS 3
if (mspVersion == MSP_V1) {
@ -388,7 +389,10 @@ static int mspSerialEncode(mspPort_t *msp, mspPacket_t *packet, mspVersion_e msp
}
// Send the frame
return mspSerialSendFrame(msp, hdrBuf, hdrLen, sbufPtr(&packet->buf), dataLen, crcBuf, crcLen);
// If it fails, resend until success
while (ret==0)
ret = mspSerialSendFrame(msp, hdrBuf, hdrLen, sbufPtr(&packet->buf), dataLen, crcBuf, crcLen);
return ret;
}
static mspPostProcessFnPtr mspSerialProcessReceivedCommand(mspPort_t *msp, mspProcessCommandFnPtr mspProcessCommandFn)