// // Created by zwsd // #pragma once #include "sdk/os/zos.hpp" #include "sdk\components\zprotocols\zcancmder_v2\api\api.hpp" namespace iflytop { namespace zcr { typedef enum { kpacketHeader = 0, kpacketData = 1, kpacketTail = 2, } packet_type_t; typedef struct { CAN_RxHeaderTypeDef pHeader; uint8_t aData[8]; /*8byte table*/ } CANPacket; }; // namespace zcr using namespace zcr; class CanPacketRxBuffer { public: uint16_t id = 0; CANPacket m_canPacket[125] = {0}; // 用于接收can消息 uint8_t m_canPacketNum = 0; uint8_t m_npacket = 0; uint8_t rxdata[1000] = {0}; int rxdataSize = 0; bool dataIsReady = false; bool isOnReceive = false; bool isUsed = false; bool lostpacket = false; public: uint16_t get_packetindex(); uint16_t get_cmdid(); uint8_t get_cmdSubId(); uint8_t get_packetType(); uint8_t *get_data(); uint16_t get_datalen(); void clear(); zcr_cmd_header_t *get_cmdheader(); bool iscmd(int32_t id); template T *get_data_as() { return (T *)get_data(); } }; } // namespace iflytop