|
|
@ -82,10 +82,12 @@ Airspeed::Airspeed(int bus, int address, unsigned conversion_interval, const cha |
|
|
|
_buffer_overflows(perf_alloc(PC_COUNT, "airspeed_buffer_overflows")), |
|
|
|
_buffer_overflows(perf_alloc(PC_COUNT, "airspeed_buffer_overflows")), |
|
|
|
_max_differential_pressure_pa(0), |
|
|
|
_max_differential_pressure_pa(0), |
|
|
|
_sensor_ok(false), |
|
|
|
_sensor_ok(false), |
|
|
|
|
|
|
|
_last_published_sensor_ok(true), /* initialize differently to force publication */ |
|
|
|
_measure_ticks(0), |
|
|
|
_measure_ticks(0), |
|
|
|
_collect_phase(false), |
|
|
|
_collect_phase(false), |
|
|
|
_diff_pres_offset(0.0f), |
|
|
|
_diff_pres_offset(0.0f), |
|
|
|
_airspeed_pub(-1), |
|
|
|
_airspeed_pub(-1), |
|
|
|
|
|
|
|
_subsys_pub(-1), |
|
|
|
_class_instance(-1), |
|
|
|
_class_instance(-1), |
|
|
|
_conversion_interval(conversion_interval), |
|
|
|
_conversion_interval(conversion_interval), |
|
|
|
_sample_perf(perf_alloc(PC_ELAPSED, "airspeed_read")), |
|
|
|
_sample_perf(perf_alloc(PC_ELAPSED, "airspeed_read")), |
|
|
@ -344,28 +346,34 @@ Airspeed::start() |
|
|
|
|
|
|
|
|
|
|
|
/* schedule a cycle to start things */ |
|
|
|
/* schedule a cycle to start things */ |
|
|
|
work_queue(HPWORK, &_work, (worker_t)&Airspeed::cycle_trampoline, this, 1); |
|
|
|
work_queue(HPWORK, &_work, (worker_t)&Airspeed::cycle_trampoline, this, 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
Airspeed::stop() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
work_cancel(HPWORK, &_work); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
Airspeed::update_status() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (_sensor_ok != _last_published_sensor_ok) { |
|
|
|
/* notify about state change */ |
|
|
|
/* notify about state change */ |
|
|
|
struct subsystem_info_s info = { |
|
|
|
struct subsystem_info_s info = { |
|
|
|
true, |
|
|
|
true, |
|
|
|
true, |
|
|
|
true, |
|
|
|
true, |
|
|
|
_sensor_ok, |
|
|
|
SUBSYSTEM_TYPE_DIFFPRESSURE |
|
|
|
SUBSYSTEM_TYPE_DIFFPRESSURE |
|
|
|
}; |
|
|
|
}; |
|
|
|
static orb_advert_t pub = -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pub > 0) { |
|
|
|
|
|
|
|
orb_publish(ORB_ID(subsystem_info), pub, &info); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_subsys_pub > 0) { |
|
|
|
|
|
|
|
orb_publish(ORB_ID(subsystem_info), _subsys_pub, &info); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
pub = orb_advertise(ORB_ID(subsystem_info), &info); |
|
|
|
_subsys_pub = orb_advertise(ORB_ID(subsystem_info), &info); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
_last_published_sensor_ok = _sensor_ok; |
|
|
|
Airspeed::stop() |
|
|
|
} |
|
|
|
{ |
|
|
|
|
|
|
|
work_cancel(HPWORK, &_work); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
@ -374,6 +382,7 @@ Airspeed::cycle_trampoline(void *arg) |
|
|
|
Airspeed *dev = (Airspeed *)arg; |
|
|
|
Airspeed *dev = (Airspeed *)arg; |
|
|
|
|
|
|
|
|
|
|
|
dev->cycle(); |
|
|
|
dev->cycle(); |
|
|
|
|
|
|
|
dev->update_status(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|