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

Move mavlink-dump from src/bin to examples/mavlink-dump #215

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- uses: actions/checkout@master
- uses: dtolnay/rust-toolchain@stable
- name: Build mavlink-dump
run: cargo build --verbose --bin mavlink-dump --features ardupilotmega
run: cargo build --verbose --example mavlink-dump

msrv:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ proc-macro2 = "1.0.43"
lazy_static = "1.2.0"
serde = { version = "1.0.115", optional = true, features = ["derive"] }

[[bin]]
[[example]]
name = "mavlink-dump"
path = "examples/mavlink-dump/src/main.rs"
required-features = ["ardupilotmega"]

[dependencies]
Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,29 @@ mavlink = "0.12.2"
```

## Examples
See [src/bin/mavlink-dump.rs](src/bin/mavlink-dump.rs) for a usage example.
See [examples/](examples/mavlink-dump/src/main) for different usage examples.

### mavlink-dump
[examples/mavlink-dump](examples/mavlink-dump/src/main) contains an executable example that can be used to test message reception.

It can be executed directly by running:
```
cargo run --example mavlink-dump [options]
```

It's also possible to install the working example via `cargo` command line:
```sh
cargo install mavlink
cargo install --path examples/mavlink-dump
```

It can then be executed by running:
```
mavlink-dump [options]
```

Execution call example:
```sh
mavlink-dump udpin:127.0.0.1:14540
```

### Community projects
Expand Down
15 changes: 15 additions & 0 deletions examples/mavlink-dump/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "mavlink-dump"
authors = [
"Patrick José Pereira <[email protected]>",
]
license = "MIT/Apache-2.0"
edition = "2018"
version = "0.1.0"

[profile.release]
opt-level = 3
lto = true # Performs "fat" LTO which attempts to perform optimizations across all crates within the dependency graph

[dependencies.mavlink] # MAVLink library
path = "../../"
8 changes: 0 additions & 8 deletions src/bin/mavlink-dump.rs → examples/mavlink-dump/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use mavlink::error::MessageReadError;
#[cfg(feature = "std")]
use std::{env, sync::Arc, thread, time::Duration};

#[cfg(not(feature = "std"))]
fn main() {}

#[cfg(feature = "std")]
fn main() {
let args: Vec<_> = env::args().collect();

Expand Down Expand Up @@ -65,7 +60,6 @@ fn main() {
}

/// Create a heartbeat message using 'ardupilotmega' dialect
#[cfg(feature = "std")]
pub fn heartbeat_message() -> mavlink::ardupilotmega::MavMessage {
mavlink::ardupilotmega::MavMessage::HEARTBEAT(mavlink::ardupilotmega::HEARTBEAT_DATA {
custom_mode: 0,
Expand All @@ -78,7 +72,6 @@ pub fn heartbeat_message() -> mavlink::ardupilotmega::MavMessage {
}

/// Create a message requesting the parameters list
#[cfg(feature = "std")]
pub fn request_parameters() -> mavlink::ardupilotmega::MavMessage {
mavlink::ardupilotmega::MavMessage::PARAM_REQUEST_LIST(
mavlink::ardupilotmega::PARAM_REQUEST_LIST_DATA {
Expand All @@ -89,7 +82,6 @@ pub fn request_parameters() -> mavlink::ardupilotmega::MavMessage {
}

/// Create a message enabling data streaming
#[cfg(feature = "std")]
pub fn request_stream() -> mavlink::ardupilotmega::MavMessage {
mavlink::ardupilotmega::MavMessage::REQUEST_DATA_STREAM(
mavlink::ardupilotmega::REQUEST_DATA_STREAM_DATA {
Expand Down
Loading