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

1 year ago
5 months ago
1 year ago
5 months ago
1 year ago
5 months ago
1 year ago
  1. //
  2. // Created by zwsd
  3. //
  4. #pragma once
  5. #include "a8000_protocol\protocol.hpp"
  6. #include "sdk/os/zos.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[20] = {0}; // 用于接收can消息
  25. uint8_t m_canPacketNum = 0;
  26. uint8_t m_npacket = 0;
  27. uint8_t rxdata[256] = {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_packetType();
  39. uint8_t *get_params();
  40. uint16_t get_params_len();
  41. void clear();
  42. uint8_t *get_rx_raw();
  43. uint16_t get_rx_raw_len();
  44. zcr_cmd_header_t *get_cmdheader();
  45. bool iscmd(int32_t id);
  46. template <typename T>
  47. T *get_param_as() {
  48. return (T *)get_params();
  49. }
  50. };
  51. } // namespace iflytop