aboutsummaryrefslogtreecommitdiff
path: root/apps/drivers/mpu6000/mpu6000.cpp
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2012-11-15 17:19:21 +0100
committerLorenz Meier <lm@inf.ethz.ch>2012-11-15 17:19:21 +0100
commitdf5e4d19042985bd567845dfa464170c169829b4 (patch)
treeb706e225daa832b354dd2f933382d818db4a7bf9 /apps/drivers/mpu6000/mpu6000.cpp
parent74d543cfc9e2d63caf2d10b4a93227608a2c2930 (diff)
downloadpx4-firmware-df5e4d19042985bd567845dfa464170c169829b4.tar.gz
px4-firmware-df5e4d19042985bd567845dfa464170c169829b4.tar.bz2
px4-firmware-df5e4d19042985bd567845dfa464170c169829b4.zip
Improved self-test logic
Diffstat (limited to 'apps/drivers/mpu6000/mpu6000.cpp')
-rw-r--r--apps/drivers/mpu6000/mpu6000.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/drivers/mpu6000/mpu6000.cpp b/apps/drivers/mpu6000/mpu6000.cpp
index 2ac71d89c..ed79440cc 100644
--- a/apps/drivers/mpu6000/mpu6000.cpp
+++ b/apps/drivers/mpu6000/mpu6000.cpp
@@ -610,9 +610,17 @@ MPU6000::ioctl(struct file *filp, int cmd, unsigned long arg)
return -EINVAL;
case ACCELIOCSSCALE:
- /* copy scale in */
- memcpy(&_accel_scale, (struct accel_scale *) arg, sizeof(_accel_scale));
- return OK;
+ {
+ /* copy scale, but only if off by a few percent */
+ 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:
/* copy scale out */