uavcan.equipment.device.Temperature.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_EQUIPMENT_DEVICE_TEMPERATURE_MAX_SIZE 5
  6. #define UAVCAN_EQUIPMENT_DEVICE_TEMPERATURE_SIGNATURE (0x70261C28A94144C6ULL)
  7. #define UAVCAN_EQUIPMENT_DEVICE_TEMPERATURE_ID 1110
  8. #define UAVCAN_EQUIPMENT_DEVICE_TEMPERATURE_ERROR_FLAG_OVERHEATING 1
  9. #define UAVCAN_EQUIPMENT_DEVICE_TEMPERATURE_ERROR_FLAG_OVERCOOLING 2
  10. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  11. class uavcan_equipment_device_Temperature_cxx_iface;
  12. #endif
  13. struct uavcan_equipment_device_Temperature {
  14. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  15. using cxx_iface = uavcan_equipment_device_Temperature_cxx_iface;
  16. #endif
  17. uint16_t device_id;
  18. float temperature;
  19. uint8_t error_flags;
  20. };
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. uint32_t _uavcan_equipment_device_Temperature_encode(struct uavcan_equipment_device_Temperature* msg, uint8_t* buffer
  26. #if CANARD_ENABLE_TAO_OPTION
  27. , bool tao
  28. #endif
  29. );
  30. bool _uavcan_equipment_device_Temperature_decode(const CanardRxTransfer* transfer, struct uavcan_equipment_device_Temperature* msg);
  31. static inline uint32_t uavcan_equipment_device_Temperature_encode(struct uavcan_equipment_device_Temperature* msg, uint8_t* buffer
  32. #if CANARD_ENABLE_TAO_OPTION
  33. , bool tao
  34. #endif
  35. ) {
  36. return _uavcan_equipment_device_Temperature_encode(msg, buffer
  37. #if CANARD_ENABLE_TAO_OPTION
  38. , tao
  39. #endif
  40. );
  41. }
  42. static inline bool uavcan_equipment_device_Temperature_decode(const CanardRxTransfer* transfer, struct uavcan_equipment_device_Temperature* msg) {
  43. return _uavcan_equipment_device_Temperature_decode(transfer, msg);
  44. }
  45. #if defined(CANARD_DSDLC_INTERNAL)
  46. static inline void __uavcan_equipment_device_Temperature_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_equipment_device_Temperature* msg, bool tao);
  47. static inline bool __uavcan_equipment_device_Temperature_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_equipment_device_Temperature* msg, bool tao);
  48. void __uavcan_equipment_device_Temperature_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_equipment_device_Temperature* msg, bool tao) {
  49. (void)buffer;
  50. (void)bit_ofs;
  51. (void)msg;
  52. (void)tao;
  53. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->device_id);
  54. *bit_ofs += 16;
  55. {
  56. uint16_t float16_val = canardConvertNativeFloatToFloat16(msg->temperature);
  57. canardEncodeScalar(buffer, *bit_ofs, 16, &float16_val);
  58. }
  59. *bit_ofs += 16;
  60. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->error_flags);
  61. *bit_ofs += 8;
  62. }
  63. /*
  64. decode uavcan_equipment_device_Temperature, return true on failure, false on success
  65. */
  66. bool __uavcan_equipment_device_Temperature_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_equipment_device_Temperature* msg, bool tao) {
  67. (void)transfer;
  68. (void)bit_ofs;
  69. (void)msg;
  70. (void)tao;
  71. canardDecodeScalar(transfer, *bit_ofs, 16, false, &msg->device_id);
  72. *bit_ofs += 16;
  73. {
  74. uint16_t float16_val;
  75. canardDecodeScalar(transfer, *bit_ofs, 16, true, &float16_val);
  76. msg->temperature = canardConvertFloat16ToNativeFloat(float16_val);
  77. }
  78. *bit_ofs += 16;
  79. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->error_flags);
  80. *bit_ofs += 8;
  81. return false; /* success */
  82. }
  83. #endif
  84. #ifdef CANARD_DSDLC_TEST_BUILD
  85. struct uavcan_equipment_device_Temperature sample_uavcan_equipment_device_Temperature_msg(void);
  86. #endif
  87. #ifdef __cplusplus
  88. } // extern "C"
  89. #ifdef DRONECAN_CXX_WRAPPERS
  90. #include <canard/cxx_wrappers.h>
  91. BROADCAST_MESSAGE_CXX_IFACE(uavcan_equipment_device_Temperature, UAVCAN_EQUIPMENT_DEVICE_TEMPERATURE_ID, UAVCAN_EQUIPMENT_DEVICE_TEMPERATURE_SIGNATURE, UAVCAN_EQUIPMENT_DEVICE_TEMPERATURE_MAX_SIZE);
  92. #endif
  93. #endif