mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 18:53:39 +08:00
drivers: report error_count in drivers where possible
This commit is contained in:
committed by
Lorenz Meier
parent
c9b8a019ea
commit
4893509344
@@ -690,6 +690,7 @@ BMA180::measure()
|
|||||||
* measurement flow without using the external interrupt.
|
* measurement flow without using the external interrupt.
|
||||||
*/
|
*/
|
||||||
report.timestamp = hrt_absolute_time();
|
report.timestamp = hrt_absolute_time();
|
||||||
|
report.error_count = 0;
|
||||||
/*
|
/*
|
||||||
* y of board is x of sensor and x of board is -y of sensor
|
* y of board is x of sensor and x of board is -y of sensor
|
||||||
* perform only the axis assignment here.
|
* perform only the axis assignment here.
|
||||||
|
|||||||
@@ -153,35 +153,36 @@ ETSAirspeed::collect()
|
|||||||
ret = transfer(nullptr, 0, &val[0], 2);
|
ret = transfer(nullptr, 0, &val[0], 2);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
log("error reading from sensor: %d", ret);
|
perf_count(_comms_errors);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t diff_pres_pa = val[1] << 8 | val[0];
|
uint16_t diff_pres_pa = val[1] << 8 | val[0];
|
||||||
if (diff_pres_pa == 0) {
|
if (diff_pres_pa == 0) {
|
||||||
// a zero value means the pressure sensor cannot give us a
|
// a zero value means the pressure sensor cannot give us a
|
||||||
// value. We need to return, and not report a value or the
|
// value. We need to return, and not report a value or the
|
||||||
// caller could end up using this value as part of an
|
// caller could end up using this value as part of an
|
||||||
// average
|
// average
|
||||||
log("zero value from sensor");
|
perf_count(_comms_errors);
|
||||||
return -1;
|
log("zero value from sensor");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff_pres_pa < _diff_pres_offset + MIN_ACCURATE_DIFF_PRES_PA) {
|
if (diff_pres_pa < _diff_pres_offset + MIN_ACCURATE_DIFF_PRES_PA) {
|
||||||
diff_pres_pa = 0;
|
diff_pres_pa = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
diff_pres_pa -= _diff_pres_offset;
|
diff_pres_pa -= _diff_pres_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track maximum differential pressure measured (so we can work out top speed).
|
// Track maximum differential pressure measured (so we can work out top speed).
|
||||||
if (diff_pres_pa > _max_differential_pressure_pa) {
|
if (diff_pres_pa > _max_differential_pressure_pa) {
|
||||||
_max_differential_pressure_pa = diff_pres_pa;
|
_max_differential_pressure_pa = diff_pres_pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX we may want to smooth out the readings to remove noise.
|
// XXX we may want to smooth out the readings to remove noise.
|
||||||
differential_pressure_s report;
|
differential_pressure_s report;
|
||||||
report.timestamp = hrt_absolute_time();
|
report.timestamp = hrt_absolute_time();
|
||||||
|
report.error_count = perf_event_count(_comms_errors);
|
||||||
report.differential_pressure_pa = diff_pres_pa;
|
report.differential_pressure_pa = diff_pres_pa;
|
||||||
report.voltage = 0;
|
report.voltage = 0;
|
||||||
report.max_differential_pressure_pa = _max_differential_pressure_pa;
|
report.max_differential_pressure_pa = _max_differential_pressure_pa;
|
||||||
@@ -209,7 +210,7 @@ ETSAirspeed::cycle()
|
|||||||
|
|
||||||
/* perform collection */
|
/* perform collection */
|
||||||
if (OK != collect()) {
|
if (OK != collect()) {
|
||||||
log("collection error");
|
perf_count(_comms_errors);
|
||||||
/* restart the measurement state machine */
|
/* restart the measurement state machine */
|
||||||
start();
|
start();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -791,6 +791,7 @@ HMC5883::collect()
|
|||||||
|
|
||||||
/* this should be fairly close to the end of the measurement, so the best approximation of the time */
|
/* this should be fairly close to the end of the measurement, so the best approximation of the time */
|
||||||
new_report.timestamp = hrt_absolute_time();
|
new_report.timestamp = hrt_absolute_time();
|
||||||
|
new_report.error_count = perf_event_count(_comms_errors);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @note We could read the status register here, which could tell us that
|
* @note We could read the status register here, which could tell us that
|
||||||
|
|||||||
@@ -774,6 +774,7 @@ L3GD20::measure()
|
|||||||
* 74 from all measurements centers them around zero.
|
* 74 from all measurements centers them around zero.
|
||||||
*/
|
*/
|
||||||
report.timestamp = hrt_absolute_time();
|
report.timestamp = hrt_absolute_time();
|
||||||
|
report.error_count = 0; // not recorded
|
||||||
|
|
||||||
switch (_orientation) {
|
switch (_orientation) {
|
||||||
|
|
||||||
|
|||||||
@@ -1252,6 +1252,7 @@ LSM303D::measure()
|
|||||||
|
|
||||||
|
|
||||||
accel_report.timestamp = hrt_absolute_time();
|
accel_report.timestamp = hrt_absolute_time();
|
||||||
|
accel_report.error_count = 0; // not reported
|
||||||
|
|
||||||
accel_report.x_raw = raw_accel_report.x;
|
accel_report.x_raw = raw_accel_report.x;
|
||||||
accel_report.y_raw = raw_accel_report.y;
|
accel_report.y_raw = raw_accel_report.y;
|
||||||
|
|||||||
@@ -490,6 +490,7 @@ MB12XX::collect()
|
|||||||
|
|
||||||
/* this should be fairly close to the end of the measurement, so the best approximation of the time */
|
/* this should be fairly close to the end of the measurement, so the best approximation of the time */
|
||||||
report.timestamp = hrt_absolute_time();
|
report.timestamp = hrt_absolute_time();
|
||||||
|
report.error_count = perf_event_count(_comms_errors);
|
||||||
report.distance = si_units;
|
report.distance = si_units;
|
||||||
report.valid = si_units > get_minimum_distance() && si_units < get_maximum_distance() ? 1 : 0;
|
report.valid = si_units > get_minimum_distance() && si_units < get_maximum_distance() ? 1 : 0;
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,6 @@ MEASAirspeed::measure()
|
|||||||
|
|
||||||
if (OK != ret) {
|
if (OK != ret) {
|
||||||
perf_count(_comms_errors);
|
perf_count(_comms_errors);
|
||||||
log("i2c::transfer returned %d", ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +160,6 @@ MEASAirspeed::collect()
|
|||||||
ret = transfer(nullptr, 0, &val[0], 4);
|
ret = transfer(nullptr, 0, &val[0], 4);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
log("error reading from sensor: %d", ret);
|
|
||||||
perf_count(_comms_errors);
|
perf_count(_comms_errors);
|
||||||
perf_end(_sample_perf);
|
perf_end(_sample_perf);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -207,6 +205,7 @@ MEASAirspeed::collect()
|
|||||||
}
|
}
|
||||||
|
|
||||||
report.timestamp = hrt_absolute_time();
|
report.timestamp = hrt_absolute_time();
|
||||||
|
report.error_count = perf_event_count(_comms_errors);
|
||||||
report.temperature = temperature;
|
report.temperature = temperature;
|
||||||
report.differential_pressure_pa = diff_press_pa;
|
report.differential_pressure_pa = diff_press_pa;
|
||||||
report.voltage = 0;
|
report.voltage = 0;
|
||||||
@@ -235,7 +234,6 @@ MEASAirspeed::cycle()
|
|||||||
|
|
||||||
/* perform collection */
|
/* perform collection */
|
||||||
if (OK != collect()) {
|
if (OK != collect()) {
|
||||||
log("collection error");
|
|
||||||
/* restart the measurement state machine */
|
/* restart the measurement state machine */
|
||||||
start();
|
start();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1186,7 +1186,7 @@ MPU6000::measure()
|
|||||||
* Adjust and scale results to m/s^2.
|
* Adjust and scale results to m/s^2.
|
||||||
*/
|
*/
|
||||||
grb.timestamp = arb.timestamp = hrt_absolute_time();
|
grb.timestamp = arb.timestamp = hrt_absolute_time();
|
||||||
|
grb.error_count = arb.error_count = 0; // not reported
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1) Scale raw value to SI units using scaling from datasheet.
|
* 1) Scale raw value to SI units using scaling from datasheet.
|
||||||
|
|||||||
@@ -573,6 +573,7 @@ MS5611::collect()
|
|||||||
struct baro_report report;
|
struct baro_report report;
|
||||||
/* this should be fairly close to the end of the conversion, so the best approximation of the time */
|
/* this should be fairly close to the end of the conversion, so the best approximation of the time */
|
||||||
report.timestamp = hrt_absolute_time();
|
report.timestamp = hrt_absolute_time();
|
||||||
|
report.error_count = perf_event_count(_comms_errors);
|
||||||
|
|
||||||
/* read the most recent measurement - read offset/size are hardcoded in the interface */
|
/* read the most recent measurement - read offset/size are hardcoded in the interface */
|
||||||
ret = _interface->read(0, (void *)&raw, 0);
|
ret = _interface->read(0, (void *)&raw, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user