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:
Farhang 2026-03-19 18:48:38 -04:00 committed by GitHub
parent 65b1c818c5
commit a1a10692ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -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;
}

View File

@ -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)