Merge r486-498 from trunk.

This commit is contained in:
Romain Tartiere 2010-07-31 14:23:33 +00:00
commit d0357cf3aa
10 changed files with 71 additions and 28 deletions

View file

@ -132,3 +132,5 @@ AC_CONFIG_FILES([
]) ])
AC_OUTPUT AC_OUTPUT
LIBNFC_DRIVERS_SUMMARY

View file

@ -111,7 +111,8 @@ int main(int argc, const char* argv[])
{ {
nfc_device_t* pnd; nfc_device_t* pnd;
(void)(argc, argv); (void)argc;
(void)argv;
// Display libnfc version // Display libnfc version
const char* acLibnfcVersion = nfc_version(); const char* acLibnfcVersion = nfc_version();

View file

@ -3,16 +3,39 @@ INCLUDES= $(all_includes) $(LIBNFC_CFLAGS)
noinst_HEADERS = acr122.h arygon.h pn531_usb.h pn532_uart.h pn533_usb.h pn53x_usb.h noinst_HEADERS = acr122.h arygon.h pn531_usb.h pn532_uart.h pn533_usb.h pn53x_usb.h
noinst_LTLIBRARIES = libnfcdrivers.la noinst_LTLIBRARIES = libnfcdrivers.la
libnfcdrivers_la_SOURCES = acr122.c arygon.c pn531_usb.c pn532_uart.c pn533_usb.c pn53x_usb.c
libnfcdrivers_la_SOURCES =
libnfcdrivers_la_CFLAGS = @DRIVERS_CFLAGS@ -I$(top_srcdir)/libnfc -I$(top_srcdir)/libnfc/buses libnfcdrivers_la_CFLAGS = @DRIVERS_CFLAGS@ -I$(top_srcdir)/libnfc -I$(top_srcdir)/libnfc/buses
libnfcdrivers_la_LIBADD = libnfcdrivers_la_LIBADD =
if DRIVER_ACR122_ENABLED
libnfcdrivers_la_SOURCES += acr122.c
endif
if DRIVER_ARYGON_ENABLED
libnfcdrivers_la_SOURCES += arygon.c
endif
if DRIVER_PN531_USB_ENABLED
libnfcdrivers_la_SOURCES += pn531_usb.c
endif
if DRIVER_PN533_USB_ENABLED
libnfcdrivers_la_SOURCES += pn533_usb.c
endif
if DRIVER_PN532_UART_ENABLED
libnfcdrivers_la_SOURCES += pn532_uart.c
endif
if PCSC_ENABLED if PCSC_ENABLED
libnfcdrivers_la_CFLAGS += @libpcsclite_CFLAGS@ libnfcdrivers_la_CFLAGS += @libpcsclite_CFLAGS@
libnfcdrivers_la_LIBADD += @libpcsclite_LIBS@ libnfcdrivers_la_LIBADD += @libpcsclite_LIBS@
endif endif
if LIBUSB_ENABLED if LIBUSB_ENABLED
libnfcdrivers_la_SOURCES += pn53x_usb.c
libnfcdrivers_la_CFLAGS += @libusb_CFLAGS@ libnfcdrivers_la_CFLAGS += @libusb_CFLAGS@
libnfcdrivers_la_LIBADD += @libusb_LIBS@ libnfcdrivers_la_LIBADD += @libusb_LIBS@
endif endif

View file

@ -22,8 +22,6 @@
* @brief Driver for ACR122 devices (e.g. Tikitag, Touchatag, ACS ACR122) * @brief Driver for ACR122 devices (e.g. Tikitag, Touchatag, ACS ACR122)
*/ */
#ifdef DRIVER_ACR122_ENABLED
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
@ -360,5 +358,3 @@ bool acr122_led_red(const nfc_device_spec_t nds, bool bOn)
} }
} }
#endif // DRIVER_ACR122_ENABLED

View file

