From d264273d2115d76f851c3aa35d604fd01aafa190 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Wed, 8 Apr 2015 09:35:36 -0700 Subject: [PATCH] ACCELSIM: fixed calls to open, close, ioctl The calls to open, close, ioctl should have been px4_open, px4_close and px4_ioctl. Signed-off-by: Mark Charlebois --- .../linux/drivers/accelsim/accelsim.cpp | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/platforms/linux/drivers/accelsim/accelsim.cpp b/src/platforms/linux/drivers/accelsim/accelsim.cpp index 1b5e76839a..1225a5f60d 100644 --- a/src/platforms/linux/drivers/accelsim/accelsim.cpp +++ b/src/platforms/linux/drivers/accelsim/accelsim.cpp @@ -1268,29 +1268,40 @@ start(enum Rotation rotation) goto fail; } - if (OK != g_dev->init()) + if (OK != g_dev->init()) { + warnx("failed init of ACCELSIM obj"); goto fail; - - /* set the poll rate to default, starts automatic data collection */ - fd = open(ACCELSIM_DEVICE_PATH_ACCEL, O_RDONLY); - - if (fd < 0) - goto fail; - - if (ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT) < 0) - goto fail; - - fd_mag = open(ACCELSIM_DEVICE_PATH_MAG, O_RDONLY); - - /* don't fail if open cannot be opened */ - if (0 <= fd_mag) { - if (ioctl(fd_mag, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT) < 0) { - goto fail; - } } - close(fd); - close(fd_mag); + /* set the poll rate to default, starts automatic data collection */ + fd = px4_open(ACCELSIM_DEVICE_PATH_ACCEL, O_RDONLY); + + if (fd < 0) { + warnx("open %s failed", ACCELSIM_DEVICE_PATH_ACCEL); + goto fail; + } + + if (px4_ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT) < 0) { + warnx("ioctl SENSORIOCSPOLLRATE %s failed", ACCELSIM_DEVICE_PATH_ACCEL); + px4_close(fd); + goto fail; + } + + fd_mag = px4_open(ACCELSIM_DEVICE_PATH_MAG, O_RDONLY); + + /* don't fail if mag dev cannot be opened */ + if (0 <= fd_mag) { + if (px4_ioctl(fd_mag, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT) < 0) { + warnx("ioctl SENSORIOCSPOLLRATE %s failed", ACCELSIM_DEVICE_PATH_ACCEL); + } + } + else + { + warnx("ioctl SENSORIOCSPOLLRATE %s failed", ACCELSIM_DEVICE_PATH_ACCEL); + } + + px4_close(fd); + px4_close(fd_mag); return 0; fail: