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.

57 lines
1.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. //
  2. // Created by zwsd
  3. //
  4. #pragma once
  5. #include "sdk/os/zos.hpp"
  6. #include "sdk\components\zprotocols\zcancmder_v2\api\api.hpp"
  7. namespace iflytop {
  8. namespace zcr {
  9. typedef enum {
  10. kpacketHeader = 0,
  11. kpacketData = 1,
  12. kpacketTail = 2,
  13. } packet_type_t;
  14. typedef struct {
  15. CAN_RxHeaderTypeDef pHeader;
  16. uint8_t aData[8]; /*8byte table*/
  17. } CANPacket;
  18. }; // namespace zcr
  19. using namespace zcr;
  20. class CanPacketRxBuffer {
  21. public:
  22. uint16_t id = 0;
  23. CANPacket m_canPacket[125] = {0}; // ���ڽ���can��Ϣ
  24. uint8_t m_canPacketNum = 0;
  25. uint8_t m_npacket = 0;
  26. uint8_t rxdata[1000] = {0};
  27. int rxdataSize = 0;
  28. bool dataIsReady = false;
  29. bool isOnReceive = false;
  30. bool isUsed = false;
  31. bool lostpacket = false;
  32. public:
  33. uint16_t get_packetindex();
  34. uint16_t get_cmdid();
  35. uint8_t get_subcmdid();
  36. uint8_t get_packetType();
  37. uint8_t *get_data();
  38. uint16_t get_datalen();
  39. void clear();
  40. zcr_cmd_header_t *get_cmdheader();
  41. bool iscmd(int32_t id);
  42. template <typename T>
  43. T *get_data_as() {
  44. return (T *)get_data();
  45. }
  46. };
  47. } // namespace iflytop