From 125553c72e0fd621c5054c66733f7c1ab270bed9 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 4 Jan 2012 21:29:43 +0000 Subject: [PATCH] verbose option back for nfc-list, and newly implemented in nfc-poll --- examples/nfc-poll.1 | 16 +++++++++++++--- examples/nfc-poll.c | 19 +++++++++++++++---- utils/nfc-list.1 | 2 +- utils/nfc-list.c | 15 +++++++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/examples/nfc-poll.1 b/examples/nfc-poll.1 index 86bf93a..682c99c 100644 --- a/examples/nfc-poll.1 +++ b/examples/nfc-poll.1 @@ -1,6 +1,6 @@ .TH nfc-poll 1 "June 26, 2009" "libnfc" "libnfc's examples" .SH NAME -nfc-poll \- Poll for one NFC target +nfc-poll \- poll first available NFC target .SH SYNOPSIS .B nfc-poll .SH DESCRIPTION @@ -8,8 +8,18 @@ nfc-poll \- Poll for one NFC target is a utility for polling any available target (tags but also NFCIP targets) using ISO14443-A, FeliCa, Jewel and ISO14443-B modulations. -This tool relies on a hardware polling feature of the PN532, it will display -available information retrieved from the tag. +This tool uses hardware polling feature if available (ie. PN532) or switch back +to software polling, it will display available information retrieved from the +tag. + +.SH OPTIONS +.TP +.B \-v +Tells +.I +nfc-poll +to be verbose and display detailed information about the targets shown. +This includes SAK decoding and fingerprinting is available. .SH IMPORTANT There are some well-know limits with this example: diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 820b26e..ded0705 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -62,6 +62,13 @@ void stop_polling (int sig) exit (EXIT_FAILURE); } +void +print_usage (char* progname) +{ + printf ("usage: %s [-v]\n", progname); + printf (" -v\t verbose display\n"); +} + int main (int argc, const char *argv[]) { @@ -72,11 +79,15 @@ main (int argc, const char *argv[]) // Display libnfc version const char *acLibnfcVersion = nfc_version (); - if (argc > 1) { - errx (1, "usage: %s", argv[0]); - } - printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion); + if (argc != 1) { + if ((argc == 2) && (0 == strcmp ("-v", argv[1]))) { + verbose = true; + } else { + print_usage (argv[0]); + exit (EXIT_FAILURE); + } + } const uint8_t uiPollNr = 20; const uint8_t uiPeriod = 2; diff --git a/utils/nfc-list.1 b/utils/nfc-list.1 index 22bfa2e..cbe74ae 100644 --- a/utils/nfc-list.1 +++ b/utils/nfc-list.1 @@ -18,7 +18,7 @@ This tool displays all available information at selection time. .SH OPTIONS .TP -.B \-v, \-\-verbose +.B \-v Tells .I nfc-list diff --git a/utils/nfc-list.c b/utils/nfc-list.c index a12a4a6..fbf8f94 100644 --- a/utils/nfc-list.c +++ b/utils/nfc-list.c @@ -59,6 +59,13 @@ static nfc_device *pnd; +void +print_usage (char* progname) +{ + printf ("usage: %s [-v]\n", progname); + printf (" -v\t verbose display\n"); +} + int main (int argc, const char *argv[]) { @@ -71,6 +78,14 @@ main (int argc, const char *argv[]) // Display libnfc version acLibnfcVersion = nfc_version (); printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion); + if (argc != 1) { + if ((argc == 2) && (0 == strcmp ("-v", argv[1]))) { + verbose = true; + } else { + print_usage (argv[0]); + exit (EXIT_FAILURE); + } + } #ifdef HAVE_LIBUSB # ifdef DEBUG