mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 11:59:17 +08:00
Improved self-test logic
This commit is contained in:
@@ -634,7 +634,9 @@ HMC5883::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
case MAGIOCSSCALE:
|
case MAGIOCSSCALE:
|
||||||
/* set new scale factors */
|
/* set new scale factors */
|
||||||
memcpy(&_scale, (mag_scale *)arg, sizeof(_scale));
|
memcpy(&_scale, (mag_scale *)arg, sizeof(_scale));
|
||||||
return check_calibration();
|
/* check calibration, but not actually return an error */
|
||||||
|
(void)check_calibration();
|
||||||
|
return 0;
|
||||||
|
|
||||||
case MAGIOCGSCALE:
|
case MAGIOCGSCALE:
|
||||||
/* copy out scale factors */
|
/* copy out scale factors */
|
||||||
|
|||||||
@@ -610,9 +610,17 @@ MPU6000::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
case ACCELIOCSSCALE:
|
case ACCELIOCSSCALE:
|
||||||
/* copy scale in */
|
{
|
||||||
memcpy(&_accel_scale, (struct accel_scale *) arg, sizeof(_accel_scale));
|
/* copy scale, but only if off by a few percent */
|
||||||
return OK;
|
struct accel_scale *s = (struct accel_scale *) arg;
|
||||||
|
float sum = s->x_scale + s->y_scale + s->z_scale;
|
||||||
|
if (sum > 2.0f && sum < 4.0f) {
|
||||||
|
memcpy(&_accel_scale, s, sizeof(_accel_scale));
|
||||||
|
return OK;
|
||||||
|
} else {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case ACCELIOCGSCALE:
|
case ACCELIOCGSCALE:
|
||||||
/* copy scale out */
|
/* copy scale out */
|
||||||
|
|||||||
Reference in New Issue
Block a user