vkweigher.WeigherStatus.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define VKWEIGHER_WEIGHERSTATUS_MAX_SIZE 35
  6. #define VKWEIGHER_WEIGHERSTATUS_SIGNATURE (0x5B77380AAF093557ULL)
  7. #define VKWEIGHER_WEIGHERSTATUS_ID 52000
  8. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  9. class vkweigher_WeigherStatus_cxx_iface;
  10. #endif
  11. struct vkweigher_WeigherStatus {
  12. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  13. using cxx_iface = vkweigher_WeigherStatus_cxx_iface;
  14. #endif
  15. uint32_t weight;
  16. uint16_t rate;
  17. uint8_t status;
  18. int16_t gx;
  19. int16_t gy;
  20. int16_t gz;
  21. int16_t ax;
  22. int16_t ay;
  23. int16_t az;
  24. float Q[4];
  25. };
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30. uint32_t vkweigher_WeigherStatus_encode(struct vkweigher_WeigherStatus* msg, uint8_t* buffer
  31. #if CANARD_ENABLE_TAO_OPTION
  32. , bool tao
  33. #endif
  34. );
  35. bool vkweigher_WeigherStatus_decode(const CanardRxTransfer* transfer, struct vkweigher_WeigherStatus* msg);
  36. #if defined(CANARD_DSDLC_INTERNAL)
  37. static inline void _vkweigher_WeigherStatus_encode(uint8_t* buffer, uint32_t* bit_ofs, struct vkweigher_WeigherStatus* msg, bool tao);
  38. static inline bool _vkweigher_WeigherStatus_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct vkweigher_WeigherStatus* msg, bool tao);
  39. void _vkweigher_WeigherStatus_encode(uint8_t* buffer, uint32_t* bit_ofs, struct vkweigher_WeigherStatus* msg, bool tao) {
  40. (void)buffer;
  41. (void)bit_ofs;
  42. (void)msg;
  43. (void)tao;
  44. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->weight);
  45. *bit_ofs += 32;
  46. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->rate);
  47. *bit_ofs += 16;
  48. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->status);
  49. *bit_ofs += 8;
  50. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->gx);
  51. *bit_ofs += 16;
  52. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->gy);
  53. *bit_ofs += 16;
  54. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->gz);
  55. *bit_ofs += 16;
  56. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->ax);
  57. *bit_ofs += 16;
  58. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->ay);
  59. *bit_ofs += 16;
  60. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->az);
  61. *bit_ofs += 16;
  62. for (size_t i=0; i < 4; i++) {
  63. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->Q[i]);
  64. *bit_ofs += 32;
  65. }
  66. }
  67. /*
  68. decode vkweigher_WeigherStatus, return true on failure, false on success
  69. */
  70. bool _vkweigher_WeigherStatus_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct vkweigher_WeigherStatus* msg, bool tao) {
  71. (void)transfer;
  72. (void)bit_ofs;
  73. (void)msg;
  74. (void)tao;
  75. canardDecodeScalar(transfer, *bit_ofs, 32, false, &msg->weight);
  76. *bit_ofs += 32;
  77. canardDecodeScalar(transfer, *bit_ofs, 16, false, &msg->rate);
  78. *bit_ofs += 16;
  79. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->status);
  80. *bit_ofs += 8;
  81. canardDecodeScalar(transfer, *bit_ofs, 16, true, &msg->gx);
  82. *bit_ofs += 16;
  83. canardDecodeScalar(transfer, *bit_ofs, 16, true, &msg->gy);
  84. *bit_ofs += 16;
  85. canardDecodeScalar(transfer, *bit_ofs, 16, true, &msg->gz);
  86. *bit_ofs += 16;
  87. canardDecodeScalar(transfer, *bit_ofs, 16, true, &msg->ax);
  88. *bit_ofs += 16;
  89. canardDecodeScalar(transfer, *bit_ofs, 16, true, &msg->ay);
  90. *bit_ofs += 16;
  91. canardDecodeScalar(transfer, *bit_ofs, 16, true, &msg->az);
  92. *bit_ofs += 16;
  93. for (size_t i=0; i < 4; i++) {
  94. canardDecodeScalar(transfer, *bit_ofs, 32, true, &msg->Q[i]);
  95. *bit_ofs += 32;
  96. }
  97. return false; /* success */
  98. }
  99. #endif
  100. #ifdef CANARD_DSDLC_TEST_BUILD
  101. struct vkweigher_WeigherStatus sample_vkweigher_WeigherStatus_msg(void);
  102. #endif
  103. #ifdef __cplusplus
  104. } // extern "C"
  105. #ifdef DRONECAN_CXX_WRAPPERS
  106. #include <canard/cxx_wrappers.h>
  107. BROADCAST_MESSAGE_CXX_IFACE(vkweigher_WeigherStatus, VKWEIGHER_WEIGHERSTATUS_ID, VKWEIGHER_WEIGHERSTATUS_SIGNATURE, VKWEIGHER_WEIGHERSTATUS_MAX_SIZE);
  108. #endif
  109. #endif