uavcan.protocol.GlobalTimeSync.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_PROTOCOL_GLOBALTIMESYNC_MAX_SIZE 7
  6. #define UAVCAN_PROTOCOL_GLOBALTIMESYNC_SIGNATURE (0x20271116A793C2DBULL)
  7. #define UAVCAN_PROTOCOL_GLOBALTIMESYNC_ID 4
  8. #define UAVCAN_PROTOCOL_GLOBALTIMESYNC_MAX_BROADCASTING_PERIOD_MS 1100
  9. #define UAVCAN_PROTOCOL_GLOBALTIMESYNC_MIN_BROADCASTING_PERIOD_MS 40
  10. #define UAVCAN_PROTOCOL_GLOBALTIMESYNC_RECOMMENDED_BROADCASTER_TIMEOUT_MS 2200
  11. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  12. class uavcan_protocol_GlobalTimeSync_cxx_iface;
  13. #endif
  14. struct uavcan_protocol_GlobalTimeSync {
  15. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  16. using cxx_iface = uavcan_protocol_GlobalTimeSync_cxx_iface;
  17. #endif
  18. uint64_t previous_transmission_timestamp_usec;
  19. };
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. uint32_t _uavcan_protocol_GlobalTimeSync_encode(struct uavcan_protocol_GlobalTimeSync* msg, uint8_t* buffer
  25. #if CANARD_ENABLE_TAO_OPTION
  26. , bool tao
  27. #endif
  28. );
  29. bool _uavcan_protocol_GlobalTimeSync_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_GlobalTimeSync* msg);
  30. static inline uint32_t uavcan_protocol_GlobalTimeSync_encode(struct uavcan_protocol_GlobalTimeSync* msg, uint8_t* buffer
  31. #if CANARD_ENABLE_TAO_OPTION
  32. , bool tao
  33. #endif
  34. ) {
  35. return _uavcan_protocol_GlobalTimeSync_encode(msg, buffer
  36. #if CANARD_ENABLE_TAO_OPTION
  37. , tao
  38. #endif
  39. );
  40. }
  41. static inline bool uavcan_protocol_GlobalTimeSync_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_GlobalTimeSync* msg) {
  42. return _uavcan_protocol_GlobalTimeSync_decode(transfer, msg);
  43. }
  44. #if defined(CANARD_DSDLC_INTERNAL)
  45. static inline void __uavcan_protocol_GlobalTimeSync_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_GlobalTimeSync* msg, bool tao);
  46. static inline bool __uavcan_protocol_GlobalTimeSync_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_GlobalTimeSync* msg, bool tao);
  47. void __uavcan_protocol_GlobalTimeSync_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_GlobalTimeSync* msg, bool tao) {
  48. (void)buffer;
  49. (void)bit_ofs;
  50. (void)msg;
  51. (void)tao;
  52. canardEncodeScalar(buffer, *bit_ofs, 56, &msg->previous_transmission_timestamp_usec);
  53. *bit_ofs += 56;
  54. }
  55. /*
  56. decode uavcan_protocol_GlobalTimeSync, return true on failure, false on success
  57. */
  58. bool __uavcan_protocol_GlobalTimeSync_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_GlobalTimeSync* msg, bool tao) {
  59. (void)transfer;
  60. (void)bit_ofs;
  61. (void)msg;
  62. (void)tao;
  63. canardDecodeScalar(transfer, *bit_ofs, 56, false, &msg->previous_transmission_timestamp_usec);
  64. *bit_ofs += 56;
  65. return false; /* success */
  66. }
  67. #endif
  68. #ifdef CANARD_DSDLC_TEST_BUILD
  69. struct uavcan_protocol_GlobalTimeSync sample_uavcan_protocol_GlobalTimeSync_msg(void);
  70. #endif
  71. #ifdef __cplusplus
  72. } // extern "C"
  73. #ifdef DRONECAN_CXX_WRAPPERS
  74. #include <canard/cxx_wrappers.h>
  75. BROADCAST_MESSAGE_CXX_IFACE(uavcan_protocol_GlobalTimeSync, UAVCAN_PROTOCOL_GLOBALTIMESYNC_ID, UAVCAN_PROTOCOL_GLOBALTIMESYNC_SIGNATURE, UAVCAN_PROTOCOL_GLOBALTIMESYNC_MAX_SIZE);
  76. #endif
  77. #endif