You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.2 KiB
63 lines
1.2 KiB
//
|
|
// Created by zwsd
|
|
//
|
|
|
|
#pragma once
|
|
#include "a8000_protocol\protocol.hpp"
|
|
#include "sdk/os/zos.hpp"
|
|
|
|
namespace iflytop {
|
|
namespace zcr {
|
|
typedef enum {
|
|
kpacketHeader = 0,
|
|
kpacketData = 1,
|
|
kpacketTail = 2,
|
|
} packet_type_t;
|
|
|
|
typedef struct {
|
|
// CAN_RxHeaderTypeDef pHeader;
|
|
uint8_t dlc;
|
|
uint8_t aData[8]; /*8byte table*/
|
|
} CANPacket;
|
|
|
|
}; // namespace zcr
|
|
using namespace zcr;
|
|
|
|
class CanPacketRxBuffer {
|
|
public:
|
|
uint16_t id = 0;
|
|
CANPacket m_canPacket[20] = {0}; // 用于接收can消息
|
|
uint8_t m_canPacketNum = 0;
|
|
uint8_t m_npacket = 0;
|
|
uint8_t rxdata[256] = {0};
|
|
int rxdataSize = 0;
|
|
|
|
bool dataIsReady = false;
|
|
bool isOnReceive = false;
|
|
bool isUsed = false;
|
|
bool lostpacket = false;
|
|
bool dataIsProcessed = false;
|
|
int32_t lastrxtime = 0;
|
|
|
|
public:
|
|
uint16_t get_packetindex();
|
|
uint16_t get_cmdid();
|
|
uint8_t get_packetType();
|
|
uint8_t *get_params();
|
|
uint16_t get_params_len();
|
|
void clear();
|
|
|
|
uint8_t *get_rx_raw();
|
|
uint16_t get_rx_raw_len();
|
|
|
|
zcr_cmd_header_t *get_cmdheader();
|
|
|
|
bool iscmd(int32_t id);
|
|
|
|
template <typename T>
|
|
T *get_param_as() {
|
|
return (T *)get_params();
|
|
}
|
|
};
|
|
|
|
} // namespace iflytop
|