mavlink_msg_esc_info.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. #pragma once
  2. // MESSAGE ESC_INFO PACKING
  3. #define MAVLINK_MSG_ID_ESC_INFO 290
  4. typedef struct __mavlink_esc_info_t {
  5. uint64_t time_usec; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.*/
  6. uint32_t error_count[4]; /*< Number of reported errors by each ESC since boot.*/
  7. uint16_t counter; /*< Counter of data packets received.*/
  8. uint16_t failure_flags[4]; /*< Bitmap of ESC failure flags.*/
  9. int16_t temperature[4]; /*< [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.*/
  10. uint8_t index; /*< Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.*/
  11. uint8_t count; /*< Total number of ESCs in all messages of this type. Message fields with an index higher than this should be ignored because they contain invalid data.*/
  12. uint8_t connection_type; /*< Connection type protocol for all ESC.*/
  13. uint8_t info; /*< Information regarding online/offline status of each ESC.*/
  14. } mavlink_esc_info_t;
  15. #define MAVLINK_MSG_ID_ESC_INFO_LEN 46
  16. #define MAVLINK_MSG_ID_ESC_INFO_MIN_LEN 46
  17. #define MAVLINK_MSG_ID_290_LEN 46
  18. #define MAVLINK_MSG_ID_290_MIN_LEN 46
  19. #define MAVLINK_MSG_ID_ESC_INFO_CRC 251
  20. #define MAVLINK_MSG_ID_290_CRC 251
  21. #define MAVLINK_MSG_ESC_INFO_FIELD_ERROR_COUNT_LEN 4
  22. #define MAVLINK_MSG_ESC_INFO_FIELD_FAILURE_FLAGS_LEN 4
  23. #define MAVLINK_MSG_ESC_INFO_FIELD_TEMPERATURE_LEN 4
  24. #if MAVLINK_COMMAND_24BIT
  25. #define MAVLINK_MESSAGE_INFO_ESC_INFO { \
  26. 290, \
  27. "ESC_INFO", \
  28. 9, \
  29. { { "index", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_esc_info_t, index) }, \
  30. { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_esc_info_t, time_usec) }, \
  31. { "counter", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_esc_info_t, counter) }, \
  32. { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 43, offsetof(mavlink_esc_info_t, count) }, \
  33. { "connection_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 44, offsetof(mavlink_esc_info_t, connection_type) }, \
  34. { "info", NULL, MAVLINK_TYPE_UINT8_T, 0, 45, offsetof(mavlink_esc_info_t, info) }, \
  35. { "failure_flags", NULL, MAVLINK_TYPE_UINT16_T, 4, 26, offsetof(mavlink_esc_info_t, failure_flags) }, \
  36. { "error_count", NULL, MAVLINK_TYPE_UINT32_T, 4, 8, offsetof(mavlink_esc_info_t, error_count) }, \
  37. { "temperature", NULL, MAVLINK_TYPE_INT16_T, 4, 34, offsetof(mavlink_esc_info_t, temperature) }, \
  38. } \
  39. }
  40. #else
  41. #define MAVLINK_MESSAGE_INFO_ESC_INFO { \
  42. "ESC_INFO", \
  43. 9, \
  44. { { "index", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_esc_info_t, index) }, \
  45. { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_esc_info_t, time_usec) }, \
  46. { "counter", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_esc_info_t, counter) }, \
  47. { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 43, offsetof(mavlink_esc_info_t, count) }, \
  48. { "connection_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 44, offsetof(mavlink_esc_info_t, connection_type) }, \
  49. { "info", NULL, MAVLINK_TYPE_UINT8_T, 0, 45, offsetof(mavlink_esc_info_t, info) }, \
  50. { "failure_flags", NULL, MAVLINK_TYPE_UINT16_T, 4, 26, offsetof(mavlink_esc_info_t, failure_flags) }, \
  51. { "error_count", NULL, MAVLINK_TYPE_UINT32_T, 4, 8, offsetof(mavlink_esc_info_t, error_count) }, \
  52. { "temperature", NULL, MAVLINK_TYPE_INT16_T, 4, 34, offsetof(mavlink_esc_info_t, temperature) }, \
  53. } \
  54. }
  55. #endif
  56. /**
  57. * @brief Pack a esc_info message
  58. * @param system_id ID of this system
  59. * @param component_id ID of this component (e.g. 200 for IMU)
  60. * @param msg The MAVLink message to compress the data into
  61. *
  62. * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
  63. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
  64. * @param counter Counter of data packets received.
  65. * @param count Total number of ESCs in all messages of this type. Message fields with an index higher than this should be ignored because they contain invalid data.
  66. * @param connection_type Connection type protocol for all ESC.
  67. * @param info Information regarding online/offline status of each ESC.
  68. * @param failure_flags Bitmap of ESC failure flags.
  69. * @param error_count Number of reported errors by each ESC since boot.
  70. * @param temperature [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.
  71. * @return length of the message in bytes (excluding serial stream start sign)
  72. */
  73. MAVLINK_WIP
  74. static inline uint16_t mavlink_msg_esc_info_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  75. uint8_t index, uint64_t time_usec, uint16_t counter, uint8_t count, uint8_t connection_type, uint8_t info, const uint16_t *failure_flags, const uint32_t *error_count, const int16_t *temperature)
  76. {
  77. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  78. char buf[MAVLINK_MSG_ID_ESC_INFO_LEN];
  79. _mav_put_uint64_t(buf, 0, time_usec);
  80. _mav_put_uint16_t(buf, 24, counter);
  81. _mav_put_uint8_t(buf, 42, index);
  82. _mav_put_uint8_t(buf, 43, count);
  83. _mav_put_uint8_t(buf, 44, connection_type);
  84. _mav_put_uint8_t(buf, 45, info);
  85. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  86. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  87. _mav_put_int16_t_array(buf, 34, temperature, 4);
  88. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_INFO_LEN);
  89. #else
  90. mavlink_esc_info_t packet;
  91. packet.time_usec = time_usec;
  92. packet.counter = counter;
  93. packet.index = index;
  94. packet.count = count;
  95. packet.connection_type = connection_type;
  96. packet.info = info;
  97. mav_array_assign_uint32_t(packet.error_count, error_count, 4);
  98. mav_array_assign_uint16_t(packet.failure_flags, failure_flags, 4);
  99. mav_array_assign_int16_t(packet.temperature, temperature, 4);
  100. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_INFO_LEN);
  101. #endif
  102. msg->msgid = MAVLINK_MSG_ID_ESC_INFO;
  103. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC);
  104. }
  105. /**
  106. * @brief Pack a esc_info message
  107. * @param system_id ID of this system
  108. * @param component_id ID of this component (e.g. 200 for IMU)
  109. * @param status MAVLink status structure
  110. * @param msg The MAVLink message to compress the data into
  111. *
  112. * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
  113. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
  114. * @param counter Counter of data packets received.
  115. * @param count Total number of ESCs in all messages of this type. Message fields with an index higher than this should be ignored because they contain invalid data.
  116. * @param connection_type Connection type protocol for all ESC.
  117. * @param info Information regarding online/offline status of each ESC.
  118. * @param failure_flags Bitmap of ESC failure flags.
  119. * @param error_count Number of reported errors by each ESC since boot.
  120. * @param temperature [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.
  121. * @return length of the message in bytes (excluding serial stream start sign)
  122. */
  123. static inline uint16_t mavlink_msg_esc_info_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  124. uint8_t index, uint64_t time_usec, uint16_t counter, uint8_t count, uint8_t connection_type, uint8_t info, const uint16_t *failure_flags, const uint32_t *error_count, const int16_t *temperature)
  125. {
  126. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  127. char buf[MAVLINK_MSG_ID_ESC_INFO_LEN];
  128. _mav_put_uint64_t(buf, 0, time_usec);
  129. _mav_put_uint16_t(buf, 24, counter);
  130. _mav_put_uint8_t(buf, 42, index);
  131. _mav_put_uint8_t(buf, 43, count);
  132. _mav_put_uint8_t(buf, 44, connection_type);
  133. _mav_put_uint8_t(buf, 45, info);
  134. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  135. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  136. _mav_put_int16_t_array(buf, 34, temperature, 4);
  137. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_INFO_LEN);
  138. #else
  139. mavlink_esc_info_t packet;
  140. packet.time_usec = time_usec;
  141. packet.counter = counter;
  142. packet.index = index;
  143. packet.count = count;
  144. packet.connection_type = connection_type;
  145. packet.info = info;
  146. mav_array_memcpy(packet.error_count, error_count, sizeof(uint32_t)*4);
  147. mav_array_memcpy(packet.failure_flags, failure_flags, sizeof(uint16_t)*4);
  148. mav_array_memcpy(packet.temperature, temperature, sizeof(int16_t)*4);
  149. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_INFO_LEN);
  150. #endif
  151. msg->msgid = MAVLINK_MSG_ID_ESC_INFO;
  152. #if MAVLINK_CRC_EXTRA
  153. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC);
  154. #else
  155. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN);
  156. #endif
  157. }
  158. /**
  159. * @brief Pack a esc_info message on a channel
  160. * @param system_id ID of this system
  161. * @param component_id ID of this component (e.g. 200 for IMU)
  162. * @param chan The MAVLink channel this message will be sent over
  163. * @param msg The MAVLink message to compress the data into
  164. * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
  165. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
  166. * @param counter Counter of data packets received.
  167. * @param count Total number of ESCs in all messages of this type. Message fields with an index higher than this should be ignored because they contain invalid data.
  168. * @param connection_type Connection type protocol for all ESC.
  169. * @param info Information regarding online/offline status of each ESC.
  170. * @param failure_flags Bitmap of ESC failure flags.
  171. * @param error_count Number of reported errors by each ESC since boot.
  172. * @param temperature [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.
  173. * @return length of the message in bytes (excluding serial stream start sign)
  174. */
  175. MAVLINK_WIP
  176. static inline uint16_t mavlink_msg_esc_info_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  177. mavlink_message_t* msg,
  178. uint8_t index,uint64_t time_usec,uint16_t counter,uint8_t count,uint8_t connection_type,uint8_t info,const uint16_t *failure_flags,const uint32_t *error_count,const int16_t *temperature)
  179. {
  180. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  181. char buf[MAVLINK_MSG_ID_ESC_INFO_LEN];
  182. _mav_put_uint64_t(buf, 0, time_usec);
  183. _mav_put_uint16_t(buf, 24, counter);
  184. _mav_put_uint8_t(buf, 42, index);
  185. _mav_put_uint8_t(buf, 43, count);
  186. _mav_put_uint8_t(buf, 44, connection_type);
  187. _mav_put_uint8_t(buf, 45, info);
  188. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  189. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  190. _mav_put_int16_t_array(buf, 34, temperature, 4);
  191. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_INFO_LEN);
  192. #else
  193. mavlink_esc_info_t packet;
  194. packet.time_usec = time_usec;
  195. packet.counter = counter;
  196. packet.index = index;
  197. packet.count = count;
  198. packet.connection_type = connection_type;
  199. packet.info = info;
  200. mav_array_assign_uint32_t(packet.error_count, error_count, 4);
  201. mav_array_assign_uint16_t(packet.failure_flags, failure_flags, 4);
  202. mav_array_assign_int16_t(packet.temperature, temperature, 4);
  203. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_INFO_LEN);
  204. #endif
  205. msg->msgid = MAVLINK_MSG_ID_ESC_INFO;
  206. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC);
  207. }
  208. /**
  209. * @brief Encode a esc_info struct
  210. *
  211. * @param system_id ID of this system
  212. * @param component_id ID of this component (e.g. 200 for IMU)
  213. * @param msg The MAVLink message to compress the data into
  214. * @param esc_info C-struct to read the message contents from
  215. */
  216. MAVLINK_WIP
  217. static inline uint16_t mavlink_msg_esc_info_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_esc_info_t* esc_info)
  218. {
  219. return mavlink_msg_esc_info_pack(system_id, component_id, msg, esc_info->index, esc_info->time_usec, esc_info->counter, esc_info->count, esc_info->connection_type, esc_info->info, esc_info->failure_flags, esc_info->error_count, esc_info->temperature);
  220. }
  221. /**
  222. * @brief Encode a esc_info struct on a channel
  223. *
  224. * @param system_id ID of this system
  225. * @param component_id ID of this component (e.g. 200 for IMU)
  226. * @param chan The MAVLink channel this message will be sent over
  227. * @param msg The MAVLink message to compress the data into
  228. * @param esc_info C-struct to read the message contents from
  229. */
  230. MAVLINK_WIP
  231. static inline uint16_t mavlink_msg_esc_info_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_esc_info_t* esc_info)
  232. {
  233. return mavlink_msg_esc_info_pack_chan(system_id, component_id, chan, msg, esc_info->index, esc_info->time_usec, esc_info->counter, esc_info->count, esc_info->connection_type, esc_info->info, esc_info->failure_flags, esc_info->error_count, esc_info->temperature);
  234. }
  235. /**
  236. * @brief Encode a esc_info struct with provided status structure
  237. *
  238. * @param system_id ID of this system
  239. * @param component_id ID of this component (e.g. 200 for IMU)
  240. * @param status MAVLink status structure
  241. * @param msg The MAVLink message to compress the data into
  242. * @param esc_info C-struct to read the message contents from
  243. */
  244. static inline uint16_t mavlink_msg_esc_info_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_esc_info_t* esc_info)
  245. {
  246. return mavlink_msg_esc_info_pack_status(system_id, component_id, _status, msg, esc_info->index, esc_info->time_usec, esc_info->counter, esc_info->count, esc_info->connection_type, esc_info->info, esc_info->failure_flags, esc_info->error_count, esc_info->temperature);
  247. }
  248. /**
  249. * @brief Send a esc_info message
  250. * @param chan MAVLink channel to send the message
  251. *
  252. * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
  253. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
  254. * @param counter Counter of data packets received.
  255. * @param count Total number of ESCs in all messages of this type. Message fields with an index higher than this should be ignored because they contain invalid data.
  256. * @param connection_type Connection type protocol for all ESC.
  257. * @param info Information regarding online/offline status of each ESC.
  258. * @param failure_flags Bitmap of ESC failure flags.
  259. * @param error_count Number of reported errors by each ESC since boot.
  260. * @param temperature [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.
  261. */
  262. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  263. MAVLINK_WIP
  264. static inline void mavlink_msg_esc_info_send(mavlink_channel_t chan, uint8_t index, uint64_t time_usec, uint16_t counter, uint8_t count, uint8_t connection_type, uint8_t info, const uint16_t *failure_flags, const uint32_t *error_count, const int16_t *temperature)
  265. {
  266. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  267. char buf[MAVLINK_MSG_ID_ESC_INFO_LEN];
  268. _mav_put_uint64_t(buf, 0, time_usec);
  269. _mav_put_uint16_t(buf, 24, counter);
  270. _mav_put_uint8_t(buf, 42, index);
  271. _mav_put_uint8_t(buf, 43, count);
  272. _mav_put_uint8_t(buf, 44, connection_type);
  273. _mav_put_uint8_t(buf, 45, info);
  274. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  275. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  276. _mav_put_int16_t_array(buf, 34, temperature, 4);
  277. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ESC_INFO, buf, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC);
  278. #else
  279. mavlink_esc_info_t packet;
  280. packet.time_usec = time_usec;
  281. packet.counter = counter;
  282. packet.index = index;
  283. packet.count = count;
  284. packet.connection_type = connection_type;
  285. packet.info = info;
  286. mav_array_assign_uint32_t(packet.error_count, error_count, 4);
  287. mav_array_assign_uint16_t(packet.failure_flags, failure_flags, 4);
  288. mav_array_assign_int16_t(packet.temperature, temperature, 4);
  289. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ESC_INFO, (const char *)&packet, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC);
  290. #endif
  291. }
  292. /**
  293. * @brief Send a esc_info message
  294. * @param chan MAVLink channel to send the message
  295. * @param struct The MAVLink struct to serialize
  296. */
  297. MAVLINK_WIP
  298. static inline void mavlink_msg_esc_info_send_struct(mavlink_channel_t chan, const mavlink_esc_info_t* esc_info)
  299. {
  300. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  301. mavlink_msg_esc_info_send(chan, esc_info->index, esc_info->time_usec, esc_info->counter, esc_info->count, esc_info->connection_type, esc_info->info, esc_info->failure_flags, esc_info->error_count, esc_info->temperature);
  302. #else
  303. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ESC_INFO, (const char *)esc_info, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC);
  304. #endif
  305. }
  306. #if MAVLINK_MSG_ID_ESC_INFO_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  307. /*
  308. This variant of _send() can be used to save stack space by reusing
  309. memory from the receive buffer. The caller provides a
  310. mavlink_message_t which is the size of a full mavlink message. This
  311. is usually the receive buffer for the channel, and allows a reply to an
  312. incoming message with minimum stack space usage.
  313. */
  314. MAVLINK_WIP
  315. static inline void mavlink_msg_esc_info_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t index, uint64_t time_usec, uint16_t counter, uint8_t count, uint8_t connection_type, uint8_t info, const uint16_t *failure_flags, const uint32_t *error_count, const int16_t *temperature)
  316. {
  317. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  318. char *buf = (char *)msgbuf;
  319. _mav_put_uint64_t(buf, 0, time_usec);
  320. _mav_put_uint16_t(buf, 24, counter);
  321. _mav_put_uint8_t(buf, 42, index);
  322. _mav_put_uint8_t(buf, 43, count);
  323. _mav_put_uint8_t(buf, 44, connection_type);
  324. _mav_put_uint8_t(buf, 45, info);
  325. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  326. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  327. _mav_put_int16_t_array(buf, 34, temperature, 4);
  328. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ESC_INFO, buf, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC);
  329. #else
  330. mavlink_esc_info_t *packet = (mavlink_esc_info_t *)msgbuf;
  331. packet->time_usec = time_usec;
  332. packet->counter = counter;
  333. packet->index = index;
  334. packet->count = count;
  335. packet->connection_type = connection_type;
  336. packet->info = info;
  337. mav_array_assign_uint32_t(packet->error_count, error_count, 4);
  338. mav_array_assign_uint16_t(packet->failure_flags, failure_flags, 4);
  339. mav_array_assign_int16_t(packet->temperature, temperature, 4);
  340. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ESC_INFO, (const char *)packet, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC);
  341. #endif
  342. }
  343. #endif
  344. #endif
  345. // MESSAGE ESC_INFO UNPACKING
  346. /**
  347. * @brief Get field index from esc_info message
  348. *
  349. * @return Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
  350. */
  351. MAVLINK_WIP
  352. static inline uint8_t mavlink_msg_esc_info_get_index(const mavlink_message_t* msg)
  353. {
  354. return _MAV_RETURN_uint8_t(msg, 42);
  355. }
  356. /**
  357. * @brief Get field time_usec from esc_info message
  358. *
  359. * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
  360. */
  361. MAVLINK_WIP
  362. static inline uint64_t mavlink_msg_esc_info_get_time_usec(const mavlink_message_t* msg)
  363. {
  364. return _MAV_RETURN_uint64_t(msg, 0);
  365. }
  366. /**
  367. * @brief Get field counter from esc_info message
  368. *
  369. * @return Counter of data packets received.
  370. */
  371. MAVLINK_WIP
  372. static inline uint16_t mavlink_msg_esc_info_get_counter(const mavlink_message_t* msg)
  373. {
  374. return _MAV_RETURN_uint16_t(msg, 24);
  375. }
  376. /**
  377. * @brief Get field count from esc_info message
  378. *
  379. * @return Total number of ESCs in all messages of this type. Message fields with an index higher than this should be ignored because they contain invalid data.
  380. */
  381. MAVLINK_WIP
  382. static inline uint8_t mavlink_msg_esc_info_get_count(const mavlink_message_t* msg)
  383. {
  384. return _MAV_RETURN_uint8_t(msg, 43);
  385. }
  386. /**
  387. * @brief Get field connection_type from esc_info message
  388. *
  389. * @return Connection type protocol for all ESC.
  390. */
  391. MAVLINK_WIP
  392. static inline uint8_t mavlink_msg_esc_info_get_connection_type(const mavlink_message_t* msg)
  393. {
  394. return _MAV_RETURN_uint8_t(msg, 44);
  395. }
  396. /**
  397. * @brief Get field info from esc_info message
  398. *
  399. * @return Information regarding online/offline status of each ESC.
  400. */
  401. MAVLINK_WIP
  402. static inline uint8_t mavlink_msg_esc_info_get_info(const mavlink_message_t* msg)
  403. {
  404. return _MAV_RETURN_uint8_t(msg, 45);
  405. }
  406. /**
  407. * @brief Get field failure_flags from esc_info message
  408. *
  409. * @return Bitmap of ESC failure flags.
  410. */
  411. MAVLINK_WIP
  412. static inline uint16_t mavlink_msg_esc_info_get_failure_flags(const mavlink_message_t* msg, uint16_t *failure_flags)
  413. {
  414. return _MAV_RETURN_uint16_t_array(msg, failure_flags, 4, 26);
  415. }
  416. /**
  417. * @brief Get field error_count from esc_info message
  418. *
  419. * @return Number of reported errors by each ESC since boot.
  420. */
  421. MAVLINK_WIP
  422. static inline uint16_t mavlink_msg_esc_info_get_error_count(const mavlink_message_t* msg, uint32_t *error_count)
  423. {
  424. return _MAV_RETURN_uint32_t_array(msg, error_count, 4, 8);
  425. }
  426. /**
  427. * @brief Get field temperature from esc_info message
  428. *
  429. * @return [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.
  430. */
  431. MAVLINK_WIP
  432. static inline uint16_t mavlink_msg_esc_info_get_temperature(const mavlink_message_t* msg, int16_t *temperature)
  433. {
  434. return _MAV_RETURN_int16_t_array(msg, temperature, 4, 34);
  435. }
  436. /**
  437. * @brief Decode a esc_info message into a struct
  438. *
  439. * @param msg The message to decode
  440. * @param esc_info C-struct to decode the message contents into
  441. */
  442. MAVLINK_WIP
  443. static inline void mavlink_msg_esc_info_decode(const mavlink_message_t* msg, mavlink_esc_info_t* esc_info)
  444. {
  445. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  446. esc_info->time_usec = mavlink_msg_esc_info_get_time_usec(msg);
  447. mavlink_msg_esc_info_get_error_count(msg, esc_info->error_count);
  448. esc_info->counter = mavlink_msg_esc_info_get_counter(msg);
  449. mavlink_msg_esc_info_get_failure_flags(msg, esc_info->failure_flags);
  450. mavlink_msg_esc_info_get_temperature(msg, esc_info->temperature);
  451. esc_info->index = mavlink_msg_esc_info_get_index(msg);
  452. esc_info->count = mavlink_msg_esc_info_get_count(msg);
  453. esc_info->connection_type = mavlink_msg_esc_info_get_connection_type(msg);
  454. esc_info->info = mavlink_msg_esc_info_get_info(msg);
  455. #else
  456. uint8_t len = msg->len < MAVLINK_MSG_ID_ESC_INFO_LEN? msg->len : MAVLINK_MSG_ID_ESC_INFO_LEN;
  457. memset(esc_info, 0, MAVLINK_MSG_ID_ESC_INFO_LEN);
  458. memcpy(esc_info, _MAV_PAYLOAD(msg), len);
  459. #endif
  460. }