uavcan.protocol.SoftwareVersion.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_PROTOCOL_SOFTWAREVERSION_MAX_SIZE 15
  6. #define UAVCAN_PROTOCOL_SOFTWAREVERSION_SIGNATURE (0xDD46FD376527FEA1ULL)
  7. #define UAVCAN_PROTOCOL_SOFTWAREVERSION_OPTIONAL_FIELD_FLAG_VCS_COMMIT 1
  8. #define UAVCAN_PROTOCOL_SOFTWAREVERSION_OPTIONAL_FIELD_FLAG_IMAGE_CRC 2
  9. struct uavcan_protocol_SoftwareVersion {
  10. uint8_t major;
  11. uint8_t minor;
  12. uint8_t optional_field_flags;
  13. uint32_t vcs_commit;
  14. uint64_t image_crc;
  15. };
  16. #ifdef __cplusplus
  17. extern "C"
  18. {
  19. #endif
  20. uint32_t _uavcan_protocol_SoftwareVersion_encode(struct uavcan_protocol_SoftwareVersion* msg, uint8_t* buffer
  21. #if CANARD_ENABLE_TAO_OPTION
  22. , bool tao
  23. #endif
  24. );
  25. bool _uavcan_protocol_SoftwareVersion_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_SoftwareVersion* msg);
  26. static inline uint32_t uavcan_protocol_SoftwareVersion_encode(struct uavcan_protocol_SoftwareVersion* msg, uint8_t* buffer
  27. #if CANARD_ENABLE_TAO_OPTION
  28. , bool tao
  29. #endif
  30. ) {
  31. return _uavcan_protocol_SoftwareVersion_encode(msg, buffer
  32. #if CANARD_ENABLE_TAO_OPTION
  33. , tao
  34. #endif
  35. );
  36. }
  37. static inline bool uavcan_protocol_SoftwareVersion_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_SoftwareVersion* msg) {
  38. return _uavcan_protocol_SoftwareVersion_decode(transfer, msg);
  39. }
  40. #if defined(CANARD_DSDLC_INTERNAL)
  41. static inline void __uavcan_protocol_SoftwareVersion_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_SoftwareVersion* msg, bool tao);
  42. static inline bool __uavcan_protocol_SoftwareVersion_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_SoftwareVersion* msg, bool tao);
  43. void __uavcan_protocol_SoftwareVersion_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_SoftwareVersion* msg, bool tao) {
  44. (void)buffer;
  45. (void)bit_ofs;
  46. (void)msg;
  47. (void)tao;
  48. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->major);
  49. *bit_ofs += 8;
  50. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->minor);
  51. *bit_ofs += 8;
  52. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->optional_field_flags);
  53. *bit_ofs += 8;
  54. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->vcs_commit);
  55. *bit_ofs += 32;
  56. canardEncodeScalar(buffer, *bit_ofs, 64, &msg->image_crc);
  57. *bit_ofs += 64;
  58. }
  59. /*
  60. decode uavcan_protocol_SoftwareVersion, return true on failure, false on success
  61. */
  62. bool __uavcan_protocol_SoftwareVersion_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_SoftwareVersion* msg, bool tao) {
  63. (void)transfer;
  64. (void)bit_ofs;
  65. (void)msg;
  66. (void)tao;
  67. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->major);
  68. *bit_ofs += 8;
  69. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->minor);
  70. *bit_ofs += 8;
  71. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->optional_field_flags);
  72. *bit_ofs += 8;
  73. canardDecodeScalar(transfer, *bit_ofs, 32, false, &msg->vcs_commit);
  74. *bit_ofs += 32;
  75. canardDecodeScalar(transfer, *bit_ofs, 64, false, &msg->image_crc);
  76. *bit_ofs += 64;
  77. return false; /* success */
  78. }
  79. #endif
  80. #ifdef CANARD_DSDLC_TEST_BUILD
  81. struct uavcan_protocol_SoftwareVersion sample_uavcan_protocol_SoftwareVersion_msg(void);
  82. #endif
  83. #ifdef __cplusplus
  84. } // extern "C"
  85. #ifdef DRONECAN_CXX_WRAPPERS
  86. #include <canard/cxx_wrappers.h>
  87. #endif
  88. #endif