This repository has been archived by the owner on Jan 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Library converts datetime_t incorrectly, causing example to fail #4
Comments
Thank for the bug report. The fix will be as follows and will be introduced in the next release
The Terminal output with the new bug fix
Could you please check and verify if there any more issue with PIO. Thanks and regards |
Hi @maxgerhardt The new RP2040_RTC releases v1.0.7 has just been published. Your contribution has been noted in Contributions and Thanks Releases v1.0.7
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
This library does
RP2040_RTC/src/DateTime_Generic.h
Lines 456 to 477 in f7650a1
to convert a
DateTime
intodatetime_t
as needed by the Pico SDK'srtc_set_datetime
function. However, the library fails to initialize thetm.dotw
(day-of-the-week) member, and as such the field will have a random value from the stack.Calling into
rtc_set_datetime
with such a datastructure leads to the validation function failingSince
if (!(t->dotw >= 0 && t->dotw <= 6)) return false;
triggers. (Since variable is allocated on the stack it has an initial random value, 0-255, only by chance if the value is 0-6 it passes this check)Hence, the example Time with NiNa (https://github.com/khoih-prog/RP2040_RTC/tree/main/examples/Time/RP2040_RTC_Time_WiFiNINA) module that uses this codepath fails randomly.
And thus the example does not run correctly.
Steps to Reproduce
Use the https://github.com/khoih-prog/RP2040_RTC/tree/main/examples/Time/RP2040_RTC_Time_WiFiNINA example with the
platformio.ini
Expected behavior
The library converts to
datetime_t
correctly without leaving any datamember uninitialized.Actual behavior
Library does not initialize the
.dotw
member causing a probabilistic failure ofrtc_set_datetime()
.Debug and AT-command log (if applicable)
None appliciable.
Screenshots
None appliciable.
Information
Please ensure to specify the following:
RP2040
Core Version: Arduino-mbed RP2040 v2.5.2RP2040
Board type: NANO_RP2040_CONNECTAdditional context
Discussed in the PlatformIO forum thread.
The text was updated successfully, but these errors were encountered: