fix(gps and sensor): fix extended uptime failures in GPS and sensor code - #2074
Closed
NickDunklee wants to merge 4 commits into
Closed
fix(gps and sensor): fix extended uptime failures in GPS and sensor code#2074NickDunklee wants to merge 4 commits into
NickDunklee wants to merge 4 commits into
Conversation
- Fix millis() wraparound (49-day) in T1000SensorManager::loop() and MicroNMEALocationProvider::loop() by switching from absolute comparison (millis() > next_*) to elapsed-time arithmetic ((uint32_t)(millis() - last_*) >= interval) with uint32_t timestamps; previous pattern could stall GPS updates and time sync for up to ~24 days after wraparound - Fix division-by-zero crash in get_heater_temperature() when ntc_volt == 0 (open circuit or bad ADC read); now returns 0.0f safely - Fix out-of-bounds array access in get_heater_temperature(): loop exit at i == 0 caused ntc_res2[i-1] / ntc_temp2[i-1] at index -1; loop exhaustion at i == 136 caused ntc_res2[136] one-past-end read; clamped i to [1, 135] with early-exit returns for edge temperatures and guarded interpolation denominator against zero
Contributor
Author
|
Just note, haven't had a t1000e failure since this change. |
# Conflicts: # src/helpers/sensors/EnvironmentSensorManager.cpp
Contributor
Author
|
#2937 fixes the GPS bug as well, so closing. Huzzah! 🎉 I'll check the other code vs 1.17.0 and open another PR if needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updated to cover all GPS code paths that have the same variable math problems.
This covers fixing GPS looping bugs and also a divide by zero potential crash in the t1000-e. Was originally an attempt to help fix t1000-e uptime, and figured might as well fix the math in all the rest in the same go. If preferred, I can break out the t1000-e sensor fix into its own PR so this is just GPS stuff.