kivancsikert / ugly-duckling

Firmware for FarmHub devices
0 stars 0 forks source link

Scheduling is off #176

Closed doramelindatunde closed 3 weeks ago

doramelindatunde commented 1 month ago

Original report from user:

tegnap este elinditottam 30pre a dudot es nem zart vissza, folyt egesz ejszaka

lptr commented 3 weeks ago

Fixed by #180

The scheduling was off by 25032 seconds (a bit less than 7 hours). This was happening across different devices.

My original thought was that somehow NTP got out of sync or something else threw the clock on the devices off. However, the clock was perfectly aligned on all of them.

What did fix things was to drop doing any calculations in ticks and keep all calculations in regular time units. The latter are handled as int64_t, while ticks are uint32_t. I'm not sure if it was about converting between them, or something about the unsigned nature of ticks, but the switch has fixed things. Damn "undefined behavior" of C++ I guess.