From c3808a240c91f6b8181cacaa8745bb950d3110ba Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Mon, 11 Jul 2011 18:53:23 +0000 Subject: [PATCH] sync nfc-utils.c with libnfc trunk. --- src/nfc-utils.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/src/nfc-utils.c b/src/nfc-utils.c index 9a0f0fb..7dfd7d0 100644 --- a/src/nfc-utils.c +++ b/src/nfc-utils.c @@ -607,6 +607,51 @@ print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi, bool verbose) } } +void +print_nfc_iso14443bi_info (const nfc_iso14443bi_info_t nii, bool verbose) +{ + printf (" DIV: "); + print_hex (nii.abtDIV, 4); + if (verbose) { + int version = (nii.btVerLog & 0x1e)>>1; + printf (" Software Version: "); + if (version == 15) { + printf ("Undefined\n"); + } else { + printf ("%i\n", version); + } + + if ((nii.btVerLog & 0x80) && (nii.btConfig & 0x80)){ + printf (" Wait Enable: yes"); + } + } + if ((nii.btVerLog & 0x80) && (nii.btConfig & 0x40)) { + printf (" ATS: "); + print_hex (nii.abtAtr, nii.szAtrLen); + } +} + +void +print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info_t nsi, bool verbose) +{ + (void) verbose; + printf (" UID: "); + print_hex (nsi.abtUID, 8); +} + +void +print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info_t nci, bool verbose) +{ + (void) verbose; + uint32_t uid; + uid = (nci.abtUID[3] << 24) + (nci.abtUID[2] << 16) + (nci.abtUID[1] << 8) + nci.abtUID[0]; + printf (" UID: "); + print_hex (nci.abtUID, sizeof(nci.abtUID)); + printf (" UID (decimal): %010u\n", uid); + printf (" Product Code: %02X\n", nci.btProdCode); + printf (" Fab Code: %02X\n", nci.btFabCode); +} + void print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose) { @@ -651,8 +696,7 @@ parse_args (int argc, const char *argv[], size_t * szFound, bool * verbose) strcpy (pndd->pcDriver, strtok (buffer, ":")); // Port. - pndd->pcPort = (char *) malloc (256); - strcpy (pndd->pcPort, strtok (NULL, ":")); + strcpy (pndd->acPort, strtok (NULL, ":")); // Speed. sscanf (strtok (NULL, ":"), "%u", &pndd->uiSpeed); @@ -712,6 +756,18 @@ print_nfc_target (const nfc_target_t nt, bool verbose) printf ("ISO/IEC 14443-4B (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); print_nfc_iso14443b_info (nt.nti.nbi, verbose); break; + case NMT_ISO14443BI: + printf ("ISO/IEC 14443-4B' (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); + print_nfc_iso14443bi_info (nt.nti.nii, verbose); + break; + case NMT_ISO14443B2SR: + printf ("ISO/IEC 14443-2B ST SRx (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); + print_nfc_iso14443b2sr_info (nt.nti.nsi, verbose); + break; + case NMT_ISO14443B2CT: + printf ("ISO/IEC 14443-2B ASK CTx (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); + 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)); print_nfc_dep_info (nt.nti.ndi, verbose);