@ -25,8 +25,6 @@
* UART connection can be direct (host<->arygon_uc) or could be provided by internal USB to serial interface (e.g. host<->ftdi_chip<->arygon_uc) * UART connection can be direct (host<->arygon_uc) or could be provided by internal USB to serial interface (e.g. host<->ftdi_chip<->arygon_uc)
*/ */
#ifdef DRIVER_ARYGON_ENABLED
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
@ -331,5 +329,3 @@ arygon_check_communication(const nfc_device_spec_t nds)
return true; return true;
} }
#endif // DRIVER_ARYGON_ENABLED

View file

@ -26,8 +26,6 @@
Thanks to d18c7db and Okko for example code Thanks to d18c7db and Okko for example code
*/ */
#ifdef DRIVER_PN531_USB_ENABLED
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
@ -73,5 +71,3 @@ nfc_device_t* pn531_usb_connect(const nfc_device_desc_t* pndd)
return pn53x_usb_connect(pndd, pndd->acDevice, NC_PN531); return pn53x_usb_connect(pndd, pndd->acDevice, NC_PN531);
} }
#endif // DRIVER_PN531_USB_ENABLED

View file

@ -22,8 +22,6 @@
* @brief PN532 driver using UART bus (UART, RS232, etc.) * @brief PN532 driver using UART bus (UART, RS232, etc.)
*/ */
#ifdef DRIVER_PN532_UART_ENABLED
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
@ -55,8 +53,15 @@
// MacOS // MacOS
// TODO: find UART connection string for PN53X device on Mac OS X // TODO: find UART connection string for PN53X device on Mac OS X
#define SERIAL_STRING "" #define SERIAL_STRING ""
#elif defined(__FreeBSD__)
// XXX: Not tested
#define SERIAL_STRING "/dev/cuau"
#else #else
// *BSD, Linux and others POSIX systems // Linux and maybe some operating systems
// FIXME: We'd rather have an #elif defined(__linux__) or something like
// that and an #else that triggers an error at compile time instead
// of "falling-back" on a value that is likely to not be suitable
// for most operating systems.
#define SERIAL_STRING "/dev/ttyUSB" #define SERIAL_STRING "/dev/ttyUSB"
#endif #endif
#endif #endif
@ -315,5 +320,3 @@ pn532_uart_check_communication(const nfc_device_spec_t nds)
return true; return true;
} }
#endif // DRIVER_PN532_UART_ENABLED

View file

@ -26,8 +26,6 @@
Thanks to d18c7db and Okko for example code Thanks to d18c7db and Okko for example code
*/ */
#ifdef DRIVER_PN533_USB_ENABLED
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
@ -71,5 +69,3 @@ nfc_device_t* pn533_usb_connect(const nfc_device_desc_t* pndd)
return pn53x_usb_connect(pndd, pndd->acDevice, NC_PN533); return pn53x_usb_connect(pndd, pndd->acDevice, NC_PN533);
} }
#endif // DRIVER_PN533_USB_ENABLED

View file

@ -30,8 +30,6 @@
Thanks to d18c7db and Okko for example code Thanks to d18c7db and Okko for example code
*/ */
#if defined (DRIVER_PN531_USB_ENABLED) || defined (DRIVER_PN533_USB_ENABLED)
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <usb.h> #include <usb.h>
@ -282,6 +280,12 @@ bool pn53x_usb_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t s
#ifdef DEBUG #ifdef DEBUG
PRINT_HEX("RX", abtRx,ret); PRINT_HEX("RX", abtRx,ret);
#endif #endif
uint8_t ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
if ((ret != 6) || (memcmp (abtRx, ack_frame, 6))) {
DBG ("%s", "===> No ACK!!!!!!");
return false;
}
if (!pn53x_transceive_callback (pnd, abtRx, ret)) if (!pn53x_transceive_callback (pnd, abtRx, ret))
return false; return false;
@ -297,6 +301,8 @@ bool pn53x_usb_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t s
PRINT_HEX("RX", abtRx,ret); PRINT_HEX("RX", abtRx,ret);
#endif #endif
usb_bulk_write(pus->pudh, pus->uiEndPointOut, (char *)ack_frame, 6, USB_TIMEOUT);
// When the answer should be ignored, just return a succesful result // When the answer should be ignored, just return a succesful result
if(pbtRx == NULL || pszRxLen == NULL) return true; if(pbtRx == NULL || pszRxLen == NULL) return true;
@ -322,5 +328,3 @@ bool pn53x_usb_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t s
return true; return true;
} }
#endif // DRIVER_PN531_USB_ENABLED || DRIVER_PN533_USB_ENABLED

