aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/hmc5883
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-01-12 11:53:56 +0100
committerLorenz Meier <lm@inf.ethz.ch>2014-01-12 11:53:56 +0100
commit28a3dc726f8e4f3696736798a1d92bf7d9de6100 (patch)
treed7974f0d221e070a4d12dc62ff701c63d4fb7706 /src/drivers/hmc5883
parentc7e2841baa98bb985b402c89bef85e56f765ec11 (diff)
downloadpx4-firmware-28a3dc726f8e4f3696736798a1d92bf7d9de6100.tar.gz
px4-firmware-28a3dc726f8e4f3696736798a1d92bf7d9de6100.tar.bz2
px4-firmware-28a3dc726f8e4f3696736798a1d92bf7d9de6100.zip
Support for publication blocking: HMC5883
Diffstat (limited to 'src/drivers/hmc5883')
-rw-r--r--src/drivers/hmc5883/hmc5883.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/drivers/hmc5883/hmc5883.cpp b/src/drivers/hmc5883/hmc5883.cpp
index d3b99ae66..49b72cf79 100644
--- a/src/drivers/hmc5883/hmc5883.cpp
+++ b/src/drivers/hmc5883/hmc5883.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
*
- * Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved.
+ * Copyright (c) 2012-2014 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -381,16 +381,6 @@ HMC5883::init()
reset();
_class_instance = register_class_devname(MAG_DEVICE_PATH);
- if (_class_instance == CLASS_DEVICE_PRIMARY) {
- /* get a publish handle on the mag topic if we are
- * the primary mag */
- struct mag_report zero_report;
- memset(&zero_report, 0, sizeof(zero_report));
- _mag_topic = orb_advertise(ORB_ID(sensor_mag), &zero_report);
-
- if (_mag_topic < 0)
- debug("failed to create sensor_mag object");
- }
ret = OK;
/* sensor is ok, but not calibrated */
@@ -885,9 +875,18 @@ HMC5883::collect()
}
#endif
- if (_mag_topic != -1) {
- /* publish it */
- orb_publish(ORB_ID(sensor_mag), _mag_topic, &new_report);
+ if (_class_instance == CLASS_DEVICE_PRIMARY && !(_pub_blocked)) {
+
+ if (_mag_topic != -1) {
+ /* publish it */
+ orb_publish(ORB_ID(sensor_mag), _mag_topic, &new_report);
+ } else {
+ _mag_topic = orb_advertise(ORB_ID(sensor_mag), &new_report);
+
+ if (_mag_topic < 0)
+ debug("failed to create sensor_mag publication");
+ }
+
}
/* post a report to the ring */
@@ -1134,10 +1133,12 @@ int HMC5883::check_calibration()
SUBSYSTEM_TYPE_MAG};
static orb_advert_t pub = -1;
- if (pub > 0) {
- orb_publish(ORB_ID(subsystem_info), pub, &info);
- } else {
- pub = orb_advertise(ORB_ID(subsystem_info), &info);
+ if (!(_pub_blocked)) {
+ if (pub > 0) {
+ orb_publish(ORB_ID(subsystem_info), pub, &info);
+ } else {
+ pub = orb_advertise(ORB_ID(subsystem_info), &info);
+ }
}
}