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.3 KiB

2 years ago
1 year 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
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 "a8000_protocol\protocol.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 dlc;
  17. uint8_t aData[8]; /*8byte table*/
  18. } CANPacket;
  19. }; // namespace zcr
  20. using namespace zcr;
  21. class CanPacketRxBuffer {
  22. public:
  23. uint16_t id = 0;
  24. CANPacket m_canPacket[100] = {0}; // ���ڽ���can��Ϣ
  25. uint8_t m_canPacketNum = 0;
  26. uint8_t m_npacket = 0;
  27. uint8_t rxdata[1000] = {0};
  28. int rxdataSize = 0;
  29. bool dataIsReady = false;
  30. bool isOnReceive = false;
  31. bool isUsed = false;
  32. bool lostpacket = false;
  33. bool dataIsProcessed = false;
  34. int32_t lastrxtime = 0;
  35. public:
  36. uint16_t get_packetindex();
  37. uint16_t get_cmdid();
  38. uint8_t get_cmdSubId();
  39. uint8_t get_packetType();
  40. uint8_t *get_params();
  41. uint16_t get_params_len();
  42. void clear();
  43. uint8_t* get_rx_raw();
  44. uint16_t get_rx_raw_len();
  45. zcr_cmd_header_t *get_cmdheader();
  46. bool iscmd(int32_t id);
  47. template <typename T>
  48. T *get_param_as() {
  49. return (T *)get_params();
  50. }
  51. };
  52. } // namespace iflytop