From 0c3681c8964f3fcd9a396bb202954a64805e8f00 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Thu, 21 May 2015 10:26:45 -0700 Subject: [PATCH] Sensors: added missing px4_close and removed _exit() call The QuRT build was broken from the call to exit. While fixing the code to clean up before returning, I found a missed call to px4_close. Signed-off-by: Mark Charlebois --- src/modules/sensors/sensors.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp index acf1726984..34bcc88e50 100644 --- a/src/modules/sensors/sensors.cpp +++ b/src/modules/sensors/sensors.cpp @@ -922,16 +922,16 @@ Sensors::gyro_init() warnx("FATAL: no gyro found: %s", GYRO0_DEVICE_PATH); return ERROR; - } else { - - /* set the gyro internal sampling rate to default rate */ - px4_ioctl(fd, GYROIOCSSAMPLERATE, GYRO_SAMPLERATE_DEFAULT); - - /* set the driver to poll at default rate */ - px4_ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT); - } + /* set the gyro internal sampling rate to default rate */ + px4_ioctl(fd, GYROIOCSSAMPLERATE, GYRO_SAMPLERATE_DEFAULT); + + /* set the driver to poll at default rate */ + px4_ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT); + + px4_close(fd); + return OK; } @@ -2086,8 +2086,12 @@ Sensors::task_main() } while (0); if (ret) { + warnx("Sensor initialization failed"); _sensors_task = -1; - _exit(ret); + if (_fd_adc >=0) { + close(_fd_adc); + _fd_adc = -1; + } return; }