Open lfdominguez opened 7 months ago
Maybe select? You could signal when GPS stops sending data and use select() to break the loop.
Maybe select? You could signal when GPS stops sending data and use select() to break the loop.
But how I have known that GPS stop sending data? Can you post an example? thanks in advance
I haven't worked with any GPS module so I don't know how they communicate.
If you are expecting some data from GPS asynchronously, then you need to keep UART alive. If you know that GPS will stop after some known command, you can also signal an event and handle that event via select().
loop {
let either = select(rx.read_until_idle(&mut read_buffer), STOP_EVENT.receive()).await
match either {
Either::First(gps_msg) => handle_gps_msg(gps_msg.unwrap()),
Either::Second(stop_evt) => break,
}
}
How about with_timeout?
I haven't worked with any GPS module so I don't know how they communicate.
If you are expecting some data from GPS asynchronously, then you need to keep UART alive. If you know that GPS will stop after some known command, you can also signal an event and handle that event via select().
loop { let either = select(rx.read_until_idle(&mut read_buffer), STOP_EVENT.receive()).await match either { Either::First(gps_msg) => handle_gps_msg(gps_msg.unwrap()), Either::Second(stop_evt) => break, } }
How about with_timeout?
Great!! thanks, I will test it.
Hi, I'm porting my firmware from Zephyr to Rust, and I'm stopped because the
read_until_idle
call is blocking forever. My task is:My problem is that when I send a command to the GPS component that is connected by UART, it's stop sending data over UART line, but the read_until_idle() get stuck.
If there is another better approach to do this please tell me... my final goal is when GPS is stopped, drop the UARTE instance because right now, on Zephyr my board is consuming 400uA, but on this is 5 mA.