pub struct Endpoint<V: MaybeVersioned> { /* private fields */ }
Expand description
MAVLink device with defined ID
and internal frame sequence counter.
§Examples
use mavio::dialects::minimal::messages::Heartbeat;
use mavio::prelude::*;
// Create a `MAVLink2` device with system and component ids
let device = Endpoint::v2(MavLinkId::new(17, 42));
device.advance(3).discard();
// Build a new frame from the provided message
let frame = device.next_frame(&Heartbeat::default()).unwrap();
assert_eq!(frame.sequence(), 3, "should be correct sequence number");
assert_eq!(frame.system_id(), 17, "should be the defined system `ID`");
assert_eq!(frame.component_id(), 42, "should be the defined component `ID`");
Implementations§
source§impl Endpoint<Versionless>
impl Endpoint<Versionless>
sourcepub fn new<V: MaybeVersioned>(id: MavLinkId) -> Endpoint<V>
pub fn new<V: MaybeVersioned>(id: MavLinkId) -> Endpoint<V>
Creates a new device with specified MavLinkId
.
sourcepub fn versionless(id: MavLinkId) -> Endpoint<Versionless>
pub fn versionless(id: MavLinkId) -> Endpoint<Versionless>
Creates a device without a specified MAVLink protocol version.
sourcepub fn next_frame<V: Versioned>(
&self,
message: &dyn Message
) -> Result<Frame<Versionless>>
pub fn next_frame<V: Versioned>( &self, message: &dyn Message ) -> Result<Frame<Versionless>>
Produces a next versionless frame from MAVLink message.
The actual protocol version still has to be specified as a generic parameter using turbofish syntax.
source§impl<V: MaybeVersioned> Endpoint<V>
impl<V: MaybeVersioned> Endpoint<V>
sourcepub fn component_id(&self) -> ComponentId
pub fn component_id(&self) -> ComponentId
MAVLink component ID
.
sourcepub fn next_sequence(&self) -> Sequence
pub fn next_sequence(&self) -> Sequence
Next MAVLink frame sequence.
sourcepub fn advance(&self, increment: Sequence) -> Behold<Sequence>
pub fn advance(&self, increment: Sequence) -> Behold<Sequence>
Skips increment
items in sequence and return the updated current value.
The return value is wrapped in Behold
since it is not guaranteed in multithreaded
environments, that the Endpoint::next_frame
will use the same value of a sequence in
this thread.
sourcepub fn fork(&self) -> Self
pub fn fork(&self) -> Self
Forks existing endpoint.
Forking is similar to cloning, except the internal frame Sequencer
will be forked to
start from the next value. This method is available for all targets, while cloning is
possible only for alloc
targets.
See Sequencer::fork
for details.
sourcepub fn sync<Version: MaybeVersioned>(&self, other: &Endpoint<Version>)
pub fn sync<Version: MaybeVersioned>(&self, other: &Endpoint<Version>)
Synchronizes this endpoint with another one.
Synchronizes internal sequencer with the sequencer of the other
Endpoint
.
See Sequencer::sync
for details.
sourcepub fn join<Version: MaybeVersioned>(&self, other: &mut Endpoint<Version>)
pub fn join<Version: MaybeVersioned>(&self, other: &mut Endpoint<Version>)
alloc
Joins another endpoint with current one.
From this moment internal sequencers will share the same counter. The current sequencer will be synced with the one it joins.
Available only when alloc
feature is enabled.
See Sequencer::join
for details.