From ad6633052d8399f51528d3b848b3b5863185f0f7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 8 Aug 2020 17:50:39 -0400 Subject: [PATCH] Update telem.c --- afsk/telem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/afsk/telem.c b/afsk/telem.c index 0dfaa75a..d31c96bf 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -126,6 +126,9 @@ struct SensorData read_sensor_data(struct SensorConfig sensor) { struct SensorConfig config_sensor(char *bus, int address, int milliAmps) { struct SensorConfig data; + #define BUFSIZE 128 + char buf[BUFSIZE]; + int pos = strlen(bus) / sizeof(bus[0]) - 1; printf("Bus size %d \n", pos); printf("Bus value %d \n", atoi(&bus[pos])); @@ -140,6 +143,9 @@ struct SensorConfig config_sensor(char *bus, int address, int milliAmps) { // printf("2\n"); // i2cdetect = popen("echo $?", "r"); // printf("getc i2cdetect 1 output: %d\n", getc(i2cdetect)); + while (fgets(buf, BUFSIZE, i2cdetect) != NULL) { + printf("OUTPUT: %s", buf); + } int error = pclose(i2cdetect)/256; printf("%s error: %d \n", &command, error); @@ -150,6 +156,9 @@ struct SensorConfig config_sensor(char *bus, int address, int milliAmps) { // printf("2\n"); // i2cdetect = popen("echo $?", "r"); // printf("getc echo output: %d\n", getc(i2cdetect)); + while (fgets(buf, BUFSIZE, i2cdetect2) != NULL) { + printf("OUTPUT: %s", buf); + } error = pclose(i2cdetect2)/256; printf("%s error: %d \n", &command, error);