Updated version with proper challenge/response code
This commit is contained in:
+11
-15
@@ -1,4 +1,4 @@
|
||||
O/*
|
||||
/*
|
||||
*i2ctest.c
|
||||
* Raspberry Pi I2C test using wiringPi library.
|
||||
*
|
||||
@@ -35,28 +35,24 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
while(data != 6) {
|
||||
wiringPiI2CWrite(fd, send);
|
||||
delay(1);
|
||||
while(1) {
|
||||
wiringPiI2CWrite(fd, send);
|
||||
data=wiringPiI2CRead(fd);
|
||||
printf(" Received data=%d\n", data);
|
||||
if(data==-1)
|
||||
{
|
||||
printf("No data\n");
|
||||
//return -1;
|
||||
}
|
||||
else if(data == send*3) {
|
||||
printf("Sending challenge");
|
||||
wiringPiI2CWrite(fd, 4);
|
||||
}
|
||||
else if(data == 6) {
|
||||
printf("Read proper response \n");
|
||||
else if(data == 17) {
|
||||
printf("Exit code received \n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
//print data
|
||||
printf("Waiting to send challenge");
|
||||
}
|
||||
printf(" data=%d\n", data);
|
||||
else if(data != 0) {
|
||||
printf("Sending response %d\n", data+3 );
|
||||
wiringPiI2CWrite(fd, data+3);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user