From 651d88fd15a576dc4069cce8d5cb5bfc8a74372c Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Thu, 5 May 2011 14:24:27 +0000 Subject: [PATCH] examples/nfc-anticol: now use nfc_abort_command() --- examples/nfc-emulate-uid.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/nfc-emulate-uid.c b/examples/nfc-emulate-uid.c index 52df6c1..f4f285d 100644 --- a/examples/nfc-emulate-uid.c +++ b/examples/nfc-emulate-uid.c @@ -68,11 +68,10 @@ byte_t abtSak[9] = { 0x08, 0xb6, 0xdd }; void intr_hdlr (void) { - printf ("\nQuitting...\n"); if (pnd != NULL) { - nfc_disconnect(pnd); + printf ("\nAborting current command...\n"); + nfc_abort_command (pnd); } - exit (EXIT_FAILURE); } void @@ -159,7 +158,7 @@ main (int argc, char *argv[]) if (!nfc_target_init (pnd, &nt, abtRecv, &szRecvBits)) { nfc_perror (pnd, "nfc_target_init"); ERR ("Could not come out of auto-emulation, no command was received"); - exit(EXIT_FAILURE); + goto error; } printf ("[+] Received initiator command: "); print_hex_bits (abtRecv, szRecvBits); @@ -208,7 +207,7 @@ main (int argc, char *argv[]) // Send and print the command to the screen if (!nfc_target_send_bits (pnd, pbtTx, szTxBits, NULL)) { nfc_perror (pnd, "nfc_target_send_bits"); - exit (EXIT_FAILURE); + goto error; } if (!quiet_output) { printf ("T: "); @@ -217,7 +216,10 @@ main (int argc, char *argv[]) } } } - nfc_disconnect (pnd); exit (EXIT_SUCCESS); + +error: + nfc_disconnect (pnd); + exit (EXIT_FAILURE); }