From 10171df59a016418279569a15ca0e1ae3e2b0bc7 Mon Sep 17 00:00:00 2001 From: tumbili Date: Wed, 9 Sep 2015 22:57:21 +0200 Subject: [PATCH] ll40ls: do not start driver if already started --- src/drivers/ll40ls/ll40ls.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/drivers/ll40ls/ll40ls.cpp b/src/drivers/ll40ls/ll40ls.cpp index 71f4134790..a4c8720dbc 100644 --- a/src/drivers/ll40ls/ll40ls.cpp +++ b/src/drivers/ll40ls/ll40ls.cpp @@ -113,6 +113,10 @@ LidarLite * get_dev(const bool use_i2c, const int bus) { */ void start(const bool use_i2c, const int bus) { + if (g_dev_int != nullptr || g_dev_ext != nullptr || g_dev_pwm != nullptr) { + errx(1,"driver already started"); + } + if (use_i2c) { /* create the driver, attempt expansion bus first */ if (bus == -1 || bus == PX4_I2C_BUS_EXPANSION) { @@ -464,7 +468,6 @@ ll40ls_main(int argc, char *argv[]) /* Start/load the driver. */ if (!strcmp(verb, "start")) { - ll40ls::start(use_i2c, bus); }