Merge remote-tracking branch 'refs/remotes/libnfc/master'

Conflicts:
	contrib/windows.h
	libnfc/CMakeLists.txt
	libnfc/log-printf.c
	utils/CMakeLists.txt
This commit is contained in:
Alex Lian 2013-01-31 22:17:33 -05:00
commit caa09db5fc
36 changed files with 301 additions and 88 deletions

View file

@ -1,3 +1,23 @@
Jan TBD, 2013 - 1.7.0-rc3 (release candidate)
--------------------------------------------
Fixes:
- Fix pn53x_usb bulk write timeout
- Fix BCC in nfc-emulate-uid example
- Fix nfc-relay-picc example
- Fix a miss returned value within some internal functions (user program could
be affected)
- Fix nfc-scan-device -i option
- Remove wrong exit() calls in library
- Fix issue in driver acr122_usb affecting Touchatag
- Reenable some idle in all drivers, add selectively PowerDown when possible
Changes:
- nfc_emulate_target() now takes timeout parameter
Special thanks to:
- Alex Lian (Windows support refresh)
Jan 20, 2013 - 1.7.0-rc2 (release candidate)
--------------------------------------------

7
NEWS
View file

@ -1,3 +1,10 @@
New in 1.7.0-rc3:
API Changes:
* Functions
- Add timeout param to nfc_emulate_target()
New in 1.7.0-rc2:
Configuration:

20
README
View file

@ -10,7 +10,7 @@ General Information
libnfc is a library which allows userspace application access to NFC devices.
The official web site is:
http://www.libnfc.org/
http://www.nfc-tools.org/
The official forum site is:
http://www.libnfc.org/community/
@ -23,17 +23,17 @@ Important note: this file covers POSIX systems, for Windows please read README-W
Requirements
============
Some NFC drivers depends on third party software:
Some NFC drivers depend on third party software:
* pn53x_usb:
* pn53x_usb & acr122_usb:
- libusb-0.1 http://libusb.sf.net
* acr122:
* acr122_pcsc:
- pcsc-lite http://pcsclite.alioth.debian.org/
The regression test suite depend on the cutter framework:
The regression test suite depends on the cutter framework:
http://cutter.sf.net
Installation
@ -69,6 +69,13 @@ Please make sure to include:
And anything else you think is relevant.
* A trace with debug activated.
Reproduce the bug with debug, e.g. if it was:
$ nfc-list -v
run it as:
$ LIBNFC_LOG_LEVEL=3 nfc-list -v
* How to reproduce the bug.
Please include a short test program that exhibits the behavior.
@ -85,7 +92,8 @@ Patches
=======
Patches can be posted to http://code.google.com/p/libnfc/issues/list or
can be sent directly to libnfc's developers: http://www.libnfc.org/contact
can be sent directly to libnfc's developers:
http://nfc-tools.org/index.php?title=Contact
If the patch fixes a bug, it is usually a good idea to include
all the information described in "How to Report Bugs".

View file

@ -1,6 +1,8 @@
*-
* Public platform independent Near Field Communication (NFC) library
* Windows-specific parts:
* Copyright (C) 2010, Glenn Ergeerts
* Copyright (C) 2013, Alex Lian
-*
Requirements

View file

@ -1,7 +1,7 @@
# General init
# /!\ Don't forget to update 'CMakeLists.txt' too /!\
AC_INIT([libnfc],[1.7.0-rc2],[info@libnfc.org])
AC_INIT([libnfc],[1.7.0-rc3],[info@libnfc.org])
AC_CONFIG_MACRO_DIR([m4])

View file

@ -1,4 +1,6 @@
SUBDIRS = sys .
EXTRA_DIST = \
err.h
err.h \
stdlib.c \
unistd.h

46
contrib/win32/stdlib.c Normal file
View file

@ -0,0 +1,46 @@
/*-
* Public platform independent Near Field Communication (NFC) library
*
* Copyright (C) 2013 Alex Lian
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
/**
* @file stdlib.c
* @brief Windows System compatibility
*/
// Handle platform specific includes
#include "contrib/windows.h"
int setenv(const char *name, const char *value, int overwrite)
{
int exists = GetEnvironmentVariableA(name, NULL, 0);
if ((exists && overwrite) || (!exists)) {
if (!SetEnvironmentVariableA(name, value)) {
// Set errno here correctly
return -1;
}
return 0;
}
// Exists and overwrite is 0.
return -1;
}
void unsetenv(const char *name)
{
SetEnvironmentVariableA(name, NULL);
}

