can_bus.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include "../common/comm.h"
  3. #include "../common/notifier.h"
  4. #include "../common/iobuffer.h"
  5. #include "../common/sensor_socket.h"
  6. class CMessageQueue;
  7. class CCanBusSensor
  8. {
  9. public:
  10. CCanBusSensor(CMessageQueue *q);
  11. void Notify(struct can_frame *date);
  12. void SetCanBusSensor(SensorCanBus<CCanBusSensor>* can);
  13. void Start();
  14. void Stop();
  15. void OnMessage(cannet_frame* frames, int32_t count = 4);
  16. void Emergency();
  17. private:
  18. void Run();
  19. void CanSendProc();
  20. void SendStatusToMSG();
  21. private:
  22. CMessageQueue* _message;
  23. SensorCanBus<CCanBusSensor> * _canbus;
  24. bool _run;
  25. std::thread _can_thread;
  26. std::mutex _last_can_lock;
  27. // struct can_frame Sendframe[4];
  28. struct can_frame Sendframe[5];
  29. bool _front_view = true;
  30. int16_t Direction;//方向
  31. int16_t Hand_Throttle;//手油门
  32. int16_t Foot_Throttle;//脚油门
  33. int16_t Brake;//刹车
  34. int64_t count;
  35. FeedData _data;
  36. int model;//0本地,1远程
  37. vehicle_control_cv control_can;
  38. };