From 93dea668dc0c0ca14c311020518de087b7abae24 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 21 Apr 2015 23:29:07 -0700 Subject: [PATCH] Posix: make simulated devices always pass self tests To facilitate testing, the simulated devices always return OK for self tests. rc.S was also upated to set CAL_XXXY_ID to the devid so tests pass the calibration check. Signed-off-by: Mark Charlebois --- posix-configs/posixtest/init/rc.S | 4 ++++ src/platforms/posix/drivers/accelsim/accelsim.cpp | 5 +++++ src/platforms/posix/drivers/gyrosim/gyrosim.cpp | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/posix-configs/posixtest/init/rc.S b/posix-configs/posixtest/init/rc.S index bc4b6a4b61..5e408cd544 100644 --- a/posix-configs/posixtest/init/rc.S +++ b/posix-configs/posixtest/init/rc.S @@ -4,6 +4,10 @@ barosim start adcsim start accelsim start gyrosim start +param set CAL_GYRO0_ID 2293760 +param set CAL_ACC0_ID 1310720 +param set CAL_ACC1_ID 1376256 +param set CAL_MAG0_ID 196608 rgbled start mavlink start sensors start diff --git a/src/platforms/posix/drivers/accelsim/accelsim.cpp b/src/platforms/posix/drivers/accelsim/accelsim.cpp index 97314ab846..704c7fc088 100644 --- a/src/platforms/posix/drivers/accelsim/accelsim.cpp +++ b/src/platforms/posix/drivers/accelsim/accelsim.cpp @@ -707,6 +707,9 @@ ACCELSIM::ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long arg) memcpy((struct accel_scale *) arg, &_accel_scale, sizeof(_accel_scale)); return OK; + case ACCELIOCSELFTEST: + return OK; + default: /* give it to the superclass */ return VDev::ioctl(handlep, cmd, arg); @@ -824,6 +827,8 @@ ACCELSIM::mag_ioctl(device::px4_dev_handle_t *handlep, int cmd, unsigned long ar */ return 0; + case MAGIOCSELFTEST: + return OK; default: /* give it to the superclass */ return VDev::ioctl(handlep, cmd, arg); diff --git a/src/platforms/posix/drivers/gyrosim/gyrosim.cpp b/src/platforms/posix/drivers/gyrosim/gyrosim.cpp index c39ebeac0f..a984a310a2 100644 --- a/src/platforms/posix/drivers/gyrosim/gyrosim.cpp +++ b/src/platforms/posix/drivers/gyrosim/gyrosim.cpp @@ -782,6 +782,8 @@ GYROSIM::self_test() int GYROSIM::accel_self_test() { + return OK; + if (self_test()) return 1; @@ -807,6 +809,8 @@ GYROSIM::accel_self_test() int GYROSIM::gyro_self_test() { + return OK; + if (self_test()) return 1;