From 97f732ccf1e05f55ae2e48ef9d21c8e9b7b57510 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 22 Jul 2013 09:19:59 +0200 Subject: [PATCH] Fixed up ets driver (not tested, WIP on meas driver) --- src/drivers/ets_airspeed/ets_airspeed.cpp | 2 +- src/drivers/meas_airspeed/meas_airspeed.cpp | 46 ++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/drivers/ets_airspeed/ets_airspeed.cpp b/src/drivers/ets_airspeed/ets_airspeed.cpp index a24bd78a5e..2e32ed3341 100644 --- a/src/drivers/ets_airspeed/ets_airspeed.cpp +++ b/src/drivers/ets_airspeed/ets_airspeed.cpp @@ -282,7 +282,7 @@ start(int i2c_bus) if (g_dev == nullptr) goto fail; - if (OK != g_dev->init()) + if (OK != g_dev->Airspeed::init()) goto fail; /* set the poll rate to default, starts automatic data collection */ diff --git a/src/drivers/meas_airspeed/meas_airspeed.cpp b/src/drivers/meas_airspeed/meas_airspeed.cpp index 6603d3452d..f31dc857de 100644 --- a/src/drivers/meas_airspeed/meas_airspeed.cpp +++ b/src/drivers/meas_airspeed/meas_airspeed.cpp @@ -278,7 +278,7 @@ namespace meas_airspeed #endif const int ERROR = -1; -MEASAirspeed *g_dev; +MEASAirspeed *g_dev = nullptr; void start(int i2c_bus); void stop(); @@ -300,16 +300,33 @@ start(int i2c_bus) /* create the driver, try the MS4525DO first */ //g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS4525DO); - { + int bus = PX4_I2C_BUS_EXPANSION; //delete g_dev; // XXX hack scan all addresses + for (int i = 0x20 / 2; i < 0xFE / 2; i++) { + warnx("scanning addr (7 bit): 0x%02x", i); + g_dev = new MEASAirspeed(bus, i); + warnx("probing"); + if (OK == g_dev->Airspeed::init()) { + warnx("SUCCESS!"); + usleep(200000); + exit(0); + } else { + warnx("FAIL!"); + usleep(200000); + delete g_dev; + } + + } + + bus = PX4_I2C_BUS_ESC; + for (int i = 1; i < 0xFF / 2; i++) { warnx("scanning addr (7 bit): %0x", i); g_dev = new MEASAirspeed(bus, i); - warnx("probing"); - if (OK == g_dev->init()) { + if (OK == g_dev->Airspeed::init()) { warnx("SUCCESS!"); exit(0); } else { @@ -318,29 +335,12 @@ start(int i2c_bus) } - // bus = PX4_I2C_BUS_ESC; - - // for (int i = 1; i < 0xFF / 2; i++) { - // warnx("scanning addr (7 bit): %0x", i); - // g_dev = new MEASAirspeed(bus, i); - // if (OK == g_dev->init()) { - // warnx("SUCCESS!"); - // exit(0); - // } else { - // delete g_dev; - // } - - // } - - exit(1); -} - /* check if the MS4525DO was instantiated */ if (g_dev == nullptr) goto fail; /* try the MS5525DSO next if init fails */ - if (OK != g_dev->init()) + if (OK != g_dev->Airspeed::init()) delete g_dev; g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS5525DSO); @@ -349,7 +349,7 @@ start(int i2c_bus) goto fail; /* both versions failed if the init for the MS5525DSO fails, give up */ - if (OK != g_dev->init()) + if (OK != g_dev->Airspeed::init()) goto fail; /* set the poll rate to default, starts automatic data collection */