* @param dev The i2c context
* @param data pointer to the byte array to read data in to
* @param length max number of bytes to read
- * @return Result of operation
+ * @return length of the read in bytes or 0
*/
-maa_result_t maa_i2c_read(maa_i2c_context dev, uint8_t *data, int length);
+int maa_i2c_read(maa_i2c_context dev, uint8_t *data, int length);
/**
* Read a single byte from the i2c context
*
* @param data Buffer to write into
* @param length Size of read
- * @return Result of operation
+ * @return length of the read or 0 if failed
*/
- maa_result_t read(unsigned char * data, int length) {
+ int read(unsigned char * data, int length) {
return maa_i2c_read(m_i2c, data, length);
}
/**
return MAA_SUCCESS;
}
-maa_result_t
+int
maa_i2c_read(maa_i2c_context dev, uint8_t* data, int length)
{
// this is the read(3) syscall not maa_i2c_read()
if (read(dev->fh, data, length) == length) {
return length;
}
- return MAA_ERROR_NO_DATA_AVAILABLE;
+ return 0;
}
uint8_t