adafruit / Adafruit_CircuitPython_Wiznet5k

Pure-Python interface for WIZNET 5k Ethernet modules
Other
15 stars 35 forks source link

replace time.monotonic with adafruit_ticks to preserve timing precision #156

Closed kevin-tritz closed 4 months ago

kevin-tritz commented 5 months ago

Time monotonic continues to lose precision as uptime gets longer. This will cause spurious timeouts to occur after a few days depending on the duration of the socket timeout (e.g. 100msec), but will cause spurious timeouts even at 1sec if the uptime gets long enough. I've replaced all of the time.monotonics with adafruit_ticks.ticks_ms and the appropriate tick_diff math to compare with timeouts. This could also be fixed by using time.monotonic_ns as long as the nanosecond ints were subtracted from each other first before being divided into float seconds. Closes #152

justmobilize commented 5 months ago

@dhalbert I would assume we would want to do the same work to ESP32SPI to keep them similar, but worry about adding adafruit_ticks as another frozen library. Thoughts?

dhalbert commented 4 months ago

@dhalbert I would assume we would want to do the same work to ESP32SPI to keep them similar, but worry about adding adafruit_ticks as another frozen library. Thoughts?

adafruit_ticks.mpy is only 634 bytes, so I think that's fine.