can_bus.h 1.2 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_busframe* frames, int32_t count = 5);
  16. void Emergency();
  17. void NoEmergency();
  18. void GetGearCurrent(uint8_t data);
  19. void SetGear_FR_Current(uint8_t data,uint8_t type);
  20. private:
  21. void Run();
  22. void CanSendProc();
  23. void SendStatusToMSG();
  24. private:
  25. CMessageQueue* _message;
  26. SensorCanBus<CCanBusSensor> * _canbus;
  27. bool _run;
  28. std::thread _can_thread;
  29. std::mutex _last_can_lock;
  30. struct can_frame Sendframe[4];
  31. bool _front_view;
  32. volatile int64_t _last_can_uptime = 0;
  33. bool halfautomatic;
  34. uint8_t Gear_position_now;//实际挡位从J1939获取
  35. uint8_t Gear_direction;//挡位方向,0,N,0x01,F,0x02,R
  36. uint8_t Gear_position_Set;//舱端设置挡位
  37. int64_t count;
  38. //FeedData _data;
  39. };