mavlink_msg_generator_status.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. #pragma once
  2. // MESSAGE GENERATOR_STATUS PACKING
  3. #define MAVLINK_MSG_ID_GENERATOR_STATUS 373
  4. typedef struct __mavlink_generator_status_t {
  5. uint64_t status; /*< Status flags.*/
  6. float battery_current; /*< [A] Current into/out of battery. Positive for out. Negative for in. NaN: field not provided.*/
  7. float load_current; /*< [A] Current going to the UAV. If battery current not available this is the DC current from the generator. Positive for out. Negative for in. NaN: field not provided*/
  8. float power_generated; /*< [W] The power being generated. NaN: field not provided*/
  9. float bus_voltage; /*< [V] Voltage of the bus seen at the generator, or battery bus if battery bus is controlled by generator and at a different voltage to main bus.*/
  10. float bat_current_setpoint; /*< [A] The target battery current. Positive for out. Negative for in. NaN: field not provided*/
  11. uint32_t runtime; /*< [s] Seconds this generator has run since it was rebooted. UINT32_MAX: field not provided.*/
  12. int32_t time_until_maintenance; /*< [s] Seconds until this generator requires maintenance. A negative value indicates maintenance is past-due. INT32_MAX: field not provided.*/
  13. uint16_t generator_speed; /*< [rpm] Speed of electrical generator or alternator. UINT16_MAX: field not provided.*/
  14. int16_t rectifier_temperature; /*< [degC] The temperature of the rectifier or power converter. INT16_MAX: field not provided.*/
  15. int16_t generator_temperature; /*< [degC] The temperature of the mechanical motor, fuel cell core or generator. INT16_MAX: field not provided.*/
  16. } mavlink_generator_status_t;
  17. #define MAVLINK_MSG_ID_GENERATOR_STATUS_LEN 42
  18. #define MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN 42
  19. #define MAVLINK_MSG_ID_373_LEN 42
  20. #define MAVLINK_MSG_ID_373_MIN_LEN 42
  21. #define MAVLINK_MSG_ID_GENERATOR_STATUS_CRC 117
  22. #define MAVLINK_MSG_ID_373_CRC 117
  23. #if MAVLINK_COMMAND_24BIT
  24. #define MAVLINK_MESSAGE_INFO_GENERATOR_STATUS { \
  25. 373, \
  26. "GENERATOR_STATUS", \
  27. 11, \
  28. { { "status", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_generator_status_t, status) }, \
  29. { "generator_speed", NULL, MAVLINK_TYPE_UINT16_T, 0, 36, offsetof(mavlink_generator_status_t, generator_speed) }, \
  30. { "battery_current", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_generator_status_t, battery_current) }, \
  31. { "load_current", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_generator_status_t, load_current) }, \
  32. { "power_generated", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_generator_status_t, power_generated) }, \
  33. { "bus_voltage", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_generator_status_t, bus_voltage) }, \
  34. { "rectifier_temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 38, offsetof(mavlink_generator_status_t, rectifier_temperature) }, \
  35. { "bat_current_setpoint", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_generator_status_t, bat_current_setpoint) }, \
  36. { "generator_temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 40, offsetof(mavlink_generator_status_t, generator_temperature) }, \
  37. { "runtime", NULL, MAVLINK_TYPE_UINT32_T, 0, 28, offsetof(mavlink_generator_status_t, runtime) }, \
  38. { "time_until_maintenance", NULL, MAVLINK_TYPE_INT32_T, 0, 32, offsetof(mavlink_generator_status_t, time_until_maintenance) }, \
  39. } \
  40. }
  41. #else
  42. #define MAVLINK_MESSAGE_INFO_GENERATOR_STATUS { \
  43. "GENERATOR_STATUS", \
  44. 11, \
  45. { { "status", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_generator_status_t, status) }, \
  46. { "generator_speed", NULL, MAVLINK_TYPE_UINT16_T, 0, 36, offsetof(mavlink_generator_status_t, generator_speed) }, \
  47. { "battery_current", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_generator_status_t, battery_current) }, \
  48. { "load_current", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_generator_status_t, load_current) }, \
  49. { "power_generated", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_generator_status_t, power_generated) }, \
  50. { "bus_voltage", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_generator_status_t, bus_voltage) }, \
  51. { "rectifier_temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 38, offsetof(mavlink_generator_status_t, rectifier_temperature) }, \
  52. { "bat_current_setpoint", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_generator_status_t, bat_current_setpoint) }, \
  53. { "generator_temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 40, offsetof(mavlink_generator_status_t, generator_temperature) }, \
  54. { "runtime", NULL, MAVLINK_TYPE_UINT32_T, 0, 28, offsetof(mavlink_generator_status_t, runtime) }, \
  55. { "time_until_maintenance", NULL, MAVLINK_TYPE_INT32_T, 0, 32, offsetof(mavlink_generator_status_t, time_until_maintenance) }, \
  56. } \
  57. }
  58. #endif
  59. /**
  60. * @brief Pack a generator_status message
  61. * @param system_id ID of this system
  62. * @param component_id ID of this component (e.g. 200 for IMU)
  63. * @param msg The MAVLink message to compress the data into
  64. *
  65. * @param status Status flags.
  66. * @param generator_speed [rpm] Speed of electrical generator or alternator. UINT16_MAX: field not provided.
  67. * @param battery_current [A] Current into/out of battery. Positive for out. Negative for in. NaN: field not provided.
  68. * @param load_current [A] Current going to the UAV. If battery current not available this is the DC current from the generator. Positive for out. Negative for in. NaN: field not provided
  69. * @param power_generated [W] The power being generated. NaN: field not provided
  70. * @param bus_voltage [V] Voltage of the bus seen at the generator, or battery bus if battery bus is controlled by generator and at a different voltage to main bus.
  71. * @param rectifier_temperature [degC] The temperature of the rectifier or power converter. INT16_MAX: field not provided.
  72. * @param bat_current_setpoint [A] The target battery current. Positive for out. Negative for in. NaN: field not provided
  73. * @param generator_temperature [degC] The temperature of the mechanical motor, fuel cell core or generator. INT16_MAX: field not provided.
  74. * @param runtime [s] Seconds this generator has run since it was rebooted. UINT32_MAX: field not provided.
  75. * @param time_until_maintenance [s] Seconds until this generator requires maintenance. A negative value indicates maintenance is past-due. INT32_MAX: field not provided.
  76. * @return length of the message in bytes (excluding serial stream start sign)
  77. */
  78. static inline uint16_t mavlink_msg_generator_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  79. uint64_t status, uint16_t generator_speed, float battery_current, float load_current, float power_generated, float bus_voltage, int16_t rectifier_temperature, float bat_current_setpoint, int16_t generator_temperature, uint32_t runtime, int32_t time_until_maintenance)
  80. {
  81. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  82. char buf[MAVLINK_MSG_ID_GENERATOR_STATUS_LEN];
  83. _mav_put_uint64_t(buf, 0, status);
  84. _mav_put_float(buf, 8, battery_current);
  85. _mav_put_float(buf, 12, load_current);
  86. _mav_put_float(buf, 16, power_generated);
  87. _mav_put_float(buf, 20, bus_voltage);
  88. _mav_put_float(buf, 24, bat_current_setpoint);
  89. _mav_put_uint32_t(buf, 28, runtime);
  90. _mav_put_int32_t(buf, 32, time_until_maintenance);
  91. _mav_put_uint16_t(buf, 36, generator_speed);
  92. _mav_put_int16_t(buf, 38, rectifier_temperature);
  93. _mav_put_int16_t(buf, 40, generator_temperature);
  94. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN);
  95. #else
  96. mavlink_generator_status_t packet;
  97. packet.status = status;
  98. packet.battery_current = battery_current;
  99. packet.load_current = load_current;
  100. packet.power_generated = power_generated;
  101. packet.bus_voltage = bus_voltage;
  102. packet.bat_current_setpoint = bat_current_setpoint;
  103. packet.runtime = runtime;
  104. packet.time_until_maintenance = time_until_maintenance;
  105. packet.generator_speed = generator_speed;
  106. packet.rectifier_temperature = rectifier_temperature;
  107. packet.generator_temperature = generator_temperature;
  108. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN);
  109. #endif
  110. msg->msgid = MAVLINK_MSG_ID_GENERATOR_STATUS;
  111. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_CRC);
  112. }
  113. /**
  114. * @brief Pack a generator_status message on a channel
  115. * @param system_id ID of this system
  116. * @param component_id ID of this component (e.g. 200 for IMU)
  117. * @param chan The MAVLink channel this message will be sent over
  118. * @param msg The MAVLink message to compress the data into
  119. * @param status Status flags.
  120. * @param generator_speed [rpm] Speed of electrical generator or alternator. UINT16_MAX: field not provided.
  121. * @param battery_current [A] Current into/out of battery. Positive for out. Negative for in. NaN: field not provided.
  122. * @param load_current [A] Current going to the UAV. If battery current not available this is the DC current from the generator. Positive for out. Negative for in. NaN: field not provided
  123. * @param power_generated [W] The power being generated. NaN: field not provided
  124. * @param bus_voltage [V] Voltage of the bus seen at the generator, or battery bus if battery bus is controlled by generator and at a different voltage to main bus.
  125. * @param rectifier_temperature [degC] The temperature of the rectifier or power converter. INT16_MAX: field not provided.
  126. * @param bat_current_setpoint [A] The target battery current. Positive for out. Negative for in. NaN: field not provided
  127. * @param generator_temperature [degC] The temperature of the mechanical motor, fuel cell core or generator. INT16_MAX: field not provided.
  128. * @param runtime [s] Seconds this generator has run since it was rebooted. UINT32_MAX: field not provided.
  129. * @param time_until_maintenance [s] Seconds until this generator requires maintenance. A negative value indicates maintenance is past-due. INT32_MAX: field not provided.
  130. * @return length of the message in bytes (excluding serial stream start sign)
  131. */
  132. static inline uint16_t mavlink_msg_generator_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  133. mavlink_message_t* msg,
  134. uint64_t status,uint16_t generator_speed,float battery_current,float load_current,float power_generated,float bus_voltage,int16_t rectifier_temperature,float bat_current_setpoint,int16_t generator_temperature,uint32_t runtime,int32_t time_until_maintenance)
  135. {
  136. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  137. char buf[MAVLINK_MSG_ID_GENERATOR_STATUS_LEN];
  138. _mav_put_uint64_t(buf, 0, status);
  139. _mav_put_float(buf, 8, battery_current);
  140. _mav_put_float(buf, 12, load_current);
  141. _mav_put_float(buf, 16, power_generated);
  142. _mav_put_float(buf, 20, bus_voltage);
  143. _mav_put_float(buf, 24, bat_current_setpoint);
  144. _mav_put_uint32_t(buf, 28, runtime);
  145. _mav_put_int32_t(buf, 32, time_until_maintenance);
  146. _mav_put_uint16_t(buf, 36, generator_speed);
  147. _mav_put_int16_t(buf, 38, rectifier_temperature);
  148. _mav_put_int16_t(buf, 40, generator_temperature);
  149. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN);
  150. #else
  151. mavlink_generator_status_t packet;
  152. packet.status = status;
  153. packet.battery_current = battery_current;
  154. packet.load_current = load_current;
  155. packet.power_generated = power_generated;
  156. packet.bus_voltage = bus_voltage;
  157. packet.bat_current_setpoint = bat_current_setpoint;
  158. packet.runtime = runtime;
  159. packet.time_until_maintenance = time_until_maintenance;
  160. packet.generator_speed = generator_speed;
  161. packet.rectifier_temperature = rectifier_temperature;
  162. packet.generator_temperature = generator_temperature;
  163. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN);
  164. #endif
  165. msg->msgid = MAVLINK_MSG_ID_GENERATOR_STATUS;
  166. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_CRC);
  167. }
  168. /**
  169. * @brief Encode a generator_status struct
  170. *
  171. * @param system_id ID of this system
  172. * @param component_id ID of this component (e.g. 200 for IMU)
  173. * @param msg The MAVLink message to compress the data into
  174. * @param generator_status C-struct to read the message contents from
  175. */
  176. static inline uint16_t mavlink_msg_generator_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_generator_status_t* generator_status)
  177. {
  178. return mavlink_msg_generator_status_pack(system_id, component_id, msg, generator_status->status, generator_status->generator_speed, generator_status->battery_current, generator_status->load_current, generator_status->power_generated, generator_status->bus_voltage, generator_status->rectifier_temperature, generator_status->bat_current_setpoint, generator_status->generator_temperature, generator_status->runtime, generator_status->time_until_maintenance);
  179. }
  180. /**
  181. * @brief Encode a generator_status struct on a channel
  182. *
  183. * @param system_id ID of this system
  184. * @param component_id ID of this component (e.g. 200 for IMU)
  185. * @param chan The MAVLink channel this message will be sent over
  186. * @param msg The MAVLink message to compress the data into
  187. * @param generator_status C-struct to read the message contents from
  188. */
  189. static inline uint16_t mavlink_msg_generator_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_generator_status_t* generator_status)
  190. {
  191. return mavlink_msg_generator_status_pack_chan(system_id, component_id, chan, msg, generator_status->status, generator_status->generator_speed, generator_status->battery_current, generator_status->load_current, generator_status->power_generated, generator_status->bus_voltage, generator_status->rectifier_temperature, generator_status->bat_current_setpoint, generator_status->generator_temperature, generator_status->runtime, generator_status->time_until_maintenance);
  192. }
  193. /**
  194. * @brief Send a generator_status message
  195. * @param chan MAVLink channel to send the message
  196. *
  197. * @param status Status flags.
  198. * @param generator_speed [rpm] Speed of electrical generator or alternator. UINT16_MAX: field not provided.
  199. * @param battery_current [A] Current into/out of battery. Positive for out. Negative for in. NaN: field not provided.
  200. * @param load_current [A] Current going to the UAV. If battery current not available this is the DC current from the generator. Positive for out. Negative for in. NaN: field not provided
  201. * @param power_generated [W] The power being generated. NaN: field not provided
  202. * @param bus_voltage [V] Voltage of the bus seen at the generator, or battery bus if battery bus is controlled by generator and at a different voltage to main bus.
  203. * @param rectifier_temperature [degC] The temperature of the rectifier or power converter. INT16_MAX: field not provided.
  204. * @param bat_current_setpoint [A] The target battery current. Positive for out. Negative for in. NaN: field not provided
  205. * @param generator_temperature [degC] The temperature of the mechanical motor, fuel cell core or generator. INT16_MAX: field not provided.
  206. * @param runtime [s] Seconds this generator has run since it was rebooted. UINT32_MAX: field not provided.
  207. * @param time_until_maintenance [s] Seconds until this generator requires maintenance. A negative value indicates maintenance is past-due. INT32_MAX: field not provided.
  208. */
  209. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  210. static inline void mavlink_msg_generator_status_send(mavlink_channel_t chan, uint64_t status, uint16_t generator_speed, float battery_current, float load_current, float power_generated, float bus_voltage, int16_t rectifier_temperature, float bat_current_setpoint, int16_t generator_temperature, uint32_t runtime, int32_t time_until_maintenance)
  211. {
  212. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  213. char buf[MAVLINK_MSG_ID_GENERATOR_STATUS_LEN];
  214. _mav_put_uint64_t(buf, 0, status);
  215. _mav_put_float(buf, 8, battery_current);
  216. _mav_put_float(buf, 12, load_current);
  217. _mav_put_float(buf, 16, power_generated);
  218. _mav_put_float(buf, 20, bus_voltage);
  219. _mav_put_float(buf, 24, bat_current_setpoint);
  220. _mav_put_uint32_t(buf, 28, runtime);
  221. _mav_put_int32_t(buf, 32, time_until_maintenance);
  222. _mav_put_uint16_t(buf, 36, generator_speed);
  223. _mav_put_int16_t(buf, 38, rectifier_temperature);
  224. _mav_put_int16_t(buf, 40, generator_temperature);
  225. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GENERATOR_STATUS, buf, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_CRC);
  226. #else
  227. mavlink_generator_status_t packet;
  228. packet.status = status;
  229. packet.battery_current = battery_current;
  230. packet.load_current = load_current;
  231. packet.power_generated = power_generated;
  232. packet.bus_voltage = bus_voltage;
  233. packet.bat_current_setpoint = bat_current_setpoint;
  234. packet.runtime = runtime;
  235. packet.time_until_maintenance = time_until_maintenance;
  236. packet.generator_speed = generator_speed;
  237. packet.rectifier_temperature = rectifier_temperature;
  238. packet.generator_temperature = generator_temperature;
  239. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GENERATOR_STATUS, (const char *)&packet, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_CRC);
  240. #endif
  241. }
  242. /**
  243. * @brief Send a generator_status message
  244. * @param chan MAVLink channel to send the message
  245. * @param struct The MAVLink struct to serialize
  246. */
  247. static inline void mavlink_msg_generator_status_send_struct(mavlink_channel_t chan, const mavlink_generator_status_t* generator_status)
  248. {
  249. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  250. mavlink_msg_generator_status_send(chan, generator_status->status, generator_status->generator_speed, generator_status->battery_current, generator_status->load_current, generator_status->power_generated, generator_status->bus_voltage, generator_status->rectifier_temperature, generator_status->bat_current_setpoint, generator_status->generator_temperature, generator_status->runtime, generator_status->time_until_maintenance);
  251. #else
  252. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GENERATOR_STATUS, (const char *)generator_status, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_CRC);
  253. #endif
  254. }
  255. #if MAVLINK_MSG_ID_GENERATOR_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  256. /*
  257. This variant of _send() can be used to save stack space by re-using
  258. memory from the receive buffer. The caller provides a
  259. mavlink_message_t which is the size of a full mavlink message. This
  260. is usually the receive buffer for the channel, and allows a reply to an
  261. incoming message with minimum stack space usage.
  262. */
  263. static inline void mavlink_msg_generator_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t status, uint16_t generator_speed, float battery_current, float load_current, float power_generated, float bus_voltage, int16_t rectifier_temperature, float bat_current_setpoint, int16_t generator_temperature, uint32_t runtime, int32_t time_until_maintenance)
  264. {
  265. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  266. char *buf = (char *)msgbuf;
  267. _mav_put_uint64_t(buf, 0, status);
  268. _mav_put_float(buf, 8, battery_current);
  269. _mav_put_float(buf, 12, load_current);
  270. _mav_put_float(buf, 16, power_generated);
  271. _mav_put_float(buf, 20, bus_voltage);
  272. _mav_put_float(buf, 24, bat_current_setpoint);
  273. _mav_put_uint32_t(buf, 28, runtime);
  274. _mav_put_int32_t(buf, 32, time_until_maintenance);
  275. _mav_put_uint16_t(buf, 36, generator_speed);
  276. _mav_put_int16_t(buf, 38, rectifier_temperature);
  277. _mav_put_int16_t(buf, 40, generator_temperature);
  278. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GENERATOR_STATUS, buf, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_CRC);
  279. #else
  280. mavlink_generator_status_t *packet = (mavlink_generator_status_t *)msgbuf;
  281. packet->status = status;
  282. packet->battery_current = battery_current;
  283. packet->load_current = load_current;
  284. packet->power_generated = power_generated;
  285. packet->bus_voltage = bus_voltage;
  286. packet->bat_current_setpoint = bat_current_setpoint;
  287. packet->runtime = runtime;
  288. packet->time_until_maintenance = time_until_maintenance;
  289. packet->generator_speed = generator_speed;
  290. packet->rectifier_temperature = rectifier_temperature;
  291. packet->generator_temperature = generator_temperature;
  292. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GENERATOR_STATUS, (const char *)packet, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_CRC);
  293. #endif
  294. }
  295. #endif
  296. #endif
  297. // MESSAGE GENERATOR_STATUS UNPACKING
  298. /**
  299. * @brief Get field status from generator_status message
  300. *
  301. * @return Status flags.
  302. */
  303. static inline uint64_t mavlink_msg_generator_status_get_status(const mavlink_message_t* msg)
  304. {
  305. return _MAV_RETURN_uint64_t(msg, 0);
  306. }
  307. /**
  308. * @brief Get field generator_speed from generator_status message
  309. *
  310. * @return [rpm] Speed of electrical generator or alternator. UINT16_MAX: field not provided.
  311. */
  312. static inline uint16_t mavlink_msg_generator_status_get_generator_speed(const mavlink_message_t* msg)
  313. {
  314. return _MAV_RETURN_uint16_t(msg, 36);
  315. }
  316. /**
  317. * @brief Get field battery_current from generator_status message
  318. *
  319. * @return [A] Current into/out of battery. Positive for out. Negative for in. NaN: field not provided.
  320. */
  321. static inline float mavlink_msg_generator_status_get_battery_current(const mavlink_message_t* msg)
  322. {
  323. return _MAV_RETURN_float(msg, 8);
  324. }
  325. /**
  326. * @brief Get field load_current from generator_status message
  327. *
  328. * @return [A] Current going to the UAV. If battery current not available this is the DC current from the generator. Positive for out. Negative for in. NaN: field not provided
  329. */
  330. static inline float mavlink_msg_generator_status_get_load_current(const mavlink_message_t* msg)
  331. {
  332. return _MAV_RETURN_float(msg, 12);
  333. }
  334. /**
  335. * @brief Get field power_generated from generator_status message
  336. *
  337. * @return [W] The power being generated. NaN: field not provided
  338. */
  339. static inline float mavlink_msg_generator_status_get_power_generated(const mavlink_message_t* msg)
  340. {
  341. return _MAV_RETURN_float(msg, 16);
  342. }
  343. /**
  344. * @brief Get field bus_voltage from generator_status message
  345. *
  346. * @return [V] Voltage of the bus seen at the generator, or battery bus if battery bus is controlled by generator and at a different voltage to main bus.
  347. */
  348. static inline float mavlink_msg_generator_status_get_bus_voltage(const mavlink_message_t* msg)
  349. {
  350. return _MAV_RETURN_float(msg, 20);
  351. }
  352. /**
  353. * @brief Get field rectifier_temperature from generator_status message
  354. *
  355. * @return [degC] The temperature of the rectifier or power converter. INT16_MAX: field not provided.
  356. */
  357. static inline int16_t mavlink_msg_generator_status_get_rectifier_temperature(const mavlink_message_t* msg)
  358. {
  359. return _MAV_RETURN_int16_t(msg, 38);
  360. }
  361. /**
  362. * @brief Get field bat_current_setpoint from generator_status message
  363. *
  364. * @return [A] The target battery current. Positive for out. Negative for in. NaN: field not provided
  365. */
  366. static inline float mavlink_msg_generator_status_get_bat_current_setpoint(const mavlink_message_t* msg)
  367. {
  368. return _MAV_RETURN_float(msg, 24);
  369. }
  370. /**
  371. * @brief Get field generator_temperature from generator_status message
  372. *
  373. * @return [degC] The temperature of the mechanical motor, fuel cell core or generator. INT16_MAX: field not provided.
  374. */
  375. static inline int16_t mavlink_msg_generator_status_get_generator_temperature(const mavlink_message_t* msg)
  376. {
  377. return _MAV_RETURN_int16_t(msg, 40);
  378. }
  379. /**
  380. * @brief Get field runtime from generator_status message
  381. *
  382. * @return [s] Seconds this generator has run since it was rebooted. UINT32_MAX: field not provided.
  383. */
  384. static inline uint32_t mavlink_msg_generator_status_get_runtime(const mavlink_message_t* msg)
  385. {
  386. return _MAV_RETURN_uint32_t(msg, 28);
  387. }
  388. /**
  389. * @brief Get field time_until_maintenance from generator_status message
  390. *
  391. * @return [s] Seconds until this generator requires maintenance. A negative value indicates maintenance is past-due. INT32_MAX: field not provided.
  392. */
  393. static inline int32_t mavlink_msg_generator_status_get_time_until_maintenance(const mavlink_message_t* msg)
  394. {
  395. return _MAV_RETURN_int32_t(msg, 32);
  396. }
  397. /**
  398. * @brief Decode a generator_status message into a struct
  399. *
  400. * @param msg The message to decode
  401. * @param generator_status C-struct to decode the message contents into
  402. */
  403. static inline void mavlink_msg_generator_status_decode(const mavlink_message_t* msg, mavlink_generator_status_t* generator_status)
  404. {
  405. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  406. generator_status->status = mavlink_msg_generator_status_get_status(msg);
  407. generator_status->battery_current = mavlink_msg_generator_status_get_battery_current(msg);
  408. generator_status->load_current = mavlink_msg_generator_status_get_load_current(msg);
  409. generator_status->power_generated = mavlink_msg_generator_status_get_power_generated(msg);
  410. generator_status->bus_voltage = mavlink_msg_generator_status_get_bus_voltage(msg);
  411. generator_status->bat_current_setpoint = mavlink_msg_generator_status_get_bat_current_setpoint(msg);
  412. generator_status->runtime = mavlink_msg_generator_status_get_runtime(msg);
  413. generator_status->time_until_maintenance = mavlink_msg_generator_status_get_time_until_maintenance(msg);
  414. generator_status->generator_speed = mavlink_msg_generator_status_get_generator_speed(msg);
  415. generator_status->rectifier_temperature = mavlink_msg_generator_status_get_rectifier_temperature(msg);
  416. generator_status->generator_temperature = mavlink_msg_generator_status_get_generator_temperature(msg);
  417. #else
  418. uint8_t len = msg->len < MAVLINK_MSG_ID_GENERATOR_STATUS_LEN? msg->len : MAVLINK_MSG_ID_GENERATOR_STATUS_LEN;
  419. memset(generator_status, 0, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN);
  420. memcpy(generator_status, _MAV_PAYLOAD(msg), len);
  421. #endif
  422. }