mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-05 13:04:05 -06:00
basecmd: Update stats timing check to support 32bit duration
Use a 32bit duration check instead of the previous 31bit check. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
f1e0730701
commit
8e107b2280
1 changed files with 8 additions and 1 deletions
|
@ -299,6 +299,13 @@ command_get_uptime(uint32_t *args)
|
|||
}
|
||||
DECL_COMMAND_FLAGS(command_get_uptime, HF_IN_SHUTDOWN, "get_uptime");
|
||||
|
||||
// Similar to timer_is_before(), but handles full 32bit duration
|
||||
static int
|
||||
timer_has_elapsed(uint32_t start, uint32_t cur, uint32_t duration)
|
||||
{
|
||||
return (uint32_t)(cur - start) >= duration;
|
||||
}
|
||||
|
||||
#define SUMSQ_BASE 256
|
||||
DECL_CONSTANT("STATS_SUMSQ_BASE", SUMSQ_BASE);
|
||||
|
||||
|
@ -322,7 +329,7 @@ stats_update(uint32_t start, uint32_t cur)
|
|||
nextsumsq = 0xffffffff;
|
||||
sumsq = nextsumsq;
|
||||
|
||||
if (timer_is_before(cur, stats_send_time + timer_from_us(5000000)))
|
||||
if (!timer_has_elapsed(stats_send_time, cur, timer_from_us(5000000)))
|
||||
return;
|
||||
sendf("stats count=%u sum=%u sumsq=%u", count, sum, sumsq);
|
||||
if (cur < stats_send_time)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue