uavcan.tunnel.Protocol.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_TUNNEL_PROTOCOL_MAX_SIZE 1
  6. #define UAVCAN_TUNNEL_PROTOCOL_SIGNATURE (0xA367483C9B920E49ULL)
  7. #define UAVCAN_TUNNEL_PROTOCOL_MAVLINK 0
  8. #define UAVCAN_TUNNEL_PROTOCOL_MAVLINK2 1
  9. #define UAVCAN_TUNNEL_PROTOCOL_GPS_GENERIC 2
  10. #define UAVCAN_TUNNEL_PROTOCOL_UNDEFINED 255
  11. struct uavcan_tunnel_Protocol {
  12. uint8_t protocol;
  13. };
  14. #ifdef __cplusplus
  15. extern "C"
  16. {
  17. #endif
  18. uint32_t _uavcan_tunnel_Protocol_encode(struct uavcan_tunnel_Protocol* msg, uint8_t* buffer
  19. #if CANARD_ENABLE_TAO_OPTION
  20. , bool tao
  21. #endif
  22. );
  23. bool _uavcan_tunnel_Protocol_decode(const CanardRxTransfer* transfer, struct uavcan_tunnel_Protocol* msg);
  24. static inline uint32_t uavcan_tunnel_Protocol_encode(struct uavcan_tunnel_Protocol* msg, uint8_t* buffer
  25. #if CANARD_ENABLE_TAO_OPTION
  26. , bool tao
  27. #endif
  28. ) {
  29. return _uavcan_tunnel_Protocol_encode(msg, buffer
  30. #if CANARD_ENABLE_TAO_OPTION
  31. , tao
  32. #endif
  33. );
  34. }
  35. static inline bool uavcan_tunnel_Protocol_decode(const CanardRxTransfer* transfer, struct uavcan_tunnel_Protocol* msg) {
  36. return _uavcan_tunnel_Protocol_decode(transfer, msg);
  37. }
  38. #if defined(CANARD_DSDLC_INTERNAL)
  39. static inline void __uavcan_tunnel_Protocol_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_tunnel_Protocol* msg, bool tao);
  40. static inline bool __uavcan_tunnel_Protocol_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_tunnel_Protocol* msg, bool tao);
  41. void __uavcan_tunnel_Protocol_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_tunnel_Protocol* msg, bool tao) {
  42. (void)buffer;
  43. (void)bit_ofs;
  44. (void)msg;
  45. (void)tao;
  46. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->protocol);
  47. *bit_ofs += 8;
  48. }
  49. /*
  50. decode uavcan_tunnel_Protocol, return true on failure, false on success
  51. */
  52. bool __uavcan_tunnel_Protocol_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_tunnel_Protocol* msg, bool tao) {
  53. (void)transfer;
  54. (void)bit_ofs;
  55. (void)msg;
  56. (void)tao;
  57. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->protocol);
  58. *bit_ofs += 8;
  59. return false; /* success */
  60. }
  61. #endif
  62. #ifdef CANARD_DSDLC_TEST_BUILD
  63. struct uavcan_tunnel_Protocol sample_uavcan_tunnel_Protocol_msg(void);
  64. #endif
  65. #ifdef __cplusplus
  66. } // extern "C"
  67. #ifdef DRONECAN_CXX_WRAPPERS
  68. #include <canard/cxx_wrappers.h>
  69. #endif
  70. #endif