uavcan.protocol.dynamic_node_id.server.Entry.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_SERVER_ENTRY_MAX_SIZE 21
  6. #define UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_SERVER_ENTRY_SIGNATURE (0x7FAA779D64FA75C2ULL)
  7. struct uavcan_protocol_dynamic_node_id_server_Entry {
  8. uint32_t term;
  9. uint8_t unique_id[16];
  10. uint8_t node_id;
  11. };
  12. #ifdef __cplusplus
  13. extern "C"
  14. {
  15. #endif
  16. uint32_t _uavcan_protocol_dynamic_node_id_server_Entry_encode(struct uavcan_protocol_dynamic_node_id_server_Entry* msg, uint8_t* buffer
  17. #if CANARD_ENABLE_TAO_OPTION
  18. , bool tao
  19. #endif
  20. );
  21. bool _uavcan_protocol_dynamic_node_id_server_Entry_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_dynamic_node_id_server_Entry* msg);
  22. static inline uint32_t uavcan_protocol_dynamic_node_id_server_Entry_encode(struct uavcan_protocol_dynamic_node_id_server_Entry* msg, uint8_t* buffer
  23. #if CANARD_ENABLE_TAO_OPTION
  24. , bool tao
  25. #endif
  26. ) {
  27. return _uavcan_protocol_dynamic_node_id_server_Entry_encode(msg, buffer
  28. #if CANARD_ENABLE_TAO_OPTION
  29. , tao
  30. #endif
  31. );
  32. }
  33. static inline bool uavcan_protocol_dynamic_node_id_server_Entry_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_dynamic_node_id_server_Entry* msg) {
  34. return _uavcan_protocol_dynamic_node_id_server_Entry_decode(transfer, msg);
  35. }
  36. #if defined(CANARD_DSDLC_INTERNAL)
  37. static inline void __uavcan_protocol_dynamic_node_id_server_Entry_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_dynamic_node_id_server_Entry* msg, bool tao);
  38. static inline bool __uavcan_protocol_dynamic_node_id_server_Entry_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_dynamic_node_id_server_Entry* msg, bool tao);
  39. void __uavcan_protocol_dynamic_node_id_server_Entry_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_dynamic_node_id_server_Entry* msg, bool tao) {
  40. (void)buffer;
  41. (void)bit_ofs;
  42. (void)msg;
  43. (void)tao;
  44. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->term);
  45. *bit_ofs += 32;
  46. for (size_t i=0; i < 16; i++) {
  47. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->unique_id[i]);
  48. *bit_ofs += 8;
  49. }
  50. *bit_ofs += 1;
  51. canardEncodeScalar(buffer, *bit_ofs, 7, &msg->node_id);
  52. *bit_ofs += 7;
  53. }
  54. /*
  55. decode uavcan_protocol_dynamic_node_id_server_Entry, return true on failure, false on success
  56. */
  57. bool __uavcan_protocol_dynamic_node_id_server_Entry_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_dynamic_node_id_server_Entry* msg, bool tao) {
  58. (void)transfer;
  59. (void)bit_ofs;
  60. (void)msg;
  61. (void)tao;
  62. canardDecodeScalar(transfer, *bit_ofs, 32, false, &msg->term);
  63. *bit_ofs += 32;
  64. for (size_t i=0; i < 16; i++) {
  65. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->unique_id[i]);
  66. *bit_ofs += 8;
  67. }
  68. *bit_ofs += 1;
  69. canardDecodeScalar(transfer, *bit_ofs, 7, false, &msg->node_id);
  70. *bit_ofs += 7;
  71. return false; /* success */
  72. }
  73. #endif
  74. #ifdef CANARD_DSDLC_TEST_BUILD
  75. struct uavcan_protocol_dynamic_node_id_server_Entry sample_uavcan_protocol_dynamic_node_id_server_Entry_msg(void);
  76. #endif
  77. #ifdef __cplusplus
  78. } // extern "C"
  79. #ifdef DRONECAN_CXX_WRAPPERS
  80. #include <canard/cxx_wrappers.h>
  81. #endif
  82. #endif