diff options
author | Nick Pelly <npelly@google.com> | 2011-10-19 18:36:47 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2011-10-21 16:03:23 -0700 |
commit | 5ea62ad25e2050f543d8e2104f5ffc1bb2c1ef28 (patch) | |
tree | 77c2c2d626ec36d1873be955fbcc161667b16be8 /Linux_x86/phDal4Nfc.c | |
parent | 31e4d8b1ad54c78cb667155ad4ed9ece33f4b075 (diff) | |
download | external_libnfc-nxp-5ea62ad25e2050f543d8e2104f5ffc1bb2c1ef28.zip external_libnfc-nxp-5ea62ad25e2050f543d8e2104f5ffc1bb2c1ef28.tar.gz external_libnfc-nxp-5ea62ad25e2050f543d8e2104f5ffc1bb2c1ef28.tar.bz2 |
Fixes to LLC and DAL to handle unreliable UART.
Use a 100ms timeout in uart_read() when reading LLC payload only.
Allow 200 retries on host.
Note that we use pn544 timeout retransmit instead of an explicit REJ
(do not use CRC_ERROR_REJ). The reason is that after a
dropped frame, a host timeout on read() is the only reliable way to recover
frame alignment, but if we send an immediate REJ then we are constantly reading
and can never regain frame alignment.
Also note that the pn544 timeout (200ms) is higher than the host (100ms). This
allows the host to abort a partial read and return to known state before the
pn544 re-transmits.
We have to turn off timeout for FW mode. Typical read time is ~100ms, but some
are 1 second+
Modify DAL & LLC layer to more reliably handle partial frames by searching for
a LLC length byte again, and log the various error paths.
Also introduce debugging tools:
debug.nfc.LOW_LEVEL_TRACES 2
Will enable LLC header decoding in the trace output.
Only read at NFC init time, use /data/local.prop to enable.
debug.nfc.UART_ERROR_RATE X
Will randomly inject errors at the uart transport, with a probability of X/1000
for every byte. 50% of those errors will be a dropped byte, 50% will be
corrupted. Recommend X=10. FW mode can't handle any errors. Can be enabled
after boot.
adb shell dumpsys nfc
Will now print the number of errors detected at the LLC layer.
Change-Id: I739ed193e3d4caa563a866b6a9d834c154917962
Diffstat (limited to 'Linux_x86/phDal4Nfc.c')
-rw-r--r-- | Linux_x86/phDal4Nfc.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c index 9bedaf9..8b4f687 100644 --- a/Linux_x86/phDal4Nfc.c +++ b/Linux_x86/phDal4Nfc.c @@ -135,9 +135,9 @@ static void refresh_low_level_traces() { return; } - property_get("debug.nfc.LOW_LEVEL_TRACES", value, ""); + property_get("debug.nfc.LOW_LEVEL_TRACES", value, "0"); if (value[0]) { - low_level_traces = atoi(value) ? 1 : 0; + low_level_traces = atoi(value); return; } #endif @@ -752,7 +752,8 @@ retry: if (low_level_traces) { - phOsalNfc_PrintData("RECV", (uint16_t)gReadWriteContext.nNbOfBytesRead, gReadWriteContext.pReadBuffer); + phOsalNfc_PrintData("RECV", (uint16_t)gReadWriteContext.nNbOfBytesRead, + gReadWriteContext.pReadBuffer, low_level_traces); } DAL_DEBUG("RX Thread Read ok. nbToRead=%d\n", gReadWriteContext.nNbOfBytesToRead); DAL_DEBUG("RX Thread NbReallyRead=%d\n", gReadWriteContext.nNbOfBytesRead); @@ -882,7 +883,11 @@ void phDal4Nfc_DeferredCb (void *params) DAL_PRINT(" Dal deferred read called \n"); TransactionInfo.buffer=gReadWriteContext.pReadBuffer; TransactionInfo.length=(uint16_t)gReadWriteContext.nNbOfBytesRead; - TransactionInfo.status=NFCSTATUS_SUCCESS; + if (gReadWriteContext.nNbOfBytesRead == gReadWriteContext.nNbOfBytesToRead) { + TransactionInfo.status=NFCSTATUS_SUCCESS; + } else { + TransactionInfo.status=NFCSTATUS_READ_FAILED; + } gReadWriteContext.nReadBusy = FALSE; @@ -900,7 +905,8 @@ void phDal4Nfc_DeferredCb (void *params) if(low_level_traces) { - phOsalNfc_PrintData("SEND", (uint16_t)gReadWriteContext.nNbOfBytesToWrite, gReadWriteContext.pWriteBuffer); + phOsalNfc_PrintData("SEND", (uint16_t)gReadWriteContext.nNbOfBytesToWrite, + gReadWriteContext.pWriteBuffer, low_level_traces); } /* DAL_DEBUG("dalMsg->transactInfo.length : %d\n", dalMsg->transactInfo.length); */ |