From ab62855d80a1d6f75b1530c9f792e9ccf4b478fe Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Tue, 3 Nov 2009 14:51:14 +0000 Subject: [PATCH 1/7] First attempt to reorganize tree. --- src/{ => include}/bitutils.h | 0 src/{ => include}/defines.h | 0 src/{devices.h => include/drivers.h} | 0 src/{ => include}/messages.h | 0 src/{libnfc.h => include/nfc.h} | 0 src/{ => include}/types.h | 0 src/{ => lib}/bitutils.c | 0 src/{ => lib/bus}/rs232.c | 0 src/{ => lib/bus}/rs232.h | 0 src/{dev_acr122.c => lib/drivers/acr122.c} | 0 src/{dev_acr122.h => lib/drivers/acr122.h} | 0 src/{dev_arygon.c => lib/drivers/arygon.c} | 0 src/{dev_arygon.h => lib/drivers/arygon.h} | 0 src/{dev_pn531.c => lib/drivers/pn531.c} | 0 src/{dev_pn531.h => lib/drivers/pn531.h} | 0 src/{dev_pn532_uart.c => lib/drivers/pn532_uart.c} | 0 src/{dev_pn532_uart.h => lib/drivers/pn532_uart.h} | 0 src/{dev_pn533.c => lib/drivers/pn533.c} | 0 src/{dev_pn533.h => lib/drivers/pn533.h} | 0 src/{libnfc.c => lib/nfc.c} | 0 20 files changed, 0 insertions(+), 0 deletions(-) rename src/{ => include}/bitutils.h (100%) rename src/{ => include}/defines.h (100%) rename src/{devices.h => include/drivers.h} (100%) rename src/{ => include}/messages.h (100%) rename src/{libnfc.h => include/nfc.h} (100%) rename src/{ => include}/types.h (100%) rename src/{ => lib}/bitutils.c (100%) rename src/{ => lib/bus}/rs232.c (100%) rename src/{ => lib/bus}/rs232.h (100%) rename src/{dev_acr122.c => lib/drivers/acr122.c} (100%) rename src/{dev_acr122.h => lib/drivers/acr122.h} (100%) rename src/{dev_arygon.c => lib/drivers/arygon.c} (100%) rename src/{dev_arygon.h => lib/drivers/arygon.h} (100%) rename src/{dev_pn531.c => lib/drivers/pn531.c} (100%) rename src/{dev_pn531.h => lib/drivers/pn531.h} (100%) rename src/{dev_pn532_uart.c => lib/drivers/pn532_uart.c} (100%) rename src/{dev_pn532_uart.h => lib/drivers/pn532_uart.h} (100%) rename src/{dev_pn533.c => lib/drivers/pn533.c} (100%) rename src/{dev_pn533.h => lib/drivers/pn533.h} (100%) rename src/{libnfc.c => lib/nfc.c} (100%) diff --git a/src/bitutils.h b/src/include/bitutils.h similarity index 100% rename from src/bitutils.h rename to src/include/bitutils.h diff --git a/src/defines.h b/src/include/defines.h similarity index 100% rename from src/defines.h rename to src/include/defines.h diff --git a/src/devices.h b/src/include/drivers.h similarity index 100% rename from src/devices.h rename to src/include/drivers.h diff --git a/src/messages.h b/src/include/messages.h similarity index 100% rename from src/messages.h rename to src/include/messages.h diff --git a/src/libnfc.h b/src/include/nfc.h similarity index 100% rename from src/libnfc.h rename to src/include/nfc.h diff --git a/src/types.h b/src/include/types.h similarity index 100% rename from src/types.h rename to src/include/types.h diff --git a/src/bitutils.c b/src/lib/bitutils.c similarity index 100% rename from src/bitutils.c rename to src/lib/bitutils.c diff --git a/src/rs232.c b/src/lib/bus/rs232.c similarity index 100% rename from src/rs232.c rename to src/lib/bus/rs232.c diff --git a/src/rs232.h b/src/lib/bus/rs232.h similarity index 100% rename from src/rs232.h rename to src/lib/bus/rs232.h diff --git a/src/dev_acr122.c b/src/lib/drivers/acr122.c similarity index 100% rename from src/dev_acr122.c rename to src/lib/drivers/acr122.c diff --git a/src/dev_acr122.h b/src/lib/drivers/acr122.h similarity index 100% rename from src/dev_acr122.h rename to src/lib/drivers/acr122.h diff --git a/src/dev_arygon.c b/src/lib/drivers/arygon.c similarity index 100% rename from src/dev_arygon.c rename to src/lib/drivers/arygon.c diff --git a/src/dev_arygon.h b/src/lib/drivers/arygon.h similarity index 100% rename from src/dev_arygon.h rename to src/lib/drivers/arygon.h diff --git a/src/dev_pn531.c b/src/lib/drivers/pn531.c similarity index 100% rename from src/dev_pn531.c rename to src/lib/drivers/pn531.c diff --git a/src/dev_pn531.h b/src/lib/drivers/pn531.h similarity index 100% rename from src/dev_pn531.h rename to src/lib/drivers/pn531.h diff --git a/src/dev_pn532_uart.c b/src/lib/drivers/pn532_uart.c similarity index 100% rename from src/dev_pn532_uart.c rename to src/lib/drivers/pn532_uart.c diff --git a/src/dev_pn532_uart.h b/src/lib/drivers/pn532_uart.h similarity index 100% rename from src/dev_pn532_uart.h rename to src/lib/drivers/pn532_uart.h diff --git a/src/dev_pn533.c b/src/lib/drivers/pn533.c similarity index 100% rename from src/dev_pn533.c rename to src/lib/drivers/pn533.c diff --git a/src/dev_pn533.h b/src/lib/drivers/pn533.h similarity index 100% rename from src/dev_pn533.h rename to src/lib/drivers/pn533.h diff --git a/src/libnfc.c b/src/lib/nfc.c similarity index 100% rename from src/libnfc.c rename to src/lib/nfc.c From 507991ac2b2c81cec1ed948423018feab30b2590 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Tue, 3 Nov 2009 15:20:36 +0000 Subject: [PATCH 2/7] Second attempt to reorganize tree --- src/{lib => examples}/bitutils.c | 0 src/{include => examples}/bitutils.h | 0 src/{include => lib}/defines.h | 0 src/{include => lib}/drivers.h | 0 src/{include => lib}/messages.h | 0 src/{include => lib}/nfc.h | 0 src/{include => lib}/types.h | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename src/{lib => examples}/bitutils.c (100%) rename src/{include => examples}/bitutils.h (100%) rename src/{include => lib}/defines.h (100%) rename src/{include => lib}/drivers.h (100%) rename src/{include => lib}/messages.h (100%) rename src/{include => lib}/nfc.h (100%) rename src/{include => lib}/types.h (100%) diff --git a/src/lib/bitutils.c b/src/examples/bitutils.c similarity index 100% rename from src/lib/bitutils.c rename to src/examples/bitutils.c diff --git a/src/include/bitutils.h b/src/examples/bitutils.h similarity index 100% rename from src/include/bitutils.h rename to src/examples/bitutils.h diff --git a/src/include/defines.h b/src/lib/defines.h similarity index 100% rename from src/include/defines.h rename to src/lib/defines.h diff --git a/src/include/drivers.h b/src/lib/drivers.h similarity index 100% rename from src/include/drivers.h rename to src/lib/drivers.h diff --git a/src/include/messages.h b/src/lib/messages.h similarity index 100% rename from src/include/messages.h rename to src/lib/messages.h diff --git a/src/include/nfc.h b/src/lib/nfc.h similarity index 100% rename from src/include/nfc.h rename to src/lib/nfc.h diff --git a/src/include/types.h b/src/lib/types.h similarity index 100% rename from src/include/types.h rename to src/lib/types.h From 4a5945e67d36598a0c78014d7bf5ccae29ccfd42 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Tue, 3 Nov 2009 15:53:35 +0000 Subject: [PATCH 3/7] Third attempt to reorganize tree. --- src/lib/buses.h | 23 +++++++++++++++++++++++ src/lib/buses/Makefile.am | 9 +++++++++ src/lib/{bus/rs232.c => buses/uart.c} | 0 src/lib/{bus/rs232.h => buses/uart.h} | 0 4 files changed, 32 insertions(+) create mode 100644 src/lib/buses.h create mode 100644 src/lib/buses/Makefile.am rename src/lib/{bus/rs232.c => buses/uart.c} (100%) rename src/lib/{bus/rs232.h => buses/uart.h} (100%) diff --git a/src/lib/buses.h b/src/lib/buses.h new file mode 100644 index 0000000..478d2e2 --- /dev/null +++ b/src/lib/buses.h @@ -0,0 +1,23 @@ +/** + * Public platform independent Near Field Communication (NFC) library + * + * Copyright (C) 2009, Roel Verdult + * + * 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 + * + * + * @file buses.h + * @brief + */ + diff --git a/src/lib/buses/Makefile.am b/src/lib/buses/Makefile.am new file mode 100644 index 0000000..7f062ef --- /dev/null +++ b/src/lib/buses/Makefile.am @@ -0,0 +1,9 @@ + +# set the include path found by configure +INCLUDES= $(all_includes) + +noinst_HEADERS = uart.h +noinst_LTLIBRARIES = libnfcbuses.la +libnfcbuses_la_SOURCES = uart.c + +DISTCLEANFILES = Makefile.in diff --git a/src/lib/bus/rs232.c b/src/lib/buses/uart.c similarity index 100% rename from src/lib/bus/rs232.c rename to src/lib/buses/uart.c diff --git a/src/lib/bus/rs232.h b/src/lib/buses/uart.h similarity index 100% rename from src/lib/bus/rs232.h rename to src/lib/buses/uart.h From 14a9112deac2375e67a7fd3f6fbac24972c4b75e Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 4 Nov 2009 10:14:17 +0000 Subject: [PATCH 4/7] It now compile using Autotools. --- configure.ac | 5 ++- libnfc.pc.in | 2 +- src/Makefile.am | 29 +--------------- src/examples/Makefile.am | 22 ++++++------ src/examples/nfc-anticol.c | 2 +- src/examples/nfc-emulate.c | 2 +- src/examples/nfc-list.c | 2 +- src/examples/nfc-mfclassic.c | 2 +- src/examples/nfc-mfultralight.c | 2 +- src/examples/nfc-relay.c | 2 +- src/examples/nfcip-initiator.c | 2 +- src/examples/nfcip-target.c | 2 +- src/lib/Makefile.am | 17 ++++++++++ src/{examples => lib}/bitutils.c | 0 src/{examples => lib}/bitutils.h | 0 src/lib/buses/Makefile.am | 1 + src/lib/buses/uart.c | 57 ++++++++++++++------------------ src/lib/buses/uart.h | 16 ++++----- src/lib/drivers.h | 22 ++++++------ src/lib/drivers/Makefile.am | 24 ++++++++++++++ src/lib/drivers/acr122.c | 17 +++++----- src/lib/drivers/acr122.h | 12 +++---- src/lib/drivers/arygon.c | 27 ++++++++------- src/lib/drivers/arygon.h | 8 ++--- src/lib/drivers/pn531.c | 11 +++--- src/lib/drivers/pn531.h | 8 ++--- src/lib/drivers/pn532_uart.c | 31 +++++++++-------- src/lib/drivers/pn532_uart.h | 8 ++--- src/lib/drivers/pn533.c | 11 +++--- src/lib/drivers/pn533.h | 8 ++--- src/lib/nfc.c | 25 +++++++------- src/lib/types.h | 8 ++--- 32 files changed, 193 insertions(+), 192 deletions(-) create mode 100644 src/lib/Makefile.am rename src/{examples => lib}/bitutils.c (100%) rename src/{examples => lib}/bitutils.h (100%) create mode 100644 src/lib/drivers/Makefile.am diff --git a/configure.ac b/configure.ac index 57c460c..7e364dc 100644 --- a/configure.ac +++ b/configure.ac @@ -165,8 +165,11 @@ fi AC_CONFIG_FILES([ Makefile - src/Makefile + src/lib/buses/Makefile + src/lib/drivers/Makefile + src/lib/Makefile src/examples/Makefile + src/Makefile libnfc.pc Doxyfile ]) diff --git a/libnfc.pc.in b/libnfc.pc.in index a22958b..7789156 100644 --- a/libnfc.pc.in +++ b/libnfc.pc.in @@ -1,7 +1,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ -includedir=@includedir@/@PACKAGE@ +includedir=@includedir@/nfc Name: libnfc Description: Near Field Communication (NFC) library Version: @VERSION@ diff --git a/src/Makefile.am b/src/Makefile.am index e088442..10863ba 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,30 +1,3 @@ -SUBDIRS = . examples - -# set the include path found by configure -INCLUDES= $(all_includes) - -nfc_devices_headers = dev_arygon.h dev_pn532_uart.h -nfcinclude_HEADERS = libnfc.h bitutils.h defines.h types.h rs232.h devices.h messages.h -nfcinclude_HEADERS += $(nfc_devices_headers) -nfcincludedir = $(includedir)/libnfc - -lib_LTLIBRARIES = libnfc.la -libnfc_la_SOURCES = bitutils.c libnfc.c rs232.c dev_arygon.c dev_pn532_uart.c -libnfc_la_CFLAGS = -libnfc_la_LIBADD = - -if PCSC_LITE_ENABLED - nfcinclude_HEADERS += dev_acr122.h - libnfc_la_CFLAGS += @LIBPCSCLITE_CFLAGS@ -DHAVE_PCSC_LITE - libnfc_la_SOURCES += dev_acr122.c - libnfc_la_LIBADD += @LIBPCSCLITE_LIBS@ -endif - -if LIBUSB_ENABLED - nfcinclude_HEADERS += dev_pn531.h dev_pn533.h - libnfc_la_CFLAGS += @LIBUSB_CFLAGS@ -DHAVE_LIBUSB - libnfc_la_SOURCES += dev_pn531.c dev_pn533.c - libnfc_la_LIBADD += @LIBUSB_LIBS@ -endif +SUBDIRS = lib examples DISTCLEANFILES = Makefile.in diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am index 54c8b90..a87a2b6 100644 --- a/src/examples/Makefile.am +++ b/src/examples/Makefile.am @@ -4,36 +4,34 @@ bin_PROGRAMS = nfc-anticol nfc-list nfc-mfclassic nfc-mfultralight nfc-relay nfc INCLUDES= $(all_includes) nfcinclude_HEADERS = mifaretag.h mifareultag.h -nfcincludedir = $(includedir)/libnfc +nfcincludedir = $(includedir)/nfc -AM_CFLAGS = -I$(top_srcdir)/src +AM_CFLAGS = -I$(top_srcdir)/src/lib nfc_anticol_SOURCES = nfc-anticol.c -nfc_anticol_LDADD = $(top_builddir)/src/libnfc.la +nfc_anticol_LDADD = $(top_builddir)/src/lib/libnfc.la nfc_list_SOURCES = nfc-list.c -nfc_list_LDADD = $(top_builddir)/src/libnfc.la +nfc_list_LDADD = $(top_builddir)/src/lib/libnfc.la nfc_mfultralight_SOURCES = nfc-mfultralight.c mifareultag.h -nfc_mfultralight_LDADD = $(top_builddir)/src/libnfc.la +nfc_mfultralight_LDADD = $(top_builddir)/src/lib/libnfc.la nfc_mfclassic_SOURCES = nfc-mfclassic.c mifaretag.h -nfc_mfclassic_LDADD = $(top_builddir)/src/libnfc.la +nfc_mfclassic_LDADD = $(top_builddir)/src/lib/libnfc.la nfc_relay_SOURCES = nfc-relay.c -nfc_relay_LDADD = $(top_builddir)/src/libnfc.la +nfc_relay_LDADD = $(top_builddir)/src/lib/libnfc.la nfc_emulate_SOURCES = nfc-emulate.c -nfc_emulate_LDADD = $(top_builddir)/src/libnfc.la +nfc_emulate_LDADD = $(top_builddir)/src/lib/libnfc.la nfcip_target_SOURCES = nfcip-target.c -nfcip_target_LDADD = $(top_builddir)/src/libnfc.la +nfcip_target_LDADD = $(top_builddir)/src/lib/libnfc.la nfcip_initiator_SOURCES = nfcip-initiator.c -nfcip_initiator_LDADD = $(top_builddir)/src/libnfc.la +nfcip_initiator_LDADD = $(top_builddir)/src/lib/libnfc.la dist_man_MANS = nfc-anticol.1 nfc-emulate.1 nfc-list.1 nfc-mfclassic.1 nfc-mfultralight.1 nfc-relay.1 -#dist_man_MANS = $(man_MANS) -#EXTRA_DIST = $(man_MANS) DISTCLEANFILES = Makefile.in diff --git a/src/examples/nfc-anticol.c b/src/examples/nfc-anticol.c index 9e0af10..048858a 100644 --- a/src/examples/nfc-anticol.c +++ b/src/examples/nfc-anticol.c @@ -28,7 +28,7 @@ #include #include -#include "libnfc.h" +#include #include "messages.h" #include "bitutils.h" diff --git a/src/examples/nfc-emulate.c b/src/examples/nfc-emulate.c index 6447cec..73d81d7 100644 --- a/src/examples/nfc-emulate.c +++ b/src/examples/nfc-emulate.c @@ -27,7 +27,7 @@ #include #include -#include "libnfc.h" +#include #include "messages.h" #include "bitutils.h" diff --git a/src/examples/nfc-list.c b/src/examples/nfc-list.c index 2e48cd8..9e81d91 100644 --- a/src/examples/nfc-list.c +++ b/src/examples/nfc-list.c @@ -27,7 +27,7 @@ #include -#include "libnfc.h" +#include #include "messages.h" #include "bitutils.h" diff --git a/src/examples/nfc-mfclassic.c b/src/examples/nfc-mfclassic.c index 6d06c83..91910a2 100644 --- a/src/examples/nfc-mfclassic.c +++ b/src/examples/nfc-mfclassic.c @@ -30,7 +30,7 @@ #include #include -#include "libnfc.h" +#include #include "mifaretag.h" #include "bitutils.h" diff --git a/src/examples/nfc-mfultralight.c b/src/examples/nfc-mfultralight.c index 9f717ba..4940688 100644 --- a/src/examples/nfc-mfultralight.c +++ b/src/examples/nfc-mfultralight.c @@ -30,7 +30,7 @@ #include #include -#include "libnfc.h" +#include #include "mifareultag.h" #include "bitutils.h" diff --git a/src/examples/nfc-relay.c b/src/examples/nfc-relay.c index a53a3e1..1a986f0 100644 --- a/src/examples/nfc-relay.c +++ b/src/examples/nfc-relay.c @@ -26,7 +26,7 @@ #include #include -#include "libnfc.h" +#include #include "messages.h" #include "bitutils.h" diff --git a/src/examples/nfcip-initiator.c b/src/examples/nfcip-initiator.c index 572b7b2..1721b8b 100644 --- a/src/examples/nfcip-initiator.c +++ b/src/examples/nfcip-initiator.c @@ -23,7 +23,7 @@ #include #include -#include "libnfc.h" +#include int main(int argc, const char *argv[]) { diff --git a/src/examples/nfcip-target.c b/src/examples/nfcip-target.c index 6d90a06..86adf15 100644 --- a/src/examples/nfcip-target.c +++ b/src/examples/nfcip-target.c @@ -22,7 +22,7 @@ */ #include -#include "libnfc.h" +#include int main(int argc, const char *argv[]) { diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am new file mode 100644 index 0000000..71ec0e6 --- /dev/null +++ b/src/lib/Makefile.am @@ -0,0 +1,17 @@ +SUBDIRS = buses drivers . + +# set the include path found by configure +INCLUDES= $(all_includes) + +nfcinclude_HEADERS = nfc.h defines.h types.h buses.h drivers.h messages.h bitutils.h +nfcincludedir = $(includedir)/nfc + +lib_LTLIBRARIES = libnfc.la +libnfc_la_SOURCES = nfc.c bitutils.c +libnfc_la_LDFLAGS = -no-undefined -version-info=0:0:0 +libnfc_la_CFLAGS = +libnfc_la_LIBADD = \ + $(top_builddir)/src/lib/buses/libnfcbuses.la \ + $(top_builddir)/src/lib/drivers/libnfcdrivers.la + +DISTCLEANFILES = Makefile.in diff --git a/src/examples/bitutils.c b/src/lib/bitutils.c similarity index 100% rename from src/examples/bitutils.c rename to src/lib/bitutils.c diff --git a/src/examples/bitutils.h b/src/lib/bitutils.h similarity index 100% rename from src/examples/bitutils.h rename to src/lib/bitutils.h diff --git a/src/lib/buses/Makefile.am b/src/lib/buses/Makefile.am index 7f062ef..6d6a840 100644 --- a/src/lib/buses/Makefile.am +++ b/src/lib/buses/Makefile.am @@ -5,5 +5,6 @@ INCLUDES= $(all_includes) noinst_HEADERS = uart.h noinst_LTLIBRARIES = libnfcbuses.la libnfcbuses_la_SOURCES = uart.c +libnfcbuses_la_CFLAGS = -I$(top_srcdir)/src/lib DISTCLEANFILES = Makefile.in diff --git a/src/lib/buses/uart.c b/src/lib/buses/uart.c index 8e3d25d..66f7cdd 100644 --- a/src/lib/buses/uart.c +++ b/src/lib/buses/uart.c @@ -17,17 +17,17 @@ * along with this program. If not, see * * - * @file rs232.c + * @file uart.c * @brief */ /* -Based on rs232-code written by Teunis van Beelen available: +Based on uart-code written by Teunis van Beelen available: http://www.teuniz.net/RS-232/index.html */ -#include "rs232.h" +#include "uart.h" #include "messages.h" @@ -48,10 +48,10 @@ struct timeval tv = { .tv_usec = 30000 // 30,000 micro seconds }; -// Work-around to claim rs232 interface using the c_iflag (software input processing) from the termios struct +// Work-around to claim uart interface using the c_iflag (software input processing) from the termios struct #define CCLAIMED 0x80000000 -serial_port rs232_open(const char* pcPortName) +serial_port uart_open(const char* pcPortName) { serial_port_unix* sp = malloc(sizeof(serial_port_unix)); @@ -60,20 +60,20 @@ serial_port rs232_open(const char* pcPortName) sp->fd = open(pcPortName, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK); if(sp->fd == -1) { - rs232_close(sp); + uart_close(sp); return INVALID_SERIAL_PORT; } if(tcgetattr(sp->fd,&sp->tiOld) == -1) { - rs232_close(sp); + uart_close(sp); return INVALID_SERIAL_PORT; } // Make sure the port is not claimed already if (sp->tiOld.c_iflag & CCLAIMED) { - rs232_close(sp); + uart_close(sp); return CLAIMED_SERIAL_PORT; } @@ -90,7 +90,7 @@ serial_port rs232_open(const char* pcPortName) if(tcsetattr(sp->fd,TCSANOW,&sp->tiNew) == -1) { - rs232_close(sp); + uart_close(sp); return INVALID_SERIAL_PORT; } @@ -98,7 +98,7 @@ serial_port rs232_open(const char* pcPortName) return sp; } -void rs232_set_speed(serial_port sp, const uint32_t uiPortSpeed) +void uart_set_speed(serial_port sp, const uint32_t uiPortSpeed) { DBG("Serial port speed requested to be set to %d bauds.", uiPortSpeed); // Set port speed (Input and Output) @@ -136,7 +136,7 @@ void rs232_set_speed(serial_port sp, const uint32_t uiPortSpeed) } } -uint32_t rs232_get_speed(const serial_port sp) +uint32_t uart_get_speed(const serial_port sp) { uint32_t uiPortSpeed = 0; const serial_port_unix* spu = (serial_port_unix*)sp; @@ -163,21 +163,21 @@ uint32_t rs232_get_speed(const serial_port sp) return uiPortSpeed; } -void rs232_close(const serial_port sp) +void uart_close(const serial_port sp) { tcsetattr(((serial_port_unix*)sp)->fd,TCSANOW,&((serial_port_unix*)sp)->tiOld); close(((serial_port_unix*)sp)->fd); free(sp); } -bool rs232_cts(const serial_port sp) +bool uart_cts(const serial_port sp) { char status; if (ioctl(((serial_port_unix*)sp)->fd,TIOCMGET,&status) < 0) return false; return (status & TIOCM_CTS); } -bool rs232_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) +bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) { int iResult; int byteCount; @@ -217,7 +217,7 @@ bool rs232_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) return (*pszRxLen > 0); } -bool rs232_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen) +bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen) { int iResult; iResult = write(((serial_port_unix*)sp)->fd,pbtTx,szTxLen); @@ -233,7 +233,7 @@ typedef struct { COMMTIMEOUTS ct; // Serial port time-out configuration } serial_port_windows; -serial_port rs232_open(const char* pcPortName) +serial_port uart_open(const char* pcPortName) { char acPortName[255]; serial_port_windows* sp = malloc(sizeof(serial_port_windows)); @@ -246,7 +246,7 @@ serial_port rs232_open(const char* pcPortName) sp->hPort = CreateFileA(acPortName,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL); if (sp->hPort == INVALID_HANDLE_VALUE) { - rs232_close(sp); + uart_close(sp); return INVALID_SERIAL_PORT; } @@ -255,14 +255,14 @@ serial_port rs232_open(const char* pcPortName) sp->dcb.DCBlength = sizeof(DCB); if(!BuildCommDCBA("baud=9600 data=8 parity=N stop=1",&sp->dcb)) { - rs232_close(sp); + uart_close(sp); return INVALID_SERIAL_PORT; } // Update the active serial port if(!SetCommState(sp->hPort,&sp->dcb)) { - rs232_close(sp); + uart_close(sp); return INVALID_SERIAL_PORT; } @@ -274,7 +274,7 @@ serial_port rs232_open(const char* pcPortName) if(!SetCommTimeouts(sp->hPort,&sp->ct)) { - rs232_close(sp); + uart_close(sp); return INVALID_SERIAL_PORT; } @@ -283,13 +283,13 @@ serial_port rs232_open(const char* pcPortName) return sp; } -void rs232_close(const serial_port sp) +void uart_close(const serial_port sp) { CloseHandle(((serial_port_windows*)sp)->hPort); free(sp); } -void rs232_set_speed(serial_port sp, const uint32_t uiPortSpeed) +void uart_set_speed(serial_port sp, const uint32_t uiPortSpeed) { serial_port_windows* spw; @@ -316,7 +316,7 @@ void rs232_set_speed(serial_port sp, const uint32_t uiPortSpeed) } } -uint32_t rs232_get_speed(const serial_port sp) +uint32_t uart_get_speed(const serial_port sp) { const serial_port_windows* spw = (serial_port_windows*)sp; if (!GetCommState(spw->hPort, (serial_port)&spw->dcb)) @@ -325,20 +325,13 @@ uint32_t rs232_get_speed(const serial_port sp) return 0; } -bool rs232_cts(const serial_port sp) -{ - DWORD dwStatus; - if (!GetCommModemStatus(((serial_port_windows*)sp)->hPort,&dwStatus)) return false; - return (dwStatus & MS_CTS_ON); -} - -bool rs232_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) +bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) { ReadFile(((serial_port_windows*)sp)->hPort,pbtRx,*pszRxLen,(LPDWORD)pszRxLen,NULL); return (*pszRxLen != 0); } -bool rs232_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen) +bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen) { DWORD dwTxLen = 0; return WriteFile(((serial_port_windows*)sp)->hPort,pbtTx,szTxLen,&dwTxLen,NULL); diff --git a/src/lib/buses/uart.h b/src/lib/buses/uart.h index 3e2f2be..373b659 100644 --- a/src/lib/buses/uart.h +++ b/src/lib/buses/uart.h @@ -17,7 +17,7 @@ * along with this program. If not, see * * - * @file rs232.h + * @file uart.h * @brief */ @@ -49,16 +49,14 @@ typedef void* serial_port; #define INVALID_SERIAL_PORT (void*)(~1) #define CLAIMED_SERIAL_PORT (void*)(~2) -serial_port rs232_open(const char* pcPortName); -void rs232_close(const serial_port sp); +serial_port uart_open(const char* pcPortName); +void uart_close(const serial_port sp); -void rs232_set_speed(serial_port sp, const uint32_t uiPortSpeed); -uint32_t rs232_get_speed(const serial_port sp); +void uart_set_speed(serial_port sp, const uint32_t uiPortSpeed); +uint32_t uart_get_speed(const serial_port sp); -bool rs232_cts(const serial_port sp); - -bool rs232_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen); -bool rs232_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen); +bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen); +bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen); #endif // _LIBNFC_RS232_H_ diff --git a/src/lib/drivers.h b/src/lib/drivers.h index c128d43..c79b137 100644 --- a/src/lib/drivers.h +++ b/src/lib/drivers.h @@ -27,26 +27,26 @@ #include "defines.h" #include "types.h" #ifdef HAVE_PCSC_LITE - #include "dev_acr122.h" + #include #endif /* HAVE_PCSC_LITE */ #ifdef HAVE_LIBUSB - #include "dev_pn531.h" - #include "dev_pn533.h" + #include + #include #endif /* HAVE_LIBUSB */ -#include "dev_arygon.h" -#include "dev_pn532_uart.h" +#include +#include -const static struct dev_callbacks dev_callbacks_list[] = { +const static struct driver_callbacks drivers_callbacks_list[] = { // Driver Name Connect Transceive Disconnect #ifdef HAVE_PCSC_LITE - { "ACR122", dev_acr122_connect, dev_acr122_transceive, dev_acr122_disconnect }, + { "ACR122", acr122_connect, acr122_transceive, acr122_disconnect }, #endif /* HAVE_PCSC_LITE */ #ifdef HAVE_LIBUSB - { "PN531USB", dev_pn531_connect, dev_pn531_transceive, dev_pn531_disconnect }, - { "PN533USB", dev_pn533_connect, dev_pn533_transceive, dev_pn533_disconnect }, + { "PN531USB", pn531_connect, pn531_transceive, pn531_disconnect }, + { "PN533USB", pn533_connect, pn533_transceive, pn533_disconnect }, #endif /* HAVE_LIBUSB */ - { "PN532_UART", dev_pn532_uart_connect, dev_pn532_uart_transceive, dev_pn532_uart_disconnect }, - { "ARYGON", dev_arygon_connect, dev_arygon_transceive, dev_arygon_disconnect } + { "PN532_UART", pn532_uart_connect, pn532_uart_transceive, pn532_uart_disconnect }, + { "ARYGON", arygon_connect, arygon_transceive, arygon_disconnect } }; #endif // _LIBNFC_DEVICES_H_ diff --git a/src/lib/drivers/Makefile.am b/src/lib/drivers/Makefile.am new file mode 100644 index 0000000..a1c9ba3 --- /dev/null +++ b/src/lib/drivers/Makefile.am @@ -0,0 +1,24 @@ +# set the include path found by configure +INCLUDES= $(all_includes) + +noinst_HEADERS = arygon.h pn532_uart.h +noinst_LTLIBRARIES = libnfcdrivers.la +libnfcdrivers_la_SOURCES = arygon.c pn532_uart.c +libnfcdrivers_la_CFLAGS = -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/buses +libnfcdrivers_la_LIBADD = + +if PCSC_LITE_ENABLED + noinst_HEADERS += acr122.h + libnfcdrivers_la_CFLAGS += @LIBPCSCLITE_CFLAGS@ -DHAVE_PCSC_LITE + libnfcdrivers_la_SOURCES += acr122.c + libnfcdrivers_la_LIBADD += @LIBPCSCLITE_LIBS@ +endif + +if LIBUSB_ENABLED + noinst_HEADERS += pn531.h pn533.h + libnfcdrivers_la_CFLAGS += @LIBUSB_CFLAGS@ -DHAVE_LIBUSB + libnfcdrivers_la_SOURCES += pn531.c pn533.c + libnfcdrivers_la_LIBADD += @LIBUSB_LIBS@ +endif + +DISTCLEANFILES = Makefile.in diff --git a/src/lib/drivers/acr122.c b/src/lib/drivers/acr122.c index 6127afd..de1e720 100644 --- a/src/lib/drivers/acr122.c +++ b/src/lib/drivers/acr122.c @@ -17,11 +17,11 @@ * along with this program. If not, see * * - * @file dev_acr122.c + * @file acr122.c * @brief */ -#include "dev_acr122.h" +#include "acr122.h" #include #include @@ -35,7 +35,6 @@ #include "defines.h" #include "messages.h" -#include "bitutils.h" // WINDOWS: #define IOCTL_CCID_ESCAPE_SCARD_CTL_CODE SCARD_CTL_CODE(3500) #define IOCTL_CCID_ESCAPE_SCARD_CTL_CODE (((0x31) << 16) | ((3500) << 2)) @@ -58,7 +57,7 @@ typedef struct { SCARD_IO_REQUEST ioCard; } dev_spec_acr122; -dev_info* dev_acr122_connect(const nfc_device_desc_t* pndd) +dev_info* acr122_connect(const nfc_device_desc_t* pndd) { char* pacReaders[MAX_DEVICES]; char acList[256+64*MAX_DEVICES]; @@ -131,7 +130,7 @@ dev_info* dev_acr122_connect(const nfc_device_desc_t* pndd) dsa.ioCard.cbPciLength = sizeof(SCARD_IO_REQUEST); // Retrieve the current firmware version - pcFirmware = dev_acr122_firmware((dev_info*)&dsa); + pcFirmware = acr122_firmware((dev_info*)&dsa); if (strstr(pcFirmware,FIRMWARE_TEXT) != NULL) { // We found a occurence, test if it has the right index @@ -163,7 +162,7 @@ dev_info* dev_acr122_connect(const nfc_device_desc_t* pndd) return INVALID_DEVICE_INFO; } -void dev_acr122_disconnect(dev_info* pdi) +void acr122_disconnect(dev_info* pdi) { dev_spec_acr122* pdsa = (dev_spec_acr122*)pdi->ds; SCardDisconnect(pdsa->hCard,SCARD_LEAVE_CARD); @@ -172,7 +171,7 @@ void dev_acr122_disconnect(dev_info* pdi) free(pdi); } -bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) +bool acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) { byte_t abtRxCmd[5] = { 0xFF,0xC0,0x00,0x00 }; size_t szRxCmdLen = sizeof(abtRxCmd); @@ -234,7 +233,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t return true; } -char* dev_acr122_firmware(const dev_spec ds) +char* acr122_firmware(const dev_spec ds) { byte_t abtGetFw[5] = { 0xFF,0x00,0x48,0x00,0x00 }; uint32_t uiResult; @@ -260,7 +259,7 @@ char* dev_acr122_firmware(const dev_spec ds) return abtFw; } -bool dev_acr122_led_red(const dev_spec ds, bool bOn) +bool acr122_led_red(const dev_spec ds, bool bOn) { byte_t abtLed[9] = { 0xFF,0x00,0x40,0x05,0x04,0x00,0x00,0x00,0x00 }; dev_spec_acr122* pdsa = (dev_spec_acr122*)ds; diff --git a/src/lib/drivers/acr122.h b/src/lib/drivers/acr122.h index 69ee2c8..5c0826d 100644 --- a/src/lib/drivers/acr122.h +++ b/src/lib/drivers/acr122.h @@ -17,7 +17,7 @@ * along with this program. If not, see * * - * @file dev_acr122.h + * @file acr122.h * @brief */ @@ -31,15 +31,15 @@ #include "types.h" // Functions used by developer to handle connection to this device -dev_info* dev_acr122_connect(const nfc_device_desc_t* pndd); -void dev_acr122_disconnect(dev_info* pdi); +dev_info* acr122_connect(const nfc_device_desc_t* pndd); +void acr122_disconnect(dev_info* pdi); // Callback function used by libnfc to transmit commands to the PN53X chip -bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); +bool acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); // Various additional features this device supports -char* dev_acr122_firmware(const dev_spec ds); -bool dev_acr122_led_red(const dev_spec ds, bool bOn); +char* acr122_firmware(const dev_spec ds); +bool acr122_led_red(const dev_spec ds, bool bOn); #endif // _LIBNFC_DEV_ACR122_H_ diff --git a/src/lib/drivers/arygon.c b/src/lib/drivers/arygon.c index 1230650..a9e4969 100644 --- a/src/lib/drivers/arygon.c +++ b/src/lib/drivers/arygon.c @@ -17,14 +17,13 @@ * along with this program. If not, see * * - * @file dev_arygon.c + * @file arygon.c * @brief */ -#include "dev_arygon.h" +#include "arygon.h" -#include "rs232.h" -#include "bitutils.h" +#include "uart.h" #include "messages.h" #ifdef _WIN32 @@ -73,7 +72,7 @@ * @note ARYGON-APDB2UA33 (PN532 + ARYGON µC): 9600,n,8,1 */ -dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd) +dev_info* arygon_connect(const nfc_device_desc_t* pndd) { uint32_t uiDevNr; serial_port sp; @@ -95,10 +94,10 @@ dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd) sprintf(acConnect,"%s%d",SERIAL_STRING,uiDevNr); #endif /* __APPLE__ */ - sp = rs232_open(acConnect); + sp = uart_open(acConnect); if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT)) { - rs232_set_speed(sp, SERIAL_DEFAULT_PORT_SPEED); + uart_set_speed(sp, SERIAL_DEFAULT_PORT_SPEED); break; } #ifdef DEBUG @@ -112,12 +111,12 @@ dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd) } else { DBG("Connecting to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed); strcpy(acConnect,pndd->pcPort); - sp = rs232_open(acConnect); + sp = uart_open(acConnect); if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",acConnect); if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",acConnect); if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return INVALID_DEVICE_INFO; - rs232_set_speed(sp, pndd->uiSpeed); + uart_set_speed(sp, pndd->uiSpeed); } DBG("Successfully connected to: %s",acConnect); @@ -134,13 +133,13 @@ dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd) return pdi; } -void dev_arygon_disconnect(dev_info* pdi) +void arygon_disconnect(dev_info* pdi) { - rs232_close((serial_port)pdi->ds); + uart_close((serial_port)pdi->ds); free(pdi); } -bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) +bool arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) { byte_t abtTxBuf[BUFFER_LENGTH] = { DEV_ARYGON_PROTOCOL_TAMA, 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff" byte_t abtRxBuf[BUFFER_LENGTH]; @@ -168,7 +167,7 @@ bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t printf(" TX: "); print_hex(abtTxBuf,szTxLen+8); #endif - if (!rs232_send((serial_port)ds,abtTxBuf,szTxLen+8)) { + if (!uart_send((serial_port)ds,abtTxBuf,szTxLen+8)) { ERR("Unable to transmit data. (TX)"); return false; } @@ -188,7 +187,7 @@ bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t * For more information, see Issue 23 on development site : http://code.google.com/p/libnfc/issues/detail?id=23 */ - if (!rs232_receive((serial_port)ds,abtRxBuf,&szRxBufLen)) { + if (!uart_receive((serial_port)ds,abtRxBuf,&szRxBufLen)) { ERR("Unable to receive data. (RX)"); return false; } diff --git a/src/lib/drivers/arygon.h b/src/lib/drivers/arygon.h index f998994..a489f38 100644 --- a/src/lib/drivers/arygon.h +++ b/src/lib/drivers/arygon.h @@ -17,7 +17,7 @@ * along with this program. If not, see * * - * @file dev_arygon.h + * @file arygon.h * @brief */ @@ -28,11 +28,11 @@ #include "types.h" // Functions used by developer to handle connection to this device -dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd); -void dev_arygon_disconnect(dev_info* pdi); +dev_info* arygon_connect(const nfc_device_desc_t* pndd); +void arygon_disconnect(dev_info* pdi); // Callback function used by libnfc to transmit commands to the PN53X chip -bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); +bool arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); #endif // _LIBNFC_DEV_ARYGON_H_ diff --git a/src/lib/drivers/pn531.c b/src/lib/drivers/pn531.c index 278a86d..1bde5b0 100644 --- a/src/lib/drivers/pn531.c +++ b/src/lib/drivers/pn531.c @@ -17,7 +17,7 @@ * along with this program. If not, see * * - * @file dev_pn531.c + * @file pn531.c * @brief */ @@ -32,8 +32,7 @@ Thanks to d18c7db and Okko for example code #include #include "defines.h" -#include "dev_pn531.h" -#include "bitutils.h" +#include "pn531.h" #include "messages.h" #define BUFFER_LENGTH 256 @@ -81,7 +80,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp) } } -dev_info* dev_pn531_connect(const nfc_device_desc_t* pndd) +dev_info* pn531_connect(const nfc_device_desc_t* pndd) { int idvendor = 0x04CC; int idproduct = 0x0531; @@ -163,7 +162,7 @@ dev_info* dev_pn531_connect(const nfc_device_desc_t* pndd) return pdi; } -void dev_pn531_disconnect(dev_info* pdi) +void pn531_disconnect(dev_info* pdi) { dev_spec_pn531* pdsp = (dev_spec_pn531*)pdi->ds; usb_release_interface(pdsp->pudh,0); @@ -172,7 +171,7 @@ void dev_pn531_disconnect(dev_info* pdi) free(pdi); } -bool dev_pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) +bool pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) { size_t uiPos = 0; int ret = 0; diff --git a/src/lib/drivers/pn531.h b/src/lib/drivers/pn531.h index 84c6be0..9ad2490 100644 --- a/src/lib/drivers/pn531.h +++ b/src/lib/drivers/pn531.h @@ -17,7 +17,7 @@ * along with this program. If not, see * * - * @file dev_pn531.h + * @file pn531.h * @brief */ @@ -31,11 +31,11 @@ #include "types.h" // Functions used by developer to handle connection to this device -dev_info* dev_pn531_connect(const nfc_device_desc_t* pndd); -void dev_pn531_disconnect(dev_info* pdi); +dev_info* pn531_connect(const nfc_device_desc_t* pndd); +void pn531_disconnect(dev_info* pdi); // Callback function used by libnfc to transmit commands to the PN53X chip -bool dev_pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); +bool pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); #endif // _LIBNFC_DEV_PN531_H_ diff --git a/src/lib/drivers/pn532_uart.c b/src/lib/drivers/pn532_uart.c index 5dfae8c..9f2db3f 100644 --- a/src/lib/drivers/pn532_uart.c +++ b/src/lib/drivers/pn532_uart.c @@ -17,14 +17,13 @@ * along with this program. If not, see * * - * @file dev_pn532_uart.c + * @file pn532_uart.c * @brief */ -#include "dev_pn532_uart.h" +#include "pn532_uart.h" -#include "rs232.h" -#include "bitutils.h" +#include "uart.h" #include "messages.h" #ifdef _WIN32 @@ -48,7 +47,7 @@ #define SERIAL_DEFAULT_PORT_SPEED 115200 -dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd) +dev_info* pn532_uart_connect(const nfc_device_desc_t* pndd) { uint32_t uiDevNr; serial_port sp; @@ -70,10 +69,10 @@ dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd) sprintf(acConnect,"%s%d",SERIAL_STRING,uiDevNr); #endif /* __APPLE__ */ - sp = rs232_open(acConnect); + sp = uart_open(acConnect); if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT)) { - rs232_set_speed(sp, SERIAL_DEFAULT_PORT_SPEED); + uart_set_speed(sp, SERIAL_DEFAULT_PORT_SPEED); break; } #ifdef DEBUG @@ -87,12 +86,12 @@ dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd) } else { DBG("Connecting to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed); strcpy(acConnect,pndd->pcPort); - sp = rs232_open(acConnect); + sp = uart_open(acConnect); if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",acConnect); if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",acConnect); if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return INVALID_DEVICE_INFO; - rs232_set_speed(sp, pndd->uiSpeed); + uart_set_speed(sp, pndd->uiSpeed); } /** @info PN532C106 wakeup. */ /** @todo Put this command in pn53x init process */ @@ -100,10 +99,10 @@ dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd) size_t szRxBufLen; const byte_t pncmd_pn532c106_wakeup[] = { 0x55,0x55,0x00,0x00,0x00,0x00,0x00,0xFF,0x03,0xFD,0xD4,0x14,0x01,0x17,0x00 }; - rs232_send(sp, pncmd_pn532c106_wakeup, sizeof(pncmd_pn532c106_wakeup)); + uart_send(sp, pncmd_pn532c106_wakeup, sizeof(pncmd_pn532c106_wakeup)); delay_ms(10); - if (!rs232_receive(sp,abtRxBuf,&szRxBufLen)) { + if (!uart_receive(sp,abtRxBuf,&szRxBufLen)) { ERR("Unable to receive data. (RX)"); return NULL; } @@ -126,13 +125,13 @@ dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd) return pdi; } -void dev_pn532_uart_disconnect(dev_info* pdi) +void pn532_uart_disconnect(dev_info* pdi) { - rs232_close((serial_port)pdi->ds); + uart_close((serial_port)pdi->ds); free(pdi); } -bool dev_pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) +bool pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) { byte_t abtTxBuf[BUFFER_LENGTH] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff" byte_t abtRxBuf[BUFFER_LENGTH]; @@ -160,7 +159,7 @@ bool dev_pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const siz printf(" TX: "); print_hex(abtTxBuf,szTxLen+7); #endif - if (!rs232_send((serial_port)ds,abtTxBuf,szTxLen+7)) { + if (!uart_send((serial_port)ds,abtTxBuf,szTxLen+7)) { ERR("Unable to transmit data. (TX)"); return false; } @@ -175,7 +174,7 @@ bool dev_pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const siz */ delay_ms(30); - if (!rs232_receive((serial_port)ds,abtRxBuf,&szRxBufLen)) { + if (!uart_receive((serial_port)ds,abtRxBuf,&szRxBufLen)) { ERR("Unable to receive data. (RX)"); return false; } diff --git a/src/lib/drivers/pn532_uart.h b/src/lib/drivers/pn532_uart.h index 27328b9..d10e7c2 100644 --- a/src/lib/drivers/pn532_uart.h +++ b/src/lib/drivers/pn532_uart.h @@ -17,7 +17,7 @@ * along with this program. If not, see * * - * @file dev_pn532_uart.h + * @file pn532_uart.h * @brief */ @@ -28,11 +28,11 @@ #include "types.h" // Functions used by developer to handle connection to this device -dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd); -void dev_pn532_uart_disconnect(dev_info* pdi); +dev_info* pn532_uart_connect(const nfc_device_desc_t* pndd); +void pn532_uart_disconnect(dev_info* pdi); // Callback function used by libnfc to transmit commands to the PN53X chip -bool dev_pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); +bool pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); #endif // _LIBNFC_DEV_PN532_UART_H_ diff --git a/src/lib/drivers/pn533.c b/src/lib/drivers/pn533.c index ea706b3..faf50d0 100644 --- a/src/lib/drivers/pn533.c +++ b/src/lib/drivers/pn533.c @@ -17,21 +17,20 @@ * along with this program. If not, see * * - * @file dev_pn533.c + * @file pn533.c * @brief */ /* Thanks to d18c7db and Okko for example code */ -#include "dev_pn533.h" +#include "pn533.h" #include #include #include #include "defines.h" -#include "bitutils.h" #include "messages.h" #define BUFFER_LENGTH 256 @@ -79,7 +78,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn533* pdsp) } } -dev_info* dev_pn533_connect(const nfc_device_desc_t* pndd) +dev_info* pn533_connect(const nfc_device_desc_t* pndd) { int idvendor = 0x04e6; int idproduct = 0x5591; @@ -158,7 +157,7 @@ dev_info* dev_pn533_connect(const nfc_device_desc_t* pndd) return pdi; } -void dev_pn533_disconnect(dev_info* pdi) +void pn533_disconnect(dev_info* pdi) { dev_spec_pn533* pdsp = (dev_spec_pn533*)pdi->ds; usb_release_interface(pdsp->pudh,0); @@ -167,7 +166,7 @@ void dev_pn533_disconnect(dev_info* pdi) free(pdi); } -bool dev_pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) +bool pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen) { size_t uiPos = 0; int ret = 0; diff --git a/src/lib/drivers/pn533.h b/src/lib/drivers/pn533.h index 97728f6..0c18e36 100644 --- a/src/lib/drivers/pn533.h +++ b/src/lib/drivers/pn533.h @@ -17,7 +17,7 @@ * along with this program. If not, see * * - * @file dev_pn533.h + * @file pn533.h * @brief */ @@ -28,11 +28,11 @@ #include "types.h" // Functions used by developer to handle connection to this device -dev_info* dev_pn533_connect(const nfc_device_desc_t* pndd); -void dev_pn533_disconnect(dev_info* pdi); +dev_info* pn533_connect(const nfc_device_desc_t* pndd); +void pn533_disconnect(dev_info* pdi); // Callback function used by libnfc to transmit commands to the PN53X chip -bool dev_pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); +bool pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); #endif // _LIBNFC_DEV_PN533_H_ diff --git a/src/lib/nfc.c b/src/lib/nfc.c index 7be8e43..9116b47 100644 --- a/src/lib/nfc.c +++ b/src/lib/nfc.c @@ -17,22 +17,21 @@ * along with this program. If not, see * * - * @file libnfc.c + * @file nfc.c * @brief */ -#include "libnfc.h" +#include "nfc.h" #include #include #include -#include "devices.h" +#include "drivers.h" -#include "bitutils.h" #include "messages.h" -#include "../config.h" +#include "../../config.h" // Registers and symbols masks used to covers parts within a register #define REG_CIU_TX_MODE 0x6302 @@ -285,20 +284,20 @@ dev_info* nfc_connect(nfc_device_desc_t* pndd) size_t szFwLen = sizeof(abtFw); // Search through the device list for an available device - for (uiDev=0; uiDevpcDriver ) ) + if( 0 != strcmp(drivers_callbacks_list[uiDev].acDriver, pndd->pcDriver ) ) { - DBG("Looking for %s, found %s... Skip it.", pndd->pcDriver, dev_callbacks_list[uiDev].acDriver); + DBG("Looking for %s, found %s... Skip it.", pndd->pcDriver, drivers_callbacks_list[uiDev].acDriver); continue; } else { - DBG("Looking for %s, found %s... Use it.", pndd->pcDriver, dev_callbacks_list[uiDev].acDriver); - pdi = dev_callbacks_list[uiDev].connect(pndd); + DBG("Looking for %s, found %s... Use it.", pndd->pcDriver, drivers_callbacks_list[uiDev].acDriver); + pdi = drivers_callbacks_list[uiDev].connect(pndd); } } @@ -307,7 +306,7 @@ dev_info* nfc_connect(nfc_device_desc_t* pndd) { DBG("[%s] has been claimed.", pdi->acName); // Great we have claimed a device - pdi->pdc = &(dev_callbacks_list[uiDev]); + pdi->pdc = &(drivers_callbacks_list[uiDev]); // Try to retrieve PN53x chip revision // We can not use pn53x_transceive() because abtRx[0] gives no status info @@ -339,7 +338,7 @@ dev_info* nfc_connect(nfc_device_desc_t* pndd) return pdi; } else { - DBG("No device found using driver: %s", dev_callbacks_list[uiDev].acDriver); + DBG("No device found using driver: %s", drivers_callbacks_list[uiDev].acDriver); } } // To bad, no reader is ready to be claimed diff --git a/src/lib/types.h b/src/lib/types.h index cabc44a..979f1bb 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -44,7 +44,7 @@ typedef enum { CT_PN533 = 0x30, } chip_type; -struct dev_callbacks; // Prototype the callback struct +struct driver_callbacks; // Prototype the callback struct /** * @struct dev_info @@ -52,7 +52,7 @@ struct dev_callbacks; // Prototype the callback struct */ typedef struct { /** Callback functions for handling device specific wrapping */ - const struct dev_callbacks* pdc; + const struct driver_callbacks* pdc; /** Device name string, including device wrapper firmware */ char acName[DEVICE_NAME_LENGTH]; /** PN53X chip type, this is useful for some "bug" work-arounds */ @@ -87,10 +87,10 @@ typedef struct { } nfc_device_desc_t; /** - * @struct dev_callbacks + * @struct driver_callbacks * @brief NFC defice callbacks */ -struct dev_callbacks { +struct driver_callbacks { /** Driver name */ const char* acDriver; /** Connect callback */ From 06a76f6470bd3d8a7a0461ca60a041a2e05bf6f1 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 4 Nov 2009 10:42:53 +0000 Subject: [PATCH 5/7] Attempt to make it works on MacOS. Small fixes. CMake work started. --- Makefile.am | 2 +- configure.ac | 2 +- src/CMakeLists.txt | 47 +--------------------------------- src/lib/CMakeLists.txt | 31 ++++++++++++++++++++++ src/lib/buses/CMakeLists.txt | 2 ++ src/lib/drivers.h | 10 ++++---- src/lib/drivers/CMakeLists.txt | 19 ++++++++++++++ 7 files changed, 60 insertions(+), 53 deletions(-) create mode 100644 src/lib/CMakeLists.txt create mode 100644 src/lib/buses/CMakeLists.txt create mode 100644 src/lib/drivers/CMakeLists.txt diff --git a/Makefile.am b/Makefile.am index 0d6fa9c..4ba301d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,7 +15,7 @@ html-am : Doxyfile .PHONY: html endif -DISTCLEANFILES = \ +DISTCLEANFILES = \ Makefile.in \ configure \ depcomp \ diff --git a/configure.ac b/configure.ac index 7e364dc..931310c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -define([rev], esyscmd([sh -c "echo -n 'r' && svnversion -n"]))dnl +define([rev], esyscmd([sh -c "echo -e 'r\c' && svnversion -n"]))dnl AC_INIT(libnfc, 1.2.1+rev, info@libnfc.org) AC_CONFIG_HEADER(config.h) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e16108a..bd08bea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,21 +1,3 @@ -SET(LIBRARY-SOURCES libnfc rs232 bitutils dev_arygon dev_pn532_uart) - -# find PCSC library and headers -IF(LIBNFC_PCSC) - FIND_PACKAGE(PCSC REQUIRED) - ADD_DEFINITIONS("-DHAVE_PCSC_LITE=1") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PCSC_CFLAGS_OTHER}") - SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "dev_acr122") -ENDIF(LIBNFC_PCSC) - -# find libusb library and headers -IF(LIBNFC_USB) - FIND_PACKAGE(LIBUSB REQUIRED) - ADD_DEFINITIONS("-DHAVE_LIBUSB=1") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS_OTHER}") - SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "dev_pn531" "dev_pn533") -ENDIF(LIBNFC_USB) - IF(LIBNFC_VERBOSE_OUTPUT) ADD_DEFINITIONS("-DDEBUG") ENDIF(LIBNFC_VERBOSE_OUTPUT) @@ -37,31 +19,4 @@ ENDIF(MSVC) INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS}) -# Library -ADD_LIBRARY(nfc SHARED ${LIBRARY-SOURCES}) -TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES} ${PCSC_LIBRARIES}) -SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0 VERSION 0.0.0) - -IF(MSVC) - # On Windows the shared (runtime) library should be either in the same - # directory as the excutables or in the path, we add it to same directory - INSTALL(TARGETS nfc RUNTIME DESTINATION bin COMPONENT libraries) - - # At compile time we need the .LIB file, we place it in the lib directory - INSTALL(TARGETS nfc ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT headers) -ELSE(MSVC) - INSTALL(TARGETS nfc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) -ENDIF(MSVC) - -# Headers -FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -INSTALL(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) -IF(MSVC) - # On Windows we also install the stdint headers, without it programs using it - # can't compile (like if we want to compile the included examples "out of - # tree") - #FILE(GLOB stdint "${CMAKE_CURRENT_SOURCE_DIR}/msvc/*.h") - #INSTALL(FILES ${stdint} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) -ENDIF(MSVC) - -ADD_SUBDIRECTORY(examples) +ADD_SUBDIRECTORY(lib examples) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt new file mode 100644 index 0000000..39cdca1 --- /dev/null +++ b/src/lib/CMakeLists.txt @@ -0,0 +1,31 @@ +SET(LIBRARY-SOURCES nfc bitutils) + +# Library +ADD_LIBRARY(nfc SHARED ${LIBRARY-SOURCES}) +TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES} ${PCSC_LIBRARIES}) +SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0 VERSION 0.0.0) + +IF(MSVC) + # On Windows the shared (runtime) library should be either in the same + # directory as the excutables or in the path, we add it to same directory + INSTALL(TARGETS nfc RUNTIME DESTINATION bin COMPONENT libraries) + + # At compile time we need the .LIB file, we place it in the lib directory + INSTALL(TARGETS nfc ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT headers) +ELSE(MSVC) + INSTALL(TARGETS nfc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) +ENDIF(MSVC) + +# Headers +FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") +INSTALL(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) +IF(MSVC) + # On Windows we also install the stdint headers, without it programs using it + # can't compile (like if we want to compile the included examples "out of + # tree") + #FILE(GLOB stdint "${CMAKE_CURRENT_SOURCE_DIR}/msvc/*.h") + #INSTALL(FILES ${stdint} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) +ENDIF(MSVC) + + +ADD_SUBDIRECTORY(buses drivers) diff --git a/src/lib/buses/CMakeLists.txt b/src/lib/buses/CMakeLists.txt new file mode 100644 index 0000000..ac25831 --- /dev/null +++ b/src/lib/buses/CMakeLists.txt @@ -0,0 +1,2 @@ +SET(LIBRARY-SOURCES uart) + diff --git a/src/lib/drivers.h b/src/lib/drivers.h index c79b137..8061f59 100644 --- a/src/lib/drivers.h +++ b/src/lib/drivers.h @@ -27,14 +27,14 @@ #include "defines.h" #include "types.h" #ifdef HAVE_PCSC_LITE - #include + #include "drivers/acr122.h" #endif /* HAVE_PCSC_LITE */ #ifdef HAVE_LIBUSB - #include - #include + #include "drivers/pn531.h" + #include "drivers/pn533.h" #endif /* HAVE_LIBUSB */ -#include -#include +#include "drivers/arygon.h" +#include "drivers/pn532_uart.h" const static struct driver_callbacks drivers_callbacks_list[] = { // Driver Name Connect Transceive Disconnect diff --git a/src/lib/drivers/CMakeLists.txt b/src/lib/drivers/CMakeLists.txt new file mode 100644 index 0000000..a1ee863 --- /dev/null +++ b/src/lib/drivers/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(LIBRARY-SOURCES arygon pn532_uart) + +# find PCSC library and headers +IF(LIBNFC_PCSC) + FIND_PACKAGE(PCSC REQUIRED) + ADD_DEFINITIONS("-DHAVE_PCSC_LITE=1") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PCSC_CFLAGS_OTHER}") + SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "acr122") +ENDIF(LIBNFC_PCSC) + +# find libusb library and headers +IF(LIBNFC_USB) + FIND_PACKAGE(LIBUSB REQUIRED) + ADD_DEFINITIONS("-DHAVE_LIBUSB=1") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS_OTHER}") + SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "pn531" "pn533") +ENDIF(LIBNFC_USB) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib) From c9689c74fb81693a34686eaf08cead6fda8b0215 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 4 Nov 2009 12:03:49 +0000 Subject: [PATCH 6/7] It cow compile using CMake. --- src/CMakeLists.txt | 3 ++- src/examples/CMakeLists.txt | 2 +- src/lib/CMakeLists.txt | 30 +++++++++++++++++++++++++++--- src/lib/buses/CMakeLists.txt | 2 -- src/lib/drivers/CMakeLists.txt | 19 ------------------- 5 files changed, 30 insertions(+), 26 deletions(-) delete mode 100644 src/lib/buses/CMakeLists.txt delete mode 100644 src/lib/drivers/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bd08bea..2c9bb88 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,4 +19,5 @@ ENDIF(MSVC) INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS}) -ADD_SUBDIRECTORY(lib examples) +ADD_SUBDIRECTORY(lib) +ADD_SUBDIRECTORY(examples) diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 6093641..5d57533 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -1,6 +1,6 @@ SET(EXAMPLES-SOURCES nfc-list nfc-mfclassic nfc-mfultralight nfcip-initiator nfcip-target nfc-anticol nfc-emulate nfc-relay) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../lib) # Examples FOREACH(source ${EXAMPLES-SOURCES}) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 39cdca1..e2177e8 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,7 +1,32 @@ -SET(LIBRARY-SOURCES nfc bitutils) +# Library's buses +SET(BUSES_SOURCES buses/uart) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/buses) + +# Library's drivers +SET(DRIVERS_SOURCES drivers/arygon drivers/pn532_uart) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/drivers) + +## find PCSC library and headers +IF(LIBNFC_PCSC) + FIND_PACKAGE(PCSC REQUIRED) + ADD_DEFINITIONS("-DHAVE_PCSC_LITE=1") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PCSC_CFLAGS_OTHER}") + SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122") +ENDIF(LIBNFC_PCSC) + +## find libusb library and headers +IF(LIBNFC_USB) + FIND_PACKAGE(LIBUSB REQUIRED) + ADD_DEFINITIONS("-DHAVE_LIBUSB=1") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS_OTHER}") + SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn531" "drivers/pn533") +ENDIF(LIBNFC_USB) + # Library -ADD_LIBRARY(nfc SHARED ${LIBRARY-SOURCES}) +SET(LIBRARY_SOURCES nfc bitutils ${DRIVERS_SOURCES} ${BUSES_SOURCES}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +ADD_LIBRARY(nfc SHARED ${LIBRARY_SOURCES}) TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES} ${PCSC_LIBRARIES}) SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0 VERSION 0.0.0) @@ -28,4 +53,3 @@ IF(MSVC) ENDIF(MSVC) -ADD_SUBDIRECTORY(buses drivers) diff --git a/src/lib/buses/CMakeLists.txt b/src/lib/buses/CMakeLists.txt deleted file mode 100644 index ac25831..0000000 --- a/src/lib/buses/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -SET(LIBRARY-SOURCES uart) - diff --git a/src/lib/drivers/CMakeLists.txt b/src/lib/drivers/CMakeLists.txt deleted file mode 100644 index a1ee863..0000000 --- a/src/lib/drivers/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -SET(LIBRARY-SOURCES arygon pn532_uart) - -# find PCSC library and headers -IF(LIBNFC_PCSC) - FIND_PACKAGE(PCSC REQUIRED) - ADD_DEFINITIONS("-DHAVE_PCSC_LITE=1") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PCSC_CFLAGS_OTHER}") - SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "acr122") -ENDIF(LIBNFC_PCSC) - -# find libusb library and headers -IF(LIBNFC_USB) - FIND_PACKAGE(LIBUSB REQUIRED) - ADD_DEFINITIONS("-DHAVE_LIBUSB=1") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS_OTHER}") - SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "pn531" "pn533") -ENDIF(LIBNFC_USB) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib) From 473965d3a6c14cc583380f70b2312ec247e5ffa5 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 4 Nov 2009 14:55:24 +0000 Subject: [PATCH 7/7] It now works on MacOS. --- configure.ac | 10 +++++++--- src/lib/Makefile.am | 10 ++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 931310c..c65f76a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,9 @@ -define([rev], esyscmd([sh -c "echo -e 'r\c' && svnversion -n"]))dnl -AC_INIT(libnfc, 1.2.1+rev, info@libnfc.org) +# SVN revison +define([svn_revision], esyscmd([sh -c "svnversion -n"])) +SVN_REVISION=svn_revision + +# General init +AC_INIT(libnfc, 1.2.1, info@libnfc.org) AC_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE @@ -24,7 +28,7 @@ AC_PATH_PROG(PKG_CONFIG, pkg-config) # Checks for header files. AC_HEADER_STDC AC_HEADER_STDBOOL -AC_CHECK_HEADERS([stdio.h stdlib.h stdint.h stddef.h stdbool.h usb.h]) +AC_CHECK_HEADERS([stdio.h stdlib.h stdint.h stddef.h stdbool.h]) # Checks for types AC_TYPE_SIZE_T diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 71ec0e6..3f2a750 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -14,4 +14,14 @@ libnfc_la_LIBADD = \ $(top_builddir)/src/lib/buses/libnfcbuses.la \ $(top_builddir)/src/lib/drivers/libnfcdrivers.la +if PCSC_LITE_ENABLED + libnfc_la_CFLAGS += @LIBPCSCLITE_CFLAGS@ -DHAVE_PCSC_LITE + libnfc_la_LIBADD += @LIBPCSCLITE_LIBS@ +endif + +if LIBUSB_ENABLED + libnfc_la_CFLAGS += @LIBUSB_CFLAGS@ -DHAVE_LIBUSB + libnfc_la_LIBADD += @LIBUSB_LIBS@ +endif + DISTCLEANFILES = Makefile.in