Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

kevin-tritz
Copy link
Contributor

@kevin-tritz kevin-tritz commented Mar 27, 2024

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
Copy link
Collaborator

@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?

Copy link
Member

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good, but I didn't test.

@dhalbert
Copy link
Contributor

@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.

@dhalbert dhalbert merged commit ccb0c36 into adafruit:main Apr 17, 2024
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 23, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_floppy to 2.0.0 from 1.0.11:
  > Merge pull request adafruit/Adafruit_CircuitPython_floppy#11 from adafruit/updates-incompatible-floppyio-floppsy

Updating https://github.com/adafruit/Adafruit_CircuitPython_SharpMemoryDisplay to 1.4.12 from 1.4.11:
  > Merge pull request adafruit/Adafruit_CircuitPython_SharpMemoryDisplay#24 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Thermistor to 3.4.11 from 3.4.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_Thermistor#22 from adafruit/dhalbert-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 5.2.1 from 5.0.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#151 from pinkavaj/pi-fix-recv
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#157 from adafruit/core-compatible-socket-type-numbers
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#153 from us3r64/fix/socket-httpserver-poll
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#149 from pinkavaj/pi-fix-close-wait
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#156 from kevin-tritz/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 10.0.7 from 10.0.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#195 from adafruit/dhalbert-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_BusDevice to 5.2.9 from 5.2.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_BusDevice#99 from RetiredWizard/spicsinit

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inevitable socket timeouts using time.monotonic()
4 participants