-
Notifications
You must be signed in to change notification settings - Fork 84
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
few tick timeout comparison and other issues/improvements: #223
Comments
Very useful indeed, thanks Michael, give me time to absorb and I will comment here, tagging issue #209 so that |
Some of the issues are just in test code, so will not affect a real application. |
Here is some more:
|
Yeah I've been noticing this repeatedly as well - though we've not been reviewing the test code applications. Zephyr does something similar as suggested by wrapping all "times" in an "opaque" (but not really) struct that is supposed to be passed into macros/static inlines to handle the encapsulated values. You can see the encapsulation in Note Zephyr does some things differently as it generally leverages |
Implementation in #225. |
Hi @RobMeades
I had some time to screen the https://github.com/u-blox/ubxlib/tree/preview_fix_tick_wrap_rmea branch a bit and found some issues many of them timeout related but not only. Towards the end you also find a suggestion how to avoid these mistakes in the future with an improved timeout API that hides the MS handling from the user.
ubxlib/cell/test/u_cell_geofence_test.c
Line 404 in 3cf5348
change: (uPortGetTickTimeMs() < gStopTimeMs)
to: (((uPortGetTickTimeMs - gStopTimeMs) < 0)
suggest to use uPortTickTimeBeyondStopMs
ubxlib/cell/test/u_cell_loc_test.c
Line 779 in 3cf5348
change: (uPortGetTickTimeMs() < gStopTimeMs)
to: (((uPortGetTickTimeMs - gStopTimeMs) < 0)
or use uPortTickTimeBeyondStopMs
ubxlib/common/geofence/src/u_geofence.c
Line 1906 in 3cf5348
review: dynamicsMinDistance.lastStatus.distanceMillimetres = uPortGetTickTimeMs();
possibly change to dynamicsMinDistance.lastStatus.timeMs = uPortGetTickTimeMs();
ubxlib/common/mqtt_client/test/u_mqtt_client_test.c
Line 471 in 3cf5348
change: (uPortGetTickTimeMs() < startTimeMs +
(U_MQTT_CLIENT_RESPONSE_WAIT_SECONDS * 1000))
to: (uPortGetTickTimeMs() - startTimeMs < (U_MQTT_CLIENT_RESPONSE_WAIT_SECONDS * 1000))
or use uPortTickTimeExpiredMs
ubxlib/gnss/src/lib_mga/u_lib_mga.c
Line 1191 in 3cf5348
change: if (now > pMsgInfo->timeOut)
to: if (now - pMsgInfo->timeOut > 0)
suggest to rename now to startTimeMs and timeOut StopTimeMs
sugguest to use uPortTickTimeBeyondStopMs
many more occasions throughout this file ....
ubxlib/gnss/src/lib_mga/u_lib_mga.c
Line 1237 in 3cf5348
ubxlib/gnss/src/lib_mga/u_lib_mga.c
Line 2246 in 3cf5348
ubxlib/gnss/src/lib_mga/u_lib_mga.c
Line 2265 in 3cf5348
ubxlib/gnss/src/lib_mga/u_lib_mga.c
Line 2291 in 3cf5348
... potentially more ..
ubxlib/gnss/test/u_gnss_geofence_test.c
Line 901 in 3cf5348
ubxlib/gnss/test/u_gnss_geofence_test.c
Line 920 in 3cf5348
change: (uPortGetTickTimeMs() < gStopTimeMs)
to: (uPortGetTickTimeMs() - gStopTimeMs < 0)
suggest use of use uPortTickTimeBeyondStopMs
ubxlib/gnss/test/u_gnss_pos_test.c
Line 777 in 3cf5348
chnage: (uPortGetTickTimeMs() < gStopTimeMs)
to: (uPortGetTickTimeMs() - gStopTimeMs < 0)
suggest use of use uPortTickTimeBeyondStopMs
maybe there are even more of these things ...
To avoid all such mistakes my suggestion is to have tick uPortGetTickTimeMs return a "handle" and move all the comparison functions into the function where this is allways properly handled. properly, this way the develpper can't make any mistakes as he does not know what using this handle has and how to convert it
You could extend the tick API with a elapsed millisecond and use this throughout the code in all the printfs
of course the current API would also take only these handles
The text was updated successfully, but these errors were encountered: