Thanks to visit codestin.com
Credit goes to github.com

Skip to content

rp2/machine_rtc: Check return value from rtc_set_alarm. #7392

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

Closed
wants to merge 1 commit into from

Conversation

kadamski
Copy link
Contributor

The rtc_set_datetime() from pico-sdk will validate the values in the
datetime_t structure and refuse to set the time if they aren't valid. It
makes sense to raise an exception if this happens instead of failing
silently which might be confusing (as an example, see:
#6928 (comment)
).

@@ -100,7 +101,10 @@ STATIC mp_obj_t machine_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
.sec = mp_obj_get_int(items[6]),
};

rtc_set_datetime(&t);
ret = rtc_set_datetime(&t);
Copy link
Member

Choose a reason for hiding this comment

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

The usual style in MicroPython (C coding) is to declare variables (eg ret here) as late as possible. You could also just write it as if (!rtc_set_datetime(&t)) { ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dpgeorge good point. I have uploaded the fixed version.

@dpgeorge
Copy link
Member

Regardless of any other changes (eg #7394), this is a good improvement.

The rtc_set_datetime() from pico-sdk will validate the values in the
datetime_t structure and refuse to set the time if they aren't valid. It
makes sense to raise an exception if this happens instead of failing
silently which might be confusing (as an example, see:
micropython#6928 (comment)
).
@dpgeorge
Copy link
Member

Merged in e7f7094 (but I discarded the change to mbedtls submodule).

@dpgeorge dpgeorge closed this Jun 14, 2021
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Jan 4, 2023
Update pins.c for lolin_c3_mini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants