Remove extra whitespaces/tabs before EOL.

find . -name '*.[ch]' | xargs perl -pi -e 's/\t+$//; s/ +$//'

Thanks to Ludovic.
This commit is contained in:
Romuald Conty 2012-05-29 00:33:22 +00:00
parent 167238c60d
commit 26865bbc19
66 changed files with 483 additions and 483 deletions

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2011, Romuald Conty * Copyright (C) 2011, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2011, Romuald Conty * Copyright (C) 2011, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for

View file

@ -1,14 +1,14 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* Copyright (C) 2011, Glenn Ergeerts * Copyright (C) 2011, Glenn Ergeerts
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
*/ */
/** /**
* @file windows.h * @file windows.h
* @brief Provide some windows related hacks due to lack of POSIX compat * @brief Provide some windows related hacks due to lack of POSIX compat
*/ */

View file

@ -1,4 +1,4 @@
/** /**
* @file quick_start_example1.c * @file quick_start_example1.c
* @brief Quick start example that presents how to use libnfc * @brief Quick start example that presents how to use libnfc
*/ */
@ -18,7 +18,7 @@ main (int argc, const char *argv[])
{ {
nfc_device *pnd; nfc_device *pnd;
nfc_target nt; nfc_target nt;
nfc_init (NULL); nfc_init (NULL);
// Display libnfc version // Display libnfc version
@ -35,7 +35,7 @@ main (int argc, const char *argv[])
// Set opened NFC device to initiator mode // Set opened NFC device to initiator mode
if (nfc_initiator_init (pnd) < 0) { if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init"); nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd)); printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));

View file

@ -1,12 +1,12 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -22,12 +22,12 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
/** /**
* @file nfc-anticol.c * @file nfc-anticol.c
* @brief Generates one ISO14443-A anti-collision process "by-hand" * @brief Generates one ISO14443-A anti-collision process "by-hand"
*/ */
@ -150,7 +150,7 @@ main (int argc, char *argv[])
} }
nfc_init (NULL); nfc_init (NULL);
// Try to open the NFC reader // Try to open the NFC reader
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);
@ -162,7 +162,7 @@ main (int argc, char *argv[])
// Initialise NFC device as "initiator" // Initialise NFC device as "initiator"
if (nfc_initiator_init (pnd) < 0) { if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init"); nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
// Configure the CRC // Configure the CRC

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -70,7 +70,7 @@ main (int argc, const char *argv[])
printf ("Usage: %s\n", argv[0]); printf ("Usage: %s\n", argv[0]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
nfc_init (NULL); nfc_init (NULL);
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */

View file

@ -1,12 +1,12 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2011, Romuald Conty * Copyright (C) 2011, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -22,7 +22,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -31,7 +31,7 @@
* @file nfc-emulate-forum-tag2.c * @file nfc-emulate-forum-tag2.c
* @brief Emulates a NFC Forum Tag Type 2 with a NDEF message * @brief Emulates a NFC Forum Tag Type 2 with a NDEF message
* This example allow to emulate an NFC Forum Tag Type 2 that contains a read-only NDEF message. * This example allow to emulate an NFC Forum Tag Type 2 that contains a read-only NDEF message.
* *
* It have been developed using PN533 USB hardware as target and Google Nexus S phone as initiator. * It have been developed using PN533 USB hardware as target and Google Nexus S phone as initiator.
* *
* This is know to NOT work with Nokia 6212 Classic and could not work with * This is know to NOT work with Nokia 6212 Classic and could not work with
@ -51,8 +51,8 @@
* NFC Forum Type 2 Tag Operation * NFC Forum Type 2 Tag Operation
* Technical Specification * Technical Specification
* NFCForum-TS-Type-2-Tag_1.0 - 2007-07-09 * NFCForum-TS-Type-2-Tag_1.0 - 2007-07-09
* *
* ISO/IEC 14443-3 * ISO/IEC 14443-3
* First edition - 2001-02-01 * First edition - 2001-02-01
* Identification cards Contactless integrated circuit(s) cards Proximity cards * Identification cards Contactless integrated circuit(s) cards Proximity cards
* Part 3: Initialization and anticollision * Part 3: Initialization and anticollision
@ -86,7 +86,7 @@ stop_emulation (int sig)
static uint8_t __nfcforum_tag2_memory_area[] = { static uint8_t __nfcforum_tag2_memory_area[] = {
0x00, 0x00, 0x00, 0x00, // Block 0 0x00, 0x00, 0x00, 0x00, // Block 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFF, 0xFF, // Block 2 (Static lock bytes: CC area and data area are read-only locked) 0x00, 0x00, 0xFF, 0xFF, // Block 2 (Static lock bytes: CC area and data area are read-only locked)
0xE1, 0x10, 0x06, 0x0F, // Block 3 (CC - NFC-Forum Tag Type 2 version 1.0, Data area (from block 4 to the end) is 48 bytes, Read-only mode) 0xE1, 0x10, 0x06, 0x0F, // Block 3 (CC - NFC-Forum Tag Type 2 version 1.0, Data area (from block 4 to the end) is 48 bytes, Read-only mode)
@ -182,7 +182,7 @@ main(int argc, char *argv[])
}; };
signal (SIGINT, stop_emulation); signal (SIGINT, stop_emulation);
nfc_init (NULL); nfc_init (NULL);
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);
if (pnd == NULL) { if (pnd == NULL) {

View file

@ -1,12 +1,12 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -22,7 +22,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -66,13 +66,13 @@ intr_hdlr (int sig)
(void) sig; (void) sig;
printf ("\nQuitting...\n"); printf ("\nQuitting...\n");
if (pnd != NULL) { if (pnd != NULL) {
nfc_close(pnd); nfc_close(pnd);
} }
nfc_exit (NULL); nfc_exit (NULL);
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
static bool static bool
target_io( nfc_target *pnt, const uint8_t *pbtInput, const size_t szInput, uint8_t *pbtOutput, size_t *pszOutput ) target_io( nfc_target *pnt, const uint8_t *pbtInput, const size_t szInput, uint8_t *pbtOutput, size_t *pszOutput )
{ {
bool loop = true; bool loop = true;
@ -182,7 +182,7 @@ main (int argc, char *argv[])
#endif #endif
nfc_init (NULL); nfc_init (NULL);
// Try to open the NFC reader // Try to open the NFC reader
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -31,7 +31,7 @@
/** /**
* @file nfc-emulate-uid.c * @file nfc-emulate-uid.c
* @brief Emulates a tag which which have a "really" custom UID * @brief Emulates a tag which which have a "really" custom UID
* *
* NFC devices are able to emulate passive tags but manufacturers restrict the * NFC devices are able to emulate passive tags but manufacturers restrict the
* customization of UID. With PN53x, UID is only 4-byte long and the first * customization of UID. With PN53x, UID is only 4-byte long and the first
* byte of emulated UID is hard-wired to 0x08 which is the standard way to say * byte of emulated UID is hard-wired to 0x08 which is the standard way to say
@ -127,7 +127,7 @@ main (int argc, char *argv[])
#endif #endif
nfc_init (NULL); nfc_init (NULL);
// Try to open the NFC device // Try to open the NFC device
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2011, Adam Laurie * Copyright (C) 2011, Adam Laurie
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,12 +23,12 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
/** /**
* @file nfc-mfsetuid.c * @file nfc-mfsetuid.c
* @brief Set UID of special Mifare cards * @brief Set UID of special Mifare cards
*/ */
@ -178,7 +178,7 @@ main (int argc, char *argv[])
} }
nfc_init (NULL); nfc_init (NULL);
// Try to open the NFC reader // Try to open the NFC reader
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);
@ -190,7 +190,7 @@ main (int argc, char *argv[])
// Initialise NFC device as "initiator" // Initialise NFC device as "initiator"
if (nfc_initiator_init (pnd) < 0) { if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init"); nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
// Configure the CRC // Configure the CRC

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* Copyright (C) 2011, Romain Tartiere, Romuald Conty * Copyright (C) 2011, Romain Tartiere, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -102,7 +102,7 @@ main (int argc, const char *argv[])
nfc_target nt; nfc_target nt;
int res = 0; int res = 0;
nfc_init (NULL); nfc_init (NULL);
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);
@ -114,7 +114,7 @@ main (int argc, const char *argv[])
if (nfc_initiator_init (pnd) < 0) { if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init"); nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd)); printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -116,9 +116,9 @@ main (int argc, char *argv[])
ERR ("%zd device found but two opened devices are needed to relay NFC.", szFound); ERR ("%zd device found but two opened devices are needed to relay NFC.", szFound);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
nfc_init (NULL); nfc_init (NULL);
// Try to open the NFC emulator device // Try to open the NFC emulator device
pndTag = nfc_open (NULL, connstrings[0]); pndTag = nfc_open (NULL, connstrings[0]);
if (pndTag == NULL) { if (pndTag == NULL) {
@ -168,10 +168,10 @@ main (int argc, char *argv[])
printf ("NFC reader device: %s opened", nfc_device_get_name (pndReader)); printf ("NFC reader device: %s opened", nfc_device_get_name (pndReader));
printf ("%s", "Configuring NFC reader settings..."); printf ("%s", "Configuring NFC reader settings...");
if (nfc_initiator_init (pndReader) < 0) { if (nfc_initiator_init (pndReader) < 0) {
nfc_perror (pndReader, "nfc_initiator_init"); nfc_perror (pndReader, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
if ((nfc_device_set_property_bool (pndReader, NP_HANDLE_CRC, false) < 0) || if ((nfc_device_set_property_bool (pndReader, NP_HANDLE_CRC, false) < 0) ||
(nfc_device_set_property_bool (pndReader, NP_HANDLE_PARITY, false) < 0) || (nfc_device_set_property_bool (pndReader, NP_HANDLE_PARITY, false) < 0) ||
@ -220,7 +220,7 @@ main (int argc, char *argv[])
} }
} }
nfc_close (pndTag); nfc_close (pndTag);
nfc_close (pndReader); nfc_close (pndReader);
nfc_exit (NULL); nfc_exit (NULL);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);

View file

@ -1,12 +1,12 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -22,12 +22,12 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
/** /**
* @file pn53x-diagnose.c * @file pn53x-diagnose.c
* @brief Small application to diagnose PN53x using dedicated commands * @brief Small application to diagnose PN53x using dedicated commands
*/ */
@ -67,9 +67,9 @@ main (int argc, const char *argv[])
if (argc > 1) { if (argc > 1) {
errx (1, "usage: %s", argv[0]); errx (1, "usage: %s", argv[0]);
} }
nfc_init (NULL); nfc_init (NULL);
// Display libnfc version // Display libnfc version
acLibnfcVersion = nfc_version (); acLibnfcVersion = nfc_version ();
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion); printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);

View file

@ -1,12 +1,12 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2010, Emanuele Bertoldi * Copyright (C) 2010, Emanuele Bertoldi
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -22,7 +22,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -74,11 +74,11 @@ main (int argc, const char *argv[])
{ {
(void) argc; (void) argc;
(void) argv; (void) argv;
int ret = EXIT_FAILURE; int ret = EXIT_FAILURE;
nfc_init (NULL); nfc_init (NULL);
// Display libnfc version // Display libnfc version
const char *acLibnfcVersion = nfc_version (); const char *acLibnfcVersion = nfc_version ();
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion); printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);

View file

@ -1,12 +1,12 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -22,7 +22,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -84,7 +84,7 @@ int main(int argc, const char* argv[])
} }
nfc_init (NULL); nfc_init (NULL);
// Try to open the NFC reader // Try to open the NFC reader
pnd = nfc_open(NULL, NULL); pnd = nfc_open(NULL, NULL);
@ -96,7 +96,7 @@ int main(int argc, const char* argv[])
printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd)); printf ("NFC reader: %s opened\n", nfc_device_get_name (pnd));
if (nfc_initiator_init (pnd) < 0) { if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init"); nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
char *cmd; char *cmd;

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
*/ */
/** /**
* @file nfc-emulation.h * @file nfc-emulation.h
* @brief Provide a small API to ease emulation in libnfc * @brief Provide a small API to ease emulation in libnfc
*/ */

View file

@ -1,15 +1,15 @@
/** /**
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romain Tartière, Romuald Conty * Copyright (C) 2010, Romain Tartière, Romuald Conty
* Copyright (C) 2011, Romain Tartière, Romuald Conty * Copyright (C) 2011, Romain Tartière, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
*/ */
/** /**
* @file nfc-types.h * @file nfc-types.h
* @brief Define NFC types * @brief Define NFC types
*/ */
@ -48,13 +48,13 @@ typedef char nfc_connstring[1024];
* Properties * Properties
*/ */
typedef enum { typedef enum {
/** /**
* Default command processing timeout * Default command processing timeout
* Property value's (duration) unit is ms and 0 means no timeout (infinite). * Property value's (duration) unit is ms and 0 means no timeout (infinite).
* Default value is set by driver layer * Default value is set by driver layer
*/ */
NP_TIMEOUT_COMMAND, NP_TIMEOUT_COMMAND,
/** /**
* Timeout between ATR_REQ and ATR_RES * Timeout between ATR_REQ and ATR_RES
* When the device is in initiator mode, a target is considered as mute if no * When the device is in initiator mode, a target is considered as mute if no
* valid ATR_RES is received within this timeout value. * valid ATR_RES is received within this timeout value.

View file

@ -1,14 +1,14 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -137,47 +137,47 @@ extern "C" {
#define NFC_EIO -1 #define NFC_EIO -1
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* Invalid argument(s) * Invalid argument(s)
*/ */
#define NFC_EINVARG -2 #define NFC_EINVARG -2
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* Operation not supported by device * Operation not supported by device
*/ */
#define NFC_EDEVNOTSUPP -3 #define NFC_EDEVNOTSUPP -3
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* No such device * No such device
*/ */
#define NFC_ENOTSUCHDEV -4 #define NFC_ENOTSUCHDEV -4
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* Buffer overflow * Buffer overflow
*/ */
#define NFC_EOVFLOW -5 #define NFC_EOVFLOW -5
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* Operation timed out * Operation timed out
*/ */
#define NFC_ETIMEOUT -6 #define NFC_ETIMEOUT -6
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* Operation aborted (by user) * Operation aborted (by user)
*/ */
#define NFC_EOPABORTED -7 #define NFC_EOPABORTED -7
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* Not (yet) implemented * Not (yet) implemented
*/ */
#define NFC_ENOTIMPL -8 #define NFC_ENOTIMPL -8
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* Target released * Target released
*/ */
#define NFC_ETGRELEASED -10 #define NFC_ETGRELEASED -10
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* Error while RF transmission * Error while RF transmission
*/ */
#define NFC_ERFTRANS -20 #define NFC_ERFTRANS -20
/** @ingroup error /** @ingroup error
@ -187,7 +187,7 @@ extern "C" {
#define NFC_ESOFT -80 #define NFC_ESOFT -80
/** @ingroup error /** @ingroup error
* @hideinitializer * @hideinitializer
* Device's internal chip error * Device's internal chip error
*/ */
#define NFC_ECHIP -90 #define NFC_ECHIP -90

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, 2010, Roel Verdult, Romuald Conty * Copyright (C) 2009, 2010, Roel Verdult, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for

View file

@ -1,15 +1,15 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult, Romuald Conty * Copyright (C) 2009, Roel Verdult, Romuald Conty
* Copyright (C) 2010, Roel Verdult, Romuald Conty * Copyright (C) 2010, Roel Verdult, Romuald Conty
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for

View file

@ -1,15 +1,15 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, 2010, Roel Verdult, Romuald Conty * Copyright (C) 2009, 2010, Roel Verdult, Romuald Conty
* Copyright (C) 2010, Roel Verdult, Romuald Conty * Copyright (C) 2010, Roel Verdult, Romuald Conty
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -138,7 +138,7 @@ void
uart_set_speed (serial_port sp, const uint32_t uiPortSpeed) uart_set_speed (serial_port sp, const uint32_t uiPortSpeed)
{ {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Serial port speed requested to be set to %d bauds.", uiPortSpeed); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Serial port speed requested to be set to %d bauds.", uiPortSpeed);
// Portability note: on some systems, B9600 != 9600 so we have to do // Portability note: on some systems, B9600 != 9600 so we have to do
// uint32_t <=> speed_t associations by hand. // uint32_t <=> speed_t associations by hand.
speed_t stPortSpeed = B9600; speed_t stPortSpeed = B9600;
@ -352,13 +352,13 @@ uart_list_ports (void)
char **res2 = realloc (res, (szRes+1) * sizeof (char *)); char **res2 = realloc (res, (szRes+1) * sizeof (char *));
if (!res2) if (!res2)
goto oom; goto oom;
res = res2; res = res2;
if (!(res[szRes-1] = malloc (6 + strlen (pdDirEnt->d_name)))) if (!(res[szRes-1] = malloc (6 + strlen (pdDirEnt->d_name))))
goto oom; goto oom;
sprintf (res[szRes-1], "/dev/%s", pdDirEnt->d_name); sprintf (res[szRes-1], "/dev/%s", pdDirEnt->d_name);
szRes++; szRes++;
res[szRes-1] = NULL; res[szRes-1] = NULL;
} }

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, 2010, Roel Verdult, Romuald Conty * Copyright (C) 2009, 2010, Roel Verdult, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -167,7 +167,7 @@ uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p
do { do {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "ReadFile"); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "ReadFile");
res = ReadFile (((struct serial_port_windows *) sp)->hPort, pbtRx + dwTotalBytesReceived, res = ReadFile (((struct serial_port_windows *) sp)->hPort, pbtRx + dwTotalBytesReceived,
dwBytesToGet, dwBytesToGet,
&dwBytesReceived, NULL); &dwBytesReceived, NULL);
dwTotalBytesReceived += dwBytesReceived; dwTotalBytesReceived += dwBytesReceived;
@ -179,7 +179,7 @@ uart_receive (serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p
} else if (dwBytesReceived == 0) { } else if (dwBytesReceived == 0) {
return NFC_ETIMEOUT; return NFC_ETIMEOUT;
} }
if (((DWORD)szRx) > dwTotalBytesReceived) { if (((DWORD)szRx) > dwTotalBytesReceived) {
dwBytesToGet -= dwBytesReceived; dwBytesToGet -= dwBytesReceived;
} }

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -74,21 +74,21 @@
#define TgGetTargetStatus 0x8A #define TgGetTargetStatus 0x8A
/** @note PN53x's normal frame: /** @note PN53x's normal frame:
* *
* .-- Start * .-- Start
* | .-- Packet length * | .-- Packet length
* | | .-- Length checksum * | | .-- Length checksum
* | | | .-- Direction (D4 Host to PN, D5 PN to Host) * | | | .-- Direction (D4 Host to PN, D5 PN to Host)
* | | | | .-- Code * | | | | .-- Code
* | | | | | .-- Packet checksum * | | | | | .-- Packet checksum
* | | | | | | .-- Postamble * | | | | | | .-- Postamble
* V | | | | | | * V | | | | | |
* ----- V V V V V V * ----- V V V V V V
* 00 FF 02 FE D4 02 2A 00 * 00 FF 02 FE D4 02 2A 00
*/ */
/** @note PN53x's extended frame: /** @note PN53x's extended frame:
* *
* .-- Start * .-- Start
* | .-- Fixed to FF to enable extended frame * | .-- Fixed to FF to enable extended frame
* | | .-- Packet length * | | .-- Packet length
@ -96,13 +96,13 @@
* | | | | .-- Direction (D4 Host to PN, D5 PN to Host) * | | | | .-- Direction (D4 Host to PN, D5 PN to Host)
* | | | | | .-- Code * | | | | | .-- Code
* | | | | | | .-- Packet checksum * | | | | | | .-- Packet checksum
* | | | | | | | .-- Postamble * | | | | | | | .-- Postamble
* V V V | | | | | * V V V | | | | |
* ----- ----- ----- V V V V V * ----- ----- ----- V V V V V
* 00 FF FF FF 00 02 FE D4 02 2A 00 * 00 FF FF FF 00 02 FE D4 02 2A 00
*/ */
/** /**
* Start bytes, packet length, length checksum, direction, packet checksum and postamble are overhead * Start bytes, packet length, length checksum, direction, packet checksum and postamble are overhead
*/ */
// The TFI is considered part of the overhead // The TFI is considered part of the overhead
@ -156,7 +156,7 @@ static const pn53x_command pn53x_commands[] = {
PNCMD( SAMConfiguration, PN531|PN532 ), PNCMD( SAMConfiguration, PN531|PN532 ),
PNCMD( PowerDown, PN531|PN532 ), PNCMD( PowerDown, PN531|PN532 ),
PNCMD( AlparCommandForTDA, PN533|RCS360 ), // Has another usage on RC-S360... PNCMD( AlparCommandForTDA, PN533|RCS360 ), // Has another usage on RC-S360...
// RF communication // RF communication
PNCMD( RFConfiguration, PN531|PN532|PN533|RCS360 ), PNCMD( RFConfiguration, PN531|PN532|PN533|RCS360 ),
PNCMD( RFRegulationTest, PN531|PN532|PN533 ), PNCMD( RFRegulationTest, PN531|PN532|PN533 ),

View file

@ -1,15 +1,15 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult, Romuald Conty * Copyright (C) 2009, Roel Verdult, Romuald Conty
* Copyright (C) 2010, Roel Verdult, Romuald Conty, Romain Tartière * Copyright (C) 2010, Roel Verdult, Romuald Conty, Romain Tartière
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -80,11 +80,11 @@ pn53x_init(struct nfc_device *pnd)
nbSupportedModulation++; nbSupportedModulation++;
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] = NMT_FELICA; CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] = NMT_FELICA;
nbSupportedModulation++; nbSupportedModulation++;
} }
if (pnd->btSupportByte & SUPPORT_ISO14443B) { if (pnd->btSupportByte & SUPPORT_ISO14443B) {
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] = NMT_ISO14443B; CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] = NMT_ISO14443B;
nbSupportedModulation++; nbSupportedModulation++;
} }
if(CHIP_DATA(pnd)->type != PN531) { if(CHIP_DATA(pnd)->type != PN531) {
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] = NMT_JEWEL; CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] = NMT_JEWEL;
nbSupportedModulation++; nbSupportedModulation++;
@ -93,11 +93,11 @@ pn53x_init(struct nfc_device *pnd)
nbSupportedModulation++; nbSupportedModulation++;
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] = 0; CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] = 0;
} }
if (!CHIP_DATA(pnd)->supported_modulation_as_target) { if (!CHIP_DATA(pnd)->supported_modulation_as_target) {
CHIP_DATA(pnd)->supported_modulation_as_target = (nfc_modulation_type*) pn53x_supported_modulation_as_target; CHIP_DATA(pnd)->supported_modulation_as_target = (nfc_modulation_type*) pn53x_supported_modulation_as_target;
} }
// CRC handling should be enabled by default as declared in nfc_device_new // CRC handling should be enabled by default as declared in nfc_device_new
// which is the case by default for pn53x, so nothing to do here // which is the case by default for pn53x, so nothing to do here
// Parity handling should be enabled by default as declared in nfc_device_new // Parity handling should be enabled by default as declared in nfc_device_new
@ -488,7 +488,7 @@ pn53x_decode_target_data (const uint8_t *pbtRawData, size_t szRawData, pn53x_typ
case NMT_ISO14443BI: case NMT_ISO14443BI:
// Skip V & T Addresses // Skip V & T Addresses
pbtRawData++; pbtRawData++;
if (*pbtRawData != 0x07) { // 0x07 = REPGEN if (*pbtRawData != 0x07) { // 0x07 = REPGEN
return NFC_ECHIP; return NFC_ECHIP;
} }
pbtRawData++; pbtRawData++;
@ -757,7 +757,7 @@ pn53x_int_to_timeout (const int ms)
return res; return res;
} }
int int
pn53x_set_property_int (struct nfc_device *pnd, const nfc_property property, const int value) pn53x_set_property_int (struct nfc_device *pnd, const nfc_property property, const int value)
{ {
switch (property) { switch (property) {
@ -846,7 +846,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co
// TODO Made some research around this point: // TODO Made some research around this point:
// timings could be tweak better than this, and maybe we can tweak timings // timings could be tweak better than this, and maybe we can tweak timings
// to "gain" a sort-of hardware polling (ie. like PN532 does) // to "gain" a sort-of hardware polling (ie. like PN532 does)
if (pn53x_RFConfiguration__MaxRetries (pnd, if (pn53x_RFConfiguration__MaxRetries (pnd,
(bEnable) ? 0xff : 0x00, // MxRtyATR, default: active = 0xff, passive = 0x02 (bEnable) ? 0xff : 0x00, // MxRtyATR, default: active = 0xff, passive = 0x02
(bEnable) ? 0xff : 0x01, // MxRtyPSL, default: 0x01 (bEnable) ? 0xff : 0x01, // MxRtyPSL, default: 0x01
(bEnable) ? 0xff : 0x02 // MxRtyPassiveActivation, default: 0xff (0x00 leads to problems with PN531) (bEnable) ? 0xff : 0x02 // MxRtyPassiveActivation, default: 0xff (0x00 leads to problems with PN531)
@ -984,7 +984,7 @@ pn53x_check_communication (struct nfc_device *pnd)
szRx = (size_t) res; szRx = (size_t) res;
if ((sizeof(abtExpectedRx) == szRx) && (0 == memcmp (abtRx, abtExpectedRx, sizeof(abtExpectedRx)))) if ((sizeof(abtExpectedRx) == szRx) && (0 == memcmp (abtRx, abtExpectedRx, sizeof(abtExpectedRx))))
return NFC_SUCCESS; return NFC_SUCCESS;
return NFC_EIO; return NFC_EIO;
} }
@ -1051,7 +1051,7 @@ pn53x_initiator_select_passive_target_ext (struct nfc_device *pnd,
const uint8_t abtReqt[]= { 0x10 }; const uint8_t abtReqt[]= { 0x10 };
// Getting product code / fab code & store it in output buffer after the serial nr we'll obtain later // Getting product code / fab code & store it in output buffer after the serial nr we'll obtain later
if ((res = pn53x_initiator_transceive_bytes (pnd, abtReqt, sizeof(abtReqt), abtTargetsData+2, sizeof(abtTargetsData)-2, timeout)) < 0) { if ((res = pn53x_initiator_transceive_bytes (pnd, abtReqt, sizeof(abtReqt), abtTargetsData+2, sizeof(abtTargetsData)-2, timeout)) < 0) {
return res; return res;
} }
szTargetsData = (size_t)res; szTargetsData = (size_t)res;
} }
@ -1123,7 +1123,7 @@ pn53x_initiator_poll_target (struct nfc_device *pnd,
nfc_target *pnt) nfc_target *pnt)
{ {
int res = 0; int res = 0;
if (CHIP_DATA(pnd)->type == PN532) { if (CHIP_DATA(pnd)->type == PN532) {
size_t szTargetTypes = 0; size_t szTargetTypes = 0;
pn53x_target_type apttTargetTypes[32]; pn53x_target_type apttTargetTypes[32];
@ -1167,7 +1167,7 @@ pn53x_initiator_poll_target (struct nfc_device *pnd,
size_t szInitiatorData; size_t szInitiatorData;
prepare_initiator_data (pnmModulations[n], &pbtInitiatorData, &szInitiatorData); prepare_initiator_data (pnmModulations[n], &pbtInitiatorData, &szInitiatorData);
const int timeout_ms = uiPeriod * 150; const int timeout_ms = uiPeriod * 150;
if ((res = pn53x_initiator_select_passive_target_ext (pnd, pnmModulations[n], pbtInitiatorData, szInitiatorData, pnt, timeout_ms)) < 0) { if ((res = pn53x_initiator_select_passive_target_ext (pnd, pnmModulations[n], pbtInitiatorData, szInitiatorData, pnt, timeout_ms)) < 0) {
if (pnd->last_error != NFC_ETIMEOUT) { if (pnd->last_error != NFC_ETIMEOUT) {
return pnd->last_error; return pnd->last_error;
@ -1631,7 +1631,7 @@ pn53x_initiator_deselect_target (struct nfc_device *pnd)
return pn53x_InDeselect (pnd, 0); // 0 mean deselect all selected targets return pn53x_InDeselect (pnd, 0); // 0 mean deselect all selected targets
} }
int int
pn53x_initiator_target_is_present (struct nfc_device *pnd, const nfc_target nt) pn53x_initiator_target_is_present (struct nfc_device *pnd, const nfc_target nt)
{ {
// TODO Check if nt is equal to current target // TODO Check if nt is equal to current target
@ -1786,7 +1786,7 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, cons
// Set System Code // Set System Code
abtFeliCaParams[16] = 0x0f; abtFeliCaParams[16] = 0x0f;
abtFeliCaParams[17] = 0xab; abtFeliCaParams[17] = 0xab;
pbtFeliCaParams = abtFeliCaParams; pbtFeliCaParams = abtFeliCaParams;
break; break;
case NMT_ISO14443B: case NMT_ISO14443B:
@ -1884,7 +1884,7 @@ pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, const size_t
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN]; uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx); size_t szRx = sizeof (abtRx);
int res = 0; int res = 0;
// Try to gather a received frame from the reader // Try to gather a received frame from the reader
if ((res = pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, szRx, -1)) < 0) if ((res = pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, szRx, -1)) < 0)
return res; return res;
@ -2048,7 +2048,7 @@ pn53x_target_send_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const siz
return pnd->last_error; return pnd->last_error;
} }
} }
// NO BREAK // NO BREAK
case NMT_JEWEL: case NMT_JEWEL:
case NMT_ISO14443B: case NMT_ISO14443B:
case NMT_ISO14443BI: case NMT_ISO14443BI:
@ -2064,7 +2064,7 @@ pn53x_target_send_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const siz
// Copy the data into the command frame // Copy the data into the command frame
memcpy (abtCmd + 1, pbtTx, szTx); memcpy (abtCmd + 1, pbtTx, szTx);
// Try to send the bits to the reader // Try to send the bits to the reader
if ((res = pn53x_transceive (pnd, abtCmd, szTx + 1, NULL, 0, timeout)) < 0) if ((res = pn53x_transceive (pnd, abtCmd, szTx + 1, NULL, 0, timeout)) < 0)
return res; return res;
@ -2565,7 +2565,7 @@ pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
return res; return res;
szRx = (size_t) res; szRx = (size_t) res;
// Note: the first byte is skip: // Note: the first byte is skip:
// its the "mode" byte which contains baudrate, DEP and Framing type (Mifare, active or FeliCa) datas. // its the "mode" byte which contains baudrate, DEP and Framing type (Mifare, active or FeliCa) datas.
if(pbtModeByte) { if(pbtModeByte) {
*pbtModeByte = abtRx[0]; *pbtModeByte = abtRx[0];
@ -2573,7 +2573,7 @@ pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
// Save the received byte count // Save the received byte count
szRx -= 1; szRx -= 1;
if ((szRx - 1) > szRxLen) if ((szRx - 1) > szRxLen)
return NFC_EOVFLOW; return NFC_EOVFLOW;
// Copy the received bytes // Copy the received bytes
@ -2831,7 +2831,7 @@ pn53x_nm_to_ptt(const nfc_modulation nm)
return PTT_UNDEFINED; return PTT_UNDEFINED;
} }
int int
pn53x_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type * *const supported_mt) pn53x_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type * *const supported_mt)
{ {
switch (mode) { switch (mode) {
@ -2841,7 +2841,7 @@ pn53x_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_m
case N_INITIATOR: case N_INITIATOR:
*supported_mt = CHIP_DATA(pnd)->supported_modulation_as_initiator; *supported_mt = CHIP_DATA(pnd)->supported_modulation_as_initiator;
break; break;
default: default:
return NFC_EINVARG; return NFC_EINVARG;
} }
return NFC_SUCCESS; return NFC_SUCCESS;
@ -2849,12 +2849,12 @@ pn53x_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_m
int int
pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate * *const supported_br) pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate * *const supported_br)
{ {
switch (nmt) { switch (nmt) {
case NMT_FELICA: case NMT_FELICA:
*supported_br = (nfc_baud_rate*)pn53x_felica_supported_baud_rates; *supported_br = (nfc_baud_rate*)pn53x_felica_supported_baud_rates;
break; break;
case NMT_ISO14443A: case NMT_ISO14443A:
*supported_br = (nfc_baud_rate*)pn53x_iso14443a_supported_baud_rates; *supported_br = (nfc_baud_rate*)pn53x_iso14443a_supported_baud_rates;
break; break;
case NMT_ISO14443B: case NMT_ISO14443B:
@ -2872,7 +2872,7 @@ pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, c
case NMT_JEWEL: case NMT_JEWEL:
*supported_br = (nfc_baud_rate*)pn53x_jewel_supported_baud_rates; *supported_br = (nfc_baud_rate*)pn53x_jewel_supported_baud_rates;
break; break;
case NMT_DEP: case NMT_DEP:
*supported_br = (nfc_baud_rate*)pn53x_dep_supported_baud_rates; *supported_br = (nfc_baud_rate*)pn53x_dep_supported_baud_rates;
break; break;
default: default:
@ -2906,7 +2906,7 @@ pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
if ((res = nfc_device_get_supported_modulation(pnd, N_INITIATOR, &nmt)) < 0) { if ((res = nfc_device_get_supported_modulation(pnd, N_INITIATOR, &nmt)) < 0) {
return res; return res;
} }
for (int i=0; nmt[i]; i++) { for (int i=0; nmt[i]; i++) {
if ((res = snprintf (buf, buflen, "%s%s (", (i==0)?"":", ", str_nfc_modulation_type (nmt[i]))) < 0) { if ((res = snprintf (buf, buflen, "%s%s (", (i==0)?"":", ", str_nfc_modulation_type (nmt[i]))) < 0) {
return NFC_ESOFT; return NFC_ESOFT;
@ -2920,7 +2920,7 @@ pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
if ((res = nfc_device_get_supported_baud_rate (pnd, nmt[i], &nbr)) < 0) { if ((res = nfc_device_get_supported_baud_rate (pnd, nmt[i], &nbr)) < 0) {
return res; return res;
} }
for (int j=0; nbr[j]; j++) { for (int j=0; nbr[j]; j++) {
if ((res = snprintf (buf, buflen, "%s%s", (j==0)?"":", ", str_nfc_baud_rate (nbr[j]))) < 0) { if ((res = snprintf (buf, buflen, "%s%s", (j==0)?"":", ", str_nfc_baud_rate (nbr[j]))) < 0) {
return NFC_ESOFT; return NFC_ESOFT;
@ -2960,7 +2960,7 @@ pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
if ((res = nfc_device_get_supported_modulation(pnd, N_TARGET, &nmt)) < 0) { if ((res = nfc_device_get_supported_modulation(pnd, N_TARGET, &nmt)) < 0) {
return res; return res;
} }
for (int i=0; nmt[i]; i++) { for (int i=0; nmt[i]; i++) {
if ((res = snprintf (buf, buflen, "%s%s (", (i==0)?"":", ", str_nfc_modulation_type (nmt[i]))) < 0) { if ((res = snprintf (buf, buflen, "%s%s (", (i==0)?"":", ", str_nfc_modulation_type (nmt[i]))) < 0) {
return NFC_ESOFT; return NFC_ESOFT;
@ -2974,7 +2974,7 @@ pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
if ((res = nfc_device_get_supported_baud_rate (pnd, nmt[i], &nbr)) < 0) { if ((res = nfc_device_get_supported_baud_rate (pnd, nmt[i], &nbr)) < 0) {
return res; return res;
} }
for (int j=0; nbr[j]; j++) { for (int j=0; nbr[j]; j++) {
if ((res = snprintf (buf, buflen, "%s%s", (j==0)?"":", ", str_nfc_baud_rate (nbr[j]))) < 0) { if ((res = snprintf (buf, buflen, "%s%s", (j==0)?"":", ", str_nfc_baud_rate (nbr[j]))) < 0) {
return NFC_ESOFT; return NFC_ESOFT;
@ -3043,10 +3043,10 @@ pn53x_data_new (struct nfc_device *pnd, const struct pn53x_io *io)
// Set default communication timeout (52 ms) // Set default communication timeout (52 ms)
CHIP_DATA (pnd)->timeout_communication = 52; CHIP_DATA (pnd)->timeout_communication = 52;
CHIP_DATA (pnd)->supported_modulation_as_initiator = NULL; CHIP_DATA (pnd)->supported_modulation_as_initiator = NULL;
CHIP_DATA (pnd)->supported_modulation_as_target = NULL; CHIP_DATA (pnd)->supported_modulation_as_target = NULL;
} }
void void

View file

@ -1,15 +1,15 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult, Romuald Conty * Copyright (C) 2009, Roel Verdult, Romuald Conty
* Copyright (C) 2010, Roel Verdult, Romuald Conty, Romain Tartière * Copyright (C) 2010, Roel Verdult, Romuald Conty, Romain Tartière
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
*/ */
/** /**
* @file pn53x.h * @file pn53x.h
* @brief PN531, PN532 and PN533 common functions * @brief PN531, PN532 and PN533 common functions
*/ */
@ -189,8 +189,8 @@ struct pn53x_data {
int timeout_atr; int timeout_atr;
/** Communication timeout */ /** Communication timeout */
int timeout_communication; int timeout_communication;
/** Supported modulation type */ /** Supported modulation type */
nfc_modulation_type *supported_modulation_as_initiator; nfc_modulation_type *supported_modulation_as_initiator;
nfc_modulation_type *supported_modulation_as_target; nfc_modulation_type *supported_modulation_as_target;
}; };
@ -210,7 +210,7 @@ typedef enum {
/** JIS X 6319-4 (Sony Felica) http://en.wikipedia.org/wiki/FeliCa */ /** JIS X 6319-4 (Sony Felica) http://en.wikipedia.org/wiki/FeliCa */
PM_FELICA_424 = 0x02, PM_FELICA_424 = 0x02,
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531) */ /** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531) */
PM_ISO14443B_106 = 0x03, PM_ISO14443B_106 = 0x03,
/** Jewel Topaz (Innovision Research & Development) (Not supported by PN531) */ /** Jewel Topaz (Innovision Research & Development) (Not supported by PN531) */
PM_JEWEL_106 = 0x04, PM_JEWEL_106 = 0x04,
/** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */ /** ISO14443-B http://en.wikipedia.org/wiki/ISO/IEC_14443 (Not supported by PN531 nor PN532) */
@ -322,7 +322,7 @@ int pn53x_initiator_poll_target (struct nfc_device *pnd,
nfc_target *pnt); nfc_target *pnt);
int pn53x_initiator_select_dep_target (struct nfc_device *pnd, int pn53x_initiator_select_dep_target (struct nfc_device *pnd,
const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const nfc_dep_info *pndiInitiator, const nfc_dep_info *pndiInitiator,
nfc_target *pnt, nfc_target *pnt,
const int timeout); const int timeout);
int pn53x_initiator_transceive_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, int pn53x_initiator_transceive_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits,

View file

@ -1,14 +1,14 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for

View file

@ -1,15 +1,15 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2011, Romain Tartiere, Romuald Conty * Copyright (C) 2011, Romain Tartiere, Romuald Conty
* Copyright (C) 2012, Romuald Conty * Copyright (C) 2012, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -282,7 +282,7 @@ acr122_pcsc_open (const nfc_connstring connstring)
pn53x_data_new (pnd, &acr122_pcsc_io); pn53x_data_new (pnd, &acr122_pcsc_io);
SCARDCONTEXT *pscc; SCARDCONTEXT *pscc;
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to open %s", ndd.pcsc_device_name); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Attempt to open %s", ndd.pcsc_device_name);
// Test if context succeeded // Test if context succeeded
if (!(pscc = acr122_pcsc_get_scardcontext ())) if (!(pscc = acr122_pcsc_get_scardcontext ()))

View file

@ -1,15 +1,15 @@
/** /**
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2011, Romain Tartiere, Romuald Conty * Copyright (C) 2011, Romain Tartiere, Romuald Conty
* Copyright (C) 2012, Romuald Conty * Copyright (C) 2012, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -17,8 +17,8 @@
* *
* You should have received a copy of the GNU Lesser General Public License * 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/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
* *
* @file acr122_pcsc.h * @file acr122_pcsc.h
* @brief Driver for ACR122 devices (behind PC/SC daemon) * @brief Driver for ACR122 devices (behind PC/SC daemon)
*/ */

View file

@ -1,15 +1,15 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romain Tartière, Romuald Conty * Copyright (C) 2010, Romain Tartière, Romuald Conty
* Copyright (C) 2011, Romain Tartière, Romuald Conty * Copyright (C) 2011, Romain Tartière, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -33,7 +33,7 @@
* Revision 1.1 * Revision 1.1
* April 22rd, 2005 * April 22rd, 2005
* http://www.usb.org/developers/devclass_docs/DWG_Smart-Card_CCID_Rev110.pdf * http://www.usb.org/developers/devclass_docs/DWG_Smart-Card_CCID_Rev110.pdf
* *
* ACR122U NFC Reader * ACR122U NFC Reader
* Application Programming Interface * Application Programming Interface
* Revision 1.2 * Revision 1.2
@ -684,7 +684,7 @@ acr122_usb_init (nfc_device *pnd)
/* /*
// See ACR122 manual: "Bi-Color LED and Buzzer Control" section // See ACR122 manual: "Bi-Color LED and Buzzer Control" section
uint8_t acr122u_get_led_state_frame[] = { uint8_t acr122u_get_led_state_frame[] = {
0x6b, // CCID 0x6b, // CCID
0x09, // lenght of frame 0x09, // lenght of frame
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // padding 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // padding

View file

@ -1,14 +1,14 @@
/** /**
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2011, Romain Tartière * Copyright (C) 2011, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -16,8 +16,8 @@
* *
* You should have received a copy of the GNU Lesser General Public License * 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/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
* *
* @file acr122_usb.h * @file acr122_usb.h
* @brief Driver for ACR122 devices using direct USB connection (without PCSC) * @brief Driver for ACR122 devices using direct USB connection (without PCSC)
*/ */

View file

@ -479,7 +479,7 @@ acr122s_probe(nfc_connstring connstrings[], size_t connstrings_len, size_t *pszD
return false; return false;
#else /* SERIAL_AUTOPROBE_ENABLED */ #else /* SERIAL_AUTOPROBE_ENABLED */
*pszDeviceFound = 0; *pszDeviceFound = 0;
serial_port sp; serial_port sp;
char **acPorts = uart_list_ports (); char **acPorts = uart_list_ports ();
const char *acPort; const char *acPort;
@ -488,7 +488,7 @@ acr122s_probe(nfc_connstring connstrings[], size_t connstrings_len, size_t *pszD
while ((acPort = acPorts[iDevice++])) { while ((acPort = acPorts[iDevice++])) {
sp = uart_open (acPort); sp = uart_open (acPort);
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Trying to find ACR122S device on serial port: %s at %d bauds.", acPort, ACR122S_DEFAULT_SPEED); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Trying to find ACR122S device on serial port: %s at %d bauds.", acPort, ACR122S_DEFAULT_SPEED);
if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT)) { if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT)) {
// We need to flush input to be sure first reply does not comes from older byte transceive // We need to flush input to be sure first reply does not comes from older byte transceive
uart_flush_input (sp); uart_flush_input (sp);
@ -512,7 +512,7 @@ acr122s_probe(nfc_connstring connstrings[], size_t connstrings_len, size_t *pszD
pn53x_data_new(pnd, &acr122s_io); pn53x_data_new(pnd, &acr122s_io);
CHIP_DATA(pnd)->type = PN532; CHIP_DATA(pnd)->type = PN532;
CHIP_DATA(pnd)->power_mode = NORMAL; CHIP_DATA(pnd)->power_mode = NORMAL;
char version[32]; char version[32];
int ret = acr122s_get_firmware_version(pnd, version, sizeof(version)); int ret = acr122s_get_firmware_version(pnd, version, sizeof(version));
if (ret == 0 && strncmp("ACR122S", version, 7) != 0) { if (ret == 0 && strncmp("ACR122S", version, 7) != 0) {
@ -525,11 +525,11 @@ acr122s_probe(nfc_connstring connstrings[], size_t connstrings_len, size_t *pszD
if (ret != 0) if (ret != 0)
continue; continue;
// ACR122S reader is found // ACR122S reader is found
memcpy (connstrings[*pszDeviceFound], connstring, sizeof(nfc_connstring)); memcpy (connstrings[*pszDeviceFound], connstring, sizeof(nfc_connstring));
(*pszDeviceFound)++; (*pszDeviceFound)++;
// Test if we reach the maximum "wanted" devices // Test if we reach the maximum "wanted" devices
if (*pszDeviceFound >= connstrings_len) if (*pszDeviceFound >= connstrings_len)
break; break;
@ -551,7 +551,7 @@ acr122s_open(const nfc_connstring connstring)
nfc_device *pnd; nfc_device *pnd;
struct acr122s_descriptor ndd; struct acr122s_descriptor ndd;
int connstring_decode_level = acr122s_connstring_decode (connstring, &ndd); int connstring_decode_level = acr122s_connstring_decode (connstring, &ndd);
if (connstring_decode_level < 2) { if (connstring_decode_level < 2) {
return NULL; return NULL;
} }

View file

@ -1,15 +1,15 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* Copyright (C) 2011, Romain Tartière, Romuald Conty * Copyright (C) 2011, Romain Tartière, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -22,7 +22,7 @@
/** /**
* @file arygon.c * @file arygon.c
* @brief ARYGON readers driver * @brief ARYGON readers driver
* *
* This driver can handle ARYGON readers that use UART as bus. * This driver can handle ARYGON readers that use UART as bus.
* 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)
*/ */
@ -50,11 +50,11 @@
#include "uart.h" #include "uart.h"
/** @def DEV_ARYGON_PROTOCOL_ARYGON_ASCII /** @def DEV_ARYGON_PROTOCOL_ARYGON_ASCII
* @brief High level language in ASCII format. (Common µC commands and Mifare® commands) * @brief High level language in ASCII format. (Common µC commands and Mifare® commands)
*/ */
#define DEV_ARYGON_PROTOCOL_ARYGON_ASCII '0' #define DEV_ARYGON_PROTOCOL_ARYGON_ASCII '0'
/** @def DEV_ARYGON_MODE_HL_ASCII /** @def DEV_ARYGON_MODE_HL_ASCII
* @brief High level language in Binary format With AddressingByte for party line. (Common µC commands and Mifare® commands) * @brief High level language in Binary format With AddressingByte for party line. (Common µC commands and Mifare® commands)
*/ */
#define DEV_ARYGON_PROTOCOL_ARYGON_BINARY_WAB '1' #define DEV_ARYGON_PROTOCOL_ARYGON_BINARY_WAB '1'
/** @def DEV_ARYGON_PROTOCOL_TAMA /** @def DEV_ARYGON_PROTOCOL_TAMA
@ -541,7 +541,7 @@ arygon_reset_tama (nfc_device *pnd)
return NFC_SUCCESS; return NFC_SUCCESS;
} }
static int static int
arygon_abort_command (nfc_device *pnd) arygon_abort_command (nfc_device *pnd)
{ {
if (pnd) { if (pnd) {

View file

@ -1,15 +1,15 @@
/** /**
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -17,8 +17,8 @@
* *
* You should have received a copy of the GNU Lesser General Public License * 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/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
* *
* @file arygon.h * @file arygon.h
* @brief Driver for PN53x-equipped ARYGON device connected using UART * @brief Driver for PN53x-equipped ARYGON device connected using UART
*/ */

View file

@ -1,14 +1,14 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2010, Roel Verdult, Romuald Conty * Copyright (C) 2010, Roel Verdult, Romuald Conty
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -61,7 +61,7 @@ struct pn532_uart_data {
volatile bool abort_flag; volatile bool abort_flag;
#endif #endif
}; };
#define DRIVER_DATA(pnd) ((struct pn532_uart_data*)(pnd->driver_data)) #define DRIVER_DATA(pnd) ((struct pn532_uart_data*)(pnd->driver_data))
bool bool

View file

@ -1,14 +1,14 @@
/** /**
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2010, Roel Verdult, Romuald Conty * Copyright (C) 2010, Roel Verdult, Romuald Conty
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -16,8 +16,8 @@
* *
* You should have received a copy of the GNU Lesser General Public License * 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/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
* *
* @file pn532_uart.h * @file pn532_uart.h
* @brief Driver for PN532 connected in UART (HSU) * @brief Driver for PN532 connected in UART (HSU)
*/ */

View file

@ -1,15 +1,15 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romain Tartière, Romuald Conty * Copyright (C) 2010, Romain Tartière, Romuald Conty
* Copyright (C) 2011, Romain Tartière, Romuald Conty * Copyright (C) 2011, Romain Tartière, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -686,19 +686,19 @@ pn53x_usb_init (nfc_device *pnd)
/* /*
On ASK LoGO hardware: On ASK LoGO hardware:
LEDs port bits definition: LEDs port bits definition:
* LED 1: bit 2 (P32) * LED 1: bit 2 (P32)
* LED 2: bit 1 (P31) * LED 2: bit 1 (P31)
* LED 3: bit 0 or 3 (depending of hardware revision) (P30 or P33) * LED 3: bit 0 or 3 (depending of hardware revision) (P30 or P33)
* LED 4: bit 5 (P35) * LED 4: bit 5 (P35)
Notes: Notes:
* Set logical 0 to switch LED on; logical 1 to switch LED off. * Set logical 0 to switch LED on; logical 1 to switch LED off.
* Bit 4 should be maintained at 1 to keep RF field on. * Bit 4 should be maintained at 1 to keep RF field on.
Progressive field activation: Progressive field activation:
The ASK LoGO hardware can progressively power-up the antenna. The ASK LoGO hardware can progressively power-up the antenna.
To use this feature we have to switch on the field by switching on To use this feature we have to switch on the field by switching on
the field on PN533 (RFConfiguration) then set P34 to '1', and cut-off the the field on PN533 (RFConfiguration) then set P34 to '1', and cut-off the
field by switching off the field on PN533 then set P34 to '0'. field by switching off the field on PN533 then set P34 to '0'.
*/ */

View file

@ -1,14 +1,14 @@
/** /**
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2011, Romain Tartière * Copyright (C) 2011, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -16,8 +16,8 @@
* *
* You should have received a copy of the GNU Lesser General Public License * 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/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
* *
* @file pn53x_usb.h * @file pn53x_usb.h
* @brief Drive for PN53x USB devices * @brief Drive for PN53x USB devices
*/ */

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -95,28 +95,28 @@ iso14443a_locate_historical_bytes (uint8_t *pbtAts, size_t szAts, size_t *pszTk)
* @brief Add cascade tags (0x88) in UID * @brief Add cascade tags (0x88) in UID
* @see ISO/IEC 14443-3 (6.4.4 UID contents and cascade levels) * @see ISO/IEC 14443-3 (6.4.4 UID contents and cascade levels)
*/ */
void void
iso14443_cascade_uid (const uint8_t abtUID[], const size_t szUID, uint8_t *pbtCascadedUID, size_t *pszCascadedUID) iso14443_cascade_uid (const uint8_t abtUID[], const size_t szUID, uint8_t *pbtCascadedUID, size_t *pszCascadedUID)
{ {
switch (szUID) { switch (szUID) {
case 7: case 7:
pbtCascadedUID[0] = 0x88; pbtCascadedUID[0] = 0x88;
memcpy (pbtCascadedUID + 1, abtUID, 7); memcpy (pbtCascadedUID + 1, abtUID, 7);
*pszCascadedUID = 8; *pszCascadedUID = 8;
break; break;
case 10: case 10:
pbtCascadedUID[0] = 0x88; pbtCascadedUID[0] = 0x88;
memcpy (pbtCascadedUID + 1, abtUID, 3); memcpy (pbtCascadedUID + 1, abtUID, 3);
pbtCascadedUID[4] = 0x88; pbtCascadedUID[4] = 0x88;
memcpy (pbtCascadedUID + 5, abtUID + 3, 7); memcpy (pbtCascadedUID + 5, abtUID + 3, 7);
*pszCascadedUID = 12; *pszCascadedUID = 12;
break; break;
case 4: case 4:
default: default:
memcpy (pbtCascadedUID, abtUID, szUID); memcpy (pbtCascadedUID, abtUID, szUID);
*pszCascadedUID = szUID; *pszCascadedUID = szUID;
break; break;
} }
} }

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for

View file

@ -41,8 +41,8 @@
__attribute__((format(printf, 3, 4))) __attribute__((format(printf, 3, 4)))
# endif # endif
; ;
#define NFC_PRIORITY_FATAL "fatal" #define NFC_PRIORITY_FATAL "fatal"
#define NFC_PRIORITY_ALERT "alert" #define NFC_PRIORITY_ALERT "alert"
#define NFC_PRIORITY_CRIT "critical" #define NFC_PRIORITY_CRIT "critical"
@ -59,7 +59,7 @@
#define log_msg(category, priority, message) do {} while (0) #define log_msg(category, priority, message) do {} while (0)
#define log_set_appender(category, appender) do {} while (0) #define log_set_appender(category, appender) do {} while (0)
#define log_put(category, priority, format, ...) do {} while (0) #define log_put(category, priority, format, ...) do {} while (0)
#define NFC_PRIORITY_FATAL 8 #define NFC_PRIORITY_FATAL 8
#define NFC_PRIORITY_ALERT 7 #define NFC_PRIORITY_ALERT 7
#define NFC_PRIORITY_CRIT 6 #define NFC_PRIORITY_CRIT 6

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for

View file

@ -1,13 +1,13 @@
/** /**
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -15,8 +15,8 @@
* *
* You should have received a copy of the GNU Lesser General Public License * 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/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
* *
* @file mirror-subr.h * @file mirror-subr.h
* @brief Mirror bytes * @brief Mirror bytes
*/ */

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2011, Romain Tartière, Romuald Conty * Copyright (C) 2011, Romain Tartière, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2011, Romuald Conty * Copyright (C) 2011, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -25,7 +25,7 @@
#include <nfc/nfc.h> #include <nfc/nfc.h>
#include "nfc-internal.h" #include "nfc-internal.h"
void void
prepare_initiator_data (const nfc_modulation nm, uint8_t **ppbtInitiatorData, size_t * pszInitiatorData) prepare_initiator_data (const nfc_modulation nm, uint8_t **ppbtInitiatorData, size_t * pszInitiatorData)
{ {
switch (nm.nmt) { switch (nm.nmt) {

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2011, Romain Tartière, Romuald Conty * Copyright (C) 2011, Romain Tartière, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -54,7 +54,7 @@
/* /*
* Buffer management macros. * Buffer management macros.
* *
* The following macros ease setting-up and using buffers: * The following macros ease setting-up and using buffers:
* BUFFER_INIT (data, 5); // data -> [ xx, xx, xx, xx, xx ] * BUFFER_INIT (data, 5); // data -> [ xx, xx, xx, xx, xx ]
* BUFFER_SIZE (data); // size -> 0 * BUFFER_SIZE (data); // size -> 0

View file

@ -1,15 +1,15 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult, Romuald Conty * Copyright (C) 2009, Roel Verdult, Romuald Conty
* Copyright (C) 2010, Roel Verdult, Romuald Conty, Romain Tartière * Copyright (C) 2010, Roel Verdult, Romuald Conty, Romain Tartière
* Copyright (C) 2011, Romuald Conty, Romain Tartière * Copyright (C) 2011, Romuald Conty, Romain Tartière
* *
* This program is free software: you can redistribute it and/or modify it * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. * option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
*/ */
/** /**
* @file nfc.c * @file nfc.c
* @brief NFC library implementation * @brief NFC library implementation
*/ */
@ -30,36 +30,36 @@
* must not call any libnfc functions after deinitialization. * must not call any libnfc functions after deinitialization.
*/ */
/** /**
* @defgroup dev NFC Device/Hardware manipulation * @defgroup dev NFC Device/Hardware manipulation
* The functionality documented below is designed to help with the following * The functionality documented below is designed to help with the following
* operations: * operations:
* - Enumerating the NFC devices currently attached to the system * - Enumerating the NFC devices currently attached to the system
* - Opening and closing the chosen device * - Opening and closing the chosen device
*/ */
/** /**
* @defgroup initiator NFC initiator * @defgroup initiator NFC initiator
* This page details how to act as "reader". * This page details how to act as "reader".
*/ */
/** /**
* @defgroup target NFC target * @defgroup target NFC target
* This page details how to act as tag (i.e. MIFARE Classic) or NFC target device. * This page details how to act as tag (i.e. MIFARE Classic) or NFC target device.
*/ */
/** /**
* @defgroup error Error reporting * @defgroup error Error reporting
* Most libnfc functions return 0 on success or one of error codes defined on failure. * Most libnfc functions return 0 on success or one of error codes defined on failure.
*/ */
/** /**
* @defgroup data Special data accessors * @defgroup data Special data accessors
* The functionnality documented below allow to access to special data as device name or device connstring. * The functionnality documented below allow to access to special data as device name or device connstring.
*/ */
/** /**
* @defgroup properties Properties accessors * @defgroup properties Properties accessors
* The functionnality documented below allow to configure parameters and registers. * The functionnality documented below allow to configure parameters and registers.
*/ */
/** /**
* @defgroup misc Miscellaneous * @defgroup misc Miscellaneous
* *
*/ */
/* vim:set ts=2 sw=2 et: */ /* vim:set ts=2 sw=2 et: */
@ -128,7 +128,7 @@ nfc_exit(nfc_context *context)
/** @ingroup dev /** @ingroup dev
* @brief Get the defaut NFC device * @brief Get the defaut NFC device
* @param connstring \a nfc_connstring pointer where the default connection string will be stored * @param connstring \a nfc_connstring pointer where the default connection string will be stored
* @return \e true on success * @return \e true on success
* *
* This function fill \e connstring with the LIBNFC_DEFAULT_DEVICE environment variable content * This function fill \e connstring with the LIBNFC_DEFAULT_DEVICE environment variable content
@ -136,11 +136,11 @@ nfc_exit(nfc_context *context)
* \e connstring with the corresponding \a nfc_connstring value. * \e connstring with the corresponding \a nfc_connstring value.
* *
* This function returns true when LIBNFC_DEFAULT_DEVICE is set or an available device is found. * This function returns true when LIBNFC_DEFAULT_DEVICE is set or an available device is found.
* *
* @note The \e connstring content can be invalid if LIBNFC_DEFAULT_DEVICE is * @note The \e connstring content can be invalid if LIBNFC_DEFAULT_DEVICE is
* set with incorrect value. * set with incorrect value.
*/ */
bool bool
nfc_get_default_device (nfc_connstring *connstring) nfc_get_default_device (nfc_connstring *connstring)
{ {
char *env_default_connstring = getenv ("LIBNFC_DEFAULT_DEVICE"); char *env_default_connstring = getenv ("LIBNFC_DEFAULT_DEVICE");
@ -166,14 +166,14 @@ nfc_get_default_device (nfc_connstring *connstring)
* @return Returns pointer to a \a nfc_device struct if successfull; otherwise returns \c NULL value. * @return Returns pointer to a \a nfc_device struct if successfull; otherwise returns \c NULL value.
* *
* If \e connstring is \c NULL, the \a nfc_get_default_device() function is used. * If \e connstring is \c NULL, the \a nfc_get_default_device() function is used.
* *
* If \e connstring is set, this function will try to claim the right device using information provided by \e connstring. * If \e connstring is set, this function will try to claim the right device using information provided by \e connstring.
* *
* When it has successfully claimed a NFC device, memory is allocated to save the device information. * When it has successfully claimed a NFC device, memory is allocated to save the device information.
* It will return a pointer to a \a nfc_device struct. * It will return a pointer to a \a nfc_device struct.
* This pointer should be supplied by every next functions of libnfc that should perform an action with this device. * This pointer should be supplied by every next functions of libnfc that should perform an action with this device.
* *
* @note Depending on the desired operation mode, the device needs to be configured by using nfc_initiator_init() or nfc_target_init(), * @note Depending on the desired operation mode, the device needs to be configured by using nfc_initiator_init() or nfc_target_init(),
* optionally followed by manual tuning of the parameters if the default parameters are not suiting your goals. * optionally followed by manual tuning of the parameters if the default parameters are not suiting your goals.
*/ */
nfc_device * nfc_device *
@ -191,12 +191,12 @@ nfc_open (nfc_context *context, const nfc_connstring connstring)
} else { } else {
strncpy (ncs, connstring, sizeof (nfc_connstring)); strncpy (ncs, connstring, sizeof (nfc_connstring));
} }
// Search through the device list for an available device // Search through the device list for an available device
const struct nfc_driver *ndr; const struct nfc_driver *ndr;
const struct nfc_driver **pndr = nfc_drivers; const struct nfc_driver **pndr = nfc_drivers;
while ((ndr = *pndr)) { while ((ndr = *pndr)) {
// Specific device is requested: using device description // Specific device is requested: using device description
if (0 != strncmp (ndr->name, ncs, strlen(ndr->name))) { if (0 != strncmp (ndr->name, ncs, strlen(ndr->name))) {
pndr++; pndr++;
continue; continue;
@ -209,7 +209,7 @@ nfc_open (nfc_context *context, const nfc_connstring connstring)
log_fini (); log_fini ();
return pnd; return pnd;
} }
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "\"%s\" (%s) has been claimed.", pnd->name, pnd->connstring); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "\"%s\" (%s) has been claimed.", pnd->name, pnd->connstring);
log_fini (); log_fini ();
return pnd; return pnd;
@ -233,7 +233,7 @@ nfc_close (nfc_device *pnd)
if (pnd) { if (pnd) {
// Go in idle mode // Go in idle mode
nfc_idle (pnd); nfc_idle (pnd);
// Close, clean up and release the device // Close, clean up and release the device
pnd->driver->close (pnd); pnd->driver->close (pnd);
} }
@ -245,7 +245,7 @@ nfc_close (nfc_device *pnd)
* @param context The context to operate on, or NULL for the default context. * @param context The context to operate on, or NULL for the default context.
* @param connstrings array of \a nfc_connstring. * @param connstrings array of \a nfc_connstring.
* @param szDevices size of the \a connstrings array. * @param szDevices size of the \a connstrings array.
* *
*/ */
size_t size_t
nfc_list_devices (nfc_context *context, nfc_connstring connstrings[] , size_t szDevices) nfc_list_devices (nfc_context *context, nfc_connstring connstrings[] , size_t szDevices)
@ -282,7 +282,7 @@ nfc_list_devices (nfc_context *context, nfc_connstring connstrings[] , size_t sz
* *
* @see nfc_property enum values * @see nfc_property enum values
*/ */
int int
nfc_device_set_property_int (nfc_device *pnd, const nfc_property property, const int value) nfc_device_set_property_int (nfc_device *pnd, const nfc_property property, const int value)
{ {
HAL (device_set_property_int, pnd, property, value); HAL (device_set_property_int, pnd, property, value);
@ -385,7 +385,7 @@ nfc_initiator_init (nfc_device *pnd)
* *
* @param[out] pnt \a nfc_target struct pointer which will filled if available * @param[out] pnt \a nfc_target struct pointer which will filled if available
* *
* The NFC device will try to find one available passive tag or emulated tag. * The NFC device will try to find one available passive tag or emulated tag.
* *
* The chip needs to know with what kind of tag it is dealing with, therefore * The chip needs to know with what kind of tag it is dealing with, therefore
* the initial modulation and speed (106, 212 or 424 kbps) should be supplied. * the initial modulation and speed (106, 212 or 424 kbps) should be supplied.
@ -519,11 +519,11 @@ nfc_initiator_poll_target (nfc_device *pnd,
* The NFC device will try to find an available D.E.P. target. The standards * The NFC device will try to find an available D.E.P. target. The standards
* (ISO18092 and ECMA-340) describe the modulation that can be used for reader * (ISO18092 and ECMA-340) describe the modulation that can be used for reader
* to passive communications. * to passive communications.
* *
* @note \a nfc_dep_info will be returned when the target was acquired successfully. * @note \a nfc_dep_info will be returned when the target was acquired successfully.
*/ */
int int
nfc_initiator_select_dep_target (nfc_device *pnd, nfc_initiator_select_dep_target (nfc_device *pnd,
const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout) const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout)
{ {
@ -544,7 +544,7 @@ nfc_initiator_select_dep_target (nfc_device *pnd,
* The NFC device will try to find an available D.E.P. target. The standards * The NFC device will try to find an available D.E.P. target. The standards
* (ISO18092 and ECMA-340) describe the modulation that can be used for reader * (ISO18092 and ECMA-340) describe the modulation that can be used for reader
* to passive communications. * to passive communications.
* *
* @note \a nfc_dep_info will be returned when the target was acquired successfully. * @note \a nfc_dep_info will be returned when the target was acquired successfully.
*/ */
int int
@ -599,7 +599,7 @@ nfc_initiator_deselect_target (nfc_device *pnd)
* @param[out] pbtRx response from the tags * @param[out] pbtRx response from the tags
* @param szRx size of \a pbtRx (Will return NFC_EOVFLOW if RX exceeds this size) * @param szRx size of \a pbtRx (Will return NFC_EOVFLOW if RX exceeds this size)
* @param timeout in milliseconds * @param timeout in milliseconds
* *
* The NFC device (configured as initiator) will transmit the supplied bytes (\a pbtTx) to the target. * The NFC device (configured as initiator) will transmit the supplied bytes (\a pbtTx) to the target.
* It waits for the response and stores the received bytes in the \a pbtRx byte array. * It waits for the response and stores the received bytes in the \a pbtRx byte array.
* *
@ -646,7 +646,7 @@ nfc_initiator_transceive_bytes (nfc_device *pnd, const uint8_t *pbtTx, const siz
* explain how it works, if you just are sending two bytes with ISO14443-A * explain how it works, if you just are sending two bytes with ISO14443-A
* compliant parity bits you better can use the * compliant parity bits you better can use the
* nfc_initiator_transceive_bytes() function. * nfc_initiator_transceive_bytes() function.
* *
* @param[out] pbtRx response from the tag * @param[out] pbtRx response from the tag
* @param[out] pbtRxPar parameter contains a byte array of the corresponding parity bits * @param[out] pbtRxPar parameter contains a byte array of the corresponding parity bits
* *
@ -850,7 +850,7 @@ nfc_target_send_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
/** @ingroup target /** @ingroup target
* @brief Receive bytes and APDU frames * @brief Receive bytes and APDU frames
* @return Returns received bytes count on success, otherwise returns libnfc's error code * @return Returns received bytes count on success, otherwise returns libnfc's error code
* *
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
* @param pbtRx pointer to Rx buffer * @param pbtRx pointer to Rx buffer
* @param szRx size of Rx buffer * @param szRx size of Rx buffer
@ -928,12 +928,12 @@ static struct sErrorMessage {
/** @ingroup error /** @ingroup error
* @brief Return the last error string * @brief Return the last error string
* @return Returns a string * @return Returns a string
* *
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
*/ */
const char * const char *
nfc_strerror (const nfc_device *pnd) nfc_strerror (const nfc_device *pnd)
{ {
const char *pcRes = "Unknown error"; const char *pcRes = "Unknown error";
size_t i; size_t i;
for (i = 0; i < (sizeof (sErrorMessages) / sizeof (struct sErrorMessage)); i++) { for (i = 0; i < (sizeof (sErrorMessages) / sizeof (struct sErrorMessage)); i++) {
@ -949,7 +949,7 @@ nfc_strerror (const nfc_device *pnd)
/** @ingroup error /** @ingroup error
* @brief Renders the last error in pcStrErrBuf for a maximum size of szBufLen chars * @brief Renders the last error in pcStrErrBuf for a maximum size of szBufLen chars
* @return Returns 0 upon success * @return Returns 0 upon success
* *
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
* @param pcStrErrBuf a string that contains the last error. * @param pcStrErrBuf a string that contains the last error.
* @param szBufLen size of buffer * @param szBufLen size of buffer
@ -962,9 +962,9 @@ nfc_strerror_r (const nfc_device *pnd, char *pcStrErrBuf, size_t szBufLen)
/** @ingroup error /** @ingroup error
* @brief Display the last error occured on a nfc_device * @brief Display the last error occured on a nfc_device
* *
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
* @param pcString a string * @param pcString a string
*/ */
void void
nfc_perror (const nfc_device *pnd, const char *pcString) nfc_perror (const nfc_device *pnd, const char *pcString)
@ -975,7 +975,7 @@ nfc_perror (const nfc_device *pnd, const char *pcString)
/** @ingroup error /** @ingroup error
* @brief Returns last error occured on a nfc_device * @brief Returns last error occured on a nfc_device
* @return Returns an integer that represents to libnfc's error code. * @return Returns an integer that represents to libnfc's error code.
* *
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
*/ */
int int
@ -989,7 +989,7 @@ nfc_device_get_last_error (const nfc_device *pnd)
/** @ingroup data /** @ingroup data
* @brief Returns the device name * @brief Returns the device name
* @return Returns a string with the device name * @return Returns a string with the device name
* *
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
*/ */
const char * const char *
@ -1001,7 +1001,7 @@ nfc_device_get_name (nfc_device *pnd)
/** @ingroup data /** @ingroup data
* @brief Returns the device connection string * @brief Returns the device connection string
* @return Returns a string with the device connstring * @return Returns a string with the device connstring
* *
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
*/ */
const char * const char *
@ -1016,9 +1016,9 @@ nfc_device_get_connstring (nfc_device *pnd)
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
* @param mode \a nfc_mode. * @param mode \a nfc_mode.
* @param supported_mt pointer of \a nfc_modulation_type array. * @param supported_mt pointer of \a nfc_modulation_type array.
* *
*/ */
int int
nfc_device_get_supported_modulation (nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt) nfc_device_get_supported_modulation (nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt)
{ {
HAL (get_supported_modulation, pnd, mode, supported_mt); HAL (get_supported_modulation, pnd, mode, supported_mt);
@ -1030,9 +1030,9 @@ nfc_device_get_supported_modulation (nfc_device *pnd, const nfc_mode mode, const
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
* @param nmt \a nfc_modulation_type. * @param nmt \a nfc_modulation_type.
* @param supported_br pointer of \a nfc_baud_rate array. * @param supported_br pointer of \a nfc_baud_rate array.
* *
*/ */
int int
nfc_device_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br) nfc_device_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br)
{ {
HAL (get_supported_baud_rate, pnd, nmt, supported_br); HAL (get_supported_baud_rate, pnd, nmt, supported_br);
@ -1043,7 +1043,7 @@ nfc_device_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type n
/** @ingroup misc /** @ingroup misc
* @brief Returns the library version * @brief Returns the library version
* @return Returns a string with the library version * @return Returns a string with the library version
* *
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
*/ */
const char * const char *
@ -1063,7 +1063,7 @@ nfc_version (void)
* @param buf string to print information * @param buf string to print information
* @param buflen buf length * @param buflen buf length
*/ */
int int
nfc_device_get_information_about (nfc_device *pnd, char *buf, size_t buflen) nfc_device_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
{ {
HAL (device_get_information_about, pnd, buf, buflen); HAL (device_get_information_about, pnd, buf, buflen);

View file

@ -18,7 +18,7 @@ test_access_storm (void)
int res = 0; int res = 0;
nfc_init (NULL); nfc_init (NULL);
size_t ref_device_count = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT); size_t ref_device_count = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT);
if (!ref_device_count) if (!ref_device_count)
cut_omit ("No NFC device found"); cut_omit ("No NFC device found");

View file

@ -93,7 +93,7 @@ target_thread (void *arg)
const uint8_t abtAttRx[] = "Hello DEP target!"; const uint8_t abtAttRx[] = "Hello DEP target!";
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; } if (res <= 0) { thread_res = -1; return (void*) thread_res; }
const uint8_t abtTx[] = "Hello DEP initiator!"; const uint8_t abtTx[] = "Hello DEP initiator!";
res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500); res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device)));
@ -121,7 +121,7 @@ initiator_thread (void *arg)
nfc_target nt; nfc_target nt;
// Active mode // Active mode
printf ("=========== INITIATOR %s (Active mode / %s Kbps) =========\n", nfc_device_get_name (device), str_nfc_baud_rate(nbr)); printf ("=========== INITIATOR %s (Active mode / %s Kbps) =========\n", nfc_device_get_name (device), str_nfc_baud_rate(nbr));
res = nfc_initiator_select_dep_target (device, NDM_ACTIVE, nbr, NULL, &nt, 1000); res = nfc_initiator_select_dep_target (device, NDM_ACTIVE, nbr, NULL, &nt, 1000);
cut_assert_operator_int (res, >, 0, cut_message ("Can't select any DEP target: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't select any DEP target: %s", nfc_strerror (device)));
@ -159,15 +159,15 @@ test_dep (void)
.device = devices[TARGET], .device = devices[TARGET],
.cut_test_context = test_context, .cut_test_context = test_context,
}; };
struct thread_data initiator_data = { struct thread_data initiator_data = {
.device = devices[INITIATOR], .device = devices[INITIATOR],
.cut_test_context = test_context, .cut_test_context = test_context,
}; };
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
initiator_data.nbr = nbrs[i]; initiator_data.nbr = nbrs[i];
if ((res = pthread_create (&(threads[TARGET]), NULL, target_thread, &target_data))) if ((res = pthread_create (&(threads[TARGET]), NULL, target_thread, &target_data)))
cut_fail ("pthread_create() returned %d", res); cut_fail ("pthread_create() returned %d", res);
if ((res = pthread_create (&(threads[INITIATOR]), NULL, initiator_thread, &initiator_data))) if ((res = pthread_create (&(threads[INITIATOR]), NULL, initiator_thread, &initiator_data)))
@ -181,5 +181,5 @@ test_dep (void)
cut_assert_equal_int (0, result[INITIATOR], cut_message ("Unexpected initiator return code")); cut_assert_equal_int (0, result[INITIATOR], cut_message ("Unexpected initiator return code"));
cut_assert_equal_int (0, result[TARGET], cut_message ("Unexpected target return code")); cut_assert_equal_int (0, result[TARGET], cut_message ("Unexpected target return code"));
} }
} }

View file

@ -30,7 +30,7 @@ cut_setup (void)
if (n < 2) { if (n < 2) {
cut_omit ("At least two NFC devices must be plugged-in to run this test"); cut_omit ("At least two NFC devices must be plugged-in to run this test");
} }
nfc_init (NULL); nfc_init (NULL);
devices[TARGET] = nfc_open (NULL, connstrings[TARGET]); devices[TARGET] = nfc_open (NULL, connstrings[TARGET]);
devices[INITIATOR] = nfc_open (NULL, connstrings[INITIATOR]); devices[INITIATOR] = nfc_open (NULL, connstrings[INITIATOR]);
@ -90,11 +90,11 @@ target_thread (void *arg)
res = nfc_target_receive_bytes (device, abtRx, sizeof (abtRx), 500); res = nfc_target_receive_bytes (device, abtRx, sizeof (abtRx), 500);
cut_assert_operator_int (res, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
szRx = (size_t) res; szRx = (size_t) res;
const uint8_t abtAttRx[] = "Hello DEP target!"; const uint8_t abtAttRx[] = "Hello DEP target!";
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; } if (res <= 0) { thread_res = -1; return (void*) thread_res; }
const uint8_t abtTx[] = "Hello DEP initiator!"; const uint8_t abtTx[] = "Hello DEP initiator!";
res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500); res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device)));
@ -107,7 +107,7 @@ target_thread (void *arg)
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; } if (res <= 0) { thread_res = -1; return (void*) thread_res; }
res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500); res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device)));
if (res <= 0) { thread_res = -1; return (void*) thread_res; } if (res <= 0) { thread_res = -1; return (void*) thread_res; }
@ -119,11 +119,11 @@ target_thread (void *arg)
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; } if (res <= 0) { thread_res = -1; return (void*) thread_res; }
res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500); res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device)));
if (res <= 0) { thread_res = -1; return (void*) thread_res; } if (res <= 0) { thread_res = -1; return (void*) thread_res; }
// Fourth pass // Fourth pass
res = nfc_target_receive_bytes (device, abtRx, sizeof (abtRx), 500); res = nfc_target_receive_bytes (device, abtRx, sizeof (abtRx), 500);
cut_assert_operator_int (res, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
@ -131,7 +131,7 @@ target_thread (void *arg)
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; } if (res <= 0) { thread_res = -1; return (void*) thread_res; }
res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500); res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device)));
if (res <= 0) { thread_res = -1; return (void*) thread_res; } if (res <= 0) { thread_res = -1; return (void*) thread_res; }
@ -226,7 +226,7 @@ initiator_thread (void *arg)
res = nfc_initiator_deselect_target (device); res = nfc_initiator_deselect_target (device);
cut_assert_operator_int (res, >=, 0, cut_message ("Can't deselect target: %s", nfc_strerror (device))); cut_assert_operator_int (res, >=, 0, cut_message ("Can't deselect target: %s", nfc_strerror (device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
// Passive mode / 424Kbps // Passive mode / 424Kbps
printf ("=========== INITIATOR %s (Passive mode / 424Kbps) =========\n", nfc_device_get_name (device)); printf ("=========== INITIATOR %s (Passive mode / 424Kbps) =========\n", nfc_device_get_name (device));
res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_424, NULL, &nt, 1000); res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_424, NULL, &nt, 1000);

View file

@ -57,7 +57,7 @@ target_thread (void *arg)
cut_set_current_test_context (((struct thread_data *) arg)->cut_test_context); cut_set_current_test_context (((struct thread_data *) arg)->cut_test_context);
printf ("=========== TARGET %s =========\n", nfc_device_get_name (device)); printf ("=========== TARGET %s =========\n", nfc_device_get_name (device));
nfc_target nt; nfc_target nt;
uint8_t abtRx[1024]; uint8_t abtRx[1024];
size_t szRx = sizeof (abtRx); size_t szRx = sizeof (abtRx);
@ -66,7 +66,7 @@ target_thread (void *arg)
int res = nfc_target_init (device, &nt, abtRx, szRx, 500); int res = nfc_target_init (device, &nt, abtRx, szRx, 500);
cut_assert_operator_int (res, >=, 0, cut_message ("Can't initialize NFC device as target: %s", nfc_strerror (device))); cut_assert_operator_int (res, >=, 0, cut_message ("Can't initialize NFC device as target: %s", nfc_strerror (device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
// 2) act as target // 2) act as target
nfc_target nt1 = { nfc_target nt1 = {
.nm = { .nm = {
@ -96,11 +96,11 @@ target_thread (void *arg)
res = nfc_target_receive_bytes (device, abtRx, sizeof (abtRx), 500); res = nfc_target_receive_bytes (device, abtRx, sizeof (abtRx), 500);
cut_assert_operator_int (res, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
szRx = (size_t) res; szRx = (size_t) res;
const uint8_t abtAttRx[] = "Hello DEP target!"; const uint8_t abtAttRx[] = "Hello DEP target!";
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data")); cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
if (res <= 0) { thread_res = -1; return (void*) thread_res; } if (res <= 0) { thread_res = -1; return (void*) thread_res; }
const uint8_t abtTx[] = "Hello DEP initiator!"; const uint8_t abtTx[] = "Hello DEP initiator!";
res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500); res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500);
cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device))); cut_assert_operator_int (res, >, 0, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device)));
@ -130,13 +130,13 @@ initiator_thread (void *arg)
cut_assert_equal_int (0, res, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device))); cut_assert_equal_int (0, res, cut_message ("Can't initialize NFC device as initiator: %s", nfc_strerror (device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
// 1) As other device should be in idle mode, nfc_initiator_poll_dep_target should return 0 // 1) As other device should be in idle mode, nfc_initiator_poll_dep_target should return 0
nfc_target nt; nfc_target nt;
res = nfc_initiator_poll_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt, 1000); res = nfc_initiator_poll_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt, 1000);
cut_assert_equal_int (0, res, cut_message ("Problem with nfc_idle")); cut_assert_equal_int (0, res, cut_message ("Problem with nfc_idle"));
if (res != 0) { thread_res = -1; return (void*) thread_res; } if (res != 0) { thread_res = -1; return (void*) thread_res; }
// 2 As other device should be in target mode, nfc_initiator_poll_dep_target should be positive. // 2 As other device should be in target mode, nfc_initiator_poll_dep_target should be positive.
nfc_target nt1; nfc_target nt1;
@ -165,12 +165,12 @@ initiator_thread (void *arg)
cut_assert_operator_int (res, >=, 0, cut_message ("Can't deselect target: %s", nfc_strerror (device))); cut_assert_operator_int (res, >=, 0, cut_message ("Can't deselect target: %s", nfc_strerror (device)));
if (res < 0) { thread_res = -1; return (void*) thread_res; } if (res < 0) { thread_res = -1; return (void*) thread_res; }
// 3) As other device should be in idle mode, nfc_initiator_poll_dep_target should return 0 // 3) As other device should be in idle mode, nfc_initiator_poll_dep_target should return 0
nfc_target nt2; nfc_target nt2;
res = nfc_initiator_poll_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt2, 1000); res = nfc_initiator_poll_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt2, 1000);
cut_assert_equal_int (0, res, cut_message ("Problem with nfc_idle")); cut_assert_equal_int (0, res, cut_message ("Problem with nfc_idle"));
if (res != 0) { thread_res = -1; return (void*) thread_res; } if (res != 0) { thread_res = -1; return (void*) thread_res; }
return (void *) thread_res; return (void *) thread_res;
} }
@ -184,12 +184,12 @@ test_dep_states (void)
.device = first_device, .device = first_device,
.cut_test_context = test_context, .cut_test_context = test_context,
}; };
struct thread_data initiator_data = { struct thread_data initiator_data = {
.device = second_device, .device = second_device,
.cut_test_context = test_context, .cut_test_context = test_context,
}; };
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if ((res = pthread_create (&(threads[1]), NULL, target_thread, &target_data))) if ((res = pthread_create (&(threads[1]), NULL, target_thread, &target_data)))
cut_fail ("pthread_create() returned %d", res); cut_fail ("pthread_create() returned %d", res);
@ -204,7 +204,7 @@ test_dep_states (void)
cut_assert_equal_int (0, result[0], cut_message ("Unexpected initiator return code")); cut_assert_equal_int (0, result[0], cut_message ("Unexpected initiator return code"));
cut_assert_equal_int (0, result[1], cut_message ("Unexpected target return code")); cut_assert_equal_int (0, result[1], cut_message ("Unexpected target return code"));
// initiator --> target, target --> initiator // initiator --> target, target --> initiator
target_data.device = second_device; target_data.device = second_device;
initiator_data.device = first_device; initiator_data.device = first_device;

View file

@ -11,7 +11,7 @@ test_register_endianness (void)
{ {
nfc_connstring connstrings[MAX_DEVICE_COUNT]; nfc_connstring connstrings[MAX_DEVICE_COUNT];
int res = 0; int res = 0;
nfc_init (NULL); nfc_init (NULL);
size_t device_count = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT); size_t device_count = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT);

View file

@ -12,7 +12,7 @@ test_register_endianness (void)
{ {
nfc_connstring connstrings[MAX_DEVICE_COUNT]; nfc_connstring connstrings[MAX_DEVICE_COUNT];
int res = 0; int res = 0;
nfc_init (NULL); nfc_init (NULL);
size_t device_count = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT); size_t device_count = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT);

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty, Romain Tartière * Copyright (C) 2010, Romuald Conty, Romain Tartière
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -45,9 +45,9 @@
* The specified MIFARE command will be executed on the tag. There are different commands possible, they all require the destination block number. * The specified MIFARE command will be executed on the tag. There are different commands possible, they all require the destination block number.
* @note There are three different types of information (Authenticate, Data and Value). * @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. * 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 (http://libnfc.org/hardware/pn53x-chip).
* After a successful authentication it will be possible to execute other commands (e.g. Read/Write). * 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. * The MIFARE Classic Specification (http://www.nxp.com/acrobat/other/identification/M001053_MF1ICS50_rev5_3.pdf) explains more about this process.
*/ */
bool bool

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty, Romain Tartière * Copyright (C) 2010, Romuald Conty, Romain Tartière
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2010, Roel Verdult, Romuald Conty * Copyright (C) 2010, Roel Verdult, Romuald Conty
* Copyright (C) 2011, Romain Tartière, Romuald Conty * Copyright (C) 2011, Romain Tartière, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -91,7 +91,7 @@ uint8_t nfcforum_capability_container[] = {
0x00, 0x0F, /* CCLEN 15 bytes */ 0x00, 0x0F, /* CCLEN 15 bytes */
0x20, /* Mapping version 2.0, use option -1 to force v1.0 */ 0x20, /* Mapping version 2.0, use option -1 to force v1.0 */
0x00, 0x54, /* MLe Maximum R-ADPU data size */ 0x00, 0x54, /* MLe Maximum R-ADPU data size */
// Notes: // Notes:
// - I (Romuald) don't know why Nokia 6212 Classic refuses the NDEF message if MLe is more than 0xFD (any suggests are welcome); // - I (Romuald) don't know why Nokia 6212 Classic refuses the NDEF message if MLe is more than 0xFD (any suggests are welcome);
// - ARYGON devices doesn't support extended frame sending, consequently these devices can't sent more than 0xFE bytes as APDU, so 0xFB APDU data bytes. // - ARYGON devices doesn't support extended frame sending, consequently these devices can't sent more than 0xFE bytes as APDU, so 0xFB APDU data bytes.
// - I (Romuald) don't know why ARYGON device doesn't ACK when MLe > 0x54 (ARYGON frame length = 0xC2 (192 bytes)) // - I (Romuald) don't know why ARYGON device doesn't ACK when MLe > 0x54 (ARYGON frame length = 0xC2 (192 bytes))
@ -364,7 +364,7 @@ main (int argc, char *argv[])
err (EXIT_FAILURE, "Can't load NDEF file '%s'", argv[1 + options]); err (EXIT_FAILURE, "Can't load NDEF file '%s'", argv[1 + options]);
} }
} }
nfc_init (NULL); nfc_init (NULL);
// Try to open the NFC reader // Try to open the NFC reader
@ -391,7 +391,7 @@ main (int argc, char *argv[])
err (EXIT_FAILURE, "Can't save NDEF file '%s'", argv[2 + options]); err (EXIT_FAILURE, "Can't save NDEF file '%s'", argv[2 + options]);
} }
} }
nfc_exit (NULL); nfc_exit (NULL);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
} }

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty, Romain Tartière * Copyright (C) 2010, Romuald Conty, Romain Tartière
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -75,7 +75,7 @@ main (int argc, const char *argv[])
int res = 0; int res = 0;
nfc_init (NULL); nfc_init (NULL);
// Display libnfc version // Display libnfc version
acLibnfcVersion = nfc_version (); acLibnfcVersion = nfc_version ();
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion); printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
@ -132,7 +132,7 @@ main (int argc, const char *argv[])
} }
if (nfc_initiator_init (pnd) < 0) { if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init"); nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
printf ("NFC device: %s opened\n", nfc_device_get_name (pnd)); printf ("NFC device: %s opened\n", nfc_device_get_name (pnd));

View file

@ -1,14 +1,14 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty, Romain Tartière * Copyright (C) 2010, Romuald Conty, Romain Tartière
* Copyright (C) 2011, Adam Laurie * Copyright (C) 2011, Adam Laurie
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -24,7 +24,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -508,7 +508,7 @@ main (int argc, const char *argv[])
// printf("Successfully opened required files\n"); // printf("Successfully opened required files\n");
nfc_init (NULL); nfc_init (NULL);
// Try to open the NFC reader // Try to open the NFC reader
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);
if (pnd == NULL) { if (pnd == NULL) {
@ -518,7 +518,7 @@ main (int argc, const char *argv[])
if (nfc_initiator_init (pnd) < 0) { if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init"); nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
}; };
// Let the reader only try once to find a tag // Let the reader only try once to find a tag
@ -594,7 +594,7 @@ main (int argc, const char *argv[])
nfc_close (pnd); nfc_close (pnd);
break; break;
}; };
nfc_exit (NULL); nfc_exit (NULL);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
} }

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -149,7 +149,7 @@ write_card (void)
bFailure = false; bFailure = false;
} }
// For the Mifare Ultralight, this write command can be used // For the Mifare Ultralight, this write command can be used
// in compatibility mode, which only actually writes the first // in compatibility mode, which only actually writes the first
// page (4 bytes). The Ultralight-specific Write command only // page (4 bytes). The Ultralight-specific Write command only
// writes one page at a time. // writes one page at a time.
uiBlock = page / 4; uiBlock = page / 4;
@ -205,7 +205,7 @@ main (int argc, const char *argv[])
DBG ("Successfully opened the dump file\n"); DBG ("Successfully opened the dump file\n");
nfc_init (NULL); nfc_init (NULL);
// Try to open the NFC device // Try to open the NFC device
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);
if (pnd == NULL) { if (pnd == NULL) {
@ -215,7 +215,7 @@ main (int argc, const char *argv[])
if (nfc_initiator_init (pnd) < 0) { if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init"); nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
// Let the device only try once to find a tag // Let the device only try once to find a tag

View file

@ -1,14 +1,14 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty, Romain Tartière * Copyright (C) 2010, Romuald Conty, Romain Tartière
* Copyright (C) 2011-2012, Romuald Conty * Copyright (C) 2011-2012, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -24,7 +24,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -75,7 +75,7 @@ main (int argc, const char *argv[])
bool verbose = false; bool verbose = false;
nfc_init (NULL); nfc_init (NULL);
// Display libnfc version // Display libnfc version
acLibnfcVersion = nfc_version (); acLibnfcVersion = nfc_version ();
printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion); printf ("%s uses libnfc %s\n", argv[0], acLibnfcVersion);

View file

@ -1,12 +1,12 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2011, Romuald Conty * Copyright (C) 2011, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -22,7 +22,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -85,7 +85,7 @@ build_felica_frame(const nfc_felica_info nfi, const uint8_t command, const uint8
} }
#define CHECK 0x06 #define CHECK 0x06
static int static int
nfc_forum_tag_type3_check (nfc_device *dev, const nfc_target nt, const uint16_t block, const uint8_t block_count, uint8_t *data, size_t *data_len) nfc_forum_tag_type3_check (nfc_device *dev, const nfc_target nt, const uint16_t block, const uint8_t block_count, uint8_t *data, size_t *data_len)
{ {
uint8_t payload[1024] = { uint8_t payload[1024] = {
@ -94,7 +94,7 @@ nfc_forum_tag_type3_check (nfc_device *dev, const nfc_target nt, const uint16_t
block_count, block_count,
0x80, block, // block 0 0x80, block, // block 0
}; };
size_t payload_len = 1 + 2 + 1; size_t payload_len = 1 + 2 + 1;
for (uint8_t b = 0; b < block_count; b++) { for (uint8_t b = 0; b < block_count; b++) {
if (block < 0x100) { if (block < 0x100) {
@ -104,7 +104,7 @@ nfc_forum_tag_type3_check (nfc_device *dev, const nfc_target nt, const uint16_t
payload[payload_len++] = 0x00; payload[payload_len++] = 0x00;
payload[payload_len++] = (block + b) >> 8; payload[payload_len++] = (block + b) >> 8;
payload[payload_len++] = (block + b) & 0xff; payload[payload_len++] = (block + b) & 0xff;
} }
} }
uint8_t frame[1024]; uint8_t frame[1024];
@ -117,7 +117,7 @@ nfc_forum_tag_type3_check (nfc_device *dev, const nfc_target nt, const uint16_t
return res; return res;
} }
const int res_overhead = 1 + 1 + 8 + 2; // 1+1+8+2: LEN + CMD + NFCID2 + STATUS const int res_overhead = 1 + 1 + 8 + 2; // 1+1+8+2: LEN + CMD + NFCID2 + STATUS
if (res < res_overhead) { if (res < res_overhead) {
// Not enough data // Not enough data
return -1; return -1;
} }
@ -154,44 +154,44 @@ main(int argc, char *argv[])
(void)argv; (void)argv;
int ch; int ch;
char *ndef_output = NULL; char *ndef_output = NULL;
while ((ch = getopt (argc, argv, "ho:")) != -1) { while ((ch = getopt (argc, argv, "ho:")) != -1) {
switch (ch) { switch (ch) {
case 'h': case 'h':
print_usage(argv[0]); print_usage(argv[0]);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
break; break;
case 'o': case 'o':
ndef_output = optarg; ndef_output = optarg;
break; break;
case '?': case '?':
if (optopt == 'o') if (optopt == 'o')
fprintf (stderr, "Option -%c requires an argument.\n", optopt); fprintf (stderr, "Option -%c requires an argument.\n", optopt);
default: default:
print_usage (argv[0]); print_usage (argv[0]);
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
}
if (ndef_output == NULL) {
print_usage (argv[0]);
exit (EXIT_FAILURE);
}
FILE* message_stream = NULL;
FILE* ndef_stream = NULL;
if ((strlen (ndef_output) == 1) && (ndef_output[0] == '-')) {
message_stream = stderr;
ndef_stream = stdout;
} else {
message_stream = stdout;
ndef_stream = fopen(ndef_output, "wb");
if (!ndef_stream) {
fprintf (stderr, "Could not open file %s.\n", ndef_output);
exit (EXIT_FAILURE);
}
} }
if (ndef_output == NULL) {
print_usage (argv[0]);
exit (EXIT_FAILURE);
}
FILE* message_stream = NULL;
FILE* ndef_stream = NULL;
if ((strlen (ndef_output) == 1) && (ndef_output[0] == '-')) {
message_stream = stderr;
ndef_stream = stdout;
} else {
message_stream = stdout;
ndef_stream = fopen(ndef_output, "wb");
if (!ndef_stream) {
fprintf (stderr, "Could not open file %s.\n", ndef_output);
exit (EXIT_FAILURE);
}
}
nfc_init (NULL); nfc_init (NULL);
pnd = nfc_open (NULL, NULL); pnd = nfc_open (NULL, NULL);
@ -214,7 +214,7 @@ main(int argc, char *argv[])
if (nfc_initiator_init (pnd) < 0) { if (nfc_initiator_init (pnd) < 0) {
nfc_perror (pnd, "nfc_initiator_init"); nfc_perror (pnd, "nfc_initiator_init");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
fprintf (message_stream, "Place your NFC Forum Tag Type 3 in the field...\n"); fprintf (message_stream, "Place your NFC Forum Tag Type 3 in the field...\n");
@ -227,7 +227,7 @@ main(int argc, char *argv[])
goto error; goto error;
} }
// Check if System Code equals 0x12fc // Check if System Code equals 0x12fc
const uint8_t abtNfcForumSysCode[] = { 0x12, 0xfc }; const uint8_t abtNfcForumSysCode[] = { 0x12, 0xfc };
if (0 != memcmp (nt.nti.nfi.abtSysCode, abtNfcForumSysCode, 2)) { if (0 != memcmp (nt.nti.nfi.abtSysCode, abtNfcForumSysCode, 2)) {
// Retry with special polling // Retry with special polling
@ -237,7 +237,7 @@ main(int argc, char *argv[])
error = EXIT_FAILURE; error = EXIT_FAILURE;
goto error; goto error;
} }
// Check again if System Code equals 0x12fc // Check again if System Code equals 0x12fc
if (0 != memcmp (nt.nti.nfi.abtSysCode, abtNfcForumSysCode, 2)) { if (0 != memcmp (nt.nti.nfi.abtSysCode, abtNfcForumSysCode, 2)) {
fprintf (stderr, "Tag is not NFC Forum Tag Type 3 compliant.\n"); fprintf (stderr, "Tag is not NFC Forum Tag Type 3 compliant.\n");
error = EXIT_FAILURE; error = EXIT_FAILURE;

View file

@ -1,12 +1,12 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2010, Romuald Conty * Copyright (C) 2010, Romuald Conty
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -22,7 +22,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */
@ -192,7 +192,7 @@ main (int argc, char *argv[])
#endif #endif
nfc_init (NULL); nfc_init (NULL);
nfc_connstring connstrings[MAX_DEVICE_COUNT]; nfc_connstring connstrings[MAX_DEVICE_COUNT];
// List available devices // List available devices
size_t szFound = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT); size_t szFound = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT);
@ -277,7 +277,7 @@ main (int argc, char *argv[])
nfc_exit (NULL); nfc_exit (NULL);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
} }
if (initiator_only_mode) { if (initiator_only_mode) {
printf ("Hint: tag <---> *INITIATOR* (relay) <-FD3/FD4-> target (relay) <---> original reader\n\n"); printf ("Hint: tag <---> *INITIATOR* (relay) <-FD3/FD4-> target (relay) <---> original reader\n\n");
@ -352,7 +352,7 @@ main (int argc, char *argv[])
printf("We will emulate:\n"); printf("We will emulate:\n");
print_nfc_iso14443a_info (ntEmulatedTarget.nti.nai, false); print_nfc_iso14443a_info (ntEmulatedTarget.nti.nai, false);
// Try to open the NFC emulator device // Try to open the NFC emulator device
pndTarget = nfc_open (NULL, connstrings[0]); pndTarget = nfc_open (NULL, connstrings[0]);
if (pndTarget == NULL) { if (pndTarget == NULL) {

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty, Romain Tartière * Copyright (C) 2010, Romuald Conty, Romain Tartière
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */

View file

@ -1,13 +1,13 @@
/*- /*-
* Public platform independent Near Field Communication (NFC) library examples * Public platform independent Near Field Communication (NFC) library examples
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2010, Romuald Conty, Romain Tartière * Copyright (C) 2010, Romuald Conty, Romain Tartière
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, * 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright * 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
@ -23,7 +23,7 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Note that this license only applies on the examples, NFC library itself is under LGPL * Note that this license only applies on the examples, NFC library itself is under LGPL
* *
*/ */

View file

@ -7,7 +7,7 @@
* *
*/ */
/* /*
* $Id: usb.h 1220 2010-05-04 03:14:56Z roger.brown $ * $Id: usb.h 1220 2010-05-04 03:14:56Z roger.brown $
*/ */
@ -18,8 +18,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <windows.h> #include <windows.h>
/* /*
* 'interface' is defined somewhere in the Windows header files. This macro * 'interface' is defined somewhere in the Windows header files. This macro
* is deleted here to avoid conflicts and compile errors. * is deleted here to avoid conflicts and compile errors.
*/ */
@ -29,7 +29,7 @@
/* /*
* PATH_MAX from limits.h can't be used on Windows if the dll and * PATH_MAX from limits.h can't be used on Windows if the dll and
* import libraries are build/used by different compilers * import libraries are build/used by different compilers
*/ */
#define LIBUSB_PATH_MAX 512 #define LIBUSB_PATH_MAX 512
@ -81,7 +81,7 @@
/* ensure byte-packed structures */ /* ensure byte-packed structures */
#include <pshpack1.h> #include <pshpack1.h>
/* All standard descriptors have these 2 fields in common */ /* All standard descriptors have these 2 fields in common */
@ -339,7 +339,7 @@ extern "C" {
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size,
int timeout); int timeout);
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, int usb_control_msg(usb_dev_handle *dev, int requesttype, int request,
int value, int index, char *bytes, int size, int value, int index, char *bytes, int size,
int timeout); int timeout);
int usb_set_configuration(usb_dev_handle *dev, int configuration); int usb_set_configuration(usb_dev_handle *dev, int configuration);
int usb_claim_interface(usb_dev_handle *dev, int interface); int usb_claim_interface(usb_dev_handle *dev, int interface);
@ -365,7 +365,7 @@ extern "C" {
int usb_install_service_np(void); int usb_install_service_np(void);
void CALLBACK usb_install_service_np_rundll(HWND wnd, HINSTANCE instance, void CALLBACK usb_install_service_np_rundll(HWND wnd, HINSTANCE instance,
LPSTR cmd_line, int cmd_show); LPSTR cmd_line, int cmd_show);
#define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1 #define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1
int usb_uninstall_service_np(void); int usb_uninstall_service_np(void);
void CALLBACK usb_uninstall_service_np_rundll(HWND wnd, HINSTANCE instance, void CALLBACK usb_uninstall_service_np_rundll(HWND wnd, HINSTANCE instance,