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

async connections #276

Merged
merged 7 commits into from
Sep 9, 2024
Merged

async connections #276

merged 7 commits into from
Sep 9, 2024

Conversation

pv42
Copy link
Contributor

@pv42 pv42 commented Aug 29, 2024

Implements #256.
Adds asynchronous connect method async connect_async(address) as async version of connect(address).
For this the following is added when the tokio-1 feature is enabled:

  • mod async_connection with connect_async(..)
  • trait AsyncMavConnection as [#[async_trait] as an async verions of trait MavConnection
  • AsyncFileConnection, AsyncTcpConnection, AsyncUdpConnection implementing AsyncMavConnection
  • AsyncPeekReader as async verions of PeekReader
  • read/write functions read_versioned_msg_async, read_versioned_msg_async_signed, read_v1_raw_message_async, read_v1_msg_async, read_v2_msg_async_signed, write_versioned_msg_async_signed, write_v2_msg_async_signed
  • change functions read_v2_raw_message_async, read_v2_raw_message_async_inner, read_v2_raw_message_async_signed, read_v2_msg_async to read from a AsyncPeekReader instead of directly for a tokio::io::AsyncReadExt
  • connect_async is exposed as mavlink::connect_async

Tests:

  • Add async versions of tcp_loopback_tests.rs and udp_loopback_async_tests.rs
  • AsyncUdpConnection tests datagram_buffering similar to its blocking sibling
  • To run test the tokio features rt, macros are needed, for this reason tokio with these additional features is required as dev-dependencies for both mavlink-core and mavlink

Caveats

  • No serial support.
  • The change of some existing function to AsyncPeekReader from tokio::io::AsyncReadExt is breaking
  • The MSRV test fails (see Test with no-dev-deps all-targets #277/Run MSRV check only for lib and bin targtets. #278), test succeds locally for bins/lib targets or without using no-dev-deps.
  • The combinations of asnyc and signing results in 4 versions of the same functions that effectifly do the same. (e.g. write_versioned_msg, write_versioned_msg_signed, write_versioned_msg_async and write_versioned_msg_async_signed)

@pv42 pv42 marked this pull request as ready for review September 8, 2024 13:01
feat: add async peek reader
feat: change async read fn to use AsyncPeekReader
feat: add read_v1_msg_async, read_v2_msg_async_signed, write_versioned_msg_async_signed, write_v2_msg_async_signed
fix: remove tokio version cap for dev-dep
doc: update for async
fix: remove unused serial code from async connection
Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@patrickelectric patrickelectric merged commit fbd2239 into mavlink:master Sep 9, 2024
41 checks passed
@pv42 pv42 deleted the async_connection branch September 9, 2024 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants