Skip to content

Commit

Permalink
Merge pull request #670 from PX4/airspeed_path_fix
Browse files Browse the repository at this point in the history
Fix airspeed sensor
  • Loading branch information
julianoes committed Feb 15, 2014
2 parents 51b7c27 + 4bd83dc commit 0f7483c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/drivers/airspeed/airspeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@

#include <drivers/airspeed/airspeed.h>

Airspeed::Airspeed(int bus, int address, unsigned conversion_interval) :
I2C("Airspeed", AIRSPEED_DEVICE_PATH, bus, address, 100000),
Airspeed::Airspeed(int bus, int address, unsigned conversion_interval, const char* path) :
I2C("Airspeed", path, bus, address, 100000),
_reports(nullptr),
_buffer_overflows(perf_alloc(PC_COUNT, "airspeed_buffer_overflows")),
_max_differential_pressure_pa(0),
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/airspeed/airspeed.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static const int ERROR = -1;
class __EXPORT Airspeed : public device::I2C
{
public:
Airspeed(int bus, int address, unsigned conversion_interval);
Airspeed(int bus, int address, unsigned conversion_interval, const char* path);
virtual ~Airspeed();

virtual int init();
Expand Down
7 changes: 4 additions & 3 deletions src/drivers/ets_airspeed/ets_airspeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

/* I2C bus address */
#define I2C_ADDRESS 0x75 /* 7-bit address. 8-bit address is 0xEA */
#define ETS_PATH "/dev/ets_airspeed"

/* Register address */
#define READ_CMD 0x07 /* Read the data */
Expand All @@ -93,7 +94,7 @@
class ETSAirspeed : public Airspeed
{
public:
ETSAirspeed(int bus, int address = I2C_ADDRESS);
ETSAirspeed(int bus, int address = I2C_ADDRESS, const char* path = ETS_PATH);

protected:

Expand All @@ -112,8 +113,8 @@ class ETSAirspeed : public Airspeed
*/
extern "C" __EXPORT int ets_airspeed_main(int argc, char *argv[]);

ETSAirspeed::ETSAirspeed(int bus, int address) : Airspeed(bus, address,
CONVERSION_INTERVAL)
ETSAirspeed::ETSAirspeed(int bus, int address, const char* path) : Airspeed(bus, address,
CONVERSION_INTERVAL, path)
{

}
Expand Down
12 changes: 7 additions & 5 deletions src/drivers/meas_airspeed/meas_airspeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@

/* I2C bus address is 1010001x */
#define I2C_ADDRESS_MS4525DO 0x28 //0x51 /* 7-bit address. */
#define PATH_MS4525 "/dev/ms4525"
/* The MS5525DSO address is 111011Cx, where C is the complementary value of the pin CSB */
#define I2C_ADDRESS_MS5525DSO 0x77 //0x77/* 7-bit address, addr. pin pulled low */
#define PATH_MS5525 "/dev/ms5525"

/* Register address */
#define ADDR_READ_MR 0x00 /* write to this address to start conversion */
Expand All @@ -101,7 +103,7 @@
class MEASAirspeed : public Airspeed
{
public:
MEASAirspeed(int bus, int address = I2C_ADDRESS_MS4525DO);
MEASAirspeed(int bus, int address = I2C_ADDRESS_MS4525DO, const char* path = PATH_MS4525);

protected:

Expand All @@ -120,8 +122,8 @@ class MEASAirspeed : public Airspeed
*/
extern "C" __EXPORT int meas_airspeed_main(int argc, char *argv[]);

MEASAirspeed::MEASAirspeed(int bus, int address) : Airspeed(bus, address,
CONVERSION_INTERVAL)
MEASAirspeed::MEASAirspeed(int bus, int address, const char* path) : Airspeed(bus, address,
CONVERSION_INTERVAL, path)
{

}
Expand Down Expand Up @@ -304,7 +306,7 @@ start(int i2c_bus)
errx(1, "already started");

/* create the driver, try the MS4525DO first */
g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS4525DO);
g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS4525DO, PATH_MS4525);

/* check if the MS4525DO was instantiated */
if (g_dev == nullptr)
Expand All @@ -313,7 +315,7 @@ start(int i2c_bus)
/* try the MS5525DSO next if init fails */
if (OK != g_dev->Airspeed::init()) {
delete g_dev;
g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS5525DSO);
g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS5525DSO, PATH_MS5525);

/* check if the MS5525DSO was instantiated */
if (g_dev == nullptr)
Expand Down

0 comments on commit 0f7483c

Please sign in to comment.