Skip to content

MAVLink2 payloads have trailing zeros #80

@clydemcqueen

Description

@clydemcqueen

The MAVLink2 spec requires senders to implement payload truncation: https://mavlink.io/en/guide/serialization.html#payload_truncation

For example, calling the API:

curl --verbose http://127.0.0.1:6040/mavlink -H "accept: application/json" --data \
'{
    "header": {
        "system_id": 1,
        "component_id": 194,
        "sequence": 52
    },
    "message": {
        "type": "DISTANCE_SENSOR",
        "time_boot_ms": 201509,
        "min_distance": 20,
        "max_distance": 5000,
        "current_distance": 2325,
        "mavtype": {"type": "MAV_DISTANCE_SENSOR_ULTRASOUND"},
        "id": 1,
        "orientation": {"type": "MAV_SENSOR_ROTATION_PITCH_270"},
        "covariance": 255,
        "horizontal_fov": 0.52,
        "vertical_fov": 0.52,
        "quaternion": [0, 0, 0, 0],
        "signal_quality": 0
    }
}'

causes this MAVLink message to be sent via UPD:

0000   fd 27 00 00 3b 01 c2 84 00 00 25 13 03 00 14 00
0010   88 13 15 09 01 01 19 ff b8 1e 05 3f b8 1e 05 3f
0020   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0030   00 f8 1a

The last 2 bytes are the CRC, the preceding 17 bytes (quaternion and signal_quality fields) should have been truncated before the CRC was calculated.

This may be the root cause of this bug: bluerobotics/BlueOS#1740

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions