mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
differential_pressure drivers update orb_publish usage to uORB::PublicationMulti<>
This commit is contained in:
@@ -124,7 +124,7 @@ ETSAirspeed::collect()
|
||||
|
||||
float diff_pres_pa_raw = (float)(val[1] << 8 | val[0]);
|
||||
|
||||
differential_pressure_s report;
|
||||
differential_pressure_s report{};
|
||||
report.timestamp = hrt_absolute_time();
|
||||
|
||||
if (diff_pres_pa_raw < FLT_EPSILON) {
|
||||
@@ -147,10 +147,7 @@ ETSAirspeed::collect()
|
||||
report.temperature = -1000.0f;
|
||||
report.device_id = _device_id.devid;
|
||||
|
||||
if (_airspeed_pub != nullptr && !(_pub_blocked)) {
|
||||
/* publish it */
|
||||
orb_publish(ORB_ID(differential_pressure), _airspeed_pub, &report);
|
||||
}
|
||||
_airspeed_pub.publish(report);
|
||||
|
||||
ret = OK;
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ MEASAirspeed::collect()
|
||||
and bottom port is used as the static port
|
||||
*/
|
||||
|
||||
struct differential_pressure_s report;
|
||||
differential_pressure_s report{};
|
||||
|
||||
report.timestamp = hrt_absolute_time();
|
||||
report.error_count = perf_event_count(_comms_errors);
|
||||
@@ -211,10 +211,7 @@ MEASAirspeed::collect()
|
||||
report.differential_pressure_raw_pa = diff_press_pa_raw - _diff_pres_offset;
|
||||
report.device_id = _device_id.devid;
|
||||
|
||||
if (_airspeed_pub != nullptr && !(_pub_blocked)) {
|
||||
/* publish it */
|
||||
orb_publish(ORB_ID(differential_pressure), _airspeed_pub, &report);
|
||||
}
|
||||
_airspeed_pub.publish(report);
|
||||
|
||||
ret = OK;
|
||||
|
||||
|
||||
@@ -259,10 +259,7 @@ MS5525::collect()
|
||||
.device_id = _device_id.devid
|
||||
};
|
||||
|
||||
if (_airspeed_pub != nullptr && !(_pub_blocked)) {
|
||||
/* publish it */
|
||||
orb_publish(ORB_ID(differential_pressure), _airspeed_pub, &diff_pressure);
|
||||
}
|
||||
_airspeed_pub.publish(diff_pressure);
|
||||
|
||||
ret = OK;
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ SDP3X::collect()
|
||||
float diff_press_pa_raw = static_cast<float>(P) / static_cast<float>(_scale);
|
||||
float temperature_c = temp / static_cast<float>(SDP3X_SCALE_TEMPERATURE);
|
||||
|
||||
differential_pressure_s report;
|
||||
differential_pressure_s report{};
|
||||
|
||||
report.timestamp = hrt_absolute_time();
|
||||
report.error_count = perf_event_count(_comms_errors);
|
||||
@@ -156,9 +156,7 @@ SDP3X::collect()
|
||||
report.differential_pressure_raw_pa = diff_press_pa_raw - _diff_pres_offset;
|
||||
report.device_id = _device_id.devid;
|
||||
|
||||
if (_airspeed_pub != nullptr && !(_pub_blocked)) {
|
||||
orb_publish(ORB_ID(differential_pressure), _airspeed_pub, &report);
|
||||
}
|
||||
_airspeed_pub.publish(report);
|
||||
|
||||
ret = OK;
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ Airspeed::Airspeed(int bus, int address, unsigned conversion_interval, const cha
|
||||
_measure_interval(0),
|
||||
_collect_phase(false),
|
||||
_diff_pres_offset(0.0f),
|
||||
_airspeed_pub(nullptr),
|
||||
_airspeed_orb_class_instance(-1),
|
||||
_class_instance(-1),
|
||||
_conversion_interval(conversion_interval),
|
||||
@@ -81,8 +80,6 @@ Airspeed::~Airspeed()
|
||||
unregister_class_devname(AIRSPEED_BASE_DEVICE_PATH, _class_instance);
|
||||
}
|
||||
|
||||
orb_unadvertise(_airspeed_pub);
|
||||
|
||||
// free perf counters
|
||||
perf_free(_sample_perf);
|
||||
perf_free(_comms_errors);
|
||||
@@ -101,15 +98,6 @@ Airspeed::init()
|
||||
|
||||
/* advertise sensor topic, measure manually to initialize valid report */
|
||||
measure();
|
||||
differential_pressure_s arp = {};
|
||||
|
||||
/* measurement will have generated a report, publish */
|
||||
_airspeed_pub = orb_advertise_multi(ORB_ID(differential_pressure), &arp, &_airspeed_orb_class_instance,
|
||||
ORB_PRIO_HIGH - _class_instance);
|
||||
|
||||
if (_airspeed_pub == nullptr) {
|
||||
PX4_WARN("uORB started?");
|
||||
}
|
||||
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <perf/perf_counter.h>
|
||||
#include <uORB/topics/differential_pressure.h>
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/PublicationMulti.hpp>
|
||||
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
|
||||
|
||||
/* Default I2C bus */
|
||||
@@ -78,7 +78,8 @@ protected:
|
||||
bool _collect_phase;
|
||||
float _diff_pres_offset;
|
||||
|
||||
orb_advert_t _airspeed_pub;
|
||||
uORB::PublicationMulti<differential_pressure_s> _airspeed_pub{ORB_ID(differential_pressure)};
|
||||
|
||||
int _airspeed_orb_class_instance;
|
||||
|
||||
int _class_instance;
|
||||
|
||||
Reference in New Issue
Block a user