Merge pull request 'fix: CheckDelay returns false forever when timedly is negative (-S2)' (#5) from fix/checkdelay-negative-timedly into main
Build Firmware / Build stm32-teslacharger (push) Successful in 1m0s
Build Firmware / Build stm32-teslacharger (push) Successful in 1m0s
This commit was merged in pull request #5.
This commit is contained in:
+2
-2
@@ -125,9 +125,9 @@
|
||||
#define CAT_COMM "Communication"
|
||||
|
||||
// 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.
|
||||
#define VERSTR STRINGIFY(4=VER-S1)
|
||||
#define VERSTR STRINGIFY(4=VER-S2)
|
||||
|
||||
/***** enums ******/
|
||||
|
||||
|
||||
+8
-2
@@ -85,9 +85,15 @@ bool CheckTimeout()
|
||||
bool CheckDelay()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user