2020-09-10 09:55:53 -03:00
# pragma once
2020-11-18 13:16:15 -04:00
# include "AP_Frsky_Backend.h"
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
/*
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
Wire Protocol :
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
Several SPort packets make up a MAVlite message .
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
A maximum of six relevant data bytes are present in an SPort packet .
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
Each SPort packet starts with a sequence number , starting with zero .
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
If the sequence number is zero then the parser is reset .
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
The first sport packet contains len at offset 1. It is the
* payload * length - does not include checksum , for example . msgid is
at offset 2 , then payload bytes .
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
Subsequent SPort packets contain a sequence number at offset zero ,
followed by more payload bytes .
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
When sufficient payload bytes have been received ( based on " len " ) , a
single checksum byte arrives . Sometimes this checksum byte goes
into an SPort packet all on its own , sharing space only with the
sequence number .
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
*/
2020-09-10 09:55:53 -03:00
2020-09-24 02:33:06 -03:00
# define MAVLITE_MAX_PAYLOAD_LEN 31 // 7 float params + cmd_id + options
# define MAVLITE_MSG_SPORT_PACKETS_COUNT(LEN) static_cast<uint8_t>(1 + ceilf((LEN-2) / 5.0f)) // number of sport packets required to transport a message with LEN payload
# define SPORT_PACKET_QUEUE_LENGTH static_cast<uint8_t>(30U*MAVLITE_MSG_SPORT_PACKETS_COUNT(MAVLITE_MAX_PAYLOAD_LEN))