添加协议解析处理
This commit is contained in:
69
app/drivers/sertrf/protocol/p_protocol.h
Normal file
69
app/drivers/sertrf/protocol/p_protocol.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef PROJECT_H
|
||||
#define PROJECT_H
|
||||
|
||||
#include "../device.h"
|
||||
#include "mavlink_control.h"
|
||||
#include "MSP.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int* uart_fd;
|
||||
sb_data_port_t* data_port;
|
||||
}protocol_port_t;
|
||||
typedef enum
|
||||
{
|
||||
PROTOCOL_IDLE,
|
||||
PROTOCOL_MSP,
|
||||
PROTOCOL_MAVLINK,
|
||||
}protocol_type_m;
|
||||
typedef enum
|
||||
{
|
||||
PORT_LINUX_UART = 0,
|
||||
PORT_LINUX_SBDATA,
|
||||
}port_type_m;
|
||||
typedef struct
|
||||
{
|
||||
protocol_port_t port;
|
||||
protocol_type_m pro_type;
|
||||
port_type_m port_type;
|
||||
|
||||
mavlink_device_t mavlink_device;
|
||||
msp_port_t msp;
|
||||
|
||||
}protocol_t;
|
||||
|
||||
/**
|
||||
* @brief 初始化协议前端
|
||||
*
|
||||
* @param port_type 使用的设备类型(如串口或其他)
|
||||
* @param port 由对应的驱动提供的绑定接口获得的句柄
|
||||
*/
|
||||
void Protocol_init(port_type_m port_type, void* port);
|
||||
/**
|
||||
* @brief 搜索协议
|
||||
*
|
||||
* @retval 协议类型
|
||||
*/
|
||||
int Protocol_search();
|
||||
/**
|
||||
* @brief 使用串口进行数据获取的主运行函数(针对需要使用串口读取)
|
||||
*/
|
||||
void Protocol_loop(void* arg);
|
||||
/**
|
||||
* @brief 搜索协议
|
||||
*
|
||||
* @param data 数据缓存
|
||||
* @param size 数据长度
|
||||
* @retval 协议类型
|
||||
*/
|
||||
int Protocol_buf_search(void* data, uint32_t size);
|
||||
/**
|
||||
* @brief 解析数据 (针对已获取到数据缓存)
|
||||
*
|
||||
* @param data 数据缓存
|
||||
* @param size 数据长度
|
||||
*/
|
||||
void Protocol_buf_decode(void* data, uint32_t size);
|
||||
#endif
|
||||
Reference in New Issue
Block a user