From 7df3bb5aeb41f07cee1584ce01e9743645eb5639 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Fri, 6 Jan 2012 13:08:16 +0000 Subject: [PATCH] various minor fixes/enhancements --- examples/nfc-poll.c | 2 +- libnfc/chips/pn53x.c | 9 ++++++--- utils/nfc-utils.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 2392f28..88c51c7 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -118,7 +118,7 @@ main (int argc, const char *argv[]) printf ("Connected to NFC reader: %s\n", nfc_device_get_name (pnd)); printf ("NFC device will poll during %ld ms (%u pollings of %lu ms for %zd modulations)\n", (unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (unsigned long) uiPeriod * 150, szModulations); if ((res = nfc_initiator_poll_target (pnd, nmModulations, szModulations, uiPollNr, uiPeriod, &nt)) < 0) { - nfc_perror (pnd, "nfc_initiator_poll_targets"); + nfc_perror (pnd, "nfc_initiator_poll_target"); nfc_disconnect (pnd); exit (EXIT_FAILURE); } diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 805265e..e5bd058 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -796,7 +796,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co // to "gain" a sort-of hardware polling (ie. like PN532 does) if (pn53x_RFConfiguration__MaxRetries (pnd, (bEnable) ? 0xff : 0x00, // MxRtyATR, default: active = 0xff, passive = 0x02 - (bEnable) ? 0xff : 0x00, // MxRtyPSL, default: 0x01 + (bEnable) ? 0xff : 0x01, // MxRtyPSL, default: 0x01 (bEnable) ? 0xff : 0x02 // MxRtyPassiveActivation, default: 0xff (0x00 leads to problems with PN531) ) == 0) return NFC_SUCCESS; @@ -1138,13 +1138,13 @@ pn53x_initiator_poll_target (struct nfc_device *pnd, } int -pn53x_initiator_select_dep_target(struct nfc_device *pnd, +pn53x_initiator_select_dep_target (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout) { - const uint8_t abtPassiveInitiatorData[] = { 0x00, 0xff, 0xff, 0x00, 0x00 }; // Only for 212/424 kpbs: First 4 bytes shall be set like this according to NFCIP-1, last byte is TSN (Time Slot Number) + const uint8_t abtPassiveInitiatorData[] = { 0x00, 0xff, 0xff, 0x00, 0x0f }; // Only for 212/424 kpbs: First 4 bytes shall be set like this according to NFCIP-1, last byte is TSN (Time Slot Number) const uint8_t * pbtPassiveInitiatorData = NULL; switch (nbr) { @@ -1843,6 +1843,9 @@ pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, const size_t } else { // Save the received bits szRxBits = szFrameBits; + + if ((szRx - 1) > szRxLen) + return NFC_EOVFLOW; // Copy the received bytes memcpy (pbtRx, abtRx + 1, szRx - 1); } diff --git a/utils/nfc-utils.c b/utils/nfc-utils.c index b0e81d5..2c9ace7 100644 --- a/utils/nfc-utils.c +++ b/utils/nfc-utils.c @@ -726,7 +726,7 @@ print_nfc_target (const nfc_target nt, bool verbose) print_nfc_iso14443b2ct_info (nt.nti.nci, verbose); break; case NMT_DEP: - printf ("D.E.P. (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); + printf ("D.E.P. (%s, %s) target:\n", str_nfc_baud_rate(nt.nm.nbr), (nt.nti.ndi.ndm == NDM_ACTIVE)? "active mode" : "passive mode"); print_nfc_dep_info (nt.nti.ndi, verbose); break; }