diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2012-08-22 08:56:33 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2012-08-22 08:56:33 +0200 |
commit | 72979032e9bfef200809e97663c613b7b530b011 (patch) | |
tree | dc47df0ecf27a101f520d6fc422a6d84f011f1ab /apps/drivers/ms5611/ms5611.cpp | |
parent | d17bbc7a0bdc30302df0001ddad91733064d3d11 (diff) | |
parent | 88f0080a0ffb299006950c0453eabddb7d17f078 (diff) | |
download | px4-firmware-72979032e9bfef200809e97663c613b7b530b011.tar.gz px4-firmware-72979032e9bfef200809e97663c613b7b530b011.tar.bz2 px4-firmware-72979032e9bfef200809e97663c613b7b530b011.zip |
Merge branch 'master' into px4dev_new_param
Diffstat (limited to 'apps/drivers/ms5611/ms5611.cpp')
-rw-r--r-- | apps/drivers/ms5611/ms5611.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/apps/drivers/ms5611/ms5611.cpp b/apps/drivers/ms5611/ms5611.cpp index 6c6951d9b..8f8f96217 100644 --- a/apps/drivers/ms5611/ms5611.cpp +++ b/apps/drivers/ms5611/ms5611.cpp @@ -125,7 +125,7 @@ private: int32_t _dT; int64_t _temp64; - int _baro_topic; + orb_advert_t _baro_topic; unsigned _reads; unsigned _measure_errors; @@ -246,6 +246,7 @@ MS5611::MS5611(int bus) : _measure_phase(0), _dT(0), _temp64(0), + _baro_topic(-1), _reads(0), _measure_errors(0), _read_errors(0), @@ -277,18 +278,6 @@ MS5611::init() /* do I2C init (and probe) first */ ret = I2C::init(); - /* assuming we're good, advertise the object */ - if (ret == OK) { - struct baro_report b; - - /* if this fails (e.g. no object in the system) that's OK */ - memset(&b, 0, sizeof(b)); - _baro_topic = orb_advertise(ORB_ID(sensor_baro), &b); - - if (_baro_topic < 0) - debug("failed to create sensor_baro object"); - } - return ret; } @@ -538,6 +527,25 @@ MS5611::cycle_trampoline(void *arg) void MS5611::cycle() { + /* + * We have to publish the baro topic in the context of the workq + * in order to ensure that the descriptor is valid when we go to publish. + * + * @bug We can't really ever be torn down and restarted, since this + * descriptor will never be closed and on the restart we will be + * unable to re-advertise. + */ + if (_baro_topic == -1) { + struct baro_report b; + + /* if this fails (e.g. no object in the system) we will cope */ + memset(&b, 0, sizeof(b)); + _baro_topic = orb_advertise(ORB_ID(sensor_baro), &b); + + if (_baro_topic < 0) + debug("failed to create sensor_baro object"); + } + /* collection phase? */ if (_collect_phase) { |