uavcan.protocol.AccessCommandShell_res.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_PROTOCOL_ACCESSCOMMANDSHELL_RESPONSE_MAX_SIZE 263
  6. #define UAVCAN_PROTOCOL_ACCESSCOMMANDSHELL_RESPONSE_SIGNATURE (0x59276B5921C9246EULL)
  7. #define UAVCAN_PROTOCOL_ACCESSCOMMANDSHELL_RESPONSE_ID 6
  8. #define UAVCAN_PROTOCOL_ACCESSCOMMANDSHELL_RESPONSE_FLAG_RUNNING 1
  9. #define UAVCAN_PROTOCOL_ACCESSCOMMANDSHELL_RESPONSE_FLAG_SHELL_ERROR 2
  10. #define UAVCAN_PROTOCOL_ACCESSCOMMANDSHELL_RESPONSE_FLAG_HAS_PENDING_STDOUT 64
  11. #define UAVCAN_PROTOCOL_ACCESSCOMMANDSHELL_RESPONSE_FLAG_HAS_PENDING_STDERR 128
  12. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  13. class uavcan_protocol_AccessCommandShell_cxx_iface;
  14. #endif
  15. struct uavcan_protocol_AccessCommandShellResponse {
  16. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  17. using cxx_iface = uavcan_protocol_AccessCommandShell_cxx_iface;
  18. #endif
  19. int32_t last_exit_status;
  20. uint8_t flags;
  21. struct { uint16_t len; uint8_t data[256]; }output;
  22. };
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. uint32_t _uavcan_protocol_AccessCommandShellResponse_encode(struct uavcan_protocol_AccessCommandShellResponse* msg, uint8_t* buffer
  28. #if CANARD_ENABLE_TAO_OPTION
  29. , bool tao
  30. #endif
  31. );
  32. bool _uavcan_protocol_AccessCommandShellResponse_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_AccessCommandShellResponse* msg);
  33. static inline uint32_t uavcan_protocol_AccessCommandShellResponse_encode(struct uavcan_protocol_AccessCommandShellResponse* msg, uint8_t* buffer
  34. #if CANARD_ENABLE_TAO_OPTION
  35. , bool tao
  36. #endif
  37. ) {
  38. return _uavcan_protocol_AccessCommandShellResponse_encode(msg, buffer
  39. #if CANARD_ENABLE_TAO_OPTION
  40. , tao
  41. #endif
  42. );
  43. }
  44. static inline bool uavcan_protocol_AccessCommandShellResponse_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_AccessCommandShellResponse* msg) {
  45. return _uavcan_protocol_AccessCommandShellResponse_decode(transfer, msg);
  46. }
  47. #if defined(CANARD_DSDLC_INTERNAL)
  48. static inline void __uavcan_protocol_AccessCommandShellResponse_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_AccessCommandShellResponse* msg, bool tao);
  49. static inline bool __uavcan_protocol_AccessCommandShellResponse_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_AccessCommandShellResponse* msg, bool tao);
  50. void __uavcan_protocol_AccessCommandShellResponse_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_AccessCommandShellResponse* msg, bool tao) {
  51. (void)buffer;
  52. (void)bit_ofs;
  53. (void)msg;
  54. (void)tao;
  55. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->last_exit_status);
  56. *bit_ofs += 32;
  57. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->flags);
  58. *bit_ofs += 8;
  59. #pragma GCC diagnostic push
  60. #pragma GCC diagnostic ignored "-Wtype-limits"
  61. const uint16_t output_len = msg->output.len > 256 ? 256 : msg->output.len;
  62. #pragma GCC diagnostic pop
  63. if (!tao) {
  64. canardEncodeScalar(buffer, *bit_ofs, 9, &output_len);
  65. *bit_ofs += 9;
  66. }
  67. for (size_t i=0; i < output_len; i++) {
  68. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->output.data[i]);
  69. *bit_ofs += 8;
  70. }
  71. }
  72. /*
  73. decode uavcan_protocol_AccessCommandShellResponse, return true on failure, false on success
  74. */
  75. bool __uavcan_protocol_AccessCommandShellResponse_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_AccessCommandShellResponse* msg, bool tao) {
  76. (void)transfer;
  77. (void)bit_ofs;
  78. (void)msg;
  79. (void)tao;
  80. canardDecodeScalar(transfer, *bit_ofs, 32, true, &msg->last_exit_status);
  81. *bit_ofs += 32;
  82. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->flags);
  83. *bit_ofs += 8;
  84. if (!tao) {
  85. canardDecodeScalar(transfer, *bit_ofs, 9, false, &msg->output.len);
  86. *bit_ofs += 9;
  87. } else {
  88. msg->output.len = ((transfer->payload_len*8)-*bit_ofs)/8;
  89. }
  90. #pragma GCC diagnostic push
  91. #pragma GCC diagnostic ignored "-Wtype-limits"
  92. if (msg->output.len > 256) {
  93. return true; /* invalid value */
  94. }
  95. #pragma GCC diagnostic pop
  96. for (size_t i=0; i < msg->output.len; i++) {
  97. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->output.data[i]);
  98. *bit_ofs += 8;
  99. }
  100. return false; /* success */
  101. }
  102. #endif
  103. #ifdef CANARD_DSDLC_TEST_BUILD
  104. struct uavcan_protocol_AccessCommandShellResponse sample_uavcan_protocol_AccessCommandShellResponse_msg(void);
  105. #endif
  106. #ifdef __cplusplus
  107. } // extern "C"
  108. #ifdef DRONECAN_CXX_WRAPPERS
  109. #include <canard/cxx_wrappers.h>
  110. #endif
  111. #endif