From ab3af9cc2d91b135b3f012631321692909a10448 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Wed, 10 Dec 2014 00:33:34 +0000 Subject: [PATCH] i2c: add busnum to context Signed-off-by: Brendan Le Foll --- include/mraa_internal_types.h | 1 + src/i2c/i2c.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/mraa_internal_types.h b/include/mraa_internal_types.h index 8c5e747..6f097fd 100644 --- a/include/mraa_internal_types.h +++ b/include/mraa_internal_types.h @@ -56,6 +56,7 @@ struct _gpio { */ struct _i2c { /*@{*/ + int busnum; /**< the bus number of the /dev/i2c-* device */ int fh; /**< the file handle to the /dev/i2c-* device */ int addr; /**< the address of the i2c slave */ /*@}*/ diff --git a/src/i2c/i2c.c b/src/i2c/i2c.c index 1dc5f67..b44e41f 100644 --- a/src/i2c/i2c.c +++ b/src/i2c/i2c.c @@ -119,6 +119,7 @@ mraa_i2c_init_raw(unsigned int bus) } char filepath[32]; + dev->busnum = bus; snprintf(filepath, 32, "/dev/i2c-%u", bus); if ((dev->fh = open(filepath, O_RDWR)) < 1) { syslog(LOG_ERR, "i2c: Failed to open requested i2c port %s", filepath);