From 5a678295b33d93a0650ff2998bb82bc376c53370 Mon Sep 17 00:00:00 2001 From: Jake Dahl Date: Tue, 28 Aug 2018 15:50:35 -0600 Subject: [PATCH] added a check to ensure the initialize settings function succeeds. If it does not, the driver fails gracefully. This handles the case that the device is not there. --- src/drivers/distance_sensor/pga460/pga460.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/drivers/distance_sensor/pga460/pga460.cpp b/src/drivers/distance_sensor/pga460/pga460.cpp index 1a41f15a4e..b7a1d7d915 100644 --- a/src/drivers/distance_sensor/pga460/pga460.cpp +++ b/src/drivers/distance_sensor/pga460/pga460.cpp @@ -649,7 +649,13 @@ void PGA460::request_results() void PGA460::run() { open_serial(); - initialize_device_settings(); + int ret = initialize_device_settings(); + + if(ret != PX4_OK) { + close_serial(); + PX4_INFO("Could not initialize device settings. Exiting."); + return; + } struct distance_sensor_s report = {}; _distance_sensor_topic = orb_advertise(ORB_ID(distance_sensor), &report);