mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
fix(bmp581): add pressure range validation (#26373)
Reject pressure readings outside the sensor's operating range (30-125 kPa) to detect I2C data corruption. When I2C transfers complete successfully but return corrupted data, this check prevents invalid samples from being published. Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
This commit is contained in:
parent
65b1c818c5
commit
a1a10692ec
@ -710,6 +710,10 @@ int BMP581::get_sensor_data(bmp5_sensor_data *sensor_data)
|
||||
/* Division by 2^6(whose equivalent value is 64) is performed to get pressure data in Pa */
|
||||
sensor_data->pressure = (float)(raw_data_p / 64.0);
|
||||
|
||||
if (sensor_data->pressure < BMP5_PRESSURE_MIN_PA || sensor_data->pressure > BMP5_PRESSURE_MAX_PA) {
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
sensor_data->pressure = 0.0;
|
||||
}
|
||||
|
||||
@ -101,6 +101,10 @@
|
||||
#define BMP5_DEEP_ENABLED (0)
|
||||
#define BMP5_DEEP_DISABLED (1)
|
||||
|
||||
/* Pressure operating range (Pa) */
|
||||
#define BMP5_PRESSURE_MIN_PA (30000.0f)
|
||||
#define BMP5_PRESSURE_MAX_PA (125000.0f)
|
||||
|
||||
/* ODR settings */
|
||||
#define BMP5_ODR_50_HZ (0x0F)
|
||||
#define BMP5_ODR_05_HZ (0x18)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user