Skip to content

Commit 9758ad6

Browse files
committed
fix: read_v2_msg_async_inner, write_versioned_msg_async_signed
doc: update for async fix: remove unused serial code from async connection
1 parent 70a8af0 commit 9758ad6

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

mavlink-core/src/async_connection/mod.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ mod file;
1313
#[cfg(feature = "signing")]
1414
use crate::SigningConfig;
1515

16-
/// A MAVLink connection
16+
/// An async MAVLink connection
1717
#[async_trait::async_trait]
1818
pub trait AsyncMavConnection<M: Message + Sync> {
1919
/// Receive a mavlink message.
2020
///
21-
/// Blocks until a valid frame is received, ignoring invalid messages.
21+
/// Wait until a valid frame is received, ignoring invalid messages.
2222
async fn recv(&self) -> Result<(MavHeader, M), crate::error::MessageReadError>;
2323

2424
/// Send a mavlink message
@@ -61,7 +61,7 @@ pub trait AsyncMavConnection<M: Message + Sync> {
6161
fn setup_signing(&mut self, signing_data: Option<SigningConfig>);
6262
}
6363

64-
/// Connect to a MAVLink node by address string.
64+
/// Connect asynchronously to a MAVLink node by address string.
6565
///
6666
/// The address must be in one of the following formats:
6767
///
@@ -70,12 +70,11 @@ pub trait AsyncMavConnection<M: Message + Sync> {
7070
/// * `udpin:<addr>:<port>` to create a UDP server, listening for incoming packets
7171
/// * `udpout:<addr>:<port>` to create a UDP client
7272
/// * `udpbcast:<addr>:<port>` to create a UDP broadcast
73-
/// * NOT `serial:<port>:<baudrate>` to create a serial connection
7473
/// * `file:<path>` to extract file data
7574
///
75+
/// Serial is currently not supported for async connections, use [`crate::connect`] instead.
7676
/// The type of the connection is determined at runtime based on the address type, so the
7777
/// connection is returned as a trait object.
78-
// TODO only reason this has to be send is udp serve
7978
pub async fn connect_async<M: Message + Sync + Send>(
8079
address: &str,
8180
) -> io::Result<Box<dyn AsyncMavConnection<M> + Sync + Send>> {
@@ -102,24 +101,13 @@ pub async fn connect_async<M: Message + Sync + Send>(
102101
{
103102
protocol_err
104103
}
105-
} else if cfg!(feature = "direct-serial") && address.starts_with("serial:") {
106-
#[cfg(feature = "direct-serial")]
107-
{
108-
todo!()
109-
//Ok(Box::new(direct_serial::open(&address["serial:".len()..])?))
110-
}
111-
#[cfg(not(feature = "direct-serial"))]
112-
{
113-
protocol_err
114-
}
115104
} else if address.starts_with("file") {
116105
Ok(Box::new(file::open(&address["file:".len()..]).await?))
117106
} else {
118107
protocol_err
119108
}
120109
}
121110

122-
// TODO remove this ?
123111
/// Returns the socket address for the given address.
124112
pub(crate) fn get_socket_addr<T: std::net::ToSocketAddrs>(
125113
address: T,

mavlink-core/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ async fn read_v2_msg_async_inner<M: Message, R: tokio::io::AsyncReadExt + Unpin>
11321132
read: &mut AsyncPeekReader<R>,
11331133
signing_data: Option<&SigningData>,
11341134
) -> Result<(MavHeader, M), error::MessageReadError> {
1135-
let message = read_v2_raw_message_async_signed::<M, _>(read, signing_data).await?;
1135+
let message = read_v2_raw_message_async_inner::<M, _>(read, signing_data).await?;
11361136

11371137
Ok((
11381138
MavHeader {
@@ -1211,7 +1211,7 @@ pub async fn write_versioned_msg_async<M: Message, W: tokio::io::AsyncWriteExt +
12111211
}
12121212

12131213
/// Async write a message with signing support using the given mavlink version
1214-
#[cfg(feature = "tokio-1")]
1214+
#[cfg(all(feature = "tokio-1", feature = "signing"))]
12151215
pub async fn write_versioned_msg_async_signed<M: Message, W: tokio::io::AsyncWriteExt + Unpin>(
12161216
w: &mut W,
12171217
version: MavlinkVersion,

0 commit comments

Comments
 (0)