use snprintf

pull/57/head
alanbjohnston 5 years ago committed by GitHub
parent 8795900a03
commit 5d6275af10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -95,6 +95,11 @@ int main(int argc, char *argv[]) {
if (digitalRead(26) != HIGH) if (digitalRead(26) != HIGH)
{ {
printf("vB5 Present\n"); // Don't print normal board detection printf("vB5 Present\n"); // Don't print normal board detection
snprintf(busStr, 10, "%d %d", test_i2c_bus(0), test_i2c_bus(3));
printf("New Bus String: %s \n", busStr);
/*
if (test_i2c_bus(0) != OFF) if (test_i2c_bus(0) != OFF)
strcpy(busStr,"1 "); strcpy(busStr,"1 ");
else else
@ -117,7 +122,7 @@ int main(int argc, char *argv[]) {
int error = pclose(i2cdetect)/256; int error = pclose(i2cdetect)/256;
// printf("%s error: %d \n", &command, error); // printf("%s error: %d \n", &command, error);
if (error != 0) if (error != 0)
*/ *
if (test_i2c_bus(11) != OFF) if (test_i2c_bus(11) != OFF)
{ {
// printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11"); // printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11");
@ -125,7 +130,7 @@ int main(int argc, char *argv[]) {
} }
else else
strcat(busStr,"11"); strcat(busStr,"11");
printf("Bus String: %s \n", busStr); * printf("Bus String: %s \n", busStr);
} else { } else {
/* char result[128]; /* char result[128];
@ -157,7 +162,8 @@ int main(int argc, char *argv[]) {
strcat(busStr,"3"); strcat(busStr,"3");
printf("Bus String: %s \n", busStr); printf("Bus String: %s \n", busStr);
} }
} */
}
else else
{ {
printf("VB3 Present\n"); printf("VB3 Present\n");
@ -262,7 +268,7 @@ int main(int argc, char *argv[]) {
int test_i2c_bus(int bus) int test_i2c_bus(int bus)
{ {
int output = 1; int output = bus; // return bus number if OK, otherwise return -1
char busDev[20] = "/dev/i2c-"; char busDev[20] = "/dev/i2c-";
char busS[5]; char busS[5];
snprintf(busS, 5, "%d", bus); snprintf(busS, 5, "%d", bus);
@ -295,5 +301,5 @@ int test_i2c_bus(int bus)
printf("ERROR: %d bus has a problem \n Check software to see if enabled \n", bus); printf("ERROR: %d bus has a problem \n Check software to see if enabled \n", bus);
output = -1; output = -1;
} }
return(output); return(output); // return bus number or -1 if there is a problem with the bus
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.