48 lines
3 KiB
Markdown
48 lines
3 KiB
Markdown
# Provenance of flowrs-connect's MAVLink bridge
|
||
|
||
Everything in `src/mavlink/` is written for flowRS (Apache-2.0) except the parts below.
|
||
|
||
## Ports
|
||
|
||
| flowRS file | Ported from | Licence |
|
||
|---|---|---|
|
||
| `src/mavlink/px4.rs` | `joulesperbit/crates/mgai-firmware-sentinel/src/mavlink_bridge.rs` (the owner's workspace, last committed 2026-07-17): `Px4Mode` and its `custom_mode` constants, the "position + yaw" and "velocity + yaw rate" `SET_POSITION_TARGET_LOCAL_NED` type masks | Apache-2.0 OR MIT (the joulesperbit workspace licence) |
|
||
|
||
Two errors in the harvested code were corrected, not carried over:
|
||
|
||
* `custom_mode` layout. PX4's `px4_custom_mode.h` (BSD-3-Clause, PX4 Development Team) packs
|
||
`{uint16 reserved; uint8 main_mode; uint8 sub_mode}` little-endian, so the sub mode is bits
|
||
24–31. The harvested constants put it in the low 16 bits (`AUTO|MISSION = 0x0004_0003`,
|
||
which is also LOITER's number) and decoded it from there; AUTO.MISSION is `0x0404_0000`.
|
||
* Type masks. `0x0FF8` ("position + yaw only") also set `YAW_IGNORE` and `FORCE_SET`; `0x0C07`
|
||
("velocity + yaw rate only") ignored the yaw rate and left the accelerations live. The
|
||
masks are now built from `POSITION_TARGET_TYPEMASK`'s entry names in the MIT XML
|
||
(`0x09F8` and `0x05C7`), and a test says what each ignores.
|
||
|
||
The rest of the harvested bridge (its `MavConnection` loop on `mavlink` 0.17, the telemetry
|
||
struct) was not ported: the bridge here owns its socket so that frames failing the checksum
|
||
are seen (`frame.rs`), and reads every field's meaning from the XML.
|
||
|
||
## Written from specifications, not ported
|
||
|
||
| flowRS file | From |
|
||
|---|---|
|
||
| `src/mavlink/frame.rs` | the MAVLink serialization guide (mavlink.io, "Packet Serialization"); the X.25 CRC is `flowrs_iface::mavlink::crc` |
|
||
| `src/mavlink/sign.rs` | the MAVLink message signing guide (mavlink.io, "Message Signing") |
|
||
| `src/mavlink/wire.rs` | the serialization guide's wire order and MAVLink 2 payload truncation |
|
||
| `src/mavlink/peer.rs` | ArduCopter's documented MAVLink behaviour (`GCS_Signing.cpp`, `GCS_MAVLink_Copter.cpp`, read for behaviour only: GPL-3.0 code, none copied) |
|
||
|
||
## Data
|
||
|
||
`dialects/mavlink/` holds nine MAVLink XML files, unchanged, MIT, from
|
||
`mavlink/mavlink@44a1229ece43cfc3ce1640451ad5aaba52a28459`, compared byte for byte with the
|
||
copy inside the `mavlink` crate 0.21.0; see its `README.md`, `MANIFEST.tsv` and `LICENSE`.
|
||
mavgen and pymavlink (LGPLv3) are neither vendored nor linked.
|
||
|
||
## Dependencies added for the bridge (feature `mavlink`)
|
||
|
||
| Crate | Licence | Why |
|
||
|---|---|---|
|
||
| `mavlink` 0.21.0, `mavlink-core` 0.21.0, `mavlink-bindgen` 0.21.0 (build), with `crc-any` 2.5, `quick-xml` 0.41 (build), `serde_arrays` 0.2 | MIT OR Apache-2.0 (`MIT/Apache-2.0`); quick-xml MIT; crc-any MIT; serde_arrays MIT OR Apache-2.0 | frames decoded, encoded and signed |
|
||
| `sha2` 0.11 (already in the lock) | MIT OR Apache-2.0 | the twin's signing check, command hashes |
|
||
| `flowrs-instruments` (workspace) | Apache-2.0 | approvals from the envelope's proposals |
|