uavcan.protocol.CANIfaceStats.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_PROTOCOL_CANIFACESTATS_MAX_SIZE 18
  6. #define UAVCAN_PROTOCOL_CANIFACESTATS_SIGNATURE (0x13B106F0C44CA350ULL)
  7. struct uavcan_protocol_CANIfaceStats {
  8. uint64_t frames_tx;
  9. uint64_t frames_rx;
  10. uint64_t errors;
  11. };
  12. #ifdef __cplusplus
  13. extern "C"
  14. {
  15. #endif
  16. uint32_t _uavcan_protocol_CANIfaceStats_encode(struct uavcan_protocol_CANIfaceStats* msg, uint8_t* buffer
  17. #if CANARD_ENABLE_TAO_OPTION
  18. , bool tao
  19. #endif
  20. );
  21. bool _uavcan_protocol_CANIfaceStats_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_CANIfaceStats* msg);
  22. static inline uint32_t uavcan_protocol_CANIfaceStats_encode(struct uavcan_protocol_CANIfaceStats* msg, uint8_t* buffer
  23. #if CANARD_ENABLE_TAO_OPTION
  24. , bool tao
  25. #endif
  26. ) {
  27. return _uavcan_protocol_CANIfaceStats_encode(msg, buffer
  28. #if CANARD_ENABLE_TAO_OPTION
  29. , tao
  30. #endif
  31. );
  32. }
  33. static inline bool uavcan_protocol_CANIfaceStats_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_CANIfaceStats* msg) {
  34. return _uavcan_protocol_CANIfaceStats_decode(transfer, msg);
  35. }
  36. #if defined(CANARD_DSDLC_INTERNAL)
  37. static inline void __uavcan_protocol_CANIfaceStats_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_CANIfaceStats* msg, bool tao);
  38. static inline bool __uavcan_protocol_CANIfaceStats_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_CANIfaceStats* msg, bool tao);
  39. void __uavcan_protocol_CANIfaceStats_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_CANIfaceStats* msg, bool tao) {
  40. (void)buffer;
  41. (void)bit_ofs;
  42. (void)msg;
  43. (void)tao;
  44. canardEncodeScalar(buffer, *bit_ofs, 48, &msg->frames_tx);
  45. *bit_ofs += 48;
  46. canardEncodeScalar(buffer, *bit_ofs, 48, &msg->frames_rx);
  47. *bit_ofs += 48;
  48. canardEncodeScalar(buffer, *bit_ofs, 48, &msg->errors);
  49. *bit_ofs += 48;
  50. }
  51. /*
  52. decode uavcan_protocol_CANIfaceStats, return true on failure, false on success
  53. */
  54. bool __uavcan_protocol_CANIfaceStats_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_CANIfaceStats* msg, bool tao) {
  55. (void)transfer;
  56. (void)bit_ofs;
  57. (void)msg;
  58. (void)tao;
  59. canardDecodeScalar(transfer, *bit_ofs, 48, false, &msg->frames_tx);
  60. *bit_ofs += 48;
  61. canardDecodeScalar(transfer, *bit_ofs, 48, false, &msg->frames_rx);
  62. *bit_ofs += 48;
  63. canardDecodeScalar(transfer, *bit_ofs, 48, false, &msg->errors);
  64. *bit_ofs += 48;
  65. return false; /* success */
  66. }
  67. #endif
  68. #ifdef CANARD_DSDLC_TEST_BUILD
  69. struct uavcan_protocol_CANIfaceStats sample_uavcan_protocol_CANIfaceStats_msg(void);
  70. #endif
  71. #ifdef __cplusplus
  72. } // extern "C"
  73. #ifdef DRONECAN_CXX_WRAPPERS
  74. #include <canard/cxx_wrappers.h>
  75. #endif
  76. #endif