uavcan.Timestamp.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_TIMESTAMP_MAX_SIZE 7
  6. #define UAVCAN_TIMESTAMP_SIGNATURE (0x5BD0B5C81087E0DULL)
  7. #define UAVCAN_TIMESTAMP_UNKNOWN 0
  8. struct uavcan_Timestamp {
  9. uint64_t usec;
  10. };
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15. uint32_t _uavcan_Timestamp_encode(struct uavcan_Timestamp* msg, uint8_t* buffer
  16. #if CANARD_ENABLE_TAO_OPTION
  17. , bool tao
  18. #endif
  19. );
  20. bool _uavcan_Timestamp_decode(const CanardRxTransfer* transfer, struct uavcan_Timestamp* msg);
  21. static inline uint32_t uavcan_Timestamp_encode(struct uavcan_Timestamp* msg, uint8_t* buffer
  22. #if CANARD_ENABLE_TAO_OPTION
  23. , bool tao
  24. #endif
  25. ) {
  26. return _uavcan_Timestamp_encode(msg, buffer
  27. #if CANARD_ENABLE_TAO_OPTION
  28. , tao
  29. #endif
  30. );
  31. }
  32. static inline bool uavcan_Timestamp_decode(const CanardRxTransfer* transfer, struct uavcan_Timestamp* msg) {
  33. return _uavcan_Timestamp_decode(transfer, msg);
  34. }
  35. #if defined(CANARD_DSDLC_INTERNAL)
  36. static inline void __uavcan_Timestamp_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_Timestamp* msg, bool tao);
  37. static inline bool __uavcan_Timestamp_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_Timestamp* msg, bool tao);
  38. void __uavcan_Timestamp_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_Timestamp* msg, bool tao) {
  39. (void)buffer;
  40. (void)bit_ofs;
  41. (void)msg;
  42. (void)tao;
  43. canardEncodeScalar(buffer, *bit_ofs, 56, &msg->usec);
  44. *bit_ofs += 56;
  45. }
  46. /*
  47. decode uavcan_Timestamp, return true on failure, false on success
  48. */
  49. bool __uavcan_Timestamp_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_Timestamp* msg, bool tao) {
  50. (void)transfer;
  51. (void)bit_ofs;
  52. (void)msg;
  53. (void)tao;
  54. canardDecodeScalar(transfer, *bit_ofs, 56, false, &msg->usec);
  55. *bit_ofs += 56;
  56. return false; /* success */
  57. }
  58. #endif
  59. #ifdef CANARD_DSDLC_TEST_BUILD
  60. struct uavcan_Timestamp sample_uavcan_Timestamp_msg(void);
  61. #endif
  62. #ifdef __cplusplus
  63. } // extern "C"
  64. #ifdef DRONECAN_CXX_WRAPPERS
  65. #include <canard/cxx_wrappers.h>
  66. #endif
  67. #endif