From 5b5de2d31bda6e494dc804285f514009f0232fbc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 17 Nov 2018 09:47:58 -0500 Subject: [PATCH] detecting i2c bus --- afsk/main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 832e850e..157214c1 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -19,6 +19,10 @@ * along with this program. If not, see . */ +//#include //Needed for I2C port +#include //Needed for I2C port +//#include //Needed for I2C port + #include #include #include @@ -80,8 +84,19 @@ int main(void) { } timestamp = time(NULL); - tempSensor = wiringPiI2CSetupInterface("/dev/i2c-3", 0x48); - + int file_i2c; + //char *filenam1e = (char*)"/dev/i2c-3"; + if ((file_i2c = open("/dev/i2c-3", O_RDWR)) < 0) + { + printf("ERROR: /dev/ic2-3 bus not present\n"); + tempSensor = -1; + } else + { + tempSensor = wiringPiI2CSetupInterface("/dev/i2c-3", 0x48); + } + + printf("tempSensor: %d \n",tempSensor); + setSpiChannel(SPI_CHANNEL); setSpiSpeed(SPI_SPEED); initializeSpi();