uavcan.protocol.file.Error.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_PROTOCOL_FILE_ERROR_MAX_SIZE 2
  6. #define UAVCAN_PROTOCOL_FILE_ERROR_SIGNATURE (0xA83071FFEA4FAE15ULL)
  7. #define UAVCAN_PROTOCOL_FILE_ERROR_OK 0
  8. #define UAVCAN_PROTOCOL_FILE_ERROR_UNKNOWN_ERROR 32767
  9. #define UAVCAN_PROTOCOL_FILE_ERROR_NOT_FOUND 2
  10. #define UAVCAN_PROTOCOL_FILE_ERROR_IO_ERROR 5
  11. #define UAVCAN_PROTOCOL_FILE_ERROR_ACCESS_DENIED 13
  12. #define UAVCAN_PROTOCOL_FILE_ERROR_IS_DIRECTORY 21
  13. #define UAVCAN_PROTOCOL_FILE_ERROR_INVALID_VALUE 22
  14. #define UAVCAN_PROTOCOL_FILE_ERROR_FILE_TOO_LARGE 27
  15. #define UAVCAN_PROTOCOL_FILE_ERROR_OUT_OF_SPACE 28
  16. #define UAVCAN_PROTOCOL_FILE_ERROR_NOT_IMPLEMENTED 38
  17. struct uavcan_protocol_file_Error {
  18. int16_t value;
  19. };
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. uint32_t _uavcan_protocol_file_Error_encode(struct uavcan_protocol_file_Error* msg, uint8_t* buffer
  25. #if CANARD_ENABLE_TAO_OPTION
  26. , bool tao
  27. #endif
  28. );
  29. bool _uavcan_protocol_file_Error_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_file_Error* msg);
  30. static inline uint32_t uavcan_protocol_file_Error_encode(struct uavcan_protocol_file_Error* msg, uint8_t* buffer
  31. #if CANARD_ENABLE_TAO_OPTION
  32. , bool tao
  33. #endif
  34. ) {
  35. return _uavcan_protocol_file_Error_encode(msg, buffer
  36. #if CANARD_ENABLE_TAO_OPTION
  37. , tao
  38. #endif
  39. );
  40. }
  41. static inline bool uavcan_protocol_file_Error_decode(const CanardRxTransfer* transfer, struct uavcan_protocol_file_Error* msg) {
  42. return _uavcan_protocol_file_Error_decode(transfer, msg);
  43. }
  44. #if defined(CANARD_DSDLC_INTERNAL)
  45. static inline void __uavcan_protocol_file_Error_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_file_Error* msg, bool tao);
  46. static inline bool __uavcan_protocol_file_Error_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_file_Error* msg, bool tao);
  47. void __uavcan_protocol_file_Error_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_protocol_file_Error* msg, bool tao) {
  48. (void)buffer;
  49. (void)bit_ofs;
  50. (void)msg;
  51. (void)tao;
  52. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->value);
  53. *bit_ofs += 16;
  54. }
  55. /*
  56. decode uavcan_protocol_file_Error, return true on failure, false on success
  57. */
  58. bool __uavcan_protocol_file_Error_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_protocol_file_Error* msg, bool tao) {
  59. (void)transfer;
  60. (void)bit_ofs;
  61. (void)msg;
  62. (void)tao;
  63. canardDecodeScalar(transfer, *bit_ofs, 16, true, &msg->value);
  64. *bit_ofs += 16;
  65. return false; /* success */
  66. }
  67. #endif
  68. #ifdef CANARD_DSDLC_TEST_BUILD
  69. struct uavcan_protocol_file_Error sample_uavcan_protocol_file_Error_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