View file

@ -4,7 +4,7 @@ AC_DEFUN([LIBNFC_ARG_WITH_DRIVERS],
[ [
AC_MSG_CHECKING(which drivers to build) AC_MSG_CHECKING(which drivers to build)
AC_ARG_WITH(drivers, AC_ARG_WITH(drivers,
AC_HELP_STRING([[[[--with-drivers=driver@<:@,driver...@:>@]]]], [Only use specific drivers (default set)]), AC_HELP_STRING([[[--with-drivers=driver@<:@,driver...@:>@]]], [Only use specific drivers (default set)]),
[ case "${withval}" in [ case "${withval}" in
yes | no) yes | no)
dnl ignore calls without any arguments dnl ignore calls without any arguments
@ -34,25 +34,36 @@ AC_DEFUN([LIBNFC_ARG_WITH_DRIVERS],
DRIVERS_CFLAGS="" DRIVERS_CFLAGS=""
driver_acr122_enabled="no"
driver_pn531_usb_enabled="no"
driver_pn533_usb_enabled="no"
driver_arygon_enabled="no"
driver_pn532_uart_enabled="no"
for driver in ${DRIVER_BUILD_LIST} for driver in ${DRIVER_BUILD_LIST}
do do
case "${driver}" in case "${driver}" in
acr122) acr122)
pcsc_required="yes" pcsc_required="yes"
driver_acr122_enabled="yes"
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_ACR122_ENABLED" DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_ACR122_ENABLED"
;; ;;
pn531_usb) pn531_usb)
libusb_required="yes" libusb_required="yes"
driver_pn531_usb_enabled="yes"
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN531_USB_ENABLED" DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN531_USB_ENABLED"
;; ;;
pn533_usb) pn533_usb)
libusb_required="yes" libusb_required="yes"
driver_pn533_usb_enabled="yes"
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN533_USB_ENABLED" DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN533_USB_ENABLED"
;; ;;
arygon) arygon)
driver_arygon_enabled="yes"
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_ARYGON_ENABLED" DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_ARYGON_ENABLED"
;; ;;
pn532_uart) pn532_uart)
driver_pn532_uart_enabled="yes"
DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN532_UART_ENABLED" DRIVERS_CFLAGS="$DRIVERS_CFLAGS -DDRIVER_PN532_UART_ENABLED"
;; ;;
*) *)
@ -61,4 +72,19 @@ AC_DEFUN([LIBNFC_ARG_WITH_DRIVERS],
esac esac
done done
AC_SUBST(DRIVERS_CFLAGS) AC_SUBST(DRIVERS_CFLAGS)
AM_CONDITIONAL(DRIVER_ACR122_ENABLED, [test x"$driver_acr122_enabled" = xyes])
AM_CONDITIONAL(DRIVER_PN531_USB_ENABLED, [test x"$driver_pn531_usb_enabled" = xyes])
AM_CONDITIONAL(DRIVER_PN533_USB_ENABLED, [test x"$driver_pn533_usb_enabled" = xyes])
AM_CONDITIONAL(DRIVER_ARYGON_ENABLED, [test x"$driver_arygon_enabled" = xyes])
AM_CONDITIONAL(DRIVER_PN532_UART_ENABLED, [test x"$driver_pn532_uart_enabled" = xyes])
])
AC_DEFUN([LIBNFC_DRIVERS_SUMMARY],[
echo
echo "Selected drivers:"
echo " acr122........... $driver_acr122_enabled"
echo " arygon........... $driver_arygon_enabled"
echo " pn531_usb........ $driver_pn531_usb_enabled"
echo " pn532_uart....... $driver_pn532_uart_enabled"
echo " pn533_usb........ $driver_pn533_usb_enabled"
]) ])