forked from Archive/PX4-Autopilot
Fixed up ets driver (not tested, WIP on meas driver)
This commit is contained in:
parent
08ddbbc23e
commit
97f732ccf1
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue