Serial Async RX Callback only gets called once #176
Replies: 3 comments 8 replies
-
Hi @cptpiepmatz, Thanks for the report and for the reproduction case. I was about to get both to build, though had to remove the For both the C and Rust version I see the callback being called once when the program starts and then again on any UART data sent to the device. I did notice that the C version has: uint32_t some_number = 42; while the Rust version has: let mut some_number = 0u32; which would explain the difference in logged counter values. |
Beta Was this translation helpful? Give feedback.
-
@dcoles thanks for your quick reply ❤️
Oh, that was an accident.
I didn't know that could cause the issue. I realized that my Rust version did not include the command that would cause it to receive bytes but nevertheless, I got a crash with the included But now that leaves me with the question how could I avoid that? Is every allocation bad? Then even working with |
Beta Was this translation helpful? Give feedback.
-
After experimenting around I found out that the following seems to be absolute necessary to have the callback not crash and fulfill to not block the next occurence: if sys::furi_hal_serial_async_rx_available(handle) {
let _ = sys::furi_hal_serial_async_rx(handle);
} |
Beta Was this translation helpful? Give feedback.
-
I'm trying to make uart work for me but I get weird problem with this crate.
I have written this very simple fap in C that writes a command on the serial bus and then I just count up how often that callback got called.
Then I implemented basically the same in Rust using this crate here.
For whatever reason my
rx_callback
in the Rust just gets called exactly once while the C variant gets called about 50 times.Beta Was this translation helpful? Give feedback.
All reactions