uavcan.tunnel.SerialConfig.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_TUNNEL_SERIALCONFIG_MAX_SIZE 8
  6. #define UAVCAN_TUNNEL_SERIALCONFIG_SIGNATURE (0x4237AACEE87E82ADULL)
  7. #define UAVCAN_TUNNEL_SERIALCONFIG_ID 2011
  8. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  9. class uavcan_tunnel_SerialConfig_cxx_iface;
  10. #endif
  11. struct uavcan_tunnel_SerialConfig {
  12. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  13. using cxx_iface = uavcan_tunnel_SerialConfig_cxx_iface;
  14. #endif
  15. uint8_t channel_id;
  16. uint32_t baud;
  17. uint32_t options;
  18. };
  19. #ifdef __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. uint32_t _uavcan_tunnel_SerialConfig_encode(struct uavcan_tunnel_SerialConfig* msg, uint8_t* buffer
  24. #if CANARD_ENABLE_TAO_OPTION
  25. , bool tao
  26. #endif
  27. );
  28. bool _uavcan_tunnel_SerialConfig_decode(const CanardRxTransfer* transfer, struct uavcan_tunnel_SerialConfig* msg);
  29. static inline uint32_t uavcan_tunnel_SerialConfig_encode(struct uavcan_tunnel_SerialConfig* msg, uint8_t* buffer
  30. #if CANARD_ENABLE_TAO_OPTION
  31. , bool tao
  32. #endif
  33. ) {
  34. return _uavcan_tunnel_SerialConfig_encode(msg, buffer
  35. #if CANARD_ENABLE_TAO_OPTION
  36. , tao
  37. #endif
  38. );
  39. }
  40. static inline bool uavcan_tunnel_SerialConfig_decode(const CanardRxTransfer* transfer, struct uavcan_tunnel_SerialConfig* msg) {
  41. return _uavcan_tunnel_SerialConfig_decode(transfer, msg);
  42. }
  43. #if defined(CANARD_DSDLC_INTERNAL)
  44. static inline void __uavcan_tunnel_SerialConfig_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_tunnel_SerialConfig* msg, bool tao);
  45. static inline bool __uavcan_tunnel_SerialConfig_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_tunnel_SerialConfig* msg, bool tao);
  46. void __uavcan_tunnel_SerialConfig_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_tunnel_SerialConfig* msg, bool tao) {
  47. (void)buffer;
  48. (void)bit_ofs;
  49. (void)msg;
  50. (void)tao;
  51. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->channel_id);
  52. *bit_ofs += 8;
  53. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->baud);
  54. *bit_ofs += 32;
  55. canardEncodeScalar(buffer, *bit_ofs, 24, &msg->options);
  56. *bit_ofs += 24;
  57. }
  58. /*
  59. decode uavcan_tunnel_SerialConfig, return true on failure, false on success
  60. */
  61. bool __uavcan_tunnel_SerialConfig_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_tunnel_SerialConfig* msg, bool tao) {
  62. (void)transfer;
  63. (void)bit_ofs;
  64. (void)msg;
  65. (void)tao;
  66. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->channel_id);
  67. *bit_ofs += 8;
  68. canardDecodeScalar(transfer, *bit_ofs, 32, false, &msg->baud);
  69. *bit_ofs += 32;
  70. canardDecodeScalar(transfer, *bit_ofs, 24, false, &msg->options);
  71. *bit_ofs += 24;
  72. return false; /* success */
  73. }
  74. #endif
  75. #ifdef CANARD_DSDLC_TEST_BUILD
  76. struct uavcan_tunnel_SerialConfig sample_uavcan_tunnel_SerialConfig_msg(void);
  77. #endif
  78. #ifdef __cplusplus
  79. } // extern "C"
  80. #ifdef DRONECAN_CXX_WRAPPERS
  81. #include <canard/cxx_wrappers.h>
  82. BROADCAST_MESSAGE_CXX_IFACE(uavcan_tunnel_SerialConfig, UAVCAN_TUNNEL_SERIALCONFIG_ID, UAVCAN_TUNNEL_SERIALCONFIG_SIGNATURE, UAVCAN_TUNNEL_SERIALCONFIG_MAX_SIZE);
  83. #endif
  84. #endif