From 0d51b4646568fb0889098018396c2f2c7f7cd947 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 6 Jul 2019 16:02:11 -0400 Subject: [PATCH] Update main.c --- afsk/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 133b68d8..ffe98214 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -197,9 +197,11 @@ int main(void) { printf("Opening of -Y fd %d\n", y_fd); z_fd = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44); printf("Opening of -Z fd %d\n", z_fd); - - if ((open("/dev/i2c-1", O_RDWR)) > 0) // Test if I2C Bus 1 is present + + int test; + if (((test = open("/dev/i2c-1", O_RDWR))) > 0) // Test if I2C Bus 1 is present { + close(test); sensor[PLUS_X] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x40); sensor[PLUS_Y] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x41); sensor[PLUS_Z] = wiringPiI2CSetupInterface("/dev/i2c-1", 0x44); @@ -213,8 +215,9 @@ int main(void) { sensor[BAT] = OFF; sensor[BUS] = OFF; } - if ((open("/dev/i2c-0", O_RDWR)) > 0) // Test if I2C Bus 0 is present + if (((test = open("/dev/i2c-0", O_RDWR))) > 0) // Test if I2C Bus 0 is present { + close(test); sensor[MINUS_X] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x40); sensor[MINUS_Y] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x41); sensor[MINUS_Z] = wiringPiI2CSetupInterface("/dev/i2c-0", 0x44);