temperature_calibration: make sure to always do an orb_copy() even when already finished

... since we do poll() on the gyro fd.
This commit is contained in:
Beat Küng
2017-02-03 13:57:48 +01:00
committed by Lorenz Meier
parent d2dd61dfbd
commit 4b8e6cf9cd
3 changed files with 21 additions and 15 deletions
@@ -78,21 +78,23 @@ void TemperatureCalibrationAccel::reset_calibration()
int TemperatureCalibrationAccel::update_sensor_instance(PerSensorData &data, int sensor_sub)
{
if (data.hot_soaked) {
// already done
return 0;
}
bool finished = data.hot_soaked;
bool updated;
orb_check(sensor_sub, &updated);
if (!updated) {
return 1;
return finished ? 0 : 1;
}
sensor_accel_s accel_data;
orb_copy(ORB_ID(sensor_accel), sensor_sub, &accel_data);
if (finished) {
// if we're done, return, but we need to return after orb_copy because of poll()
return 0;
}
data.device_id = accel_data.device_id;
data.sensor_sample_filt[0] = accel_data.x;
@@ -67,21 +67,23 @@ void TemperatureCalibrationBaro::reset_calibration()
int TemperatureCalibrationBaro::update_sensor_instance(PerSensorData &data, int sensor_sub)
{
if (data.hot_soaked) {
// already done
return 0;
}
bool finished = data.hot_soaked;
bool updated;
orb_check(sensor_sub, &updated);
if (!updated) {
return 1;
return finished ? 0 : 1;
}
sensor_baro_s baro_data;
orb_copy(ORB_ID(sensor_baro), sensor_sub, &baro_data);
if (finished) {
// if we're done, return, but we need to return after orb_copy because of poll()
return 0;
}
data.device_id = baro_data.device_id;
data.sensor_sample_filt[0] = 100.0f * baro_data.pressure; // convert from hPA to Pa
@@ -67,21 +67,23 @@ void TemperatureCalibrationGyro::reset_calibration()
int TemperatureCalibrationGyro::update_sensor_instance(PerSensorData &data, int sensor_sub)
{
if (data.hot_soaked) {
// already done
return 0;
}
bool finished = data.hot_soaked;
bool updated;
orb_check(sensor_sub, &updated);
if (!updated) {
return 1;
return finished ? 0 : 1;
}
sensor_gyro_s gyro_data;
orb_copy(ORB_ID(sensor_gyro), sensor_sub, &gyro_data);
if (finished) {
// if we're done, return, but we need to return after orb_copy because of poll()
return 0;
}
data.device_id = gyro_data.device_id;
data.sensor_sample_filt[0] = gyro_data.x;