examples/nfc-anticol: now use nfc_abort_command()

This commit is contained in:
Romuald Conty 2011-05-05 14:24:27 +00:00
parent 8dd8d25ef7
commit 651d88fd15

View file

@ -68,11 +68,10 @@ byte_t abtSak[9] = { 0x08, 0xb6, 0xdd };
void void
intr_hdlr (void) intr_hdlr (void)
{ {
printf ("\nQuitting...\n");
if (pnd != NULL) { if (pnd != NULL) {
nfc_disconnect(pnd); printf ("\nAborting current command...\n");
nfc_abort_command (pnd);
} }
exit (EXIT_FAILURE);
} }
void void
@ -159,7 +158,7 @@ main (int argc, char *argv[])
if (!nfc_target_init (pnd, &nt, abtRecv, &szRecvBits)) { if (!nfc_target_init (pnd, &nt, abtRecv, &szRecvBits)) {
nfc_perror (pnd, "nfc_target_init"); nfc_perror (pnd, "nfc_target_init");
ERR ("Could not come out of auto-emulation, no command was received"); ERR ("Could not come out of auto-emulation, no command was received");
exit(EXIT_FAILURE); goto error;
} }
printf ("[+] Received initiator command: "); printf ("[+] Received initiator command: ");
print_hex_bits (abtRecv, szRecvBits); print_hex_bits (abtRecv, szRecvBits);
@ -208,7 +207,7 @@ main (int argc, char *argv[])
// Send and print the command to the screen // Send and print the command to the screen
if (!nfc_target_send_bits (pnd, pbtTx, szTxBits, NULL)) { if (!nfc_target_send_bits (pnd, pbtTx, szTxBits, NULL)) {
nfc_perror (pnd, "nfc_target_send_bits"); nfc_perror (pnd, "nfc_target_send_bits");
exit (EXIT_FAILURE); goto error;
} }
if (!quiet_output) { if (!quiet_output) {
printf ("T: "); printf ("T: ");
@ -217,7 +216,10 @@ main (int argc, char *argv[])
} }
} }
} }
nfc_disconnect (pnd); nfc_disconnect (pnd);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
error:
nfc_disconnect (pnd);
exit (EXIT_FAILURE);
} }