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.
 
 

61 lines
1.2 KiB

//
// 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 dlc;
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;
bool dataIsProcessed = false;
int32_t lastrxtime = 0;
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 <typename T>
T *get_data_as() {
return (T *)get_data();
}
};
} // namespace iflytop