mavlink_msg_esc_info.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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. static inline uint16_t mavlink_msg_esc_info_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  74. 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)
  75. {
  76. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  77. char buf[MAVLINK_MSG_ID_ESC_INFO_LEN];
  78. _mav_put_uint64_t(buf, 0, time_usec);
  79. _mav_put_uint16_t(buf, 24, counter);
  80. _mav_put_uint8_t(buf, 42, index);
  81. _mav_put_uint8_t(buf, 43, count);
  82. _mav_put_uint8_t(buf, 44, connection_type);
  83. _mav_put_uint8_t(buf, 45, info);
  84. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  85. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  86. _mav_put_int16_t_array(buf, 34, temperature, 4);
  87. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_INFO_LEN);
  88. #else
  89. mavlink_esc_info_t packet;
  90. packet.time_usec = time_usec;
  91. packet.counter = counter;
  92. packet.index = index;
  93. packet.count = count;
  94. packet.connection_type = connection_type;
  95. packet.info = info;
  96. mav_array_memcpy(packet.error_count, error_count, sizeof(uint32_t)*4);
  97. mav_array_memcpy(packet.failure_flags, failure_flags, sizeof(uint16_t)*4);
  98. mav_array_memcpy(packet.temperature, temperature, sizeof(int16_t)*4);
  99. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_INFO_LEN);
  100. #endif
  101. msg->msgid = MAVLINK_MSG_ID_ESC_INFO;
  102. 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);
  103. }
  104. /**
  105. * @brief Pack a esc_info message
  106. * @param system_id ID of this system
  107. * @param component_id ID of this component (e.g. 200 for IMU)
  108. * @param status MAVLink status structure
  109. * @param msg The MAVLink message to compress the data into
  110. *
  111. * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
  112. * @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.
  113. * @param counter Counter of data packets received.
  114. * @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.
  115. * @param connection_type Connection type protocol for all ESC.
  116. * @param info Information regarding online/offline status of each ESC.
  117. * @param failure_flags Bitmap of ESC failure flags.
  118. * @param error_count Number of reported errors by each ESC since boot.
  119. * @param temperature [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.
  120. * @return length of the message in bytes (excluding serial stream start sign)
  121. */
  122. 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,
  123. 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)
  124. {
  125. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  126. char buf[MAVLINK_MSG_ID_ESC_INFO_LEN];
  127. _mav_put_uint64_t(buf, 0, time_usec);
  128. _mav_put_uint16_t(buf, 24, counter);
  129. _mav_put_uint8_t(buf, 42, index);
  130. _mav_put_uint8_t(buf, 43, count);
  131. _mav_put_uint8_t(buf, 44, connection_type);
  132. _mav_put_uint8_t(buf, 45, info);
  133. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  134. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  135. _mav_put_int16_t_array(buf, 34, temperature, 4);
  136. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_INFO_LEN);
  137. #else
  138. mavlink_esc_info_t packet;
  139. packet.time_usec = time_usec;
  140. packet.counter = counter;
  141. packet.index = index;
  142. packet.count = count;
  143. packet.connection_type = connection_type;
  144. packet.info = info;
  145. mav_array_memcpy(packet.error_count, error_count, sizeof(uint32_t)*4);
  146. mav_array_memcpy(packet.failure_flags, failure_flags, sizeof(uint16_t)*4);
  147. mav_array_memcpy(packet.temperature, temperature, sizeof(int16_t)*4);
  148. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_INFO_LEN);
  149. #endif
  150. msg->msgid = MAVLINK_MSG_ID_ESC_INFO;
  151. #if MAVLINK_CRC_EXTRA
  152. 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);
  153. #else
  154. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN);
  155. #endif
  156. }
  157. /**
  158. * @brief Pack a esc_info message on a channel
  159. * @param system_id ID of this system
  160. * @param component_id ID of this component (e.g. 200 for IMU)
  161. * @param chan The MAVLink channel this message will be sent over
  162. * @param msg The MAVLink message to compress the data into
  163. * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
  164. * @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.
  165. * @param counter Counter of data packets received.
  166. * @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.
  167. * @param connection_type Connection type protocol for all ESC.
  168. * @param info Information regarding online/offline status of each ESC.
  169. * @param failure_flags Bitmap of ESC failure flags.
  170. * @param error_count Number of reported errors by each ESC since boot.
  171. * @param temperature [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.
  172. * @return length of the message in bytes (excluding serial stream start sign)
  173. */
  174. static inline uint16_t mavlink_msg_esc_info_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  175. mavlink_message_t* msg,
  176. 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)
  177. {
  178. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  179. char buf[MAVLINK_MSG_ID_ESC_INFO_LEN];
  180. _mav_put_uint64_t(buf, 0, time_usec);
  181. _mav_put_uint16_t(buf, 24, counter);
  182. _mav_put_uint8_t(buf, 42, index);
  183. _mav_put_uint8_t(buf, 43, count);
  184. _mav_put_uint8_t(buf, 44, connection_type);
  185. _mav_put_uint8_t(buf, 45, info);
  186. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  187. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  188. _mav_put_int16_t_array(buf, 34, temperature, 4);
  189. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_INFO_LEN);
  190. #else
  191. mavlink_esc_info_t packet;
  192. packet.time_usec = time_usec;
  193. packet.counter = counter;
  194. packet.index = index;
  195. packet.count = count;
  196. packet.connection_type = connection_type;
  197. packet.info = info;
  198. mav_array_memcpy(packet.error_count, error_count, sizeof(uint32_t)*4);
  199. mav_array_memcpy(packet.failure_flags, failure_flags, sizeof(uint16_t)*4);
  200. mav_array_memcpy(packet.temperature, temperature, sizeof(int16_t)*4);
  201. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_INFO_LEN);
  202. #endif
  203. msg->msgid = MAVLINK_MSG_ID_ESC_INFO;
  204. 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);
  205. }
  206. /**
  207. * @brief Encode a esc_info struct
  208. *
  209. * @param system_id ID of this system
  210. * @param component_id ID of this component (e.g. 200 for IMU)
  211. * @param msg The MAVLink message to compress the data into
  212. * @param esc_info C-struct to read the message contents from
  213. */
  214. 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)
  215. {
  216. 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);
  217. }
  218. /**
  219. * @brief Encode a esc_info struct on a channel
  220. *
  221. * @param system_id ID of this system
  222. * @param component_id ID of this component (e.g. 200 for IMU)
  223. * @param chan The MAVLink channel this message will be sent over
  224. * @param msg The MAVLink message to compress the data into
  225. * @param esc_info C-struct to read the message contents from
  226. */
  227. 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)
  228. {
  229. 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);
  230. }
  231. /**
  232. * @brief Encode a esc_info struct with provided status structure
  233. *
  234. * @param system_id ID of this system
  235. * @param component_id ID of this component (e.g. 200 for IMU)
  236. * @param status MAVLink status structure
  237. * @param msg The MAVLink message to compress the data into
  238. * @param esc_info C-struct to read the message contents from
  239. */
  240. 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)
  241. {
  242. 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);
  243. }
  244. /**
  245. * @brief Send a esc_info message
  246. * @param chan MAVLink channel to send the message
  247. *
  248. * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
  249. * @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.
  250. * @param counter Counter of data packets received.
  251. * @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.
  252. * @param connection_type Connection type protocol for all ESC.
  253. * @param info Information regarding online/offline status of each ESC.
  254. * @param failure_flags Bitmap of ESC failure flags.
  255. * @param error_count Number of reported errors by each ESC since boot.
  256. * @param temperature [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.
  257. */
  258. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  259. 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)
  260. {
  261. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  262. char buf[MAVLINK_MSG_ID_ESC_INFO_LEN];
  263. _mav_put_uint64_t(buf, 0, time_usec);
  264. _mav_put_uint16_t(buf, 24, counter);
  265. _mav_put_uint8_t(buf, 42, index);
  266. _mav_put_uint8_t(buf, 43, count);
  267. _mav_put_uint8_t(buf, 44, connection_type);
  268. _mav_put_uint8_t(buf, 45, info);
  269. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  270. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  271. _mav_put_int16_t_array(buf, 34, temperature, 4);
  272. _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);
  273. #else
  274. mavlink_esc_info_t packet;
  275. packet.time_usec = time_usec;
  276. packet.counter = counter;
  277. packet.index = index;
  278. packet.count = count;
  279. packet.connection_type = connection_type;
  280. packet.info = info;
  281. mav_array_memcpy(packet.error_count, error_count, sizeof(uint32_t)*4);
  282. mav_array_memcpy(packet.failure_flags, failure_flags, sizeof(uint16_t)*4);
  283. mav_array_memcpy(packet.temperature, temperature, sizeof(int16_t)*4);
  284. _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);
  285. #endif
  286. }
  287. /**
  288. * @brief Send a esc_info message
  289. * @param chan MAVLink channel to send the message
  290. * @param struct The MAVLink struct to serialize
  291. */
  292. static inline void mavlink_msg_esc_info_send_struct(mavlink_channel_t chan, const mavlink_esc_info_t* esc_info)
  293. {
  294. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  295. 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);
  296. #else
  297. _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);
  298. #endif
  299. }
  300. #if MAVLINK_MSG_ID_ESC_INFO_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  301. /*
  302. This variant of _send() can be used to save stack space by re-using
  303. memory from the receive buffer. The caller provides a
  304. mavlink_message_t which is the size of a full mavlink message. This
  305. is usually the receive buffer for the channel, and allows a reply to an
  306. incoming message with minimum stack space usage.
  307. */
  308. 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)
  309. {
  310. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  311. char *buf = (char *)msgbuf;
  312. _mav_put_uint64_t(buf, 0, time_usec);
  313. _mav_put_uint16_t(buf, 24, counter);
  314. _mav_put_uint8_t(buf, 42, index);
  315. _mav_put_uint8_t(buf, 43, count);
  316. _mav_put_uint8_t(buf, 44, connection_type);
  317. _mav_put_uint8_t(buf, 45, info);
  318. _mav_put_uint32_t_array(buf, 8, error_count, 4);
  319. _mav_put_uint16_t_array(buf, 26, failure_flags, 4);
  320. _mav_put_int16_t_array(buf, 34, temperature, 4);
  321. _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);
  322. #else
  323. mavlink_esc_info_t *packet = (mavlink_esc_info_t *)msgbuf;
  324. packet->time_usec = time_usec;
  325. packet->counter = counter;
  326. packet->index = index;
  327. packet->count = count;
  328. packet->connection_type = connection_type;
  329. packet->info = info;
  330. mav_array_memcpy(packet->error_count, error_count, sizeof(uint32_t)*4);
  331. mav_array_memcpy(packet->failure_flags, failure_flags, sizeof(uint16_t)*4);
  332. mav_array_memcpy(packet->temperature, temperature, sizeof(int16_t)*4);
  333. _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);
  334. #endif
  335. }
  336. #endif
  337. #endif
  338. // MESSAGE ESC_INFO UNPACKING
  339. /**
  340. * @brief Get field index from esc_info message
  341. *
  342. * @return Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
  343. */
  344. static inline uint8_t mavlink_msg_esc_info_get_index(const mavlink_message_t* msg)
  345. {
  346. return _MAV_RETURN_uint8_t(msg, 42);
  347. }
  348. /**
  349. * @brief Get field time_usec from esc_info message
  350. *
  351. * @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.
  352. */
  353. static inline uint64_t mavlink_msg_esc_info_get_time_usec(const mavlink_message_t* msg)
  354. {
  355. return _MAV_RETURN_uint64_t(msg, 0);
  356. }
  357. /**
  358. * @brief Get field counter from esc_info message
  359. *
  360. * @return Counter of data packets received.
  361. */
  362. static inline uint16_t mavlink_msg_esc_info_get_counter(const mavlink_message_t* msg)
  363. {
  364. return _MAV_RETURN_uint16_t(msg, 24);
  365. }
  366. /**
  367. * @brief Get field count from esc_info message
  368. *
  369. * @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.
  370. */
  371. static inline uint8_t mavlink_msg_esc_info_get_count(const mavlink_message_t* msg)
  372. {
  373. return _MAV_RETURN_uint8_t(msg, 43);
  374. }
  375. /**
  376. * @brief Get field connection_type from esc_info message
  377. *
  378. * @return Connection type protocol for all ESC.
  379. */
  380. static inline uint8_t mavlink_msg_esc_info_get_connection_type(const mavlink_message_t* msg)
  381. {
  382. return _MAV_RETURN_uint8_t(msg, 44);
  383. }
  384. /**
  385. * @brief Get field info from esc_info message
  386. *
  387. * @return Information regarding online/offline status of each ESC.
  388. */
  389. static inline uint8_t mavlink_msg_esc_info_get_info(const mavlink_message_t* msg)
  390. {
  391. return _MAV_RETURN_uint8_t(msg, 45);
  392. }
  393. /**
  394. * @brief Get field failure_flags from esc_info message
  395. *
  396. * @return Bitmap of ESC failure flags.
  397. */
  398. static inline uint16_t mavlink_msg_esc_info_get_failure_flags(const mavlink_message_t* msg, uint16_t *failure_flags)
  399. {
  400. return _MAV_RETURN_uint16_t_array(msg, failure_flags, 4, 26);
  401. }
  402. /**
  403. * @brief Get field error_count from esc_info message
  404. *
  405. * @return Number of reported errors by each ESC since boot.
  406. */
  407. static inline uint16_t mavlink_msg_esc_info_get_error_count(const mavlink_message_t* msg, uint32_t *error_count)
  408. {
  409. return _MAV_RETURN_uint32_t_array(msg, error_count, 4, 8);
  410. }
  411. /**
  412. * @brief Get field temperature from esc_info message
  413. *
  414. * @return [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC.
  415. */
  416. static inline uint16_t mavlink_msg_esc_info_get_temperature(const mavlink_message_t* msg, int16_t *temperature)
  417. {
  418. return _MAV_RETURN_int16_t_array(msg, temperature, 4, 34);
  419. }
  420. /**
  421. * @brief Decode a esc_info message into a struct
  422. *
  423. * @param msg The message to decode
  424. * @param esc_info C-struct to decode the message contents into
  425. */
  426. static inline void mavlink_msg_esc_info_decode(const mavlink_message_t* msg, mavlink_esc_info_t* esc_info)
  427. {
  428. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  429. esc_info->time_usec = mavlink_msg_esc_info_get_time_usec(msg);
  430. mavlink_msg_esc_info_get_error_count(msg, esc_info->error_count);
  431. esc_info->counter = mavlink_msg_esc_info_get_counter(msg);
  432. mavlink_msg_esc_info_get_failure_flags(msg, esc_info->failure_flags);
  433. mavlink_msg_esc_info_get_temperature(msg, esc_info->temperature);
  434. esc_info->index = mavlink_msg_esc_info_get_index(msg);
  435. esc_info->count = mavlink_msg_esc_info_get_count(msg);
  436. esc_info->connection_type = mavlink_msg_esc_info_get_connection_type(msg);
  437. esc_info->info = mavlink_msg_esc_info_get_info(msg);
  438. #else
  439. uint8_t len = msg->len < MAVLINK_MSG_ID_ESC_INFO_LEN? msg->len : MAVLINK_MSG_ID_ESC_INFO_LEN;
  440. memset(esc_info, 0, MAVLINK_MSG_ID_ESC_INFO_LEN);
  441. memcpy(esc_info, _MAV_PAYLOAD(msg), len);
  442. #endif
  443. }