uavcan.protocol.GetNodeInfo_res.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #include <uavcan.protocol.HardwareVersion.h>
  6. #include <uavcan.protocol.NodeStatus.h>
  7. #include <uavcan.protocol.SoftwareVersion.h>
  8. #define UAVCAN_PROTOCOL_GETNODEINFO_RESPONSE_MAX_SIZE 377
  9. #define UAVCAN_PROTOCOL_GETNODEINFO_RESPONSE_SIGNATURE (0xEE468A8121C46A9EULL)
  10. #define UAVCAN_PROTOCOL_GETNODEINFO_RESPONSE_ID 1
  11. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  12. class uavcan_protocol_GetNodeInfo_cxx_iface;
  13. #endif
  14. struct uavcan_protocol_GetNodeInfoResponse {
  15. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  16. using cxx_iface = uavcan_protocol_GetNodeInfo_cxx_iface;
  17. #endif
  18. struct uavcan_protocol_NodeStatus status;
  19. struct uavcan_protocol_SoftwareVersion software_version;
  20. struct uavcan_protocol_HardwareVersion hardware_version;
  21. struct { uint8_t len; uint8_t data[80]; }name;
  22. };
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. uint32_t _uavcan_protocol_GetNodeInfoResponse_encode(struct uavcan_protocol_GetNodeInfoResponse* msg, uint8_t* buffer
  28. #if CANARD_ENABLE_TAO_OPTION
  29. , bool tao
  30. #endif
  31. );
  32. bool _uavcan_protocol_GetNodeInfoResponse_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_GetNodeInfoResponse* msg);
  33. static inline uint32_t uavcan_protocol_GetNodeInfoResponse_encode(struct uavcan_protocol_GetNodeInfoResponse* msg, uint8_t* buffer
  34. #if CANARD_ENABLE_TAO_OPTION
  35. , bool tao
  36. #endif
  37. ) {
  38. return _uavcan_protocol_GetNodeInfoResponse_encode(msg, buffer
  39. #if CANARD_ENABLE_TAO_OPTION
  40. , tao
  41. #endif
  42. );
  43. }
  44. static inline bool uavcan_protocol_GetNodeInfoResponse_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_GetNodeInfoResponse* msg) {
  45. return _uavcan_protocol_GetNodeInfoResponse_decode(transfer, msg);
  46. }
  47. #if defined(CANARD_DSDLC_INTERNAL)
  48. static inline void __uavcan_protocol_GetNodeInfoResponse_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_GetNodeInfoResponse* msg, bool tao);
  49. static inline bool __uavcan_protocol_GetNodeInfoResponse_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_GetNodeInfoResponse* msg, bool tao);
  50. void __uavcan_protocol_GetNodeInfoResponse_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_GetNodeInfoResponse* msg, bool tao) {
  51. (void)buffer;
  52. (void)bit_ofs;
  53. (void)msg;
  54. (void)tao;
  55. __uavcan_protocol_NodeStatus_encode(buffer, bit_ofs, &msg->status, false);
  56. __uavcan_protocol_SoftwareVersion_encode(buffer, bit_ofs, &msg->software_version, false);
  57. __uavcan_protocol_HardwareVersion_encode(buffer, bit_ofs, &msg->hardware_version, false);
  58. #pragma GCC diagnostic push
  59. #pragma GCC diagnostic ignored "-Wtype-limits"
  60. const uint8_t name_len = msg->name.len > 80 ? 80 : msg->name.len;
  61. #pragma GCC diagnostic pop
  62. if (!tao) {
  63. canardEncodeScalar(buffer, *bit_ofs, 7, &name_len);
  64. *bit_ofs += 7;
  65. }
  66. for (size_t i=0; i < name_len; i++) {
  67. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->name.data[i]);
  68. *bit_ofs += 8;
  69. }
  70. }
  71. /*
  72. decode uavcan_protocol_GetNodeInfoResponse, return true on failure, false on success
  73. */
  74. bool __uavcan_protocol_GetNodeInfoResponse_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_GetNodeInfoResponse* msg, bool tao) {
  75. (void)transfer;
  76. (void)bit_ofs;
  77. (void)msg;
  78. (void)tao;
  79. if (__uavcan_protocol_NodeStatus_decode(transfer, bit_ofs, &msg->status, false)) {return true;}
  80. if (__uavcan_protocol_SoftwareVersion_decode(transfer, bit_ofs, &msg->software_version, false)) {return true;}
  81. if (__uavcan_protocol_HardwareVersion_decode(transfer, bit_ofs, &msg->hardware_version, false)) {return true;}
  82. if (!tao) {
  83. canardDecodeScalar(transfer, *bit_ofs, 7, false, &msg->name.len);
  84. *bit_ofs += 7;
  85. } else {
  86. msg->name.len = ((transfer->payload_len*8)-*bit_ofs)/8;
  87. }
  88. #pragma GCC diagnostic push
  89. #pragma GCC diagnostic ignored "-Wtype-limits"
  90. if (msg->name.len > 80) {
  91. return true; /* invalid value */
  92. }
  93. #pragma GCC diagnostic pop
  94. for (size_t i=0; i < msg->name.len; i++) {
  95. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->name.data[i]);
  96. *bit_ofs += 8;
  97. }
  98. return false; /* success */
  99. }
  100. #endif
  101. #ifdef CANARD_DSDLC_TEST_BUILD
  102. struct uavcan_protocol_GetNodeInfoResponse sample_uavcan_protocol_GetNodeInfoResponse_msg(void);
  103. #endif
  104. #ifdef __cplusplus
  105. } // extern "C"
  106. #ifdef DRONECAN_CXX_WRAPPERS
  107. #include <canard/cxx_wrappers.h>
  108. #endif
  109. #endif