mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 06:43:34 +08:00
Subsystem_info status flags & checks : Initial commit, updating the health flags in a centralized way mostly in commander and the votedSensorsUpdate function.
This commit is contained in:
committed by
Beat Küng
parent
40e6a5a39b
commit
6f1f414b49
@@ -54,20 +54,17 @@
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/topics/differential_pressure.h>
|
||||
#include <uORB/topics/subsystem_info.h>
|
||||
|
||||
#include <drivers/airspeed/airspeed.h>
|
||||
|
||||
Airspeed::Airspeed(int bus, int address, unsigned conversion_interval, const char *path) :
|
||||
I2C("Airspeed", path, bus, address, 100000),
|
||||
_sensor_ok(false),
|
||||
_last_published_sensor_ok(true), /* initialize differently to force publication */
|
||||
_measure_ticks(0),
|
||||
_collect_phase(false),
|
||||
_diff_pres_offset(0.0f),
|
||||
_airspeed_pub(nullptr),
|
||||
_airspeed_orb_class_instance(-1),
|
||||
_subsys_pub(nullptr),
|
||||
_class_instance(-1),
|
||||
_conversion_interval(conversion_interval),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "aspd_read")),
|
||||
@@ -248,33 +245,9 @@ Airspeed::stop()
|
||||
work_cancel(HPWORK, &_work);
|
||||
}
|
||||
|
||||
void
|
||||
Airspeed::update_status()
|
||||
{
|
||||
if (_sensor_ok != _last_published_sensor_ok) {
|
||||
/* notify about state change */
|
||||
struct subsystem_info_s info = {};
|
||||
info.present = true;
|
||||
info.enabled = true;
|
||||
info.ok = _sensor_ok;
|
||||
info.subsystem_type = subsystem_info_s::SUBSYSTEM_TYPE_DIFFPRESSURE;
|
||||
|
||||
if (_subsys_pub != nullptr) {
|
||||
orb_publish(ORB_ID(subsystem_info), _subsys_pub, &info);
|
||||
|
||||
} else {
|
||||
_subsys_pub = orb_advertise(ORB_ID(subsystem_info), &info);
|
||||
}
|
||||
|
||||
_last_published_sensor_ok = _sensor_ok;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Airspeed::cycle_trampoline(void *arg)
|
||||
{
|
||||
Airspeed *dev = (Airspeed *)arg;
|
||||
dev->cycle();
|
||||
|
||||
dev->update_status();
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include <systemlib/airspeed.h>
|
||||
#include <perf/perf_counter.h>
|
||||
#include <uORB/topics/differential_pressure.h>
|
||||
#include <uORB/topics/subsystem_info.h>
|
||||
#include <uORB/uORB.h>
|
||||
|
||||
/* Default I2C bus */
|
||||
@@ -75,14 +74,8 @@ protected:
|
||||
virtual int measure() = 0;
|
||||
virtual int collect() = 0;
|
||||
|
||||
/**
|
||||
* Update the subsystem status
|
||||
*/
|
||||
void update_status();
|
||||
|
||||
work_s _work;
|
||||
bool _sensor_ok;
|
||||
bool _last_published_sensor_ok;
|
||||
uint32_t _measure_ticks;
|
||||
bool _collect_phase;
|
||||
float _diff_pres_offset;
|
||||
@@ -90,8 +83,6 @@ protected:
|
||||
orb_advert_t _airspeed_pub;
|
||||
int _airspeed_orb_class_instance;
|
||||
|
||||
orb_advert_t _subsys_pub;
|
||||
|
||||
int _class_instance;
|
||||
|
||||
unsigned _conversion_interval;
|
||||
|
||||
Reference in New Issue
Block a user