From 80335b18b6d3892e55ba801ee74850eadcbf6c89 Mon Sep 17 00:00:00 2001 From: Sanrio Alvares Date: Wed, 3 May 2017 09:16:49 -0700 Subject: [PATCH] peripheralman: i2c_read_bytes_data returns length of read bytes Return length of read bytes rather than 0 on success. MRAA calls I2C_RDWR ioctl which returns number of bytes read. PIO is yet to implement that API so currently does I2C_SMBUS ioctl instead, which returns 0 in case of success. Signed-off-by: Sanrio Alvares --- src/peripheralman/peripheralman.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/peripheralman/peripheralman.c b/src/peripheralman/peripheralman.c index 69f7bab..ff37eaf 100644 --- a/src/peripheralman/peripheralman.c +++ b/src/peripheralman/peripheralman.c @@ -499,9 +499,10 @@ mraa_pman_i2c_read_bytes_data_replace(mraa_i2c_context dev, uint8_t command, uin return -1; } + //TODO Replace with I2C_RDWR Ioctl from PIO when available since i2c_read_bytes_data expects length on success rc = AI2cDevice_readRegBuffer(dev->bi2c, command, data, length); - return rc; + return ((rc == 0)?length:rc); } static int