8 ms·
Unless you're overloading the |= to death that assignment isn't checking any of the things that are being checked (either at compile or runtime) in the rust cod
by arlort 3y ago
Unless you're overloading the |= to death that assignment isn't checking any of the things that are being checked (either at compile or runtime) in the rust code
This specific example is from the concurrency chapter so it's already handling multiple threads and that's why all those checks are needed.
This is a random example I found to blink a led on a rp2040:
> let mut led_pin = pins.gpio25.into_push_pull_output();
>
> loop {
> led_pin.set_high().unwrap();
> delay.delay_ms(500);
> led_pin.set_low().unwrap();
> delay.delay_ms(500);
> }
And this is how to do it using embassy, which is an async framework for embedded in rust:
https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/blinky.rs https://github.com/embassy-rs/embassy/blob/main/examples/rp/...
- mgoetzke 3y agoAs a newcomer to Rust (specifically Async/Threads) why are their multiple runtimes and thus different code for embedded async/threads between desktop and embedded ? I know it isn't in the standard library, so things just happened, but there is still no clear winner that does it all ? How can we make code be portable (e.g node.js like) between embedded and other platforms if they differ so much?
- steveklabnik 3y agoThere is no one set of tradeoffs that you can perfectly make across situations. Each have different needs, and so have executors that provide for those different needs.
- arlort 3y ago> How can we make code be portable (e.g node.js like) between embedded and other platforms if they differ so much? By embedded here we are talking about running bare metal on single core microcontrollers with kilobytes of memory and megabytes of storage which are more interested in driving or reading gpio/adc pins than serving a rest api or rendering a webpage To answer your question, you can't because the difference in code comes from huge differences in the use case and requirements. And trying to force using the same runtime for anything from webservers with dozens of processors and hundreds of gigabytes of ram to the kind of device that barely draws any power at all is going to make no one happy I only have a passing knowledge of embedded programming but it already seems to me that being able to effectively use this kind of abstractions in this domain is already halfway through a miracle, and probably only possible because the rust team decided to decouple the async model from a specific runtime