View file

@ -1,7 +1,7 @@
/*-
* Public platform independent Near Field Communication (NFC) library
*
* Copyright (C) 2011, 2012 Romuald Conty
* Copyright (C) 2011, 2012, 2013 Romuald Conty
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
@ -31,5 +31,11 @@
# include <winbase.h>
# define sleep(X) Sleep( X * 1000)
// With MinGW, getopt(3) is provided as separate header
#if defined(WIN32) && defined(__GNUC__) /* mingw compiler */
#include <getopt.h>
#endif
#endif /* _UNISTD_H_ */

4
debian/changelog vendored
View file

@ -1,8 +1,8 @@
libnfc (1.7.0~rc2-1) unstable; urgency=low
libnfc (1.7.0~rc3-1) unstable; urgency=low
* Upload to Debian. (Closes: #672795)
-- Nobuhiro Iwamatsu <iwamatsu@debian.org> Mon, 21 Jan 2013 14:19:24 +0900
-- Nobuhiro Iwamatsu <iwamatsu@debian.org> Fri, 01 Feb 2013 09:01:53 +0900
libnfc (1.7.0~rc2-0) unstable; urgency=low

66
debian/control vendored
View file

@ -4,7 +4,7 @@ Priority: extra
Maintainer: Nobuhiro Iwamatsu <iwamatsu@debian.org>
Build-Depends: debhelper (>= 8), dh-autoreconf, libtool, pkg-config, libusb-dev
Standards-Version: 3.9.4
Homepage: http://www.libnfc.org/
Homepage: http://www.nfc-tools.org/
Vcs-Git: https://code.googlecode.com/p/libnfc/
Vcs-Browser: http://code.google.com/p/libnfc/source/browse/
@ -14,9 +14,14 @@ Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Near Field Communication (NFC) library
libnfc is a Free Software library for Near Field Communication.
Supported NFC hardware devices are, theorically, all hardware
based on the NXP PN531, PN532 or PN533 NFC controller chip.
libnfc is a library for Near Field Communication. It abstracts the
low-level details of communicating with the devices away behind an
easy-to-use high-level API.
It supports most hardware based on the NXP PN531, PN532 or PN533
controller chips.
.
This package contains the runtime library files needed to run software
using libnfc.
Package: libnfc-dev
Section: libdevel
@ -24,24 +29,57 @@ Architecture: any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, libnfc4 (= ${binary:Version}), libusb-dev
Description: Near Field Communication library (development files)
libnfc is a free software library for near-field communication.
Description: Near Field Communication (NFC) library (development files)
libnfc is a library for Near Field Communication. It abstracts the
low-level details of communicating with the devices away behind an
easy-to-use high-level API.
It supports most hardware based on the NXP PN531, PN532 or PN533
controller chips.
.
This package contains the header and development files needed to build
programs and packages using libnfc.
Package: libnfc4-dbg
Section: debug
Architecture: any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, libnfc4 (= ${binary:Version})
Description: Near Field Communication (NFC) library (debugging information)
libnfc is a library for Near Field Communication. It abstracts the
low-level details of communicating with the devices away behind an
easy-to-use high-level API.
It supports most hardware based on the NXP PN531, PN532 or PN533
controller chips.
.
This package contains the debugging information.
Package: libnfc-bin
Section: utils
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libnfc4 (>= ${binary:Version})
Description: Near Field Communication binaries
Some binaries are provided with libnfc useful for development
purposes (nfc-list, nfc-mfclassic, nfc-mfultralight, etc.).
Description: Near Field Communication (NFC) binaries
libnfc is a library for Near Field Communication. It abstracts the
low-level details of communicating with the devices away behind an
easy-to-use high-level API.
It supports most hardware based on the NXP PN531, PN532 or PN533
controller chips.
.
This package contains some utils that come along with libnfc, for
development or debugging purposes (including nfc-list, nfc-mfclassic,
nfc-mfultralight, etc).
Package: libnfc-examples
Section: utils
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libnfc4 (>= ${binary:Version})
Description: Near Field Communication examples
Description: Near Field Communication (NFC) examples
libnfc is a library for Near Field Communication. It abstracts the
low-level details of communicating with the devices away behind an
easy-to-use high-level API.
It supports most hardware based on the NXP PN531, PN532 or PN533
controller chips.
.
Some examples are provided with libnfc for debugging and/or
educational purposes (nfc-anticol, nfc-emulate, etc.).
@ -49,6 +87,12 @@ Package: libnfc-pn53x-examples
Section: utils
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libnfc4 (>= ${binary:Version})
Description: Near Field Communication examples for PN53x chips only
Description: Near Field Communication (NFC) examples for PN53x chips only
libnfc is a library for Near Field Communication. It abstracts the
low-level details of communicating with the devices away behind an
easy-to-use high-level API.
It supports most hardware based on the NXP PN531, PN532 or PN533
controller chips.
.
Some PN53x-only examples are provided with libnfc for debugging
and/or educational purposes (pn53x-sam, pn53x-tamashell, etc.).

2
debian/copyright vendored
View file

@ -1,6 +1,6 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: libnfc
Source: http://www.libnfc.org/
Source: http://libnfc.googlecode.com/
Files: *
Copyright: 2009, Roel Verdult <roel@libnfc.org>, Romuald Conty <romuald@libnfc.org>

View file

@ -10,6 +10,7 @@ debian/tmp/usr/bin/nfc-relay
debian/tmp/usr/share/man/man1/nfc-anticol.1
debian/tmp/usr/share/man/man1/nfc-dep-initiator.1
debian/tmp/usr/share/man/man1/nfc-dep-target.1
debian/tmp/usr/share/man/man1/nfc-emulate-forum-tag2.1
debian/tmp/usr/share/man/man1/nfc-emulate-tag.1
debian/tmp/usr/share/man/man1/nfc-emulate-uid.1
debian/tmp/usr/share/man/man1/nfc-mfsetuid.1

54
debian/libnfc4.symbols vendored Normal file
View file

@ -0,0 +1,54 @@
libnfc.so.4 libnfc4 #MINVER#
iso14443a_crc@Base 1.7.0~rc2
iso14443a_crc_append@Base 1.7.0~rc2
iso14443a_locate_historical_bytes@Base 1.7.0~rc2
nfc_abort_command@Base 1.7.0~rc2
nfc_close@Base 1.7.0~rc2
nfc_context_free@Base 1.7.0~rc2
nfc_context_new@Base 1.7.0~rc2
nfc_device_free@Base 1.7.0~rc2
nfc_device_get_connstring@Base 1.7.0~rc2
nfc_device_get_information_about@Base 1.7.0~rc2
nfc_device_get_last_error@Base 1.7.0~rc2
nfc_device_get_name@Base 1.7.0~rc2
nfc_device_get_supported_baud_rate@Base 1.7.0~rc2
nfc_device_get_supported_modulation@Base 1.7.0~rc2
nfc_device_new@Base 1.7.0~rc2
nfc_device_set_property_bool@Base 1.7.0~rc2
nfc_device_set_property_int@Base 1.7.0~rc2
nfc_drivers@Base 1.7.0~rc2
nfc_emulate_target@Base 1.7.0~rc2
nfc_exit@Base 1.7.0~rc2
nfc_idle@Base 1.7.0~rc2
nfc_init@Base 1.7.0~rc2
nfc_initiator_deselect_target@Base 1.7.0~rc2
nfc_initiator_init@Base 1.7.0~rc2
nfc_initiator_init_secure_element@Base 1.7.0~rc2
nfc_initiator_list_passive_targets@Base 1.7.0~rc2
nfc_initiator_poll_dep_target@Base 1.7.0~rc2
nfc_initiator_poll_target@Base 1.7.0~rc2
nfc_initiator_select_dep_target@Base 1.7.0~rc2
nfc_initiator_select_passive_target@Base 1.7.0~rc2
nfc_initiator_target_is_present@Base 1.7.0~rc2
nfc_initiator_transceive_bits@Base 1.7.0~rc2
nfc_initiator_transceive_bits_timed@Base 1.7.0~rc2
nfc_initiator_transceive_bytes@Base 1.7.0~rc2
nfc_initiator_transceive_bytes_timed@Base 1.7.0~rc2
nfc_list_devices@Base 1.7.0~rc2
nfc_open@Base 1.7.0~rc2
nfc_perror@Base 1.7.0~rc2
nfc_strerror@Base 1.7.0~rc2
nfc_strerror_r@Base 1.7.0~rc2
nfc_target_init@Base 1.7.0~rc2
nfc_target_receive_bits@Base 1.7.0~rc2
nfc_target_receive_bytes@Base 1.7.0~rc2
nfc_target_send_bits@Base 1.7.0~rc2
nfc_target_send_bytes@Base 1.7.0~rc2
nfc_version@Base 1.7.0~rc2
pn532_SAMConfiguration@Base 1.7.0~rc2
pn53x_read_register@Base 1.7.0~rc2
pn53x_transceive@Base 1.7.0~rc2
pn53x_write_register@Base 1.7.0~rc2
str_nfc_baud_rate@Base 1.7.0~rc2
str_nfc_modulation_type@Base 1.7.0~rc2
str_nfc_target@Base 1.7.0~rc2

4
debian/rules vendored
View file

@ -27,3 +27,7 @@ override_dh_auto_configure:
%:
dh $@ --with autoreconf
override_dh_strip:
dh_strip -plibnfc4 --dbg-package=libnfc4-dbg
dh_strip --remaining-packages

View file

@ -96,6 +96,7 @@ dist_man_MANS = \
nfc-mfsetuid.1 \
pn53x-diagnose.1 \
pn53x-sam.1 \
pn53x-tamashell.1
pn53x-tamashell.1 \
nfc-emulate-forum-tag2.1
EXTRA_DIST = CMakeLists.txt

View file

@ -197,7 +197,7 @@ main(int argc, char *argv[])
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
printf("Emulating NDEF tag now, please touch it with a second NFC device\n");
if (nfc_emulate_target(pnd, &emulator) < 0) {
if (nfc_emulate_target(pnd, &emulator, 0) < 0) {
goto error;
}

View file

@ -55,7 +55,7 @@ extern "C" {
void *data;
};
NFC_EXPORT int nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator);
NFC_EXPORT int nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator, const int timeout);
#ifdef __cplusplus
}

View file

@ -1,7 +1,7 @@
# Windows MinGW workarounds
IF(WIN32)
message("Adding in contrib win32 sources")
SET(WINDOWS_SOURCES ../contrib/win32/nfc_win32)
SET(WINDOWS_SOURCES ../contrib/win32/stdlib)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32)
message("Win32: " ${WINDOWS_SOURCES})
ENDIF(WIN32)

View file

@ -4,7 +4,7 @@
* @section intro_sec Introduction
* This is the developer manual for \b libnfc.
* libnfc is an open source library that allows you to communicate with NFC devices. For more info, see the
* <a href="http://www.libnfc.org">libnfc homepage</a>.
* <a href="http://www.nfc-tools.org">libnfc homepage</a>.
*
* @section quick_start_sec Quick start
* If you are looking for libnfc's public API, you should start with the Modules page which links to the different categories of libnfc's functionality.

View file

@ -947,30 +947,25 @@ pn53x_idle(struct nfc_device *pnd)
if ((res = pn53x_InRelease(pnd, 0)) < 0) {
return res;
}
if (CHIP_DATA(pnd)->type == PN532) {
if ((CHIP_DATA(pnd)->type == PN532) && (pnd->driver->powerdown)) {
// Use PowerDown to go in "Low VBat" power mode
if ((res = pn53x_PowerDown(pnd)) < 0) {
if ((res = pnd->driver->powerdown(pnd)) < 0) {
return res;
}
}
break;
case INITIATOR:
// Deselect all active communications
if ((res = pn53x_InDeselect(pnd, 0)) < 0) {
// Use InRelease to go in "Standby mode"
if ((res = pn53x_InRelease(pnd, 0)) < 0) {
return res;
}
// Disable RF field to avoid heating
if ((res = nfc_device_set_property_bool(pnd, NP_ACTIVATE_FIELD, false)) < 0) {
return res;
}
if (CHIP_DATA(pnd)->type == PN532) {
if ((CHIP_DATA(pnd)->type == PN532) && (pnd->driver->powerdown)) {
// Use PowerDown to go in "Low VBat" power mode
if ((res = pn53x_PowerDown(pnd)) < 0) {
return res;
}
} else {
// Use InRelease to go in "Standby mode"
if ((res = pn53x_InRelease(pnd, 0)) < 0) {
if ((res = pnd->driver->powerdown(pnd)) < 0) {
return res;
}
}

View file

@ -80,7 +80,7 @@
#define ACR122_PCSC_RESPONSE_LEN 268
#define LOG_GROUP NFC_LOG_GROUP_DRIVER
#define LOG_CATEGORY "libnfc.driver.acr122"
#define LOG_CATEGORY "libnfc.driver.acr122_pcsc"
// Internal data struct
const struct pn53x_io acr122_pcsc_io;
@ -324,6 +324,8 @@ error:
static void
acr122_pcsc_close(nfc_device *pnd)
{
pn53x_idle(pnd);
SCardDisconnect(DRIVER_DATA(pnd)->hCard, SCARD_LEAVE_CARD);
acr122_pcsc_free_scardcontext();
@ -516,6 +518,8 @@ const struct nfc_driver acr122_pcsc_driver = {
.device_get_information_about = pn53x_get_information_about,
.abort_command = NULL, // Abort is not supported in this driver
.idle = NULL, // Idle is not supported in this driver
.idle = pn53x_idle,
/* Even if PN532, PowerDown is not recommended on those devices */
.powerdown = NULL,
};

View file

@ -551,7 +551,6 @@ static void
acr122_usb_close(nfc_device *pnd)
{
acr122_usb_ack(pnd);
pn53x_idle(pnd);
int res;
@ -896,4 +895,6 @@ const struct nfc_driver acr122_usb_driver = {
.abort_command = acr122_usb_abort_command,
.idle = pn53x_idle,
/* Even if PN532, PowerDown is not recommended on those devices */
.powerdown = NULL,
};

View file

@ -520,6 +520,8 @@ static void
acr122s_close(nfc_device *pnd)
{
acr122s_deactivate_sam(pnd);
pn53x_idle(pnd);
uart_close(DRIVER_DATA(pnd)->port);
#ifndef WIN32
@ -726,5 +728,7 @@ const struct nfc_driver acr122s_driver = {
.device_get_information_about = pn53x_get_information_about,
.abort_command = acr122s_abort_command,
.idle = NULL,
.idle = pn53x_idle,
/* Even if PN532, PowerDown is not recommended on those devices */
.powerdown = NULL,
};

View file

@ -211,6 +211,8 @@ arygon_connstring_decode(const nfc_connstring connstring, struct arygon_descript
static void
arygon_close(nfc_device *pnd)
{
pn53x_idle(pnd);
// Release UART port
uart_close(DRIVER_DATA(pnd)->port);
@ -587,6 +589,8 @@ const struct nfc_driver arygon_driver = {
.device_get_information_about = pn53x_get_information_about,
.abort_command = arygon_abort_command,
.idle = NULL, // FIXME arygon driver does not support idle()
.idle = pn53x_idle,
/* Even if PN532, PowerDown is not recommended on those devices */
.powerdown = NULL,
};

View file

@ -188,6 +188,8 @@ pn532_connstring_decode(const nfc_connstring connstring, struct pn532_uart_descr
static void
pn532_uart_close(nfc_device *pnd)
{
pn53x_idle(pnd);
// Release UART port
uart_close(DRIVER_DATA(pnd)->port);
@ -529,5 +531,6 @@ const struct nfc_driver pn532_uart_driver = {
.abort_command = pn532_uart_abort_command,
.idle = pn53x_idle,
.powerdown = pn53x_PowerDown,
};

View file

@ -447,14 +447,14 @@ pn53x_usb_close(nfc_device *pnd)
{
pn53x_usb_ack(pnd);
pn53x_idle(pnd);
if (DRIVER_DATA(pnd)->model == ASK_LOGO) {
/* Set P30, P31, P32, P33, P35 to logic 1 and P34 to 0 logic */
/* ie. Switch all LEDs off and turn off progressive field */
pn53x_write_register(pnd, PN53X_SFR_P3, 0xFF, _BV(P30) | _BV(P31) | _BV(P32) | _BV(P33) | _BV(P35));
}
pn53x_idle(pnd);
int res;
if ((res = usb_release_interface(DRIVER_DATA(pnd)->pudh, 0)) < 0) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to release USB interface (%s)", _usb_strerror(res));
@ -652,7 +652,7 @@ read:
int
pn53x_usb_ack(nfc_device *pnd)
{
return pn53x_usb_bulk_write(DRIVER_DATA(pnd), (uint8_t *) pn53x_ack_frame, sizeof(pn53x_ack_frame), -1);
return pn53x_usb_bulk_write(DRIVER_DATA(pnd), (uint8_t *) pn53x_ack_frame, sizeof(pn53x_ack_frame), 1000);
}
int
@ -792,4 +792,5 @@ const struct nfc_driver pn53x_usb_driver = {
.abort_command = pn53x_usb_abort_command,
.idle = pn53x_idle,
.powerdown = pn53x_PowerDown,
};

View file

@ -28,14 +28,24 @@
#include "iso7816.h"
/** @ingroup emulation
* @brief Emulate a target
* @return Returns 0 on success, otherwise returns libnfc's error code (negative value).
*
* @param pnd \a nfc_device struct pointer that represents currently used device
* @param emulator \nfc_emulator struct point that handles input/output functions
*
* If timeout equals to 0, the function blocks indefinitely (until an error is raised or function is completed)
* If timeout equals to -1, the default timeout will be used
*/
int
nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator)
nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator, const int timeout)
{
uint8_t abtRx[ISO7816_SHORT_R_APDU_MAX_LEN];
uint8_t abtTx[ISO7816_SHORT_C_APDU_MAX_LEN];
int res;
if ((res = nfc_target_init(pnd, emulator->target, abtRx, sizeof(abtRx), 0)) < 0) {
if ((res = nfc_target_init(pnd, emulator->target, abtRx, sizeof(abtRx), timeout)) < 0) {
return res;
}
@ -44,12 +54,12 @@ nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator)
while (io_res >= 0) {
io_res = emulator->state_machine->io(emulator, abtRx, szRx, abtTx, sizeof(abtTx));
if (io_res > 0) {
if ((res = nfc_target_send_bytes(pnd, abtTx, io_res, 0)) < 0) {
if ((res = nfc_target_send_bytes(pnd, abtTx, io_res, timeout)) < 0) {
return res;
}
}
if (io_res >= 0) {
if ((res = nfc_target_receive_bytes(pnd, abtRx, sizeof(abtRx), 0)) < 0) {
if ((res = nfc_target_receive_bytes(pnd, abtRx, sizeof(abtRx), timeout)) < 0) {
return res;
}
szRx = res;
@ -57,3 +67,4 @@ nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator)
}
return (io_res < 0) ? io_res : 0;
}

View file

@ -147,6 +147,7 @@ struct nfc_driver {
int (*abort_command)(struct nfc_device *pnd);
int (*idle)(struct nfc_device *pnd);
int (*powerdown)(struct nfc_device *pnd);
};
# define DEVICE_NAME_LENGTH 256

View file

@ -114,10 +114,6 @@ const struct nfc_driver *nfc_drivers[] = {
void
nfc_init(nfc_context **context)
{
if (!context) {
printf("Error: NULL context is not supported anymore, please fix your code.\n");
exit(EXIT_FAILURE);
}
*context = nfc_context_new();
}
@ -213,11 +209,8 @@ void
nfc_close(nfc_device *pnd)
{
if (pnd) {
// Go in idle mode
nfc_idle(pnd);
// Close, clean up and release the device
pnd->driver->close(pnd);
}
}
@ -236,11 +229,6 @@ nfc_list_devices(nfc_context *context, nfc_connstring connstrings[], const size_
const struct nfc_driver *ndr;
const struct nfc_driver **pndr = nfc_drivers;
if (!context) {
printf("NULL context is not supported anymore! Please fix your code.\n");
exit(EXIT_FAILURE);
}
// Load manually configured devices (from config file and env variables)
// TODO From env var...
for (uint32_t i = 0; i < context->user_defined_device_count; i++) {
@ -251,8 +239,10 @@ nfc_list_devices(nfc_context *context, nfc_connstring connstrings[], const size_
char *old_env_log_level = NULL;
// do it silently
if (env_log_level) {
if ((old_env_log_level = malloc(strlen(env_log_level) + 1)) == NULL)
exit(EXIT_FAILURE);
if ((old_env_log_level = malloc(strlen(env_log_level) + 1)) == NULL) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Unable to malloc()");
return 0;
}
strcpy(old_env_log_level, env_log_level);
}
setenv("LIBNFC_LOG_LEVEL", "0", 1);

View file

@ -21,10 +21,12 @@ FOREACH(source ${UTILS-SOURCES})
LIST(APPEND TARGETS mifare)
ENDIF((${source} MATCHES "nfc-mfultralight") OR (${source} MATCHES "nfc-mfclassic"))
IF(WIN32)
IF(${source} MATCHES "nfc-scan-device")
LIST(APPEND TARGETS ../contrib/win32/nfc_win32)
LIST(APPEND TARGETS ../contrib/win32/stdlib)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32)
ENDIF(${source} MATCHES "nfc-scan-device")
ENDIF(WIN32)
ADD_EXECUTABLE(${source} ${TARGETS})

View file

@ -47,7 +47,7 @@
* @note There are three different types of information (Authenticate, Data and Value).
*
* First an authentication must take place using Key A or B. It requires a 48 bit Key (6 bytes) and the UID.
* They are both used to initialize the internal cipher-state of the PN53X chip (http://libnfc.org/hardware/pn53x-chip).
* They are both used to initialize the internal cipher-state of the PN53X chip.
* After a successful authentication it will be possible to execute other commands (e.g. Read/Write).
* The MIFARE Classic Specification (http://www.nxp.com/acrobat/other/identification/M001053_MF1ICS50_rev5_3.pdf) explains more about this process.
*/

View file

@ -382,7 +382,7 @@ main(int argc, char *argv[])
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
printf("Emulating NDEF tag now, please touch it with a second NFC device\n");
if (0 != nfc_emulate_target(pnd, &emulator)) { // contains already nfc_target_init() call
if (0 != nfc_emulate_target(pnd, &emulator, 0)) { // contains already nfc_target_init() call
nfc_perror(pnd, "nfc_emulate_target");
}

View file

@ -77,11 +77,6 @@ main(int argc, const char *argv[])
bool verbose = false;
nfc_context *context;
nfc_init(&context);
// Display libnfc version
acLibnfcVersion = nfc_version();
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
// Get commandline options
for (int arg = 1; arg < argc; arg++) {
@ -91,6 +86,7 @@ main(int argc, const char *argv[])
} else if (0 == strcmp(argv[arg], "-v")) {
verbose = true;
} else if (0 == strcmp(argv[arg], "-i")) {
// This has to be done before the call to nfc_init()
setenv("LIBNFC_INTRUSIVE_SCAN", "yes", 1);
} else {
ERR("%s is not supported option.", argv[arg]);
@ -99,6 +95,12 @@ main(int argc, const char *argv[])
}
}
nfc_init(&context);
// Display libnfc version
acLibnfcVersion = nfc_version();
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
#ifdef HAVE_LIBUSB
# ifdef DEBUG
usb_set_debug(4);

View file

@ -21,7 +21,7 @@
; #define? COMPANY_PRODUCT_ICON ..\win32\libnfc.ico ;; override from company.mmh
#define? UISAMPLE_DIALOG_FILE_dlgbmp nfcleft.bmp ;; override uisample.mmh
#define? UISAMPLE_BLINE_TEXT www.libnfc.org
#define? UISAMPLE_BLINE_TEXT www.nfc-tools.org
#define? COMPANY_WANT_TO_INSTALL_DOCUMENTATION N
;--- Include MAKEMSI support (with my customisations and MSI branding) ------