AP_Airspeed_UAVCAN.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "AP_Airspeed_Backend.h"
  3. #include <AP_UAVCAN/AP_UAVCAN.h>
  4. class AirspeedCb;
  5. class AP_Airspeed_UAVCAN : public AP_Airspeed_Backend {
  6. public:
  7. AP_Airspeed_UAVCAN(AP_Airspeed &_frontend, uint8_t _instance);
  8. bool init(void) override;
  9. // return the current differential_pressure in Pascal
  10. bool get_differential_pressure(float &pressure) override;
  11. // temperature not available via analog backend
  12. bool get_temperature(float &temperature) override;
  13. static void subscribe_msgs(AP_UAVCAN* ap_uavcan);
  14. static AP_Airspeed_Backend* probe(AP_Airspeed &_fronted, uint8_t _instance);
  15. private:
  16. static void handle_airspeed(AP_UAVCAN* ap_uavcan, uint8_t node_id, const AirspeedCb &cb);
  17. static AP_Airspeed_UAVCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id);
  18. float _pressure; // Pascal
  19. float _temperature; // Celcius
  20. uint32_t _last_sample_time_ms;
  21. HAL_Semaphore _sem_airspeed;
  22. // Module Detection Registry
  23. static struct DetectedModules {
  24. AP_UAVCAN* ap_uavcan;
  25. uint8_t node_id;
  26. AP_Airspeed_UAVCAN *driver;
  27. } _detected_modules[AIRSPEED_MAX_SENSORS];
  28. static HAL_Semaphore _sem_registry;
  29. };