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

examples: Add asynchronous Rust example #20830

Merged
merged 5 commits into from
Aug 26, 2024

Conversation

chrysn
Copy link
Member

@chrysn chrysn commented Aug 23, 2024

Contribution description

Async is a popular coding style in Rust. Basic support for it is provided in riot-wrappers, mainly deferring to embassy tools.

Testing procedure

  • Run the example

Caveats

There are fewer components exposed for async than there are for synchronous code in the riot-wrappers. Nonetheless, this should be user visible, if only to find what users' priorities are in terms of added components.

[edit: This is based on #20829, only the most recent commit "counts"; I should probably rebase once that is merged so that GitHub shows things correctly]
[edit2: This is now blocked by #20831 to avoid merge races]

@github-actions github-actions bot added Area: doc Area: Documentation Area: tests Area: tests and testing framework Area: drivers Area: Device drivers Area: sys Area: System Area: examples Area: Example Applications labels Aug 23, 2024
@chrysn chrysn added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: Rust Area: Rust wrapper and removed Area: doc Area: Documentation Area: tests Area: tests and testing framework Area: drivers Area: Device drivers Area: sys Area: System labels Aug 23, 2024
@riot-ci
Copy link

riot-ci commented Aug 23, 2024

Murdock results

✔️ PASSED

a491841 examples/rust-async: Add Makefile.ci

Success Failures Total Runtime
499 0 500 03m:59s

Artifacts

@github-actions github-actions bot added Area: doc Area: Documentation Area: tests Area: tests and testing framework Area: drivers Area: Device drivers Area: sys Area: System labels Aug 23, 2024
@chrysn
Copy link
Member Author

chrysn commented Aug 23, 2024

It's not pretty that this has to take care of its own to enable the right portable-atomics; looking for better ways, but that shouldn't need to stop things here.

C preprocessor defines in non-function form are assumed by C2Rust to be
constant if they are an expression and not a statement; the LED_PORT was
the only place in the code where that was wrong, and led to compiler
errors due to the value not being constant.

Altering the internal macro to use function form sidesteps that issue.
The generally preferred alternative of using a `const` is unavailable in
this case because the dereferencing operator is already part of the
vendor header file cpu/stellaris_common/include/vendor/cortex-m4-def.h.

The changed macro is documented as required by doccheck. The doccheck
rule that grandfathered in the LED_PORT macro as allowed undocumented is
not removed because it is also used in other board.h files.
@github-actions github-actions bot added Area: boards Area: Board ports and removed Area: drivers Area: Device drivers Area: sys Area: System labels Aug 23, 2024
@chrysn
Copy link
Member Author

chrysn commented Aug 23, 2024

Added Makefile.ci (a short one -- this is just firing a few timers), and rebased onto #20831 to avoid logging a BOARDS_BLACKLIST entry around through parallel development.

@chrysn chrysn marked this pull request as ready for review August 23, 2024 15:52
@chrysn
Copy link
Member Author

chrysn commented Aug 24, 2024

On the caveat topic of not many wrappers being available, there is now a structured list at RIOT-OS/rust-riot-wrappers#111

Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

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

Code looks good to me and I trust your testing :)

@maribu maribu enabled auto-merge August 26, 2024 08:04
@maribu maribu added this pull request to the merge queue Aug 26, 2024
@chrysn chrysn removed this pull request from the merge queue due to a manual request Aug 26, 2024
@chrysn
Copy link
Member Author

chrysn commented Aug 26, 2024

I've taken this out of the merge queue for a moment (it's a few-minutes merge) because this PR includes #20831 commits as well.

If you have reviewed both parts and are happy with them, please leave an ACK there too, and we can restart this PR's merge queue run. I don't know what'd would happen if a a PR (20831) gets merged by another PR without itself qualifying for lack of ACKs, it could leave the PR in a weird state.

@chrysn chrysn added this pull request to the merge queue Aug 26, 2024
@chrysn
Copy link
Member Author

chrysn commented Aug 26, 2024

Thank you and mguetschow, both reviewed now, pressing the button. (With checks green, even if there is a fluke that keeps 20831 from being merged through the queue, and this one goes through, GitHub should recognize both as merged with all checks green).

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to invalid changes in the merge commit Aug 26, 2024
@chrysn chrysn added this pull request to the merge queue Aug 26, 2024
Merged via the queue into RIOT-OS:master with commit 2eefc68 Aug 26, 2024
26 checks passed
@chrysn chrysn deleted the rust-example-async branch August 26, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: doc Area: Documentation Area: examples Area: Example Applications Area: Rust Area: Rust wrapper Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants