mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-04-19 21:16:16 +00:00
pn53x_usb: leave the device in cleaner state (Fixes Issue 123)
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <nfc/nfc.h>
|
||||
|
||||
@@ -49,6 +50,16 @@ static nfc_device_t *pnd;
|
||||
static bool quiet_output = false;
|
||||
static bool init_mfc_auth = false;
|
||||
|
||||
void
|
||||
intr_hdlr (void)
|
||||
{
|
||||
printf ("\nQuitting...\n");
|
||||
if (pnd != NULL) {
|
||||
nfc_disconnect(pnd);
|
||||
}
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bool
|
||||
target_io( const nfc_target_t nt, const byte_t * pbtInput, const size_t szInput, byte_t * pbtOutput, size_t *pszOutput )
|
||||
{
|
||||
@@ -139,6 +150,12 @@ main (int argc, char *argv[])
|
||||
{
|
||||
const char *acLibnfcVersion;
|
||||
|
||||
#ifdef WIN32
|
||||
signal (SIGINT, (void (__cdecl *) (int)) intr_hdlr);
|
||||
#else
|
||||
signal (SIGINT, (void (*)()) intr_hdlr);
|
||||
#endif
|
||||
|
||||
// Try to open the NFC reader
|
||||
pnd = nfc_connect (NULL);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <nfc/nfc.h>
|
||||
|
||||
@@ -54,6 +55,16 @@ byte_t abtAtqa[2] = { 0x04, 0x00 };
|
||||
byte_t abtUidBcc[5] = { 0xDE, 0xAD, 0xBE, 0xAF, 0x62 };
|
||||
byte_t abtSak[9] = { 0x08, 0xb6, 0xdd };
|
||||
|
||||
void
|
||||
intr_hdlr (void)
|
||||
{
|
||||
printf ("\nQuitting...\n");
|
||||
if (pnd != NULL) {
|
||||
nfc_disconnect(pnd);
|
||||
}
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void
|
||||
print_usage (char *argv[])
|
||||
{
|
||||
@@ -99,6 +110,12 @@ main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
signal (SIGINT, (void (__cdecl *) (int)) intr_hdlr);
|
||||
#else
|
||||
signal (SIGINT, (void (*)()) intr_hdlr);
|
||||
#endif
|
||||
|
||||
// Try to open the NFC device
|
||||
pnd = nfc_connect (NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user