Low level drive access functions should not generate output; it interferes with higher level formatting
This commit is contained in:
parent
7c4f9eb8e9
commit
bb9b4c8063
@ -1540,4 +1540,7 @@
|
||||
modem in nsh. From Vladimir Komendantskiy (2019-01-31).
|
||||
* apps/system/ubloxmodem: Moved the modem application from
|
||||
examples/ to system/ (2016-01-31).
|
||||
* apps/system/i2c: The I2C tool now obeys it OS interfacing:
|
||||
it now uses an I2C character driver to access the I2C bus
|
||||
(2016-02-02).
|
||||
|
||||
|
@ -126,7 +126,7 @@ int i2ccmd_dev(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
|
||||
|
||||
/* Get a handle to the I2C bus */
|
||||
|
||||
fd = i2cdev_open(i2ctool, i2ctool->bus);
|
||||
fd = i2cdev_open(i2ctool->bus);
|
||||
if (fd < 0)
|
||||
{
|
||||
i2ctool_printf(i2ctool, "Failed to get bus %d\n", i2ctool->bus);
|
||||
@ -176,15 +176,15 @@ int i2ccmd_dev(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
|
||||
|
||||
if (i2ctool->start)
|
||||
{
|
||||
ret = i2cdev_transfer(i2ctool, fd, &msg[0], 1);
|
||||
ret = i2cdev_transfer(fd, &msg[0], 1);
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = i2cdev_transfer(i2ctool, fd, &msg[1], 1);
|
||||
ret = i2cdev_transfer(fd, &msg[1], 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = i2cdev_transfer(i2ctool, fd, msg, 2);
|
||||
ret = i2cdev_transfer(fd, msg, 2);
|
||||
}
|
||||
|
||||
if (ret == OK)
|
||||
|
@ -112,7 +112,7 @@ bool i2cdev_exists(int bus)
|
||||
* Name: i2cdev_open
|
||||
****************************************************************************/
|
||||
|
||||
int i2cdev_open(FAR struct i2ctool_s *i2ctool, int bus)
|
||||
int i2cdev_open(int bus)
|
||||
{
|
||||
FAR char *devpath;
|
||||
int fd;
|
||||
@ -123,27 +123,14 @@ int i2cdev_open(FAR struct i2ctool_s *i2ctool, int bus)
|
||||
|
||||
/* Open the file for read-only access (we need only IOCTLs) */
|
||||
|
||||
fd = open(devpath, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
|
||||
/* We failed to open the driver */
|
||||
|
||||
i2ctool_printf(i2ctool, "ERROR: Failed to open %s: %d\n",
|
||||
devpath, errcode);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
return fd;
|
||||
return open(devpath, O_RDONLY);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: i2cdev_transfer
|
||||
****************************************************************************/
|
||||
|
||||
int i2cdev_transfer(FAR struct i2ctool_s *i2ctool, int fd,
|
||||
FAR struct i2c_msg_s *msgv, int msgc)
|
||||
int i2cdev_transfer(int fd, FAR struct i2c_msg_s *msgv, int msgc)
|
||||
{
|
||||
struct i2c_transfer_s xfer;
|
||||
int ret;
|
||||
@ -155,17 +142,5 @@ int i2cdev_transfer(FAR struct i2ctool_s *i2ctool, int fd,
|
||||
|
||||
/* Perform the IOCTL */
|
||||
|
||||
ret = ioctl(fd, I2CIOC_TRANSFER, (unsigned long)((uintptr_t)&xfer));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
|
||||
/* We failed to open the driver */
|
||||
|
||||
i2ctool_printf(i2ctool, "ERROR: ioctl(I2CIOC_TRANSFER) failed: %d\n",
|
||||
errcode);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
return OK;
|
||||
return ioctl(fd, I2CIOC_TRANSFER, (unsigned long)((uintptr_t)&xfer));
|
||||
}
|
@ -113,7 +113,7 @@ int i2ccmd_get(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv)
|
||||
|
||||
/* Get a handle to the I2C bus */
|
||||
|
||||
fd = i2cdev_open(i2ctool, i2ctool->bus);
|
||||
fd = i2cdev_open(i2ctool->bus);
|
||||
if (fd < 0)
|
||||
{
|
||||
i2ctool_printf(i2ctool, "Failed to get bus %d\n", i2ctool->bus);
|
||||
@ -205,15 +205,15 @@ int i2ctool_get(FAR struct i2ctool_s *i2ctool, int fd, uint8_t regaddr,
|
||||
|
||||
if (i2ctool->start)
|
||||
{
|
||||
ret = i2cdev_transfer(i2ctool, fd, &msg[0], 1);
|
||||
ret = i2cdev_transfer(fd, &msg[0], 1);
|
||||
if (ret== OK)
|
||||
{
|
||||
ret = i2cdev_transfer(i2ctool, fd, &msg[1], 1);
|
||||
ret = i2cdev_transfer(fd, &msg[1], 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = i2cdev_transfer(i2ctool, fd, msg, 2);
|
||||
ret = i2cdev_transfer(fd, msg, 2);
|
||||
}
|
||||
|
||||
/* Return the result of the read operation */
|
||||
|
@ -141,7 +141,7 @@ int i2ccmd_set(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv)
|
||||
|
||||
/* Get a handle to the I2C bus */
|
||||
|
||||
fd = i2cdev_open(i2ctool, i2ctool->bus);
|
||||
fd = i2cdev_open(i2ctool->bus);
|
||||
if (fd < 0)
|
||||
{
|
||||
i2ctool_printf(i2ctool, "Failed to get bus %d\n", i2ctool->bus);
|
||||
@ -233,15 +233,15 @@ int i2ctool_set(FAR struct i2ctool_s *i2ctool, int fd, uint8_t regaddr,
|
||||
|
||||
if (i2ctool->start)
|
||||
{
|
||||
ret = i2cdev_transfer(i2ctool, fd, &msg[0], 1);
|
||||
ret = i2cdev_transfer(fd, &msg[0], 1);
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = i2cdev_transfer(i2ctool, fd, &msg[1], 1);
|
||||
ret = i2cdev_transfer(fd, &msg[1], 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = i2cdev_transfer(i2ctool, fd, msg, 2);
|
||||
ret = i2cdev_transfer(fd, msg, 2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -143,7 +143,7 @@ int i2ccmd_verf(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv)
|
||||
|
||||
/* Get a handle to the I2C bus */
|
||||
|
||||
fd = i2cdev_open(i2ctool, i2ctool->bus);
|
||||
fd = i2cdev_open(i2ctool->bus);
|
||||
if (fd < 0)
|
||||
{
|
||||
i2ctool_printf(i2ctool, "Failed to get bus %d\n", i2ctool->bus);
|
||||
|
@ -208,8 +208,7 @@ int arg_hex(FAR char **arg, FAR long *value);
|
||||
|
||||
FAR char *i2cdev_path(int bus);
|
||||
bool i2cdev_exists(int bus);
|
||||
int i2cdev_open(FAR struct i2ctool_s *i2ctool, int bus);
|
||||
int i2cdev_transfer(FAR struct i2ctool_s *i2ctool, int fd,
|
||||
FAR struct i2c_msg_s *msgv, int msgc);
|
||||
int i2cdev_open(int bus);
|
||||
int i2cdev_transfer(int fd, FAR struct i2c_msg_s *msgv, int msgc);
|
||||
|
||||
#endif /* __APPS_SYSTEM_I2C_I2CTOOLS_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user