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

mavlink: mavlink_camera: Add shutdown mechanism #314

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
mavlink: mavlink_camera: Use try_recv over recv to avoid blocking sco…
…pe when finishing loop

Signed-off-by: Patrick José Pereira <[email protected]>
patrickelectric committed Nov 29, 2023
commit 9a030e4786b5dddcaa8f9aae15d7b7e513dd8c09
7 changes: 4 additions & 3 deletions src/mavlink/mavlink_camera.rs
Original file line number Diff line number Diff line change
@@ -190,14 +190,15 @@ impl MavlinkCamera {
break;
}

let (header, message) = match receiver.recv().await {
std::thread::sleep(std::time::Duration::from_millis(10));
let (header, message) = match receiver.try_recv() {
Ok(Message::Received(message)) => message,
Err(broadcast::error::RecvError::Closed) => {
Err(broadcast::error::TryRecvError::Closed) => {
unreachable!(
"Closed channel: This should never happen, this channel is static!"
);
}
Ok(Message::ToBeSent(_)) | Err(broadcast::error::RecvError::Lagged(_)) => continue,
Ok(Message::ToBeSent(_)) | Err(_) => continue,
};

trace!("Message received: {header:?}, {message:?}");