Path: blob/master/libraries/AP_Frsky_Telem/AP_Frsky_MAVlite_SPortToMAVlite.h
9879 views
#pragma once12#include "AP_Frsky_MAVlite_Message.h"3#include "AP_Frsky_SPort.h"45#include <stdint.h>67#if HAL_WITH_FRSKY_TELEM_BIDIRECTIONAL8/*9* An instance of this class decodes a stream of SPort packets into a10* MAVlite message (see AP_Frsky_MAVlite_Message.h). It is expected11* that the same rxmsg is passed into process() multiple times, each12* time with a new sport packet. If a packet is successfully decodes13* then process() will return true and rxmsg can be used as a MAVlite14* message.15*16* See AP_Frsky_MAVlite.h for a description of the encoding of a17* MAVlite message in SPort packets.18*/19class AP_Frsky_MAVlite_SPortToMAVlite {20public:2122bool process(AP_Frsky_MAVlite_Message &rxmsg,23const AP_Frsky_SPort::sport_packet_t &packet) WARN_IF_UNUSED;2425private:2627void reset();2829uint8_t expected_seq;30uint8_t payload_next_byte;3132enum class State : uint8_t {33IDLE=0,34ERROR,35WANT_LEN,36WANT_MSGID,37WANT_PAYLOAD,38WANT_CHECKSUM,39MESSAGE_RECEIVED,40};41State parse_state = State::IDLE;4243AP_Frsky_MAVlite_Message _rxmsg;44void parse(const uint8_t byte);4546int16_t checksum; // sent at end of packet47void update_checksum(const uint8_t c);48};49#endif5051