radar_sensor.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #include "../common/notifier.h"
  3. #include <thread>
  4. #pragma pack(1)
  5. struct Radar_Frame//��Ӧ���״�
  6. {
  7. uint8_t Addr=0x01;
  8. uint8_t Func=0x03;
  9. uint8_t RegAddr[2]={0x01,0x06};
  10. uint8_t RegData[2]={0x00,0x04};
  11. //uint8_t RegCRC[2] = { 0xa5,0xf4 };
  12. uint16_t crc;
  13. };
  14. #pragma pack(1)
  15. struct Radar_Frame_CM
  16. {
  17. int8_t DLC;
  18. int32_t Addr;
  19. int8_t RegData[8];
  20. };
  21. #pragma pack(1)
  22. struct Radar_Frame_CM_Revice
  23. {
  24. int8_t DLC_radar1;
  25. int32_t Addr_radar1;
  26. int8_t RegData_radar1[8];
  27. int8_t DLC_radar2;
  28. int32_t Addr_radar2;
  29. int8_t RegData_radar2[8];
  30. };
  31. #pragma pack(1)
  32. struct Radar_Frame_Nl_Revice
  33. {
  34. int8_t DLC_Nl_radar;
  35. int32_t Addr_Nl_radar;
  36. uint8_t RegData_Nl_radar1[8];
  37. };
  38. class CMessageQueue;
  39. class CRadarSensor//:public ISensorNotify
  40. {
  41. public:
  42. CRadarSensor(CMessageQueue *q);
  43. void Notify(int8_t * buffer,int32_t size);
  44. //void SetSensorSocket(SensorSocket<CRadarSensor>* can);
  45. void SetSensorSocket(SensorSocket<CRadarSensor>* can);
  46. void Start();
  47. void Stop();
  48. // void PreProcess();
  49. private:
  50. void Run();
  51. uint16_t bcd2dec(const int8_t *data);
  52. unsigned int CRC16(uint8_t *buf, int len);
  53. void CRC_DYP(uint8_t *buf);
  54. private:
  55. CMessageQueue* _message;
  56. SensorSocket<CRadarSensor> * _socket;
  57. std::thread _thread;
  58. bool _run;
  59. int32_t _count=0;
  60. };