fix: CheckDelay returns false forever when timedly is negative (-S2) #5

Merged
bastian merged 1 commits from fix/checkdelay-negative-timedly into main 2026-05-10 09:34:45 -04:00
2 changed files with 10 additions and 4 deletions
Showing only changes of commit 5dc715558f - Show all commits
+2 -2
View File
@@ -125,9 +125,9 @@
#define CAT_COMM "Communication" #define CAT_COMM "Communication"
// SKUDAK customization suffix: bump on every Skudak-side change so the OpenInverter // SKUDAK customization suffix: bump on every Skudak-side change so the OpenInverter
// web UI shows a distinct version (e.g. "4=1.19.R-S1") and we can visually confirm // web UI shows a distinct version (e.g. "4=1.19.R-S2") and we can visually confirm
// the right firmware is flashed. Match the stm32-sine -S<N> convention. // the right firmware is flashed. Match the stm32-sine -S<N> convention.
#define VERSTR STRINGIFY(4=VER-S1) #define VERSTR STRINGIFY(4=VER-S2)
/***** enums ******/ /***** enums ******/
+8 -2
View File
@@ -85,9 +85,15 @@ bool CheckTimeout()
bool CheckDelay() bool CheckDelay()
{ {
uint32_t now = rtc_get_counter_val(); uint32_t now = rtc_get_counter_val();
uint32_t start = Param::GetInt(Param::timedly) * 60; // Upstream uses uint32_t here, which wraps a negative timedly (the param's
// documented -1 "no delay" sentinel) into a ~4 billion-second timeout that
// never expires — leaving the state machine wedged in WaitStart forever.
// Use signed math for the short-circuit so timedly <= 0 still means
// "start immediately." The cast on the elapsed-comparison side is only
// reached when start > 0, so it can't reinterpret a negative as huge.
int start = Param::GetInt(Param::timedly) * 60;
return start <= 0 || (now - startTime) > start; return start <= 0 || (now - startTime) > (uint32_t)start;
} }