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
6 files changed