added test for bus 3 and 11

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

@ -95,12 +95,15 @@ 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
if (test_i2c_bus(0) != OFF)
printf("Result: %d \n",test_i2c_bus(3)); strcpy(busStr,"1 ");
else
strcpy(busStr,"-1 ");
// printf("Result: %d \n",test_i2c_bus(3));
if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present
printf("/dev/i2c-11 is present\n\n"); printf("/dev/i2c-11 is present\n\n");
/*
char result[128]; char result[128];
char command[50] = "timeout 10 i2cdetect -y "; char command[50] = "timeout 10 i2cdetect -y ";
strcat (command, "11"); strcat (command, "11");
@ -114,14 +117,18 @@ 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)
{ {
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");
strcpy(busStr,"1 -1"); strcat(busStr,"-1");
} }
else else
strcpy(busStr,"1 11"); strcat(busStr,"11");
printf("Bus String: %s \n", busStr);
} else { } else {
char result[128]; /* char result[128];
char command[50] = "timeout 10 i2cdetect -y "; char command[50] = "timeout 10 i2cdetect -y ";
strcat (command, "3"); strcat (command, "3");
// printf("Command: %s \n", command); // printf("Command: %s \n", command);
@ -140,7 +147,16 @@ int main(int argc, char *argv[]) {
} }
else else
strcpy(busStr,"1 3"); strcpy(busStr,"1 3");
} */
if (test_i2c_bus(3) != OFF)
{
// printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11");
strcat(busStr,"-1");
}
else
strcat(busStr,"3");
printf("Bus String: %s \n", busStr);
}
} }
else else
{ {
@ -248,7 +264,6 @@ int test_i2c_bus(int bus)
{ {
int output = 1; int output = 1;
char busDev[20] = "/dev/i2c-"; char busDev[20] = "/dev/i2c-";
char busString[25];
char busS[5]; char busS[5];
snprintf(busS, 5, "%d", bus); snprintf(busS, 5, "%d", bus);
strcat (busDev, busS); strcat (busDev, busS);

Loading…
Cancel
Save

Powered by TurnKey Linux.