首页 > 其他 > 详细

GCS流程

时间:2021-07-13 12:00:42      阅读:16      评论:0      收藏:0      [点我收藏+]

两个任务

1 SCHED_TASK_CLASS(GCS,                  (GCS*)&copter._gcs,          update_receive, 400, 180),
2 SCHED_TASK_CLASS(GCS,                  (GCS*)&copter._gcs,          update_send,    400, 550),

Update_receive

void GCS::update_receive(void)
{
    for (uint8_t i=0; i<num_gcs(); i++) 
	{
        chan(i)->update_receive();
    }
    // also update UART pass-thru, if enabled
    //如果使能,也更新UART透传
    update_passthru();
}

 GCS_MAVLINK::update_receive

void GCS_MAVLINK::update_receive(uint32_t max_time_us)
{
  if (mavlink_parse_char(chan, c, &msg, &status))
    {
    packetReceived(status, msg);
   }
}

 Message

技术分享图片

typedef struct __mavlink_message 
{
	uint16_t checksum; /// sent at end of packet
	uint8_t magic;   ///< protocol magic marker
	uint8_t len;     ///< Length of payload
	uint8_t seq;     ///< Sequence of packet
	uint8_t sysid;   ///< ID of message sender system/aircraft
	uint8_t compid;  ///< ID of the message sender component
	uint8_t msgid;   ///< ID of message in payload
	uint64_t payload64[(MAVLINK_MAX_PAYLOAD_LEN+MAVLINK_NUM_CHECKSUM_BYTES+7)/8];
} mavlink_message_t;

 Status

typedef struct __mavlink_status 
{
    uint8_t msg_received;               ///< Number of received messages 接受的消息数量
    uint8_t buffer_overrun;             ///< Number of buffer overruns缓冲区溢出次数
    uint8_t parse_error;                ///< Number of parse errors 解析错误次数
    mavlink_parse_state_t parse_state;  ///< Parsing state machine 解析状态机
    uint8_t packet_idx;                 ///< Index in current packet  当前包的index
    uint8_t current_rx_seq;             ///< Sequence number of last packet received 最后接受包的序列号
    uint8_t current_tx_seq;             ///< Sequence number of last packet sent  最后发送包的序列号
    uint16_t packet_rx_success_count;   ///< Received packets 接受的包
    uint16_t packet_rx_drop_count;      ///< Number of packet drops 丢弃的包
} mavlink_status_t;

 Parser_state

typedef enum 
{
    MAVLINK_PARSE_STATE_UNINIT=0,
    MAVLINK_PARSE_STATE_IDLE,
    MAVLINK_PARSE_STATE_GOT_STX,
    MAVLINK_PARSE_STATE_GOT_SEQ,
    MAVLINK_PARSE_STATE_GOT_LENGTH,
    MAVLINK_PARSE_STATE_GOT_SYSID,
    MAVLINK_PARSE_STATE_GOT_COMPID,
    MAVLINK_PARSE_STATE_GOT_MSGID,
    MAVLINK_PARSE_STATE_GOT_PAYLOAD,
    MAVLINK_PARSE_STATE_GOT_CRC1,
    MAVLINK_PARSE_STATE_GOT_BAD_CRC1
} mavlink_parse_state_t; ///< The state machine for the comm parser

 

GCS流程

原文:https://www.cnblogs.com/beepeg/p/15005062.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!