From b5d824985ca85bda978185bddca4066ac63a249c Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Thu, 4 Oct 2012 08:05:53 -0400 Subject: more sensible warnings if hardware is missing --- i2c.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'i2c.c') diff --git a/i2c.c b/i2c.c index 6571798..767e4f6 100644 --- a/i2c.c +++ b/i2c.c @@ -10,6 +10,9 @@ #define I2C_BUS "/dev/i2c-3" +gboolean write_error_flagged; +gboolean read_error_flagged; + void I2C_Write(gulong address, guchar value) { @@ -23,7 +26,8 @@ void I2C_Write(gulong address, guchar value) int device = open(I2C_BUS, O_RDWR); - if (device == -1) { + if ((device == -1) && !write_error_flagged) { + write_error_flagged = TRUE; g_print_debug("ERROR: could not open I2C bus %s for writing\n", I2C_BUS); return; } @@ -48,7 +52,8 @@ guchar I2C_Read(gulong address) int device = open(I2C_BUS, O_RDWR); - if (device == -1) { + if ((device == -1) && !read_error_flagged) { + read_error_flagged = TRUE; g_print_debug("ERROR: could not open I2C bus %s for reading\n", I2C_BUS); return 0; } -- cgit From ff3ecc0632fbe0671f000595604e7c1de77f33dc Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Thu, 4 Oct 2012 08:06:25 -0400 Subject: astyle fixes --- i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'i2c.c') diff --git a/i2c.c b/i2c.c index 767e4f6..dc52337 100644 --- a/i2c.c +++ b/i2c.c @@ -53,7 +53,7 @@ guchar I2C_Read(gulong address) int device = open(I2C_BUS, O_RDWR); if ((device == -1) && !read_error_flagged) { - read_error_flagged = TRUE; + read_error_flagged = TRUE; g_print_debug("ERROR: could not open I2C bus %s for reading\n", I2C_BUS); return 0; } -- cgit