mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 23:05:19 +03:00
Improved retry timeout check and 10 seconds of no response from ESCs check
This commit is contained in:
parent
2ffe57761e
commit
c1d442279f
1 changed files with 39 additions and 36 deletions
|
@ -89,7 +89,7 @@ static uint8_t tlmFramePosition = 0;
|
||||||
static serialPort_t *escSensorPort = NULL;
|
static serialPort_t *escSensorPort = NULL;
|
||||||
static esc_telemetry_t escSensorData[MAX_SUPPORTED_MOTORS];
|
static esc_telemetry_t escSensorData[MAX_SUPPORTED_MOTORS];
|
||||||
static uint32_t escTriggerTimestamp = -1;
|
static uint32_t escTriggerTimestamp = -1;
|
||||||
static uint32_t escTriggerLastTimestamp = -1;
|
static uint32_t escLastResponseTimestamp;
|
||||||
static uint8_t timeoutRetryCount = 0;
|
static uint8_t timeoutRetryCount = 0;
|
||||||
static uint8_t totalRetryCount = 0;
|
static uint8_t totalRetryCount = 0;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ void escSensorProcess(timeUs_t currentTimeUs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait period of time before requesting telemetry (let the system boot first)
|
// Wait period of time before requesting telemetry (let the system boot first)
|
||||||
if (millis() < ESC_BOOTTIME) {
|
if (currentTimeMs < ESC_BOOTTIME) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (escSensorTriggerState == ESC_SENSOR_TRIGGER_WAIT) {
|
else if (escSensorTriggerState == ESC_SENSOR_TRIGGER_WAIT) {
|
||||||
|
@ -216,7 +216,7 @@ void escSensorProcess(timeUs_t currentTimeUs)
|
||||||
escSensorTriggerState = ESC_SENSOR_TRIGGER_READY;
|
escSensorTriggerState = ESC_SENSOR_TRIGGER_READY;
|
||||||
escSensorMotor = 0;
|
escSensorMotor = 0;
|
||||||
escTriggerTimestamp = currentTimeMs;
|
escTriggerTimestamp = currentTimeMs;
|
||||||
escTriggerLastTimestamp = escTriggerTimestamp;
|
escLastResponseTimestamp = escTriggerTimestamp;
|
||||||
}
|
}
|
||||||
else if (escSensorTriggerState == ESC_SENSOR_TRIGGER_READY) {
|
else if (escSensorTriggerState == ESC_SENSOR_TRIGGER_READY) {
|
||||||
DEBUG_SET(DEBUG_ESC_SENSOR, 0, escSensorMotor+1);
|
DEBUG_SET(DEBUG_ESC_SENSOR, 0, escSensorMotor+1);
|
||||||
|
@ -225,6 +225,7 @@ void escSensorProcess(timeUs_t currentTimeUs)
|
||||||
motor->requestTelemetry = true;
|
motor->requestTelemetry = true;
|
||||||
escSensorTriggerState = ESC_SENSOR_TRIGGER_PENDING;
|
escSensorTriggerState = ESC_SENSOR_TRIGGER_PENDING;
|
||||||
}
|
}
|
||||||
|
else if (escSensorTriggerState == ESC_SENSOR_TRIGGER_PENDING) {
|
||||||
|
|
||||||
if (escTriggerTimestamp + ESC_REQUEST_TIMEOUT < currentTimeMs) {
|
if (escTriggerTimestamp + ESC_REQUEST_TIMEOUT < currentTimeMs) {
|
||||||
// ESC did not repond in time, retry
|
// ESC did not repond in time, retry
|
||||||
|
@ -265,9 +266,11 @@ void escSensorProcess(timeUs_t currentTimeUs)
|
||||||
|
|
||||||
selectNextMotor();
|
selectNextMotor();
|
||||||
escSensorTriggerState = ESC_SENSOR_TRIGGER_READY;
|
escSensorTriggerState = ESC_SENSOR_TRIGGER_READY;
|
||||||
|
escLastResponseTimestamp = currentTimeMs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (escTriggerLastTimestamp + 10000 < currentTimeMs) {
|
if (escLastResponseTimestamp + 10000 < currentTimeMs) {
|
||||||
// ESCs did not respond for 10 seconds
|
// ESCs did not respond for 10 seconds
|
||||||
// Disable ESC telemetry and reset voltage and current to let the use know something is wrong
|
// Disable ESC telemetry and reset voltage and current to let the use know something is wrong
|
||||||
freeEscSensorPort();
|
freeEscSensorPort();
|
||||||
|
@ -282,8 +285,8 @@ static void selectNextMotor(void)
|
||||||
if (escSensorMotor == getMotorCount()) {
|
if (escSensorMotor == getMotorCount()) {
|
||||||
escSensorMotor = 0;
|
escSensorMotor = 0;
|
||||||
}
|
}
|
||||||
|
timeoutRetryCount = 0;
|
||||||
escTriggerTimestamp = millis();
|
escTriggerTimestamp = millis();
|
||||||
escTriggerLastTimestamp = escTriggerTimestamp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-- CRC
|
//-- CRC
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue