1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 03:20:00 +03:00

BLHeliSuite32 holds 4wayif code in indefinite loop waiting for ESC so remove timeout (#13287)

This commit is contained in:
Steve Evans 2024-01-13 22:24:01 +00:00 committed by GitHub
parent 90ab9f374b
commit d039124e44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -92,7 +92,6 @@
#define SERIAL_4WAY_VERSION_HI (uint8_t) (SERIAL_4WAY_VERSION / 100) #define SERIAL_4WAY_VERSION_HI (uint8_t) (SERIAL_4WAY_VERSION / 100)
#define SERIAL_4WAY_VERSION_LO (uint8_t) (SERIAL_4WAY_VERSION % 100) #define SERIAL_4WAY_VERSION_LO (uint8_t) (SERIAL_4WAY_VERSION % 100)
#define ESC_TIMEOUT_US 3000000
#define CMD_TIMEOUT_US 50000 #define CMD_TIMEOUT_US 50000
#define ARG_TIMEOUT_US 25000 #define ARG_TIMEOUT_US 25000
#define DAT_TIMEOUT_US 10000 #define DAT_TIMEOUT_US 10000
@ -400,7 +399,7 @@ static bool ReadByte(uint8_t *data, timeDelta_t timeoutUs)
// need timedOut? // need timedOut?
timeUs_t startTime = micros(); timeUs_t startTime = micros();
while (!serialRxBytesWaiting(port)) { while (!serialRxBytesWaiting(port)) {
if (cmpTimeUs(micros(), startTime) > timeoutUs) { if (timeoutUs && (cmpTimeUs(micros(), startTime) > timeoutUs)) {
return true; return true;
} }
} }
@ -464,8 +463,9 @@ void esc4wayProcess(serialPort_t *mspPort)
// restart looking for new sequence from host // restart looking for new sequence from host
do { do {
CRC_in.word = 0; CRC_in.word = 0;
timedOut = ReadByteCrc(&ESC, ESC_TIMEOUT_US); // No timeout as BLHeliSuite32 has this loops sitting indefinitely waiting for input
} while ((ESC != cmd_Local_Escape) && !timedOut); ReadByteCrc(&ESC, 0);
} while (ESC != cmd_Local_Escape);
RX_LED_ON; RX_LED_ON;
@ -473,27 +473,24 @@ void esc4wayProcess(serialPort_t *mspPort)
O_PARAM = &Dummy.bytes[0]; O_PARAM = &Dummy.bytes[0];
O_PARAM_LEN = 1; O_PARAM_LEN = 1;
timedOut = ReadByteCrc(&CMD, CMD_TIMEOUT_US) ||
ReadByteCrc(&ioMem.D_FLASH_ADDR_H, ARG_TIMEOUT_US) ||
ReadByteCrc(&ioMem.D_FLASH_ADDR_L, ARG_TIMEOUT_US) ||
ReadByteCrc(&I_PARAM_LEN, ARG_TIMEOUT_US);
if (!timedOut) { if (!timedOut) {
timedOut = ReadByteCrc(&CMD, CMD_TIMEOUT_US); uint8_t i = I_PARAM_LEN;
timedOut |= ReadByteCrc(&ioMem.D_FLASH_ADDR_H, ARG_TIMEOUT_US);
timedOut |= ReadByteCrc(&ioMem.D_FLASH_ADDR_L, ARG_TIMEOUT_US);
timedOut |= ReadByteCrc(&I_PARAM_LEN, ARG_TIMEOUT_US);
if (!timedOut) { InBuff = ParamBuf;
InBuff = ParamBuf; do {
uint8_t i = I_PARAM_LEN; timedOut = ReadByteCrc(InBuff++, DAT_TIMEOUT_US);
do { } while ((--i > 0) && !timedOut);
timedOut |= ReadByteCrc(InBuff, DAT_TIMEOUT_US);
InBuff++;
i--;
} while ((i > 0) && !timedOut);
if (!timedOut) { for (int8_t i = 1; (i >= 0) && !timedOut; i--) {
timedOut |= ReadByte(&CRC_check.bytes[1], CRC_TIMEOUT_US); timedOut = ReadByte(&CRC_check.bytes[i], CRC_TIMEOUT_US);
timedOut |= ReadByte(&CRC_check.bytes[0], CRC_TIMEOUT_US);
}
} }
} }
if ((CRC_check.word == CRC_in.word) && !timedOut) { if ((CRC_check.word == CRC_in.word) && !timedOut) {
ACK_OUT = ACK_OK; ACK_OUT = ACK_OK;
} else { } else {