aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-05-12 22:57:07 +0200
committerLorenz Meier <lm@inf.ethz.ch>2014-05-12 22:57:07 +0200
commite09c0dd8b9a3275d13fd8069e381bf2c32820236 (patch)
tree0c80656b06fa462abb53a209e590d2103279deb3
parent29ffb3bad34f146a553423d8a871669bbd91c2b6 (diff)
downloadpx4-firmware-e09c0dd8b9a3275d13fd8069e381bf2c32820236.tar.gz
px4-firmware-e09c0dd8b9a3275d13fd8069e381bf2c32820236.tar.bz2
px4-firmware-e09c0dd8b9a3275d13fd8069e381bf2c32820236.zip
Reduce RAM footprint of HoTT driver, fix publication to contain ESC data
-rw-r--r--src/drivers/hott/messages.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/drivers/hott/messages.cpp b/src/drivers/hott/messages.cpp
index 90a744015..fe8ad6a9e 100644
--- a/src/drivers/hott/messages.cpp
+++ b/src/drivers/hott/messages.cpp
@@ -62,7 +62,6 @@ static int _airspeed_sub = -1;
static int _esc_sub = -1;
static orb_advert_t _esc_pub;
-struct esc_status_s _esc;
static bool _home_position_set = false;
static double _home_lat = 0.0d;
@@ -82,8 +81,6 @@ init_sub_messages(void)
void
init_pub_messages(void)
{
- memset(&_esc, 0, sizeof(_esc));
- _esc_pub = orb_advertise(ORB_ID(esc_status), &_esc);
}
void
@@ -106,13 +103,8 @@ publish_gam_message(const uint8_t *buffer)
size_t size = sizeof(msg);
memset(&msg, 0, size);
memcpy(&msg, buffer, size);
-
- /* announce the esc if needed, just publish else */
- if (_esc_pub > 0) {
- orb_publish(ORB_ID(esc_status), _esc_pub, &_esc);
- } else {
- _esc_pub = orb_advertise(ORB_ID(esc_status), &_esc);
- }
+ struct esc_status_s _esc;
+ memset(&_esc, 0, sizeof(_esc));
// Publish it.
_esc.esc_count = 1;
@@ -123,6 +115,13 @@ publish_gam_message(const uint8_t *buffer)
_esc.esc[0].esc_temperature = msg.temperature1 - 20;
_esc.esc[0].esc_voltage = (uint16_t)((msg.main_voltage_H << 8) | (msg.main_voltage_L & 0xff));
_esc.esc[0].esc_current = (uint16_t)((msg.current_H << 8) | (msg.current_L & 0xff));
+
+ /* announce the esc if needed, just publish else */
+ if (_esc_pub > 0) {
+ orb_publish(ORB_ID(esc_status), _esc_pub, &_esc);
+ } else {
+ _esc_pub = orb_advertise(ORB_ID(esc_status), &_esc);
+ }
}
void