mavlink_msg_file_transfer_protocol.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. #pragma once
  2. // MESSAGE FILE_TRANSFER_PROTOCOL PACKING
  3. #define MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL 110
  4. typedef struct __mavlink_file_transfer_protocol_t {
  5. uint8_t target_network; /*< Network ID (0 for broadcast)*/
  6. uint8_t target_system; /*< System ID (0 for broadcast)*/
  7. uint8_t target_component; /*< Component ID (0 for broadcast)*/
  8. uint8_t payload[251]; /*< Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.*/
  9. } mavlink_file_transfer_protocol_t;
  10. #define MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN 254
  11. #define MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN 254
  12. #define MAVLINK_MSG_ID_110_LEN 254
  13. #define MAVLINK_MSG_ID_110_MIN_LEN 254
  14. #define MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC 84
  15. #define MAVLINK_MSG_ID_110_CRC 84
  16. #define MAVLINK_MSG_FILE_TRANSFER_PROTOCOL_FIELD_PAYLOAD_LEN 251
  17. #if MAVLINK_COMMAND_24BIT
  18. #define MAVLINK_MESSAGE_INFO_FILE_TRANSFER_PROTOCOL { \
  19. 110, \
  20. "FILE_TRANSFER_PROTOCOL", \
  21. 4, \
  22. { { "target_network", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_file_transfer_protocol_t, target_network) }, \
  23. { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_file_transfer_protocol_t, target_system) }, \
  24. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_file_transfer_protocol_t, target_component) }, \
  25. { "payload", NULL, MAVLINK_TYPE_UINT8_T, 251, 3, offsetof(mavlink_file_transfer_protocol_t, payload) }, \
  26. } \
  27. }
  28. #else
  29. #define MAVLINK_MESSAGE_INFO_FILE_TRANSFER_PROTOCOL { \
  30. "FILE_TRANSFER_PROTOCOL", \
  31. 4, \
  32. { { "target_network", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_file_transfer_protocol_t, target_network) }, \
  33. { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_file_transfer_protocol_t, target_system) }, \
  34. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_file_transfer_protocol_t, target_component) }, \
  35. { "payload", NULL, MAVLINK_TYPE_UINT8_T, 251, 3, offsetof(mavlink_file_transfer_protocol_t, payload) }, \
  36. } \
  37. }
  38. #endif
  39. /**
  40. * @brief Pack a file_transfer_protocol message
  41. * @param system_id ID of this system
  42. * @param component_id ID of this component (e.g. 200 for IMU)
  43. * @param msg The MAVLink message to compress the data into
  44. *
  45. * @param target_network Network ID (0 for broadcast)
  46. * @param target_system System ID (0 for broadcast)
  47. * @param target_component Component ID (0 for broadcast)
  48. * @param payload Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
  49. * @return length of the message in bytes (excluding serial stream start sign)
  50. */
  51. static inline uint16_t mavlink_msg_file_transfer_protocol_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  52. uint8_t target_network, uint8_t target_system, uint8_t target_component, const uint8_t *payload)
  53. {
  54. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  55. char buf[MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN];
  56. _mav_put_uint8_t(buf, 0, target_network);
  57. _mav_put_uint8_t(buf, 1, target_system);
  58. _mav_put_uint8_t(buf, 2, target_component);
  59. _mav_put_uint8_t_array(buf, 3, payload, 251);
  60. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
  61. #else
  62. mavlink_file_transfer_protocol_t packet;
  63. packet.target_network = target_network;
  64. packet.target_system = target_system;
  65. packet.target_component = target_component;
  66. mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*251);
  67. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
  68. #endif
  69. msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL;
  70. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
  71. }
  72. /**
  73. * @brief Pack a file_transfer_protocol message on a channel
  74. * @param system_id ID of this system
  75. * @param component_id ID of this component (e.g. 200 for IMU)
  76. * @param chan The MAVLink channel this message will be sent over
  77. * @param msg The MAVLink message to compress the data into
  78. * @param target_network Network ID (0 for broadcast)
  79. * @param target_system System ID (0 for broadcast)
  80. * @param target_component Component ID (0 for broadcast)
  81. * @param payload Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
  82. * @return length of the message in bytes (excluding serial stream start sign)
  83. */
  84. static inline uint16_t mavlink_msg_file_transfer_protocol_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  85. mavlink_message_t* msg,
  86. uint8_t target_network,uint8_t target_system,uint8_t target_component,const uint8_t *payload)
  87. {
  88. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  89. char buf[MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN];
  90. _mav_put_uint8_t(buf, 0, target_network);
  91. _mav_put_uint8_t(buf, 1, target_system);
  92. _mav_put_uint8_t(buf, 2, target_component);
  93. _mav_put_uint8_t_array(buf, 3, payload, 251);
  94. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
  95. #else
  96. mavlink_file_transfer_protocol_t packet;
  97. packet.target_network = target_network;
  98. packet.target_system = target_system;
  99. packet.target_component = target_component;
  100. mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*251);
  101. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
  102. #endif
  103. msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL;
  104. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
  105. }
  106. /**
  107. * @brief Encode a file_transfer_protocol struct
  108. *
  109. * @param system_id ID of this system
  110. * @param component_id ID of this component (e.g. 200 for IMU)
  111. * @param msg The MAVLink message to compress the data into
  112. * @param file_transfer_protocol C-struct to read the message contents from
  113. */
  114. static inline uint16_t mavlink_msg_file_transfer_protocol_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_file_transfer_protocol_t* file_transfer_protocol)
  115. {
  116. return mavlink_msg_file_transfer_protocol_pack(system_id, component_id, msg, file_transfer_protocol->target_network, file_transfer_protocol->target_system, file_transfer_protocol->target_component, file_transfer_protocol->payload);
  117. }
  118. /**
  119. * @brief Encode a file_transfer_protocol struct on a channel
  120. *
  121. * @param system_id ID of this system
  122. * @param component_id ID of this component (e.g. 200 for IMU)
  123. * @param chan The MAVLink channel this message will be sent over
  124. * @param msg The MAVLink message to compress the data into
  125. * @param file_transfer_protocol C-struct to read the message contents from
  126. */
  127. static inline uint16_t mavlink_msg_file_transfer_protocol_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_file_transfer_protocol_t* file_transfer_protocol)
  128. {
  129. return mavlink_msg_file_transfer_protocol_pack_chan(system_id, component_id, chan, msg, file_transfer_protocol->target_network, file_transfer_protocol->target_system, file_transfer_protocol->target_component, file_transfer_protocol->payload);
  130. }
  131. /**
  132. * @brief Send a file_transfer_protocol message
  133. * @param chan MAVLink channel to send the message
  134. *
  135. * @param target_network Network ID (0 for broadcast)
  136. * @param target_system System ID (0 for broadcast)
  137. * @param target_component Component ID (0 for broadcast)
  138. * @param payload Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
  139. */
  140. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  141. static inline void mavlink_msg_file_transfer_protocol_send(mavlink_channel_t chan, uint8_t target_network, uint8_t target_system, uint8_t target_component, const uint8_t *payload)
  142. {
  143. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  144. char buf[MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN];
  145. _mav_put_uint8_t(buf, 0, target_network);
  146. _mav_put_uint8_t(buf, 1, target_system);
  147. _mav_put_uint8_t(buf, 2, target_component);
  148. _mav_put_uint8_t_array(buf, 3, payload, 251);
  149. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, buf, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
  150. #else
  151. mavlink_file_transfer_protocol_t packet;
  152. packet.target_network = target_network;
  153. packet.target_system = target_system;
  154. packet.target_component = target_component;
  155. mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*251);
  156. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, (const char *)&packet, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
  157. #endif
  158. }
  159. /**
  160. * @brief Send a file_transfer_protocol message
  161. * @param chan MAVLink channel to send the message
  162. * @param struct The MAVLink struct to serialize
  163. */
  164. static inline void mavlink_msg_file_transfer_protocol_send_struct(mavlink_channel_t chan, const mavlink_file_transfer_protocol_t* file_transfer_protocol)
  165. {
  166. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  167. mavlink_msg_file_transfer_protocol_send(chan, file_transfer_protocol->target_network, file_transfer_protocol->target_system, file_transfer_protocol->target_component, file_transfer_protocol->payload);
  168. #else
  169. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, (const char *)file_transfer_protocol, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
  170. #endif
  171. }
  172. #if MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  173. /*
  174. This varient of _send() can be used to save stack space by re-using
  175. memory from the receive buffer. The caller provides a
  176. mavlink_message_t which is the size of a full mavlink message. This
  177. is usually the receive buffer for the channel, and allows a reply to an
  178. incoming message with minimum stack space usage.
  179. */
  180. static inline void mavlink_msg_file_transfer_protocol_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_network, uint8_t target_system, uint8_t target_component, const uint8_t *payload)
  181. {
  182. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  183. char *buf = (char *)msgbuf;
  184. _mav_put_uint8_t(buf, 0, target_network);
  185. _mav_put_uint8_t(buf, 1, target_system);
  186. _mav_put_uint8_t(buf, 2, target_component);
  187. _mav_put_uint8_t_array(buf, 3, payload, 251);
  188. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, buf, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
  189. #else
  190. mavlink_file_transfer_protocol_t *packet = (mavlink_file_transfer_protocol_t *)msgbuf;
  191. packet->target_network = target_network;
  192. packet->target_system = target_system;
  193. packet->target_component = target_component;
  194. mav_array_memcpy(packet->payload, payload, sizeof(uint8_t)*251);
  195. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, (const char *)packet, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
  196. #endif
  197. }
  198. #endif
  199. #endif
  200. // MESSAGE FILE_TRANSFER_PROTOCOL UNPACKING
  201. /**
  202. * @brief Get field target_network from file_transfer_protocol message
  203. *
  204. * @return Network ID (0 for broadcast)
  205. */
  206. static inline uint8_t mavlink_msg_file_transfer_protocol_get_target_network(const mavlink_message_t* msg)
  207. {
  208. return _MAV_RETURN_uint8_t(msg, 0);
  209. }
  210. /**
  211. * @brief Get field target_system from file_transfer_protocol message
  212. *
  213. * @return System ID (0 for broadcast)
  214. */
  215. static inline uint8_t mavlink_msg_file_transfer_protocol_get_target_system(const mavlink_message_t* msg)
  216. {
  217. return _MAV_RETURN_uint8_t(msg, 1);
  218. }
  219. /**
  220. * @brief Get field target_component from file_transfer_protocol message
  221. *
  222. * @return Component ID (0 for broadcast)
  223. */
  224. static inline uint8_t mavlink_msg_file_transfer_protocol_get_target_component(const mavlink_message_t* msg)
  225. {
  226. return _MAV_RETURN_uint8_t(msg, 2);
  227. }
  228. /**
  229. * @brief Get field payload from file_transfer_protocol message
  230. *
  231. * @return Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
  232. */
  233. static inline uint16_t mavlink_msg_file_transfer_protocol_get_payload(const mavlink_message_t* msg, uint8_t *payload)
  234. {
  235. return _MAV_RETURN_uint8_t_array(msg, payload, 251, 3);
  236. }
  237. /**
  238. * @brief Decode a file_transfer_protocol message into a struct
  239. *
  240. * @param msg The message to decode
  241. * @param file_transfer_protocol C-struct to decode the message contents into
  242. */
  243. static inline void mavlink_msg_file_transfer_protocol_decode(const mavlink_message_t* msg, mavlink_file_transfer_protocol_t* file_transfer_protocol)
  244. {
  245. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  246. file_transfer_protocol->target_network = mavlink_msg_file_transfer_protocol_get_target_network(msg);
  247. file_transfer_protocol->target_system = mavlink_msg_file_transfer_protocol_get_target_system(msg);
  248. file_transfer_protocol->target_component = mavlink_msg_file_transfer_protocol_get_target_component(msg);
  249. mavlink_msg_file_transfer_protocol_get_payload(msg, file_transfer_protocol->payload);
  250. #else
  251. uint8_t len = msg->len < MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN? msg->len : MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN;
  252. memset(file_transfer_protocol, 0, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
  253. memcpy(file_transfer_protocol, _MAV_PAYLOAD(msg), len);
  254. #endif
  255. }