pamoja_mavlink/drivers/mod.rs
1//! Real [`ByteLink`](crate::link::ByteLink) drivers over serial ports, UDP, and TCP.
2//!
3//! The wire core and the [`Vehicle`](crate::vehicle::Vehicle) are written against the
4//! [`ByteLink`](crate::link::ByteLink) seam, so a real autopilot is reached by plugging one of
5//! these drivers into it: a serial line to a flight controller, or a UDP or TCP socket to a
6//! SITL simulator or a ground-station bridge. PX4 SITL exposes MAVLink over UDP; ArduPilot SITL
7//! exposes it over TCP (port 5760) and can also be told to send UDP; a companion computer wired
8//! to a Pixhawk speaks it over serial.
9//!
10//! These drivers are available with the default `std` feature and run on the tokio runtime; the
11//! serial driver additionally needs the `serial` feature, which pulls in a serial-port backend.
12
13mod tcp;
14mod udp;
15
16pub use tcp::TcpLink;
17pub use udp::UdpLink;
18
19#[cfg(feature = "serial")]
20mod serial;
21
22#[cfg(feature = "serial")]
23pub use serial::SerialLink;
24
25// Maps a link IO error onto the wire layer's error model. A read or write that fails ends the
26// link, which the connection treats the same as a clean end of input.
27#[inline]
28fn link_fault(_err: std::io::Error) -> crate::MavlinkError {
29 crate::MavlinkError::Closed
30}