summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2011-05-12 14:32:05 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-05-12 14:32:05 -0700
commita3a6104ebe26097e24623aa0b557fe322069b51f (patch)
tree35ac0004d7660d2a3891ee5e713c37889af5303c
parent7825db42b02c4ad3426d258e1590b01f5547f06b (diff)
parent92c7e0144b84a27b4573043fef718a8ba458d062 (diff)
downloadexternal_libnfc-nxp-a3a6104ebe26097e24623aa0b557fe322069b51f.zip
external_libnfc-nxp-a3a6104ebe26097e24623aa0b557fe322069b51f.tar.gz
external_libnfc-nxp-a3a6104ebe26097e24623aa0b557fe322069b51f.tar.bz2
am 92c7e014: Retry i2c read 5 times on i2c read error.
* commit '92c7e0144b84a27b4573043fef718a8ba458d062': Retry i2c read 5 times on i2c read error.
-rw-r--r--Linux_x86/phDal4Nfc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c
index d7e306b..a39f062 100644
--- a/Linux_x86/phDal4Nfc.c
+++ b/Linux_x86/phDal4Nfc.c
@@ -661,6 +661,7 @@ int phDal4Nfc_ReaderThread(void * pArg)
phDal4Nfc_Message_t sMsg;
phOsalNfc_Message_t OsalMsg ;
int i;
+ int i2c_error_count;
pthread_setname_np(pthread_self(), "reader");
@@ -677,6 +678,9 @@ int phDal4Nfc_ReaderThread(void * pArg)
sem_wait(&nfc_read_sem);
DAL_PRINT("RX Thread Sem UnLock\n");
/* Issue read operation.*/
+
+ i2c_error_count = 0;
+retry:
gReadWriteContext.nNbOfBytesRead=0;
DAL_DEBUG("\n*New *** *****Request Length = %d",gReadWriteContext.nNbOfBytesToRead);
memsetRet=memset(gReadWriteContext.pReadBuffer,0,gReadWriteContext.nNbOfBytesToRead);
@@ -691,11 +695,18 @@ int phDal4Nfc_ReaderThread(void * pArg)
*/
if(gReadWriteContext.nNbOfBytesToRead == 1 && gReadWriteContext.pReadBuffer[0] == 0x57)
{
+ i2c_error_count++;
+ DAL_DEBUG("Read 0x57 %d times\n", i2c_error_count);
+ if (i2c_error_count < 5) {
+ usleep(2000);
+ goto retry;
+ }
DAL_PRINT("NOTHING TO READ, RECOVER");
phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1);
}
else
{
+ i2c_error_count = 0;
DAL_DEBUG("Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead);
DAL_DEBUG("NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead);
DAL_PRINT("ReadBuff[]={ ");