forked from Archive/PX4-Autopilot
i2c_posix: fix use of wrong device path
previously, get_devname() was used as the I2C device path, but on NuttX, get_devname() is the device file which the driver creates. This patch changes it, so the sematics are the same as on NuttX: both now use _bus to decide to which I2C bus device to talk to. I did not see any other use-cases than the led on ocpoc.
This commit is contained in:
parent
fc4affbb5f
commit
bf11362dae
|
@ -11,7 +11,7 @@ param set SYS_MC_EST_GROUP 2
|
|||
df_mpu9250_wrapper start_without_mag -R 10
|
||||
df_hmc5883_wrapper start
|
||||
df_ms5611_wrapper start
|
||||
rgbled start -b /dev/i2c-1
|
||||
rgbled start -b 1
|
||||
ocpoc_adc start
|
||||
gps start -d /dev/ttyS5 -s
|
||||
sensors start
|
||||
|
|
|
@ -56,4 +56,3 @@
|
|||
#include "../common/board_common.h"
|
||||
|
||||
#define BOARD_MAX_LEDS 1 // Number external of LED's this board has
|
||||
#define BOARD_RGBLED0_PATH "/dev/i2c-1"
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include <sys/ioctl.h>
|
||||
|
||||
#define PX4_SIMULATE_I2C 0
|
||||
static int simulate = PX4_SIMULATE_I2C;
|
||||
static constexpr const int simulate = PX4_SIMULATE_I2C;
|
||||
|
||||
namespace device
|
||||
{
|
||||
|
@ -104,13 +104,6 @@ I2C::init()
|
|||
return ret;
|
||||
}
|
||||
|
||||
_fd = px4_open(get_devname(), PX4_F_RDONLY | PX4_F_WRONLY);
|
||||
|
||||
if (_fd < 0) {
|
||||
DEVICE_DEBUG("px4_open failed of device %s", get_devname());
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
#ifdef __PX4_QURT
|
||||
simulate = true;
|
||||
#endif
|
||||
|
@ -120,11 +113,14 @@ I2C::init()
|
|||
|
||||
} else {
|
||||
#ifndef __PX4_QURT
|
||||
// Open the actual I2C device and map to the virtual dev name
|
||||
_fd = ::open(get_devname(), O_RDWR);
|
||||
|
||||
// Open the actual I2C device
|
||||
char dev_path[16];
|
||||
snprintf(dev_path, sizeof(dev_path), "/dev/i2c-%i", _bus);
|
||||
_fd = ::open(dev_path, O_RDWR);
|
||||
|
||||
if (_fd < 0) {
|
||||
warnx("could not open %s", get_devname());
|
||||
PX4_ERR("could not open %s", dev_path);
|
||||
px4_errno = errno;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
|
|
@ -57,8 +57,4 @@
|
|||
// set the queue size to the number of LED's, so that each led can be controlled individually
|
||||
static const int LED_UORB_QUEUE_LENGTH = BOARD_MAX_LEDS;
|
||||
|
||||
#if defined(BOARD_RGBLED0_PATH)
|
||||
#define RGBLED0_DEVICE_PATH BOARD_RGBLED0_PATH
|
||||
#else
|
||||
#define RGBLED0_DEVICE_PATH "/dev/rgbled0"
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue