Module px4::uorb

source ·
Expand description

Bindings to the uORB messaging system.

Message definitions

This crate provides a way to import a message definition from a .msg file:

use px4::px4_message;

#[px4_message("msg/foo.msg")] pub struct foo;

This will read msg/foo.msg, relative to the root of the crate (where your Cargo.toml is), parse its contents, and generate the equivalent Rust struct. In addition, Message, Clone and Debug are derived automatically.

Subscribing

Subscribing is done through the Subscribe trait, which is automatically implemented for all messages.

use px4::uorb::Subscribe;

let sub = foo::subscribe().unwrap();

info!("Latest foo: {:?}", sub.get().unwrap());

Publishing

Publishing is done through the Publish trait, which is automatically implemented for all messages.

use px4::uorb::Publish;

let mut publ = foo::advertise();

publ.publish(&foo { timestamp: 123, a: 4, b: 5 }).unwrap();

Modules

Structs

The meta data of a message.
A publisher of Messages.
A subscription to a Message topic.

Traits

A message which can be published and/or subscribed to.
Use one of the functions below to create a Publisher.
Functions related to subscribing to message topics.