Compare commits

...

1902 Commits

Author SHA1 Message Date
28ce753431 Document environment variables in README.md 2023-06-23 07:55:29 +00:00
80ef76fdda Fixes error libnfc.driver.acr122_usb Invalid RDR_to_PC_DataBlock frame 2023-05-27 18:12:06 +00:00
Philippe Teuwen
42de50f2b7
Merge pull request #688 from gentilkiwi/master
pn53x initiator set registers for ISO14443B-2 ST SRx
2023-02-13 21:00:49 +01:00
Benjamin DELPY
5b9ae7ee51 pn53x initiator set registers for ISO14443B-2 ST SRx
Modification to set PN53X_REG_CIU_TxAuto, PN53X_REG_CIU_CWGsP & PN53X_REG_CIU_ModGsP registers values before init.
Avoids a dummy scan in B mode before
2023-02-12 19:37:04 +01:00
Romain Tartière
3df7f25f11
Merge pull request #655 from Ujjwal0501/patch-1 2021-09-19 20:28:20 -10:00
Ujjwal Kumar
16671bd0a3
fix: Typo in configuration commands 2021-09-20 11:33:57 +05:30
Romain Tartière
6d0e8a5d9b
Merge pull request #652 from xanderio/fix-freebsd
Fix builds on FreeBSD
2021-08-14 07:25:45 -10:00
Alexander Sieg
a884a45ab1 Fix builds on FreeBSD
Without this patch the cmake config assume that every UNIX system that
is not APPLE is automatically a linux system. This however causes
problems on FreeBSD and properly on other BSD systems.

We now explicitly check if the CMAKE_SYSTEM_NAME is set to Linux.
2021-08-14 12:07:59 +02:00
Philippe Teuwen
c8185c9eca
Merge pull request #639 from rstular/fix-atqa-comparison
Fix - assignment instead of comparison (PCSC driver)
2021-08-05 09:12:47 +02:00
Philippe Teuwen
56f6bd4fbb
Merge pull request #649 from linkclau/master
Include unistd.h (required because of usleep())
2021-08-05 09:12:11 +02:00
Claudius Link
1b8c244e38 Include unistd.h (required because of usleep()) 2021-08-04 23:02:32 +02:00
Philippe Teuwen
fb290be070
Merge pull request #645 from gentilkiwi/master
Add nfc-st25b example
2021-07-10 20:05:43 +02:00
Benjamin DELPY
a9cb26b28f
Fix, lib Win32 again 2021-06-13 22:24:32 +02:00
Benjamin DELPY
c924e5e00c
Fix contrib code for Win32 example 2021-06-13 22:14:52 +02:00
Benjamin DELPY
ba14d10e79
Add utils lib dep 2021-06-13 21:49:05 +02:00
Benjamin DELPY
9a94f20050
Some cast for Windows platform build 2021-06-13 21:19:57 +02:00
Benjamin DELPY
180fbabfe1
Add nfc-st25b example
This new example allows to operate on some ISO-14443-B ST25TB* and legacy SR* cards (read, write, info)
2021-06-13 20:00:52 +02:00
Dave T
1dc9dcb664
Make README.md more helpful for newcommer, remove ref to missing INSTALL (#636) 2021-06-09 14:40:25 +02:00
rstular
1f4d2fb3d4
Fix - assignment instead of comparison (PCSC driver) 2021-05-12 18:23:53 +02:00
Ludovic Rousseau
2b5ad9ce0b
README.md: fix URL of pcsc-lite
The project moved from .alioth.debian.org to .apdu.fr
2021-01-22 13:08:21 +01:00
Philippe Teuwen
7ebf9b92d6
Merge pull request #626 from aviallon/fix-typo-pcsc
Fix typo in variable name in pcsc.c
2020-11-02 13:24:33 +01:00
Antoine Viallon
3af2e14acc
Fix typo in variable name in pcsc.c 2020-11-02 12:30:59 +01:00
Adam Laurie
b5180a6a70
Merge pull request #624 from FeitianSmartcardReader/master
Modify code to add compatibility of readers
2020-10-24 15:28:25 +01:00
Feitian Technologies
0cd314c514
Modify code to add compatibility of readers
Follow the NXP  Contactless card IC rules to be compatible with Feitian new and old R502 reader.
2020-10-20 14:29:15 +08:00
Philippe Teuwen
c3f739dea3
Merge pull request #622 from timgates42/bugfix_typo_mechanism
docs: fix simple typo, mecanism -> mechanism
2020-10-11 16:33:51 +02:00
Tim Gates
126cf9c1be
docs: fix simple typo, mecanism -> mechanism
There is a small typo in contrib/win32/libnfc/buses/uart.c, libnfc/drivers/acr122_usb.c, libnfc/drivers/acr122s.c, libnfc/drivers/arygon.c, libnfc/drivers/pn532_uart.c, libnfc/drivers/pn53x_usb.c.

Should read `mechanism` rather than `mecanism`.
2020-10-11 07:43:16 +11:00
Philippe Teuwen
d9a04a54ff document RC_FILE_TYPE 2020-07-11 15:12:57 +02:00
Philippe Teuwen
cc4311acab
Merge pull request #611 from gelotus/msvc
windows compiling with native tools and clang, macos catalina compiling, added travis ci build tests
2020-07-11 15:12:13 +02:00
Unknown
e37d24e691 Merge branch 'msvc2' into msvc 2020-07-08 13:38:46 +02:00
Unknown
1077228fbd style 2020-07-08 13:26:45 +02:00
Unknown
5c09dc180a forget to add linux clang cmake 2020-07-08 13:24:26 +02:00
Unknown
d5fcd08d41 remove unused packages 2020-07-08 13:14:13 +02:00
Unknown
f56bbabf6c easy reading condition 2020-07-08 13:06:45 +02:00
Unknown
9cece8b55d add cr 2020-07-08 13:06:03 +02:00
Unknown
7ad18a2120 some cleanings 2020-07-07 19:41:07 +02:00
WangYi
e21fab3685 Example and util compile fine. 2020-07-05 00:55:23 +02:00
WangYi
82f23c411d Make it compile under MSVC2017. 2020-07-05 00:54:54 +02:00
Adam Laurie
66d3560608
Merge pull request #609 from gelotus/fix-4k
Fix 4k - [@gelotus]
(we can re-introduce support for other card types later as long as we adhere to the principal that we don't write unless requested to)
2020-07-04 18:20:34 +01:00
Philippe Teuwen
fc51c8662b
Merge pull request #610 from iceman1001/master
chg: make version printing obey verbose flag
2020-07-01 21:48:47 +02:00
iceman1001
db081ed12d chg: make version printing obey verbose flag 2020-07-01 21:28:02 +02:00
Unknown
6fb61d3c1e error handling 2020-06-30 17:19:24 +02:00
Unknown
f2677da74c too many different clone tags, let the user to chose action
too many different clone tags, let the user to chose action
2020-06-30 16:18:47 +02:00
Unknown
0bf4cec661 remove direct write check 2020-06-30 14:52:07 +02:00
Adam Laurie
0de55961c4
Merge pull request #608 from gelotus/nfc-mfclassic
Improve support for gen2 and gen3 tags
thanks @gelotus
2020-06-28 14:20:32 +01:00
Unknown
c8fcaea8ab no need to differentiate routines 2020-06-27 16:17:15 +02:00
Unknown
6921e57fb8 correct typo 2020-06-27 13:33:04 +02:00
Unknown
01bc5693d9 another hardcode value 2020-06-26 19:08:04 +02:00
Unknown
db957aabdf adds write condition check in unlock_card() 2020-06-26 18:29:01 +02:00
Unknown
f7b9b0eafa remove unused stuff for block 0 writing 2020-06-26 13:36:18 +02:00
Unknown
709ef8381f reinit for retrieving new uid after block 0 write 2020-06-26 13:34:50 +02:00
Unknown
3c55b8746b swap 0 block write and other blocks write
when writing to gen2 and possible on gen3, it writes first block 3 wich is the trailing sector before writing to block 0, so the last write to block 0 fails because authenticate to old keyset
2020-06-26 01:50:11 +02:00
Unknown
02f0f6b290 add verbose case
add verbose case
2020-06-26 01:28:57 +02:00
Unknown
7a5e654309 hardcoded values 2020-06-25 23:56:38 +02:00
Unknown
2b21d87e8e add gen2 desc to help
add gen2 desc to help
2020-06-25 23:45:17 +02:00
Unknown
4e922e8194 sends lib log to /dev/null in posix and added option (v) to reactivate
There in an error handling and messaging inside
2020-06-25 23:32:03 +02:00
Unknown
3f4b7a037a add rewrite support for gen2 tags with W command
add rewrite support for gen2 tags with W command
2020-06-25 23:10:06 +02:00
Unknown
dd96571f88 no need to loop, only one block 2020-06-25 19:49:04 +02:00
Unknown
5a87f1f3db Splitting block 0 writing and other block writing, not needed anymore 2020-06-25 19:29:38 +02:00
Adam Laurie
7b6ff73c4b only test DirectWrite write if we need to. only write block 0 if specifically requested to. 2020-06-25 17:45:20 +02:00
Adam Laurie
e560689f60 restore original block count logic and add debuggers for block0 2020-06-25 17:44:20 +02:00
Adam Laurie
a28a537610 partial fix of nfc-mfclassic which only writes first sector of each block and not sector 1,2,3 unles 'unlocked' write - debuggers still in! 2020-06-25 17:43:19 +02:00
Philippe Teuwen
4b7791f845
Merge pull request #605 from ffontaine/master
autotools: make example build optional
2020-06-24 16:18:29 +02:00
Philippe Teuwen
1f6f75af38
Merge pull request #606 from FeitianSmartcardReader/master
Add length check when work with Feitian OEM R502
2020-06-22 11:20:50 +02:00
hongbin@ftsafe.com
435e2ffc81 Add length check to have compatible with R502
improve the code, to have compatible with OEM R502 firmware.
2020-06-22 14:33:15 +08:00
Fabrice Fontaine
874d9605aa autotools: make example build optional
This patch makes example build optional for autotools build system.

In order to keep the former behavior, example build is enabled by default.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
[Retrieved (and slightly updated to remove CMakeLists.txt) from:
https://git.buildroot.net/buildroot/tree/package/libnfc/0001-build-systems-make-example-build-optional.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-06-21 23:38:44 +02:00
Philippe Teuwen
53eccd4be4
Merge pull request #603 from FeitianSmartcardReader/master
Update pcsc.c
2020-05-27 19:15:22 +02:00
Feitian Technologies
b02f94d7da
Update pcsc.c
1. Fix bug for Mifare card, before do authentication, need to load PIN/password first
2. Fix bug when to get card ATS
2020-05-28 00:54:20 +08:00
Philippe Teuwen
f02ff51449 Prepare 1.8.0 version 2020-05-22 12:20:17 +02:00
Philippe Teuwen
5c3c468a6a Restore nfc_modulation_type order of v1.7.1 2020-05-22 12:20:17 +02:00
Ludovic Rousseau
63cf0acb0b pcsc: remove unused function pcsc_initiator_deselect_target
pcsc.c:763:12: warning: ‘pcsc_initiator_deselect_target’ defined but not used [-Wunused-function]
 static int pcsc_initiator_deselect_target(struct nfc_device *pnd)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-05-22 10:13:52 +02:00
Ludovic Rousseau
5294c0290f Fix compiler warnings: no previous prototype
Local function should be declared static.

Fix:
pcsc.c:107:1: warning: no previous prototype for ‘pcsc_get_scardcontext’ [-Wmissing-prototypes]
 pcsc_get_scardcontext(void)
 ^~~~~~~~~~~~~~~~~~~~~
pcsc.c:119:1: warning: no previous prototype for ‘pcsc_free_scardcontext’ [-Wmissing-prototypes]
 pcsc_free_scardcontext(void)
 ^~~~~~~~~~~~~~~~~~~~~~
pcsc.c:135:5: warning: no previous prototype for ‘pcsc_transmit’ [-Wmissing-prototypes]
 int pcsc_transmit(struct nfc_device *pnd, const uint8_t *tx, const size_t tx_len, uint8_t *rx, size_t *rx_len)
     ^~~~~~~~~~~~~
pcsc.c:160:5: warning: no previous prototype for ‘pcsc_get_status’ [-Wmissing-prototypes]
 int pcsc_get_status(struct nfc_device *pnd, int *target_present, uint8_t *atr, size_t *atr_len)
     ^~~~~~~~~~~~~~~
pcsc.c:178:5: warning: no previous prototype for ‘pcsc_reconnect’ [-Wmissing-prototypes]
 int pcsc_reconnect(struct nfc_device *pnd, DWORD share_mode, DWORD protocol, DWORD disposition)
     ^~~~~~~~~~~~~~
pcsc.c:194:9: warning: no previous prototype for ‘pcsc_get_icc_type’ [-Wmissing-prototypes]
 uint8_t pcsc_get_icc_type(const struct nfc_device *pnd)
         ^~~~~~~~~~~~~~~~~
pcsc.c:203:6: warning: no previous prototype for ‘is_pcsc_reader_vendor’ [-Wmissing-prototypes]
 bool is_pcsc_reader_vendor(const struct nfc_device *pnd, const char *target_vendor_name)
      ^~~~~~~~~~~~~~~~~~~~~
pcsc.c:219:5: warning: no previous prototype for ‘pcsc_get_atqa’ [-Wmissing-prototypes]
 int pcsc_get_atqa(struct nfc_device *pnd, uint8_t *atqa, size_t atqa_len)
     ^~~~~~~~~~~~~
pcsc.c:245:5: warning: no previous prototype for ‘pcsc_get_ats’ [-Wmissing-prototypes]
 int pcsc_get_ats(struct nfc_device *pnd, uint8_t *ats, size_t ats_len)
     ^~~~~~~~~~~~
[...]
2020-05-22 10:11:52 +02:00
Ludovic Rousseau
fa78e8b883 Doxygen: unset DOT_FONTNAME
Fix warning:
warning: doxygen no longer ships with the FreeSans font.
You may want to clear or change DOT_FONTNAME.
Otherwise you run the risk that the wrong font is being used for dot generated graphs.
2020-05-22 10:02:37 +02:00
Ludovic Rousseau
357ae384af Doxygen: update Doxyfile.in to version 1.8.13
Fix warnings:
warning: Tag `SYMBOL_CACHE_SIZE' at line 299 of file `./Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag `SHOW_DIRECTORIES' at line 487 of file `./Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag `HTML_ALIGN_MEMBERS' at line 823 of file `./Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag `USE_INLINE_TREES' at line 976 of file `./Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag `XML_SCHEMA' at line 1169 of file `./Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag `XML_DTD' at line 1175 of file `./Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
2020-05-22 09:58:44 +02:00
Ludovic Rousseau
c8692aa239 Fix compiler warning: no previous prototype
nfc-mfclassic.c:623:6: warning: no previous prototype for ‘is_directwrite’ [-Wmissing-prototypes]
 bool is_directwrite(void)
      ^~~~~~~~~~~~~~
2020-05-22 09:51:14 +02:00
Ludovic Rousseau
91d7c5d32f Fix compiler warning: old-style function definition
nfc-mfclassic.c:623:6: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
 bool is_directwrite()
      ^~~~~~~~~~~~~~
nfc-mfclassic.c: In function ‘is_directwrite’:
nfc-mfclassic.c:623:6: warning: old-style function definition [-Wold-style-definition]
2020-05-22 09:50:26 +02:00
Philippe Teuwen
4525cd1c32 make style 2020-05-21 15:06:17 +02:00
Philippe Teuwen
f52d04e0a7 remove warnings 2020-05-21 15:05:48 +02:00
Philippe Teuwen
5a059db901 remove warnings 2020-05-21 14:50:30 +02:00
Philippe Teuwen
730f705c0d pcsc.c: fix error and remove warnings 2020-05-21 14:42:45 +02:00
Philippe Teuwen
6b4f6249bd rework README 2020-05-21 14:27:13 +02:00
Philippe Teuwen
d29b3170d9 update changelog 2020-05-21 14:14:43 +02:00
Adam Laurie
4a2c764961 Prepare 1.7.2 version 2020-05-21 12:05:38 +01:00
Adam Laurie
020f5317a6
Merge pull request #601 from h3xx/fix-typo
Fix typo
2020-05-21 11:40:22 +01:00
Philippe Teuwen
675c30eb93
Merge pull request #600 from FeitianSmartcardReader/master
Modify pcsc.c to have support for Mifare classic and Ultralight card
2020-05-14 12:49:43 +02:00
Feitian Technologies
beb8fdd759
Update pcsc.c
Remove call pcsc_get_vendor_name, get the vendor name from struct nfc_device
2020-05-14 11:08:23 +08:00
Dan Church
6f41ea3ad3
Fix typo
Introduced in #598
2020-05-13 09:05:27 -05:00
hongbin@ftsafe.com
8352c80679 Modify pcsc.c to have support for Mifare classic and Ultralight card
Modify pcsc.c and mifare.c files.
1. add code into pcsc.c to have support Mifare classic card.
2. The PCSC reader has SW value, add response data length for PCSC
reader
2020-05-13 12:15:28 +08:00
Adam Laurie
66176016ed bring nfc-list man page up to date 2020-05-12 16:52:47 +01:00
Adam Laurie
f1bb27d1af
Merge pull request #598 from h3xx/add-check-libnfc-nci
Add check for Libnfc-NCI before enabling pn71xx
thanks @h3xx
2020-05-12 12:36:55 +01:00
Adam Laurie
c884f36b94
Merge pull request #597 from nfc-tools/iclass
Iclass from Adam
2020-05-11 20:23:24 +01:00
Dan Church
17e615e8b1
Add check for Libnfc-NCI before enabling pn71xx
If the user specifically requests the driver, throw an error if it
cannot find libnfc-nci.

Also use the value from pkg-config to determine the library name,
instead of hard-coding it.
2020-05-11 13:45:53 -05:00
Philippe Teuwen
a07d879496 rework NMT_END_ENUM 2020-05-11 20:00:04 +02:00
Philippe Teuwen
10f880374c nfc-list bitfield 2020-05-11 19:55:44 +02:00
Philippe Teuwen
96568a1023 fix nfc-list for types B 2020-05-11 19:46:46 +02:00
Adam Laurie
dcc52cd4d5 updates as per @goedox comments 2020-05-11 18:04:57 +01:00
Adam Laurie
19a51dc2bd first cut iClass support - get nfc-list to see UID 2020-05-11 11:45:28 +01:00
Adam Laurie
61e93c1cdf
Merge pull request #591 from FeitianSmartcardReader/master
Update readme and add Feitian R502 and bR500 support into pcsc driver
2020-05-05 11:27:19 +01:00
hongbin@ftsafe.com
cbc4e7b5c4 Update readme and add Feitian R502 and bR500 support into pcsc driver
1. Modify pcsc.c code, add R502 and bR500 support into PCSC driver
2. Update readme, tell user how to build with pcsc driver
3. Add FAQ for bR500 and R502 in readme
2020-04-09 11:29:11 +08:00
Adam Laurie
692038ceaf
Merge pull request #561 from jpwidera/master
Added check for USB alternate settings
2020-04-05 14:37:22 +01:00
Adam Laurie
f3f588671c
Merge pull request #559 from frankmorgner/pcsc
Added driver for contactless PC/SC readers
(tested as far as it can see my PC/SC readers but could not open - needs debugging!)
2020-04-04 19:11:56 +01:00
Adam Laurie
fbae17186b
Merge branch 'master' into pcsc 2020-04-04 18:35:27 +01:00
Adam Laurie
004eff8e96
Merge pull request #544 from kraj/kraj/musl
usbbus: Include stdint.h for uintX_t
2020-04-04 18:31:26 +01:00
Adam Laurie
7908d405dd
Merge pull request #539 from rstular/patch-2
Updated function declaration in utils/nfc-mfultralight.c
2020-04-04 18:25:39 +01:00
Adam Laurie
ff4e1efa7b
Merge branch 'master' into patch-2 2020-04-04 18:24:40 +01:00
Adam Laurie
c34c446831
Merge pull request #520 from stawiski/master
Fixed format warnings.
2020-04-04 18:16:17 +01:00
Adam Laurie
54ba7359ce
Merge branch 'master' into master 2020-04-04 18:15:56 +01:00
Adam Laurie
fba969472d
Merge pull request #469 from jgeslin/master
Adding pn71xx NXP's NFC Controllers through Linux Libnfc-nci
(note I have only tested this does not break build etc. as I do not have a reader with this chipset)
2020-04-04 18:06:13 +01:00
Adam Laurie
a85f003d91
Merge pull request #451 from hph86/3_verbose_rats_cmd
Add RATS support indicator to nfc-mfclassic
2020-04-04 17:39:46 +01:00
Adam Laurie
8a1e14901d
Merge pull request #590 from AdamLaurie/master
add debugging for high level config requests
2020-04-04 17:18:46 +01:00
Adam Laurie
2a6a8e6e29 add debugging for high level config requests 2020-04-04 15:10:02 +01:00
jpwidera
07f918283b Fixed missing whitespaces 2019-09-05 22:33:33 +02:00
jpwidera
6e035c33f3 Re-enabled claim
If there are alternative interfaces, claim interface 0. Otherwise skip this step.
2019-09-05 22:32:03 +02:00
jpwidera
a77a2a8497 Removed USB alternate setting.
Quick and dirty fix for https://github.com/nfc-tools/libnfc/issues/535
2019-09-05 21:59:46 +02:00
Frank Morgner
6f793da1c1 cleanup 2019-09-03 22:44:44 +02:00
Frank Morgner
8e7a8e1b61 cmake: fixed pcsc requirement for acr122_pcsc 2019-09-03 15:51:38 +02:00
Frank Morgner
959a992a81 added PC/SC driver to cmake 2019-09-03 15:50:28 +02:00
Frank Morgner
75e5e23c81 Added driver for contactless PC/SC readers
- only initiator mode is supported
- properties are choosen as they are available via PC/SC, the rest of
the defaults are chosen to be compatible with Mifare DESFire
- This commit allows reading Mifare DESFire via PC/SC with libfreefare
2019-09-03 14:54:13 +02:00
Philippe Teuwen
f8b28523d7
Merge pull request #554 from quantum-x/master-UL-4K-DirectWrite-OneTimeWrite
Adding extended Magic Card support
2019-08-21 19:22:24 +03:00
quantum-x
ad695d0a18
Update .travis.yml 2019-08-21 10:06:19 +02:00
Philippe Teuwen
454a8c4d70 remove libcutter from travis as it's not available anymore in the repos 2019-08-19 19:48:16 +02:00
quantum-x
fbdbe6eff3
Update nfc-mfclassic.c
Adding support for extended Magic cards:
 - DirectWrite cards
 - One Time Write cards

Direct Write cards support modification of B0 directly, without any unlock codes. When we are attempting to detect if a card is 'magic', we will attempt to modify B0 directly as an initial check.

One Time Write cards support modification of B0 directly, one time only. They do not respond to magic commands, but have a fixed UID coming out of the factory. We now detect this UID, and if so, deem the card 'magic'.
2019-08-19 19:07:18 +02:00
quantum-x
c109d37783
Update nfc-mfultralight.c
Adding support for "DirectWrite" Ultralight tags.
 - The latest generation of "Magic" Ultralight tags support DirectWrite to B0.
 - Several versions of these cards are bricked if the older 'unlock' command is issued to the card.
 - To avoid this, when detecting if a card is magic, we attempt to modify B0 directly. If this fails, we proceed with an unlock command.
2019-08-19 19:04:52 +02:00
Philippe Teuwen
141907e127
Merge pull request #549 from admo/cmake_config_h
Generate config.h into build instead source directory.
2019-07-19 14:38:47 +02:00
Adam Oleksy
48d5f6b666 Generate config.h into build instead source directory. 2019-07-19 14:34:17 +02:00
Philippe Teuwen
a4af2be66c Fix PN533 hardcoded ednpoints table 2019-07-17 22:29:09 +02:00
Khem Raj
91f7db5b4d usbbus: Include stdint.h for uintX_t
stdint.h is needed for uintX_t typedefs which are
used to replace u_intX_t in libusb API headers in the cmake files

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2019-05-20 23:50:49 -07:00
rstular
ebb13d8965
Updated function declaration in utils/nfc-mfultralight.c
Updated a function declaration in utils/nfc-mfultralight.c to match the new style of C function declarations.
2019-04-29 09:49:09 +02:00
rstular
c42e2502d4 Fixed a typo in examples/nfc-emulate-uid.1 2019-04-28 13:25:43 -10:00
Romain Tartière
c59219905c Do outsource builds on CI
This helps figurig-out missing -I more easily.
2019-02-08 07:29:42 -10:00
Romain Tartière
ae56188005 Fix outsource build with the autotools 2019-02-08 07:25:55 -10:00
Romain Tartière
a9e4c915f2 Add missing INCLUDES
CC       pn53x-tamashell.o
    pn53x-tamashell.c:48:12: fatal error: 'readline/readline.h' file not found
    #  include <readline/readline.h>
    	   ^~~~~~~~~~~~~~~~~~~~~
    1 error generated.
2019-02-05 08:16:59 -10:00
Mikolaj Stawiski
793d5adde6 Fixed format warnings. 2018-11-25 13:48:04 +11:00
Emmanuel Dreyfus
7ca85a02de Fix typos 2018-11-19 19:16:26 +01:00
Emmanuel Dreyfus
85100c0aae Prefer hardcoded PN533 descriptors to the real ones
PN533 easily corrupts its USB descriptors. We know that and we
already try to detect and even repair them.

However there are situations where lower software layers get
confused before libnfc can help. On Windows, libusb may set
dev->config to NULL, but we can also have a non NULL dev->config
referencing corrupted data.

In order to get more robust, let us replace the Windows libusb
specific (dev->config == NULL) test by an inconditionnal use of
hardcoded descriptors when they are available.
2018-11-19 19:16:26 +01:00
Romuald Conty
ddfe2e648a
Merge pull request #517 from manu0401/timeout1
Add missing timeout
2018-11-13 11:31:54 +01:00
Emmanuel Dreyfus
2418d946a3 Add missing timeout
Add a tiemout in pn53x_initiator_select_passive_target()
so that we do not get stuck forever when pn533 misses a toggle
bit change.
2018-11-12 14:46:31 +00:00
Philippe Teuwen
b5641f8562
Merge pull request #513 from Stean/master
Add undocumented option -s to nfc-relay-picc help
2018-11-07 12:19:08 +01:00
Stean
f93169feb4 Add undocumented option -s to nfc-relay-picc man page 2018-11-04 21:30:35 +01:00
Stean
c52cdb10c8 Add undocumented option -s to usage listing 2018-11-04 21:22:46 +01:00
Markus Werle
4ae4cc86f8
Merge pull request #450 from hph86/2_fix_typo
Fix typo in nfc-mfclassic
2018-10-02 12:32:45 +02:00
Markus Werle
980513f4d1
Merge pull request #506 from nfc-tools/fix-cmake-module-path
fix CMAKE_MODULE_PATH for libnfc as a submodule
2018-10-02 12:22:41 +02:00
Markus Werle
d11db46ddd
fix CMAKE_MODULE_PATH for libnfc as a submodule
This fixes #496
2018-10-02 12:14:29 +02:00
Philippe Teuwen
a9af1927e6
Merge pull request #504 from AdamLaurie/master
Fix handling of NTAG OTP and LOCK bytes
2018-09-18 16:36:13 +02:00
Adam Laurie
25ee3a2f76 Add OTP/Capability Bytes handling to NTAG 2018-09-18 11:14:08 +01:00
Adam Laurie
3ba065f00b Remove redundant EV1 types and rely on NTAG types instead 2018-09-17 21:40:48 +01:00
Adam Laurie
40b54a10d7 Fix NTAG OTP and LOCK BYTES (Dynamic LOCK also applies to MF0UL21). Fix MF0UL21 sizing issue. 2018-09-17 16:58:49 +01:00
Adam Laurie
2229b9ed69 Merge remote-tracking branch 'upstream/master' 2018-09-17 14:40:34 +01:00
Adam Laurie
4c914e67e5 Fix handling of NTAG OTP and LOCK bytes 2018-09-17 14:37:09 +01:00
Philippe Teuwen
7c9a2a8062
Merge pull request #503 from AdamLaurie/master
Add support for Ultralight NTAG213/215/216
2018-09-16 22:37:51 +02:00
Adam Laurie
62f27c1c58 Add support for Ultralight NTAG213/215/216 2018-09-15 16:19:35 +01:00
Hanno Heinrichs
7a0a469c8a add more verbosity to RATS handling 2017-09-17 21:04:33 +02:00
Hanno Heinrichs
df4f9c0fbd fix typo 2017-09-17 21:02:50 +02:00
Hanno Heinrichs
e4ca7f45d2 remove redundant blanks 2017-09-17 21:01:12 +02:00
Philippe Teuwen
216145fba5 Merge pull request #440 from rocco8620/patch-1
Wrong variable names
2017-09-03 22:10:44 +02:00
rocco8620
2b96c9f3c5 Wrong variable names
Wrong variable names (missing dots) on line 269, 270, 271
2017-09-03 21:53:17 +02:00
Romain Tartière
2869ae2eb8 Merge pull request #420 from hramrach/master
nfc-poll: print "Waiting for card removing..." before waiting for card removal
2017-07-19 15:02:43 +02:00
Michal Suchanek
f9417586c0 nfc-poll: print "Waiting for card removing..." before waiting 2017-07-14 16:19:26 +02:00
Philippe Teuwen
14f48d0122 Fix mem leak 2017-05-18 10:40:46 +02:00
Philippe Teuwen
00700bc66d Make Travis happy 2017-05-17 15:56:41 +02:00
Philippe Teuwen
dcdbff0705 New NFC modulation type NMT_BARCODE 2017-05-17 13:58:16 +02:00
Philippe Teuwen
9f1a68530a nfc-barcode: add options -r & -n 2017-05-16 14:35:58 +02:00
Philippe Teuwen
9f4290b61b Add nfc-barcode 2017-05-16 13:22:30 +02:00
Philippe Teuwen
c9ac17c9f5 Fix USB descriptors in SCL3711, NXP_PN533 and ASK LoGO also when corrupted by received data
The problem occurs in the following succession of events:

* Emit commands returning an answer larger than 16 bytes
* Re-enumerate USB devices without power cycle, e.g. a warm reboot of the PC

The bug can be reproduced for testing purposes with usbreset.c from
https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line#661

$ lsusb|grep NFC
Bus 001 Device 010: ID 04e6:5591 SCM Microsystems, Inc. SCL3711-NFC&RW
$ sudo ./usbreset /dev/bus/usb/001/010
Resetting USB device /dev/bus/usb/001/010
Reset successful
$ echo -e "4a 01 00\n423000" |pn53x-tamashell
$ sudo ./usbreset /dev/bus/usb/001/010
Resetting USB device /dev/bus/usb/001/010
Error in ioctl: No such device
$ lsusb|grep NFC
... device disappeared

In the example above, reading 4 pages of a MFUL corrupted one single byte.
The entire buffer can be corrupted e.g. with fast-reading a MFUL EV1:
$ echo -e "4a 01 00\n423a0013"|pn53x-tamashell
2017-04-20 09:06:47 +02:00
Philippe Teuwen
1bf542b9e2 cosmetic 2017-04-20 09:06:41 +02:00
Philippe Teuwen
767abe50e2 PN533: Abuse the overflow bug to restore USB descriptors in one go 2017-04-20 08:35:46 +02:00
Philippe Teuwen
38164c49ef Fix USB descriptors in SCL3711, NXP_PN533 and ASK LoGO if needed when closing device
The problem occurs in the following succession of events:

* Emit commands larger than 17 bytes
* Re-enumerate USB devices without power cycle, e.g. a warm reboot of the PC

The bug can be reproduced for testing purposes with usbreset.c from
https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line#661

$ lsusb|grep NFC
Bus 001 Device 010: ID 04e6:5591 SCM Microsystems, Inc. SCL3711-NFC&RW
$ sudo ./usbreset /dev/bus/usb/001/010
Resetting USB device /dev/bus/usb/001/010
Reset successful
$ echo 06000000000000000000000000000000000000 |pn53x-tamashell
$ sudo ./usbreset /dev/bus/usb/001/010
Resetting USB device /dev/bus/usb/001/010
Error in ioctl: No such device
$ lsusb|grep NFC
... device disappeared
2017-04-20 01:46:32 +02:00
Philippe Teuwen
c958b2c25d Enable missing USB desc workaround for NXP_PN533 too 2017-04-19 20:24:55 +02:00
Emmanuel Dreyfus
a06bfe50a5 Workaround missing USB config
After a DESfire operation SCL3711 will sometimes enter a state where
libusb-0.x is unable to fill config field in struct usb_device. The
USB device has to be power-cycled to restore a sane state.

This introduce a work around, by using hardcoded values for endpoints
and packet size when they are unavailable.
2017-04-19 19:46:14 +02:00
Philippe Teuwen
6235a8a26b Update example script to support PCard 2017-04-16 00:05:21 +02:00
Philippe Teuwen
b59f8fb3b4 Add more missing files 2017-04-04 13:31:39 +02:00
Philippe Teuwen
fead8d6849 Add missing files to autotools release process 2017-04-04 11:10:46 +02:00
Philippe Teuwen
e41a42cf96 nfc-mfultralight: avoid compilation warning 2017-04-01 01:03:41 +02:00
Philippe Teuwen
024fca9cb7 make style 2017-04-01 00:46:12 +02:00
Philippe Teuwen
3ec9ecf800 nfc-mfultralight: fix support for MF0UL21 2017-04-01 00:25:14 +02:00
Philippe Teuwen
560f6a6413 nfc-mfultralight: better parameters checks 2017-03-31 23:21:17 +02:00
Philippe Teuwen
abae2bb17b Merge remote-tracking branch 'adam/master'
* adam/master:
  allow partial writes. tidy up usage.
  vary expected dump size based on tag type
  read extra mf-ul EV1 blocks
  show EV1 auth PACK (tag/reader trust secret)
  show EV1 storage size
  add EV1 password auth to nfc-mfultralight
2017-03-31 23:00:15 +02:00
Philippe Teuwen
f2457d0559 Add pn53x-* to CMakeLists 2017-03-31 22:46:11 +02:00
Adam Laurie
a9f3e3a2ac allow partial writes. tidy up usage. 2017-03-23 18:19:59 +00:00
Adam Laurie
963eb074ec vary expected dump size based on tag type 2017-03-23 16:42:10 +00:00
Adam Laurie
c04dd91e98 read extra mf-ul EV1 blocks 2017-03-23 16:04:02 +00:00
Adam Laurie
fe04b85678 show EV1 auth PACK (tag/reader trust secret) 2017-03-23 12:03:34 +00:00
Adam Laurie
3f8bb59f1e show EV1 storage size 2017-03-23 11:05:00 +00:00
Adam Laurie
ca96e50e9b add EV1 password auth to nfc-mfultralight 2017-03-22 23:05:48 +00:00
Philippe Teuwen
32bb627108 Fix typo in drivers blacklist, thanks Godfrey Chung 2017-03-07 10:49:25 +01:00
Philippe Teuwen
86ce8dff52 Test Travis builds 2017-03-03 18:41:13 +01:00
Philippe Teuwen
b65674a8e3 Some systems (e.g. glibc < 2.17) require librt to get clock_gettime -> CMAKE 2017-03-02 23:42:36 +01:00
Philippe Teuwen
2d2a664f6c Some systems (e.g. glibc < 2.17) require librt to get clock_gettime 2017-03-02 22:03:22 +01:00
Philippe Teuwen
9ccfba2125 Update changelog & authors 2017-03-02 16:00:51 +01:00
Philippe Teuwen
787382f4d5 Merge pull request #394 from lab-401/master-4k-magic
Adding support for 4K magic cards
2017-03-02 15:01:05 +01:00
Philippe Teuwen
b7ae7cb5fd Merge remote-tracking branch 'adam/master'
* adam/master:
  Tidier fix for incorrect block write/count as per @doegox
  Fix number of blocks written. Fix number of written blocks reported.
2017-03-01 18:51:35 +01:00
Simon Yorkston
6c44c20ffc Adding support for 4K magic cards 2017-03-01 18:41:16 +01:00
Philippe Teuwen
c51caf424a nfc-mfultralight: fix failed read reporting and add failed pages count 2017-02-27 17:22:42 +01:00
Adam Laurie
e119296680 Tidier fix for incorrect block write/count as per @doegox 2017-02-19 12:42:30 +00:00
Philippe Teuwen
bf31594410 conf: close file 2017-02-18 22:20:15 +01:00
Philippe Teuwen
04ef5ca902 Reduce variables scopes 2017-02-18 22:20:15 +01:00
Philippe Teuwen
2033519b0c Add asserts to tell static analyzer we know what we're doing...
nfc.c:1244:19: warning: Dereference of undefined pointer value
  for (int i = 0; nmt[i]; i++) {
                  ^~~~~~
nfc.c:1256:23: warning: Dereference of undefined pointer value
      for (int j = 0; nbr[j]; j++) {
                      ^~~~~~
2017-02-18 18:08:27 +01:00
Philippe Teuwen
f2c264d4ae pn53x: avoid warning about uninitialized value (false positive)
pn53x.c:1746:15: warning: Function call argument is an uninitialized value
    *cycles = __pn53x_get_timer(pnd, pbtTxRaw[szTx + 1]);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-02-18 17:29:57 +01:00
Philippe Teuwen
05220537ea i2c: fix struct initialization
pn532_i2c.c:125:57: warning: missing field 'tv_nsec' initializer [-Wmissing-field-initializers]
        struct timespec transaction_start, bus_free_time = { 0 };
                                                               ^
pn532_i2c.c:153:57: warning: missing field 'tv_nsec' initializer [-Wmissing-field-initializers]
        struct timespec transaction_start, bus_free_time = { 0 };
2017-02-18 17:23:22 +01:00
Philippe Teuwen
c815c7a059 nfc-mfultralight: remove dead assignment
nfc-mfultralight.c:274:7: warning: Value stored to 'bFailure' is never read
      bFailure = false;
      ^          ~~~~~
2017-02-18 17:17:53 +01:00
Philippe Teuwen
9a749e1a66 arygon: remove unused variable
arygon.c:94:22: warning: unused variable 'arygon_error_incomplete_command' [-Wunused-const-variable]
static const uint8_t arygon_error_incomplete_command[] = "FF0C0000\x0d\x0a";
                     ^
2017-02-18 17:17:33 +01:00
Philippe Teuwen
e4df2f3334 astyle 2017-02-18 13:05:59 +01:00
Philippe Teuwen
f184407cc5 Makefile: fix option for recent astyle 2017-02-18 13:05:45 +01:00
Philippe Teuwen
e8d44f1ee8 typo 2017-02-18 13:05:02 +01:00
Philippe Teuwen
4e4438435d Update README about pn533_usb 2017-02-18 01:59:27 +01:00
Philippe Teuwen
02c06c8e28 Update ChangeLog 2017-02-18 01:51:59 +01:00
Philippe Teuwen
047379406e Merge pull request #392 from jaasuarezvi/patch-1
Update README.md
2017-02-18 00:15:01 +01:00
Philippe Teuwen
be1b897617 Merge pull request #308 from AxisRay/master
Bugfix:function setenv() and unsetenv() are invalid on windows AND no variable prefix set for WIN32 in CMakeLists
2017-02-17 12:24:38 +01:00
Philippe Teuwen
15c31aecdb Merge pull request #362 from snowy13/master
Raspberry Pi 3 Conf Sample
2017-02-17 12:15:48 +01:00
Philippe Teuwen
ff37cdb2be Replace deprecated readdir_r by readdir
This reverts 262555d5, 7fb53873 and a0b859b2
2017-02-17 12:10:33 +01:00
Philippe Teuwen
99a7d9aa35 Merge pull request #387 from ChristophGr/master
allow to cross-compile 32 and 64 bit versions of the library for windows
2017-02-17 11:45:55 +01:00
Philippe Teuwen
c5e8adc169 mfclassic: avoid hardcoded offsets & sizes 2017-02-17 11:31:13 +01:00
Philippe Teuwen
646ab57ace fix typo 2017-02-17 10:31:25 +01:00
Philippe Teuwen
db4433f116 CMake: set policy CMP0045 2017-02-17 10:28:53 +01:00
Philippe Teuwen
7e3a7a6d05 Merge pull request #366 from oliv3r/master
Improve logging and allow building of debian packages
2017-02-17 10:15:27 +01:00
Philippe Teuwen
732a282190 Merge branch 'master' into master 2017-02-17 10:15:04 +01:00
Philippe Teuwen
d808802b16 typos 2017-02-17 10:11:34 +01:00
Philippe Teuwen
b86b7efb10 Fix number of blocks written
A strange move changed the way written pages are bound in commit ed62b01a.
As a result the last 3 blocks weren't written anymore.
2017-02-17 09:56:35 +01:00
Philippe Teuwen
11bcf05a75 Fix typo. Fix issue #377 2017-02-16 23:12:38 +01:00
Emmanuel Dreyfus
e26fe912fd NetBSD serial ports 2017-02-16 23:08:41 +01:00
Emmanuel Dreyfus
20a1b978f3 NetBSD definition for CCID ioctl 2017-02-16 23:08:36 +01:00
Philippe Teuwen
968f59a988 Remove unneeded test, fix issue #376 2017-02-16 23:05:02 +01:00
Philippe Teuwen
e50b18848f Remove spurious mirror_uint8_ts declaration, fix issue #375 2017-02-16 23:00:37 +01:00
Philippe Teuwen
372bf37eec Blacklist pn533_usb to fix issue #391 2017-02-16 22:32:16 +01:00
Philippe Teuwen
295c70911a Restrict MFC Mini detection according to AN10833 2017-02-16 22:31:10 +01:00
Philippe Teuwen
f16aeda9d0 Merge pull request #380 from llorephie/patch-2
Update README.md
2017-02-16 22:21:21 +01:00
Jairo Andres Suarez
7991c7d60c Update README.md 2017-02-14 18:47:27 -05:00
Adam Laurie
84c3e8a3ba Fix number of blocks written. Fix number of written blocks reported. 2017-01-30 21:47:06 +00:00
Christoph Gritschenberger
11a2da2811 allow to cross-compile 32 and 64 bit versions of the library for windows 2017-01-25 18:44:44 +01:00
jgeslin
f9f03fa7fa Debug dedicated implementation removed 2017-01-12 09:53:40 +01:00
Romuald Conty
8e5ec4acf3 Merge pull request #383 from centromere/patch-2
Fix typo in nfc.c
2016-12-11 16:46:36 +01:00
Romuald Conty
e0c72b782f Merge pull request #382 from centromere/patch-1
Fix typo in nfc.h
2016-12-11 16:46:04 +01:00
Romuald Conty
3592a60c1d Merge pull request #381 from llorephie/patch-1
Update Makefile.am
2016-12-11 16:45:22 +01:00
John Galt
9c7b9eda8c Fix typo in nfc.c 2016-12-07 07:22:27 -05:00
John Galt
b38597f1e0 Fix typo in nfc.h 2016-12-07 06:17:04 -05:00
Romuald Conty
e9a750fc00 Merge pull request #379 from oliv3r/Errata_on_i2c_timing
drivers: pn532_i2c: Errata on i2c timing
2016-12-06 17:58:30 +01:00
Maxim Martyanov
e32cc068ec Update README.md
README-Windows.txt => README-Windows.md
2016-12-06 20:44:31 +04:00
Maxim Martyanov
b29332a309 Update Makefile.am
README-Windows.txt -> README-Windows.md
2016-12-06 20:43:08 +04:00
Olliver Schinagl
e946f7a97a drivers: pn532_i2c: Errata on i2c timing
The datasheet is wrong for the pn532_i2c. After having constant issues
with the device failing to respond on the bus and after contacting NXP
about this, it turns out 1.3 ms is too tight. The official timing spec
is unknown for now, but we tested 4 and 5 ms without problems. Thus we
have choosen 5 ms as a safe delay.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-12-06 11:40:56 +01:00
Romuald Conty
b2a9cce037 Merge pull request #367 from oliv3r/respect_pn532_i2c_timing
Respect pn532 i2c timing
2016-12-05 22:12:52 +01:00
Romuald Conty
c3b3f64224 Merge pull request #372 from timzi/fix-cmakelists
Fixed file name "README" in cmakelists.txt
2016-12-05 22:10:33 +01:00
Romuald Conty
a07a496234 Merge pull request #378 from BourgeoisLab/patch-1
Match nfc.h
2016-12-05 19:50:49 +01:00
Frédéric Bourgeois
65477eea5e Match nfc.h
Synchronized with nfc.h with all API functions
2016-12-05 13:11:45 +01:00
timzi
a625d6a02d Fixed file name "README" in cmakelists.txt 2016-11-20 20:32:25 +03:00
Olliver Schinagl
d960673681 drivers: pn532_i2c: Add retry on error mechanism
Currently, we very occasionally can EXNIO errors from pn532_i2c_write() ->
i2c_write() -> write(). This may happen about once every 30 seconds.
Based from the kernel sources, EXNIO happens if the chip no longer
responds to its own address.

To make sure we do not loose any sent packets, we retry to send
PN532_SEND_RETRIES number of times. Since we miss 1 every 30 or so
seconds, doing 1 retry should be fine.

This might be considered a hack as the failure may be some other timing
related issue.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-10-24 13:05:42 +02:00
Olliver Schinagl
8f8f780c2b drivers: pn532_i2c: Respect proper timing specifications
The pn532 user manual states that after a i2c stop condition and before a i2c
start condition there should be a delay of minimally 1.3 milliseconds.
This is probably a limitation of the i2c peripheral or the firmware. In
any case, each i2c_read and i2c_write creates the packets which are
complemented with start/stop markers. It is thus required to take care
of timing in these two functions.

We solve this by wrapping the lower i2c_read and i2c_write functions for
the pn532, as this requirement is not for all chips.

Currently, we keep time using local variable, and thus the code is not
thread-safe. With libnfc being single threaded and only one instances of
libnfc can open a bus anyway, this is not yet a problem.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-10-24 12:02:58 +02:00
Olliver Schinagl
b953002f8f drivers: pn532_i2c: Clarify preamble and start byte
The pn532 documentation differs slightly from the included ascii art
documentation on how a packet looks like. The preamble was omitted
however the postamble is mentioned. This patch adds the Preamble to the
ascii frame documentation.

The code later refers incorrectly to the start byte as the preamble.
This variable was renamed to more descriptively state that it is the
preambe and the start bytes.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-10-24 12:00:36 +02:00
Olliver Schinagl
512be89700 busses: i2c: improve logging
Currently we only inform the user with the error logging mechanism that
we received a different number of bytes than expected.

Thus in case of an error, we say that we sent/received -1 bytes. However
-1 indicates an error and errno is set to indicate the error state.

This patch extends the logging to also print the actual error.

Additionally the same debugging printing was added to read, which is now
silently returned to the caller.

Signed-off-by: Olliver Schinagl <o.schinagl@ultimaker.com>
2016-10-21 14:20:51 +02:00
Olliver Schinagl
61b42396d9 CMake: allow building of debian packages
This patch allows for using the CMakefile to generate debian packages.
While CPack is far from perfect for generating debian packages, it is a
minimal change and quite helpful for quick deployment on debian based
systems.

Signed-off-by: Olliver Schinagl <o.schinagl@ultimaker.com>
2016-10-21 14:20:51 +02:00
Jeremy
4a10d0f21b Cosmetics changes 2016-10-10 17:36:55 +02:00
Jeremy
7eae55e929 Adding pn71xx NXP's NFC Controllers through Linux Libnfc-nci 2016-10-06 17:40:48 +02:00
Jim Anastassiou
0d3d5c13ff Add R-Pi 3 conf sample.
There have been changes to the Raspberry Pi 3's usage of serial ports with the addition of a Bluetooth LE module.
This configuration uses the mini UART without disabling any devices except for the linux serial console.
2016-08-19 19:22:06 -04:00
Jim Anastassiou
27ed3acc1a Update pn532_uart_on_rpi_3.conf.sample 2016-08-19 18:38:19 -04:00
Jim Anastassiou
35cc69dffb Rename pn532_uart_on_rpi3.conf.sample to pn532_uart_on_rpi_3.conf.sample 2016-08-19 18:37:04 -04:00
Jim Anastassiou
4076046a66 Create pn532_uart_on_rpi3.conf.sample 2016-08-19 18:36:48 -04:00
Romuald Conty
659f5f407f Merge pull request #357 from yerzhanm/patch-1
added support for ACR1222U-C1
2016-06-24 02:49:29 +02:00
yerzhanm
41d694013c added support for ACR1222U-C1
added ACR1222U-C1 ACS ACR1222 1SAM PICC Reader in supported devices
2016-06-23 18:20:39 +06:00
Romuald Conty
403650a0fc Merge pull request #350 from oliv3r/master
Allow mfultralight and mfc tools to work also with specific UID's
2016-05-15 11:48:39 +02:00
Olliver Schinagl
a4bc1b9f6c nfc-mfultralight: also set failure state on uid write error
Currently, we return false, and after turning set the bFailure state.
This is of course not possible.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-05-13 14:44:07 +02:00
Olliver Schinagl
ed62b01a0f nfc-mfultralight: write uiBlocks, as we read
We use a variable, uiBlocks, to determine how many blocks to read/write.
Reading is actually done via a hardcoded 0xF value however.

Additionally, make uiblocks a const, as we use it as a constant and
change the page variable to uint32_t for consistency sake.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-05-13 14:44:07 +02:00
Olliver Schinagl
4b8871fd8f nfc-mfultralight: Remove whitespaces
Clean up some stray unintended whitespaces. This patch does not
introduce any binary changes.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-05-11 09:38:39 +02:00
Olliver Schinagl
ecd0e59b5c nfc-mfultralight: Add option to specify UID
When several tags are in range, nfc-mfultralight uses the lowest ID it
finds by default. This patch adds some code from nfc-list that lists the
tags in range whenever an operation is performed (r/w). Further more it
adds the --with-uid <UID> option to force reading/writing of a specific
tag.

The UID can be up to 10 bytes long and can be optionally separated by
colons or hyphens (MAC address style).

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-05-11 09:38:39 +02:00
Olliver Schinagl
7b1ff70a52 nfc-mfultralight: Show help when no arguments are supplied
For some reason, 0cece94778 changed the argc count check to only show
the help if argc is 0. Obviously, argc is never zero, as the first
argument in argv is always the binary itself. Revert that and show usage
if there is no arguments supplied to the binary.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-05-11 09:38:39 +02:00
Olliver Schinagl
e1a25a8203 nfc-mfclassic: Add option to specify key
The nfc-mfclassic utility will pick a seemingly random (the libnfc
default which seems to be the lowest UID). With the new (u|U) options
it is now possible to force a UID and thus write a specific tag, which
can be very useful if there are more then one tag visible.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-05-11 09:38:39 +02:00
Olliver Schinagl
898f3a4d2f nfc-mfclassic: check argc < 4 only once
Currently the check on argc is done twice, once in each if branch. This
is silly and we can just check once and fail right away.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-05-11 09:38:39 +02:00
Romuald Conty
83b70d6326 Merge pull request #349 from frankmorgner/foreign
tell Automake that we will not follow GNU Standards
2016-05-03 11:15:47 +02:00
Frank Morgner
7d4352dc98 tell Automake that we will not follow GNU Standards
NEWS and README are mandatory for autoconf. Fixes problem introduced in
b1a81b385ddabb704b4cea64fda56abb9928c3c3

closes https://github.com/nfc-tools/libnfc/pull/346
fixes https://github.com/nfc-tools/libnfc/issues/347
2016-05-03 10:53:55 +02:00
Romuald Conty
e23f8a9f9c Merge pull request #345 from quantum-x/ultralight-gen-2
Adding support for UL Gen 2 Badges
2016-04-09 11:25:11 +02:00
Simon Yorkston
e37de54e18 Updated to remove bugs
- For cards that aren’t magic, system will refuse to attempt writing
to block 0  / 1

 - Tested on Gen 1 & Gen 2 cards:

Gen 1
$ ./nfc-mfultralight w ul-test.dmp --full
NFC device: SCM Micro / SCL3711-NFC&RW opened
Found MIFARE Ultralight card with UID: 044e075ad42184
Writing 16 pages |................|
Done, 16 of 16 pages written (0 pages skipped).

Gen 2
$ ./nfc-mfultralight w ul-test.dmp --full
NFC device: SCM Micro / SCL3711-NFC&RW opened
Found MIFARE Ultralight card with UID: 044e075ad42184
Writing 16 pages |................|
Done, 16 of 16 pages written (0 pages skipped).

Non-magic
$ ./nfc-mfultralight w ul-test.dmp --full
NFC device: SCM Micro / SCL3711-NFC&RW opened
Found MIFARE Ultralight card with UID: 044e075ad42184
Writing 16 pages |
Unable to unlock card - are you sure the card is magic?
$
2016-04-09 03:42:01 +10:00
Romuald Conty
e8e1826eeb Merge pull request #344 from hiddewie/markdown2
Actual Markdown for the README and HACKING files
2016-04-08 18:53:05 +02:00
Simon Yorkston
8de7ce3899 Adding support for UL Gen 2 Badges 2016-04-09 01:32:14 +10:00
Hidde Wieringa
1f68888020
Added Markdown to HACKING file 2016-04-08 11:02:40 +02:00
Hidde Wieringa
291f70edee
Updated README-Windows for Markdown 2016-04-08 10:56:12 +02:00
Hidde Wieringa
62159a33ef
Added more Markdown formatting to README 2016-04-08 10:52:25 +02:00
Romuald Conty
d63e624b09 Merge pull request #341 from hiddewie/markdown
Changed a few README Markdown files to the .md extension so GitHub interprets it as Markdown
2016-04-07 20:09:46 +02:00
Hidde Wieringa
b1a81b385d
Changed a few README Markdown files to the .md extension so GitHub
interprets it as Markdown
2016-04-07 13:52:12 +02:00
Romuald Conty
bc8bb8de89 Merge pull request #315 from xantares/travis
Add travis config file
2016-03-19 12:44:59 +01:00
Romuald Conty
c228396c2d Merge pull request #337 from surr/typo
Fix improper pnd->name initialization
2016-03-19 12:43:32 +01:00
Alexander Inyukhin
10398b6bd9 А typo leads to improper pnd->name initialization
A for loop condition is always false so pnd->name
is not initialized. This results in garbage when
printing device name.
2016-03-19 08:08:38 +03:00
Romuald Conty
24979c65cc Merge pull request #327 from paulmenzel/fix-typo-in-readme
README: Fix typo in *is a registered*
2015-12-04 14:12:42 +01:00
Paul Menzel
c7f386dbcf README: Fix typo in *is a registered* 2015-12-04 13:59:59 +01:00
Romuald Conty
42d455c4e7 Merge pull request #325 from quantum-x/master
Extends nfc-mfultralight functionality (Magic cards, unattended mode)
2015-11-19 00:02:04 +01:00
Simon Yorkston
619b476028 Cleaned non-magic exit 2015-11-18 23:11:59 +01:00
Simon Yorkston
0cece94778 Adds --check-magic flag to nfc-mfultralight 2015-11-18 23:03:36 +01:00
Simon Yorkston
3aa2d46588 Added automatic mode to nfc-mfultralight 2015-11-18 08:56:48 +01:00
Romuald Conty
73c2ef8582 Merge pull request #323 from bhack/SCL3712
Add SCM_SCL3712 support
2015-11-04 20:34:21 +01:00
bhack
1d4720671e Add SCM_SCL3712 support 2015-11-04 20:15:56 +01:00
Romuald Conty
2046fb9461 Merge pull request #322 from quantum-x/quantum-x-unlockbehavior
Unlock read/write magic card fallback
2015-11-04 02:03:02 +01:00
quantum-x
758cb0cc05 Update nfc-mfclassic.c 2015-11-03 18:52:39 +01:00
quantum-x
c71d7267ac Update nfc-mfclassic.c
Tweaking back the unlocked_read / write_block_zero after magic2 card discovered
2015-11-03 18:48:22 +01:00
quantum-x
20f22b97e7 Updating nesting typo 2015-11-03 18:39:03 +01:00
quantum-x
b5684c1755 Removing typo
Removing typo
2015-11-03 18:33:53 +01:00
quantum-x
87c6053d6f Updating nfc-mfclassic.c
Modifying behavior relating to magic cards.
If a user has a 'magic2' card (IE, direct-write, not a 'fully magic' card) - we'll warn them that they don't need to use the W / R modes, and then proceed with the unlock operation, instead of exiting.
2015-11-03 18:11:51 +01:00
xantares
e7feb6587d Add travis config file 2015-09-01 09:33:06 +02:00
Romuald Conty
48c271e49d Merge pull request #314 from xantares/patch-3
CMake: use options() to disable examples and utils
2015-09-01 09:13:45 +02:00
Romuald Conty
53edc32a21 Merge pull request #313 from xantares/patch-2
CMake: use options() function
2015-09-01 09:13:13 +02:00
Romuald Conty
4193bb4873 Merge pull request #312 from xantares/patch-1
set default cmake build type
2015-09-01 09:12:43 +02:00
xantares
b7f620fdab options to disable samples 2015-09-01 08:58:35 +02:00
xantares
141e99959e use options 2015-09-01 08:57:11 +02:00
xantares
5d2052e77f set default cmake build type 2015-09-01 08:55:53 +02:00
Romuald Conty
555f9ce4cf Fixes #286: udev rule was executed to early 2015-08-19 11:50:52 +02:00
Romuald Conty
792e3d9cbd Do not include extra header in nfc.h
Fixes #310
2015-08-19 11:47:22 +02:00
Romuald Conty
13fee61e87 Fix typo
Closes #309
2015-08-19 11:44:23 +02:00
Ray Lee
09ce2233ce Bugfix:Set variable "prefix" for WIN32 2015-08-16 18:22:15 +08:00
Ray Lee
e72fe468a4 Bugfix:function setenv()and unsetenv()
The original setenv() and unsetenv() function is invalid,I have rewrited to fix.
2015-08-16 16:34:35 +08:00
Romuald Conty
738970c135 Merge pull request #304 from xaqq/drop_pcre
Drop PCRE dependency.
2015-08-04 10:14:01 +02:00
Romuald Conty
c55bbec50d Merge pull request #306 from Mincka/master
Fix nfc-poll card removing check
2015-08-03 17:43:54 +02:00
Julien Ehrhart
7ae5a0c333 Fix nfc-poll card removing check (should be done only if a target has been found). 2015-08-02 16:16:19 +00:00
xaqq
17ed36a7a5 Drop PCRE dependency.
The config file is now manually parsed instead of using regex.
While this is less beautifull, it allows us to drop PCRE
as a dependency on Windows.
2015-07-22 15:47:36 +02:00
Romuald Conty
6be73720fa Merge pull request #301 from xantares/patch-1
CMake: fix drivers include
2015-06-23 06:43:26 +02:00
xantares
59f6c5de54 fix drivers include
```
cc1: warning: /home/xantares/projects/libnfc/drivers: No such file or directory [-Wmissing-include-dirs]
```
2015-06-22 20:47:04 +02:00
Philippe Teuwen
49dde9c28c Merge branch 'nfc_get_supported_baud_rate_proposal'
* nfc_get_supported_baud_rate_proposal:
  nfc_get_supported_baud_rate() proposal to reverse API
2015-06-18 22:07:09 +02:00
Romuald Conty
7f23f1f84d Merge pull request #297 from mativait/master
export iso14443b* symbols
2015-06-09 14:39:07 +02:00
Philippe Teuwen
04a51df796 nfc_get_supported_baud_rate() proposal to reverse API
cf issue #298
nfc_get_supported_baud_rate() would be the one for "initiator mode"
and we add nfc_get_supported_baud_rate_target_mode()
2015-06-08 11:34:16 +02:00
Mati Vait
68094b4f6d export iso14443b* symbol 2015-05-27 23:01:48 +03:00
Romuald Conty
fecc19de4c Merge pull request #296 from cyberbobs/master
Fix nfc_initiator_poll_target without tag on PN532
2015-05-26 11:17:28 +02:00
Boris Moiseev
11a4e3cd7f Fix nfc_initiator_poll_target without tag on PN532
When there is no tag on PN532 reader, the library
incorrectly processed call result and returned
NFC_ECHIP (chip error) instead of 0 (no targets
found).
2015-05-25 17:22:25 +03:00
Romuald Conty
af8fe86b0d Git: ignore generated files 2015-05-18 20:43:32 +02:00
Romuald Conty
d028bc725d Fix comparison when nfc_initiator_target_is_present() with a specified target 2015-05-18 20:43:10 +02:00
Romuald Conty
22078a8509 Documentation: fix str_nfc_target() explanation 2015-05-18 20:08:33 +02:00
xantares
ef74d81a8b Added config files 2015-04-30 15:34:08 +02:00
Dario Carluccio
e96061e44b nfc-mfsetuid: allow to write complete Block0, instead of only UID
Fixes #282
2015-04-30 14:45:05 +02:00
Romuald Conty
33ce39ff71 nfc-relay-picc: fix wrong open mode for file descriptor
Fixes #280
2015-04-30 14:33:59 +02:00
Romuald Conty
8fbedb87f5 Update links from googlecode to github. 2015-04-30 14:19:03 +02:00
Romuald Conty
c31f8bd9be Doc: minor documentation fixes 2015-04-28 19:22:16 +02:00
Romuald Conty
0f77565a3c Fix cmake soversion (doesn't match autotools)
Thanks to Julien Schueller
2015-04-15 17:19:42 +02:00
Romuald Conty
1fe7c00e48 Git: ignore utils/nfc-jewel 2015-04-15 17:13:54 +02:00
Romuald Conty
fce491c829 README: add a section to help to configure libnfc 2015-04-15 17:11:11 +02:00
Romuald Conty
f82aa75072 Merge remote-tracking branch 'socram8888/cygfix' 2015-04-14 17:16:20 +02:00
Romuald Conty
eeb226aceb Merge pull request #290 from neffs/master
Use more serial devices on Mac OS X
2015-04-07 11:01:07 +02:00
David Kreitschmann
1785ac14c2 Use more serial devices on Mac OS X
Some USB-serial adapters just use tty.usbserial or tty.usbmodem as a
device name. (e.g.
Prolific).  Currently part of a patch for homebrew here:
https://github.com/Homebrew/homebrew/blob/master/Library/Formula/libnfc.
rb
2015-04-04 22:37:03 +02:00
Marcos Vives Del Sol
4e823d8db0 Use TIOCINQ instead of FIONREAD in Cygwin 2015-02-22 20:41:59 +01:00
Marcos Vives Del Sol
92c5bd864b Added Windows-specific files to .gitignore 2015-02-22 13:29:07 +01:00
Marcos Vives Del Sol
5a08fcf2bc Fix "undefined reference"s 2015-02-22 13:27:13 +01:00
Marcos Vives Del Sol
9d82d598f0 Fix "missing return" compiler warnings 2015-02-21 23:04:06 +01:00
Marcos Vives Del Sol
b6a8745838 Fix compilation under Cygwin 2015-02-21 22:57:36 +01:00
Adam Laurie
b978c45a11 tolerate errors when writing as well as reading 2014-05-25 16:39:47 +01:00
Philippe Teuwen
bb9babbeda Fix out-of-bounds access in nfc-mfultralight unveiled by coverity scan:
*** CID 1090333:  Out-of-bounds access  (OVERRUN)
2014-04-14 23:29:18 +02:00
Philippe Teuwen
bd92f74a58 Update ChangeLog 2014-03-12 00:38:46 +01:00
Philippe Teuwen
9a254712b5 nfc_initiator_select_passive_target(): validate modulation and baud rate 2014-03-12 00:28:39 +01:00
Philippe Teuwen
e57dc8a746 Better list of supported modulations & baud rates
* Extend supported baud rates for TypeA
* Extend supported modulations B->BI,B2SR,B2CT
* Use InPSL only on TypeA
* Add mode to nfc_get_supported_baud_rate() (API change!)
* Fix supported baud rates for BI,B2SR,B2CT
* Remove supported modulations as target for ASK LoGO

Before:

$ nfc-scan-device -v
3 NFC device(s) found:
- ACS / ACR122U PICC Interface:
    acr122_usb:002:024
chip: PN532 v1.4
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- SCM Micro / SCL3711-NFC&RW:
    pn53x_usb:002:028
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- ASK / LoGO:
    pn53x_usb:002:023
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)

After:

$ nfc-scan-device -v
3 NFC device(s) found:
- ACS / ACR122U PICC Interface:
    acr122_usb:002:024
chip: PN532 v1.4
initator mode modulations: ISO/IEC 14443A (424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (106 kbps), ISO/IEC 14443-4B' (106 kbps), ISO/IEC 14443-2B ST SRx (106 kbps), ISO/IEC 14443-2B ASK CTx (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- SCM Micro / SCL3711-NFC&RW:
    pn53x_usb:002:025
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (847 kbps, 424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), ISO/IEC 14443-4B' (106 kbps), ISO/IEC 14443-2B ST SRx (106 kbps), ISO/IEC 14443-2B ASK CTx (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- ASK / LoGO:
    pn53x_usb:002:023
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (847 kbps, 424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), ISO/IEC 14443-4B' (106 kbps), ISO/IEC 14443-2B ST SRx (106 kbps), ISO/IEC 14443-2B ASK CTx (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations:
2014-03-12 00:00:08 +01:00
Philippe Teuwen
89fc6a723e make style 2014-03-11 00:25:33 +01:00
Philippe Teuwen
ddde2dd8f2 initiator_select_passive_target(): now supports all speeds for ISO14443-4A tags 2014-03-11 00:13:26 +01:00
Philippe Teuwen
108de27c1b Fix typo baud<>bauds thanks to Polluks 2014-03-05 17:48:55 +01:00
Philippe Teuwen
6b74323369 target_is_present(): remove unreachable code 2014-03-04 01:47:42 +01:00
Philippe Teuwen
6ab3c368b8 nfc-emulate-uid: remove unreachable code and add proper cleaning when interrupted 2014-03-04 01:41:01 +01:00
Philippe Teuwen
db4fae9c2c Remove unreachable statements
As seen with clang -Wunreachable-code
2014-03-04 01:39:12 +01:00
Philippe Teuwen
7adad098c3 Document -Wunreachable-code in HACKING file 2014-03-04 01:38:44 +01:00
Romuald Conty
2d4543673e Prepare 1.7.1 version 2014-02-24 15:57:13 +01:00
Romuald Conty
101245a4a6 NEWS: add API changes for upcomming 1.7.1 2014-02-24 15:55:41 +01:00
Romuald Conty
78b827aa33 Bump library revision
According to https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
2014-02-24 15:50:49 +01:00
Philippe Teuwen
c0b9db6860 Update ChangeLog & AUTHORS 2014-02-18 15:40:22 +01:00
Philippe Teuwen
a7649da2b0 nfc-read-forum-tag3: add -q and document -o - 2014-02-18 00:22:24 +01:00
Philippe Teuwen
2aa4b99b7b nfc-read-forum-tag3: full parsing of NDEF Attribute Block 2014-02-17 23:57:59 +01:00
Pim 't Hart
73c84c214d nfc-read-forum-tag3: fix incomplete NDEF retrieval and size of output file 2014-02-17 23:09:15 +01:00
Philippe Teuwen
491db20d54 nfc-jewel: remove extraneous parentheses to silence warning 2014-02-11 23:23:42 +01:00
Philippe Teuwen
415ad7cbac nfc_initiator_select_passive_target() accepts NULL pbtInitData and provides default values 2014-02-10 01:09:07 +01:00
Philippe Teuwen
fd30e63b80 nfc_initiator_target_is_present(): Fixes issue #267, second attempt 2014-02-10 00:01:34 +01:00
Philippe Teuwen
766ed55c79 nfc-jewel: fix out-of-bounds array access
Defect(s) Reported-by: Coverity Scan
** CID 1169884:  Out-of-bounds read  (OVERRUN)
/utils/nfc-jewel.c: 186 in write_card()
2014-02-07 23:09:40 +01:00
Philippe Teuwen
2d584baa9b Update ChangeLog 2014-02-07 14:39:44 +01:00
Philippe Teuwen
85bef73734 nfc_initiator_target_is_present(): Fixes issue #267
Fixes some -4A cards removal on PN533
but fixes also same -4A cards on PN532
2014-02-07 14:00:57 +01:00
Philippe Teuwen
1f5e14f862 cppcheck on pn53x.c: Array 'apttTargetTypes' is filled incompletely 2014-02-07 01:29:42 +01:00
Philippe Teuwen
a38279793a cppcheck on nfc-pool: Variable 'res' is assigned a value that is never used 2014-02-07 01:22:27 +01:00
Philippe Teuwen
1e4fe3bd27 nfc_initiator_target_is_present(): Support B2 ST SRx 2014-02-07 01:11:19 +01:00
Philippe Teuwen
9fd11d331b nfc_initiator_target_is_present(): Support B2 ASK CT 2014-02-07 00:53:35 +01:00
Philippe Teuwen
a3a7111210 nfc_initiator_target_is_present(): Support B' 2014-02-07 00:31:31 +01:00
Philippe Teuwen
7254e1b2ea nfc_initiator_target_is_present(): Support Jewel 2014-02-03 00:24:23 +01:00
Pim 't Hart
ef81f06344 Adding nfc-jewel util 2014-02-03 00:04:08 +01:00
Philippe Teuwen
827d9792dd Save & restore NP_INFINITE_SELECT status when changing it internally 2014-02-01 02:45:17 +01:00
Philippe Teuwen
69c4d0768a nfc_initiator_select_passive_target(): grant NP_INFINITE_SELECT also for ISO14443B* 2014-02-01 02:45:17 +01:00
Philippe Teuwen
510228b6e0 nfc_initiator_select_passive_target(): save current target info even if pnt=NULL 2014-02-01 02:45:16 +01:00
Philippe Teuwen
e11c5254af nfc_initiator_select_passive_target(): save current target info also for ISO14443B* 2014-01-31 23:53:29 +01:00
Philippe Teuwen
81e1dd715d nfc_initiator_target_is_present(): Fix error type in case no target is selected yet 2014-01-31 23:19:04 +01:00
Philippe Teuwen
71eda315c7 nfc_initiator_target_is_present(): Fix MFC support on PN532 2014-01-31 22:33:05 +01:00
Philippe Teuwen
7d41ed34a3 *_is_present(): more robust detection of tag gone 2014-01-30 18:30:45 +01:00
Philippe Teuwen
9a84bb0ba0 Split pn53x_initiator_target_is_present() for readability 2014-01-30 18:10:30 +01:00
Philippe Teuwen
62e78ab582 nfc_initiator_target_is_present(): support -4B on PN532 2014-01-30 12:55:51 +01:00
Philippe Teuwen
d6330a55d0 nfc_initiator_target_is_present(): better error handling 2014-01-30 11:37:37 +01:00
Philippe Teuwen
05579fde09 nfc_initiator_target_is_present(): better Felica support 2014-01-30 11:19:02 +01:00
Romuald Conty
70f5c23486 Git: ignore generated examples/doc/.deps directory 2014-01-30 11:11:54 +01:00
Romuald Conty
5fe3fbdb5d Fix nfc_target_is_present() when removing a ISO14443-4A target from a PN532-based device 2014-01-30 11:10:18 +01:00
Philippe Teuwen
d893e4398c nfc_initiator_target_is_present(): fix ISO14443B-4 support 2014-01-30 00:32:21 +01:00
Philippe Teuwen
ade71ee8a6 nfc_initiator_target_is_present(): reuse iso14443_cascade_uid() 2014-01-30 00:24:06 +01:00
Philippe Teuwen
095f945224 nfc_initiator_target_is_present(): improve MFC support for 7-byte UID 2014-01-30 00:09:03 +01:00
Philippe Teuwen
9d63a93dd8 nfc_initiator_target_is_present(): improve MFC support
Increase timeout to support Tikitag & PN533
Fix support for MFC Mini on PN533
2014-01-29 23:30:50 +01:00
Philippe Teuwen
94f4e001f4 nfc_initiator_target_is_present(): support MFUL on PN532 too 2014-01-29 23:02:36 +01:00
Romuald Conty
7b5ab23452 Partial MFC support while checking target presence on PN532/PN531
Goal is to implement "ping" on MFC the same as PN533 does. This patch implements MFC re-selection, but do not take care about authentication; this means this will have side effect while you are authenticated on a MFC block.
2014-01-29 11:36:12 +01:00
Philippe Teuwen
1a3acdadc4 Prepare nfc_initiator_target_is_present() to support more cases
and return NFC_EDEVNOTSUPP for cases not yet supported, depending on the chipset.

Little helper to debug future additions to that function:

// LIBNFC_LOG_LEVEL=193 ./nfc-testing
int
main(void)
{
  nfc_device *pnd;
  nfc_modulation nm = {  .nmt = NMT_ISO14443A,  .nbr = NBR_106,  };
  nfc_context *context;
  nfc_init(&context);
  pnd = nfc_open(context, NULL);
  nfc_initiator_init(pnd);
  nfc_target nt;
  nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt);
  while (nfc_initiator_target_is_present(pnd, NULL) == NFC_SUCCESS);
  nfc_close(pnd);
  nfc_exit(context);
}
2014-01-29 01:54:46 +01:00
Philippe Teuwen
744e052fbe update ChangeLog 2014-01-28 13:20:03 +01:00
Philippe Teuwen
65ad186109 make style 2014-01-28 13:09:33 +01:00
Romuald Conty
e5c732e181 Fix internal current target when using nfc_initiator_poll_target() (Thanks to Bjoern Kinscher)
Fixes Issue 265.
2014-01-28 10:45:05 +01:00
Romuald Conty
b7f590acc8 Set correctly last_error when running pn53x_initiator_target_is_present() 2014-01-28 10:40:18 +01:00
Romuald Conty
9a0a10826b Fix pn53x_initiator_target_is_present() when saved target is NULL
This patch prevents from running any command to check target presence when none have been saved
2014-01-28 10:27:10 +01:00
Philippe Teuwen
7a30e35496 nfc-mfclassic: update help & man page 2014-01-28 00:22:33 +01:00
Philippe Teuwen
d47623319d nfc_initiator_target_is_present() allows pnt==NULL 2014-01-27 16:07:24 +01:00
Philippe Teuwen
7b7f506142 make style 2013-12-08 19:51:01 +01:00
Jiapeng Li
8026d6c047 CMake: find and use pcre3.dll when looking for PCRE 2013-12-08 14:24:48 +01:00
Jiapeng Li
aa2c1c47cd Config: bring configuration feature to Windows 2013-12-08 14:17:39 +01:00
Jiapeng Li
d89affd819 UART (Windows): fix uart_flush_input format
This patch allow uart files to be compiled under Windows, it adds a 'wait' parameter but do not use it.

Please note that patch fixes compilation but do not add any feature to Windows support
2013-12-08 14:15:36 +01:00
Jiapeng Li
76a85ce84b CMake: remove tailing newline from date under Windows
This patch prevents from having a newline (\n) within date result in generated RC file
2013-12-08 14:12:06 +01:00
Jiapeng Li
0ee6dcad4b Cmake: add CONFFILES define like available in autotools build system 2013-12-08 14:09:50 +01:00
Romuald Conty
a7fc1bddaf Fix nfc_target_init() timeout return
This patch prevent from returning a successfull error code while timeout occurred.

Thanks to blck on forum:
http://www.libnfc.org/community/post/4913/#p4913
2013-12-06 16:03:00 +01:00
Philippe Teuwen
4817a6e5c9 make style 2013-12-02 22:55:10 +01:00
Philippe Teuwen
a1ef329962 Fix use after free
pn532_uart.c:293:5: warning: Use of memory after it is freed
    log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "pn53x_check_communication error on %s", ndd.port);
    ^                                                                                                 ~~~~~~~~
2013-11-12 00:43:43 +01:00
Philippe Teuwen
b8e0eec91d nfc-mfclassic: initialize always bFormatCard 2013-11-12 00:43:25 +01:00
Adam Laurie
250068462b add format/wipe command to nfc-mfclassic 2013-11-11 22:03:09 +00:00
Philippe Teuwen
7e5257dd44 Update Changelog 2013-10-01 14:29:51 +02:00
Philippe Teuwen
186cccfe6a pn532_uart: make use of log level for pn53x_check_communication() 2013-10-01 14:14:00 +02:00
Philippe Teuwen
1d0d3c3b45 uart_flush_input() can now wait a bit
Calling ioctl flush too fast before actual garbage bytes arrive was useless.
It solves an issue e.g. when config asks for scanning for multiple incompatible serial devices:
One scan can mess up the reader and we've to wait & flush properly for the next driver to be able to scan correctly
2013-10-01 14:09:15 +02:00
Philippe Teuwen
de1ca46066 Add envvars LIBNFC_DEVICE (to force only one device, no matter the conf files) and LIBNFC_AUTO_SCAN 2013-10-01 14:08:57 +02:00
Philippe Teuwen
1596255506 driver Arygon: don't try to send commands if reset failed 2013-10-01 12:27:19 +02:00
Philippe Teuwen
252f590d5c Revert "Check data from getenv("LIBNFC_LOG_LEVEL") and config file"
This reverts commit 846189b62c9640c29049c51e56d502131af7f165.
It didn't solve Coverity somplain and it broke bitfield support of log_level
2013-09-22 19:55:31 +02:00
Philippe Teuwen
846189b62c Check data from getenv("LIBNFC_LOG_LEVEL") and config file
Problem reported by Coverity:
CID 1090344 (#1 of 1): Use of untrusted string value (TAINTED_STRING)
. tainted_string: Passing tainted string "res->log_level" to "log_init(nfc_context const *)", which cannot accept tainted data.[show details]
2013-09-22 19:32:37 +02:00
Philippe Teuwen
9bb568b799 driver acr122_usb: fix dead code issue
Redundant result check leading to dead code was probably indicative
of a missing return value check of acr122_usb_send_apdu()

Problem reported by Coverity:
  at_least: At condition "res < 0", the value of "res" must be at least 12.
  cannot_single: At condition "res < 0", the value of "res" cannot be equal to -6.
  dead_error_condition: The condition "res < 0" cannot be true.
CID 1090327 (#1 of 1): Logically dead code (DEADCODE)
  dead_error_begin: Execution cannot reach this statement "acr122_usb_ack(pnd);".
2013-09-22 19:08:26 +02:00
Philippe Teuwen
117b58f501 nfc-read-forum-tag3: avoid passing large struct as parameter
Problem reported by Coverity:
CID 1090334 (#1 of 1): Big parameter passed by value (PASS_BY_VALUE)
  pass_by_value: Passing parameter nt of type nfc_target const (size 291 bytes) by value.
2013-09-22 18:32:47 +02:00
Philippe Teuwen
4a91859150 Fix unharmful warning
Commit 54729fb4581d8cbe722292eb3ba73e76711bd461 removed some dead code spotted by Coverity
but it had as effect to trigger a gcc warning, which prefers to see all enum in a switch rather than dead code:

pn53x.c: In function 'pn53x_InJumpForDEP':
pn53x.c:2552:5: warning: enumeration value 'NBR_UNDEFINED' not handled in switch [-Wswitch]
pn53x.c:2552:5: warning: enumeration value 'NBR_847' not handled in switch [-Wswitch]

So both switches were merged, which slightly optimizes the code for speed.
2013-09-22 12:02:31 +02:00
Philippe Teuwen
7cb8fd3833 verify return of pn53x_set_property_bool()
Problem reported by Coverity:
CID 1090321 (#1 of 1): Unchecked return value (CHECKED_RETURN)
  unchecked_value: No check of the return value of "pn53x_set_property_bool(pnd, NP_INFINITE_SELECT, true)".
2013-09-22 03:36:45 +02:00
Philippe Teuwen
2e51318bcb pn53x_usb driver: verify return of pn53x_build_frame()
Problem reported by Coverity:
CID 1090322 (#1 of 1): Unchecked return value (CHECKED_RETURN)
  unchecked_value: No check of the return value of "pn53x_build_frame(abtFrame, &szFrame, pbtData, szData)".
2013-09-22 03:31:50 +02:00
Philippe Teuwen
90160d6507 Fix possible overflow
Note that this could happen e.g. if a fake PN533 sends malicious frames over USB

CID 1090329 (#1 of 1): Overflowed return value (INTEGER_OVERFLOW)
  overflow_sink: Overflowed or truncated value (or a value computed from an overflowed or truncated value) "res" used as return value.
2013-09-22 03:26:33 +02:00
Philippe Teuwen
618ca1e92b Remove dead code
Problem reported by Coverity:
at_most: At condition "io_res < 0", the value of "io_res" must be at most -1.
dead_error_condition: The condition "io_res < 0" must be true.
CID 1090328 (#1 of 1): Logically dead code (DEADCODE)
  dead_error_line: Execution cannot reach this expression "0" inside statement "return (io_res < 0) ? io_re...".
2013-09-22 03:13:09 +02:00
Philippe Teuwen
54729fb458 Remove dead code
Problem reported by Coverity:
  dead_error_condition: The switch value "nbr" cannot be "NBR_UNDEFINED".
  CID 1090326 (#1 of 2): Logically dead code (DEADCODE)
  dead_error_begin: Execution cannot reach this statement "case NBR_UNDEFINED:".
2013-09-22 03:09:08 +02:00
Philippe Teuwen
cedbefb880 nfc-relay-picc: sleep() expects unsigned int
This avoids Coverity being unhappy that only lower bound was defined, well I hope

lower_bounds: Checking lower bounds of signed scalar "waiting_time" by "waiting_time > 0".
CID 1090343 (#1 of 1): Untrusted value as argument (TAINTED_SCALAR)
  tainted_data: Passing tainted variable "waiting_time" to a tainted sink.
  sleep(waiting_time);
2013-09-22 03:00:58 +02:00
Philippe Teuwen
61884967ea nfc-mfclassic: verify return of nfc_initiator_select_passive_target()
Problem reported by Coverity:
CID 1090323 (#1 of 1): Unchecked return value (CHECKED_RETURN)
  unchecked_value: No check of the return value of "nfc_initiator_select_passive_target(pnd, nmMifare, nt.nti.nai.abtUid, nt.nti.nai.szUidLen, NULL)".
2013-09-22 02:45:23 +02:00
Philippe Teuwen
a4f466df06 Verify return of nfc_device_set_property_bool()
Problem reported by Coverity:
CID 1090325 (#1 of 1): Unchecked return value (CHECKED_RETURN)
  unchecked_value: No check of the return value of "nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false)".
2013-09-22 02:41:11 +02:00
Philippe Teuwen
e2135dbaa5 pn53x-sam: fix truncated stdio return value
Problem reported by Coverity:
CID 1090318 (#1 of 1): Truncated stdio return value (CHAR_IO)
char_io: Assigning the return value of "getchar(void)" to char "input" truncates its value
2013-09-22 02:38:17 +02:00
Philippe Teuwen
679897d0a1 nfc-emulate-forum-tag4: fix TOCTOU
Hopefully fix TOCTOU by calling fopen() before stat()

At least this should prevent Coverity to complain about it:
CID 1090346 (#1 of 1): Time of check time of use (TOCTOU)
  fs_check_call: Calling function "stat(char const *, struct stat *)" to perform check on "filename".
  toctou: Calling function "fopen(char const * restrict, char const * restrict)" that uses "filename" after a check function. This can cause a time-of-check, time-of-use race condition.

Note that it seems pretty hard to avoid completely:
https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use#Preventing_TOCTTOU
2013-09-22 02:29:07 +02:00
Philippe Teuwen
feb5f37aa3 nfc-read-forum-tag3: remove redundant error
switch case was redundant as getopt was already telling the issue:

  nfc-read-forum-tag3: option requires an argument -- 'o'
  Option -o requires an argument.

This fixes also a problem reported by Coverity about missing break:

CID 1090330 (#1 of 1): Missing break in switch (MISSING_BREAK)
  unterminated_case: This case (value 63) is not terminated by a 'break' statement.
2013-09-22 02:14:08 +02:00
Philippe Teuwen
70048a0b2c uart.c: check return of read()
Fix warning
uart.c:146:3: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]

Also reported by Coverity:
CID undefined (#1 of 1): Ignoring number of bytes read (CHECKED_RETURN)
  check_return: "read(int, void *, size_t)" returns the number of bytes read, but it is ignored.
2013-09-22 02:06:58 +02:00
Philippe Teuwen
b5d76a327d Fix strcpy into fixed size buffer in conf.c
Problem reported by Coverity:

CID 1090340 (#1 of 2): Copy into fixed size buffer (STRING_OVERFLOW)
  fixed_size_dest: You might overrun the 256 byte fixed-size string "context->user_defined_devices[context->user_defined_device_count - 1U].name" by copying "value" without checking the length.
  parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.
CID 1090340 (#2 of 2): Copy into fixed size buffer (STRING_OVERFLOW)[select issue]
2013-09-22 01:57:58 +02:00
Philippe Teuwen
d9854cfdd9 Fix out-of-bounds access in driver acr122_pcsc
Problem reported by Coverity:
CID 1091328 (#1 of 1): Out-of-bounds access (OVERRUN)
  overrun-buffer-arg: Overrunning buffer pointed to by "&abtTxBuf[6]" of 271 bytes by passing it to a function which accesses it at byte offset 271 using argument "szData" (which evaluates to 266).
2013-09-22 01:47:15 +02:00
Philippe Teuwen
d9b531f50f Verify return of nfc_device_set_property_bool()
Problem reported by Coverity
CID 1090319 (#1 of 1): Unchecked return value (CHECKED_RETURN)
  unchecked_value: No check of the return value of "nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, nt.nti.nai.btSak & 0x20)".
CID 1090320 (#1 of 1): Unchecked return value (CHECKED_RETURN)
  unchecked_value: No check of the return value of "nfc_device_set_property_bool(dev, NP_HANDLE_CRC, false)".
CID 1090324 (#1 of 2): Unchecked return value (CHECKED_RETURN)
  unchecked_value: No check of the return value of "nfc_device_set_property_bool(pnd, NP_ACTIVATE_FIELD, true)".
CID 1090325 (#1 of 1): Unchecked return value (CHECKED_RETURN)
  unchecked_value: No check of the return value of "nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false)".
2013-09-22 01:31:45 +02:00
Philippe Teuwen
ddf58f2d69 Changing conditions to avoid Coverity to complain in artificial situations
CID 1090331 (#1 of 1): Out-of-bounds access (OVERRUN)
11. overrun-buffer-arg: Overrunning array "pnti->nai.abtUid" of 10 bytes by passing it to a function which accesses it at byte offset 11 using argument "pnti->nai.szUidLen" (which evaluates to 12).
2013-09-20 00:13:21 +02:00
Philippe Teuwen
a5e7dec797 Initialize array to keep Coverity happy
as Coverity fails seeing that szTargetTypes will always be = 0 in the case believed to lead to reading unitialized data in apttTargetTypes.

CID 1090347 (#1 of 1): Uninitialized scalar variable (UNINIT)
4. uninit_use_in_call: Using uninitialized element of array "apttTargetTypes" when calling "pn53x_InAutoPoll(struct nfc_device *, pn53x_target_type const *, size_t const, uint8_t const, uint8_t const, nfc_target *, int const)".
2013-09-20 00:01:41 +02:00
Philippe Teuwen
30fdf1d9c2 Fix unbounded source buffer
source could be larger than destination

Problem reported by Coverity
CID 1090342 (#1 of 1): Unbounded source buffer (STRING_SIZE)
10. string_size: Passing string "envvar" of unknown size to "strcpy(char * restrict, char const * restrict)", which expects a string of a particular size.
2013-09-19 23:48:44 +02:00
Philippe Teuwen
9240770ab1 acr122s_scan should not return -1 if of type size_t 2013-09-19 23:39:03 +02:00
Philippe Teuwen
3d040d73f3 Fix memory leak
Problems reported by Coverity:

CID 1090335 (#1 of 1): Resource leak (RESOURCE_LEAK)
24. leaked_storage: Variable "acPorts" going out of scope leaks the storage it points to.

CID 1090336 (#1 of 1): Resource leak (RESOURCE_LEAK)
10. leaked_storage: Variable "acPorts" going out of scope leaks the storage it points to.

CID 1090337 (#1 of 1): Resource leak (RESOURCE_LEAK)
21. leaked_storage: Variable "i2cPorts" going out of scope leaks the storage it points to.

CID 1090338 (#1 of 1): Resource leak (RESOURCE_LEAK)
21. leaked_storage: Variable "acPorts" going out of scope leaks the storage it points to.

CID 1090339 (#1 of 1): Resource leak (RESOURCE_LEAK)
23. leaked_storage: Variable "acPorts" going out of scope leaks the storage it points to.
2013-09-19 23:34:52 +02:00
Philippe Teuwen
b6b63f10b4 Fix warning about out-of-bound read
Actually the second part of the condition guaranteed that an out-of-bound read would never occur but now code is neater.
It was:  for (j = 0; (j < "too_large_bound") && (const_ca[i].saklist[j] >= 0); j++)

Problem reported by Coverity
CID 1090332 (#1 of 1): Out-of-bounds read (OVERRUN)
67. overrun-local: Overrunning array "const_ca[i].saklist" of 8 4-byte elements at element index 31 (byte offset 124) using index "j" (which evaluates to 31).
2013-09-19 23:08:06 +02:00
Philippe Teuwen
3e7dab1e8d Fix buffer overflow and fix triple-size UID reported by PN531
A buffer overflow could occur is a triple-size UID card was read with a PN531.
Moreover the way cascade tags were removed was just wrong.

Problem reported by Coverity
CID 1090331 (#1 of 1): Out-of-bounds access (OVERRUN)
10. overrun-buffer-arg: Overrunning buffer pointed to by "&pnti->nai.abtUid[5]" of 10 bytes by passing it to a function which accesses it at byte offset 11 using argument "7UL".

Coverity reported a read out of bounds but actually the real problem if PN531 and triple-size UID will already occur at
    memcpy(pnti->nai.abtUid, pbtRawData, pnti->nai.szUidLen); where abtUid is of size 10 and szUidLen of size 12
2013-09-19 22:57:15 +02:00
Ludovic Rousseau
107b4ece8b Fix use after free bug
nfc_exit(context); was called 2 times

CID 1090348 (#1 of 1): Use after free (USE_AFTER_FREE)53. deref_arg:
Calling "nfc_exit(nfc_context *)" dereferences freed pointer "context".
(The dereference is assumed on the basis of the 'nonnull' parameter
attribute.)
2013-09-19 20:38:56 +02:00
Ludovic Rousseau
967f6e5623 Remove dead code
The switch case has a default rule and a return in every cases. So the
code after the switch will never be executed.

Problem reported by thei Coverity tool
CID 1090408 (#1 of 1): Structurally dead code (UNREACHABLE)unreachable:
This code cannot be reached: "if (pn53x_current_target_ne...".
2013-09-19 20:34:58 +02:00
Philippe Teuwen
3a8db49a83 Remove debian/ now that there is an official inclusion in Debian 2013-09-11 00:00:43 +02:00
Nobuhiro Iwamatsu
fdcb2c3290 Add support kFreeBSD
kFreeBSD use cuaX as uart device.
This supports the kFreeBSD in Debian, and fix failure to build.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
2013-09-10 21:12:59 +02:00
Philippe Teuwen
70f6c24ebb Debian: fix Vcs-Git URL 2013-09-10 20:51:51 +02:00
Philippe Teuwen
ad9694cf00 nfc-list: New option to choose which technologies to poll for
This is useful especially against chips emulating several types
at once (e.g. PN53x, PN544 etc)
2013-09-09 15:58:07 +02:00
Ludovic Rousseau
dcb7d137c1 Fix watch file
Using the example at https://wiki.debian.org/debian/watch
2013-09-07 13:22:28 +02:00
Philippe Teuwen
c227e375ae Debian: 1.7.0~rc7 -> 1.7.0 2013-09-03 21:40:19 +02:00
Romuald Conty
ec933731b7 Prepare 1.7.0 version 2013-09-03 16:42:46 +02:00
Peter Meerwald
40672ed62b pn532: fix typo in comment
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-09-03 16:31:25 +02:00
Peter Meerwald
733080ba0c uart: fix typo 'eaten'
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-09-03 16:31:04 +02:00
Peter Meerwald
34bf7b3089 nfs-list: drop outdated examples superseeded by connection string
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-09-03 16:30:43 +02:00
Peter Meerwald
0b9fe52b2b pn53x: fix logging, timeout value
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-09-03 16:30:01 +02:00
Marcello Morena
98c4eee28f Modified the preamble sent to PN532 via UART from 5 bytes to 16 bytes, to comply with PN532 manual that says to send a "large" preamble in order to wake up the PN532. This is done to solve wakeup timeout problems on some PN532 Breakout Boards. 2013-09-03 16:01:36 +02:00
Romuald Conty
bcd479a5d2 Update ChangeLog and NEWS 2013-09-03 15:57:12 +02:00
Ludovic Rousseau
565134d4c4 Add missing \n in a printf() 2013-08-31 17:59:24 +02:00
Philippe Teuwen
a2a335e3d4 make style 2013-08-31 17:35:41 +02:00
Adam Laurie
07c54cd91b allow setting of UID for special 'chinese' ultralight cards 2013-08-31 16:15:27 +01:00
Philippe Teuwen
f6fff26f0f Fix warning "empty.c:1:0: warning: ISO C forbids an empty translation unit [-pedantic]" 2013-08-29 22:37:23 +02:00
Philippe Teuwen
b52308d071 TypeB ProtocolInfo: limit mask for ISO14443-4 support flag 2013-08-29 22:23:01 +02:00
Nobuhiro Iwamatsu
f1b4c8e7c2 Add entry for 1.7.0~rc7-1
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
2013-08-29 19:11:52 +02:00
Nobuhiro Iwamatsu
6f90560fa9 Remove unnecessary changelog
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
2013-08-29 19:10:00 +02:00
Ludovic Rousseau
f889de514b Fix symbols file contains debian revision
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
2013-08-29 19:09:33 +02:00
Ludovic Rousseau
e24d730644 Use bzip2 instead of gzip compression algorithm
The libnfc-1.7.0-rc7.tar.bz2 file is 25% smaller than the equivalent
libnfc-1.7.0-rc7.tar.gz file.
2013-08-29 19:04:04 +02:00
Ludovic Rousseau
f8d2d178d5 Use automake option subdir-objects
Fix for:
examples/Makefile.am:79: warning: source file
'doc/quick_start_example1.c' is in a subdirectory,
examples/Makefile.am:79: but option 'subdir-objects' is disabled
2013-08-29 18:59:41 +02:00
Ludovic Rousseau
c89532fa19 libnfcbuses.la use at least an empty source file
Closes issue #254: acr122_pcsc compilation failed on Mac OSX 10.8.4
2013-08-29 18:55:55 +02:00
Philippe Teuwen
8fe13ece62 pn53x_initiator_transceive_bytes_timed(): use proper CRC_B if TypeB 2013-08-19 15:47:44 +02:00
Philippe Teuwen
c3a5fba028 Adding iso14443b_crc_append() 2013-08-19 14:55:27 +02:00
Philippe Teuwen
bb5b712a74 Adding link to AUTHORS in the copyright headers 2013-07-17 13:57:56 +02:00
Philippe Teuwen
18fe330413 Fix warning Function call argument is an uninitialized value
acr122_usb.c:237:3: warning: Function call argument is an uninitialized value
  LOG_HEX(NFC_LOG_GROUP_COM, "TX", abtTx, szTx);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../libnfc/log.h:107:7: note: expanded from macro 'LOG_HEX'
      snprintf (__acBuf + __szBuf, sizeof(__acBuf) - __szBuf, "%02x ",((uint8_t *)(pbtData))[__szPos]); \
      ^                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Maybe a side effect of the #pragma pack not properly understood by the static analyser
but anyway acr122_usb_frame_template is also used the same way to initialize the other frames
2013-07-03 01:02:18 +02:00
Philippe Teuwen
2db4a0e7e4 make style
new version of astyle, better separation of XOR
2013-07-03 00:16:15 +02:00
Philippe Teuwen
a5d40cefc8 Fix warning about garbage value
acr122s.c:196:23: warning: The left operand of '<<' is a garbage value
  size_t frame_size = FRAME_SIZE(frame);
                      ^          ~~~~~~
acr122s.c:76:24: note: expanded from macro 'FRAME_SIZE'
                       ^
acr122s.c:74:47: note: expanded from macro 'APDU_SIZE'
2013-07-03 00:10:24 +02:00
Philippe Teuwen
5cda3af5d4 Fix warnings Null pointer passed as an argument to a nonnull parameter
acr122s.c:331:3: warning: Null pointer passed as an argument to a 'nonnull' parameter
  memcpy(buf, data, data_size);
  ^           ~~~~

pn53x.c:3138:3: warning: Null pointer passed as an argument to a 'nonnull' parameter
  memcpy(CHIP_DATA(pnd)->current_target, pnt, sizeof(nfc_target));
  ^                                      ~~~
2013-07-02 23:47:45 +02:00
Philippe Teuwen
56e9f1978d Fix warning increasing required alignment
acr122_usb.c:513:20: warning: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align]
  uint32_t *pu32 = (uint32_t *)u8;
                   ^~~~~~~~~~~~~~
2013-07-02 23:11:38 +02:00
Philippe Teuwen
cc7c0c32f1 Fix warning about incompatible types
pn53x.c:85:57: warning: Result of 'malloc' is converted to a pointer of type 'nfc_modulation_type', which is incompatible with sizeof operand type 'nfc_modulation'
    CHIP_DATA(pnd)->supported_modulation_as_initiator = malloc(sizeof(nfc_modulation) * 9);
                                                        ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
2013-07-02 22:44:55 +02:00
Mike Auty
ebe6335fc1 Rerun usb_find_busses() and usb_find_devices() without recalling usb_init()
Fixes issue #252
2013-06-22 20:03:45 +02:00
Philippe Teuwen
03e1f23a40 Make use of new PN53x_ACK_FRAME__LEN 2013-06-15 23:14:54 +02:00
Laurent Latil
005713921e Update PN532/I2C sample config file for rev2.0 boards. Add a note regarding the change of I2C bus routing on R-Pi board rev 2.0. 2013-06-15 22:53:45 +02:00
Laurent Latil
80a41010fb Fix various problems in I2C support of PN532: - Fix a memory leak in pn532_i2c_wait_rdyframe() - Remove unused parameters and local variables - Fix all other compilation warnings
Note: a new constant (PN53x_ACK_FRAME__LEN) has been defined in
pn53x-internal.h file to avoid hard coding the ACK frame length.
2013-06-15 22:53:35 +02:00
Philippe Teuwen
957bebfd48 make style 2013-06-15 22:51:53 +02:00
Philippe Teuwen
9de66d463b UART: add support for BeagleBone serial ports
Thanks to Johan Henselmans!
2013-06-15 22:01:28 +02:00
Philippe Teuwen
d99bcb79fa I2C: add i2c support to CMake 2013-06-15 00:41:20 +02:00
Philippe Teuwen
5cc3f3551a I2C: add i2c to cppcheck 2013-06-15 00:37:08 +02:00
Philippe Teuwen
35da0c0b8a Update ChangeLog & NEWS 2013-06-15 00:35:18 +02:00
Philippe Teuwen
4c707e04ad I2C: add conf example 2013-06-15 00:25:08 +02:00
Philippe Teuwen
77445f1672 I2C: remove unneeded I2C_DRIVERS_ENABLED 2013-06-15 00:20:04 +02:00
Philippe Teuwen
3cd26a18f1 I2C: add Laurent Latil as author 2013-06-15 00:04:06 +02:00
Philippe Teuwen
238be3f068 make style 2013-06-15 00:01:25 +02:00
Laurent Latil
1b11450312 Add I2C protocol support for PN532. 2013-06-14 23:59:46 +02:00
Philippe Teuwen
6038aca7d1 acr122_usb: remove ACR122<>TOUCHATAG model distinction 2013-06-14 23:58:55 +02:00
Philippe Teuwen
c6bda74f44 acr122_usb: ACR122U does not need PCSC Escape anymore
ACR122U:
Through PCSC we couldn't send APDUs to the reader if there was no card
but now that we communicate directly with the reader, we can send APDUs
even if there is no card, so we don't need the Escape mechanism anymore
2013-06-14 23:39:43 +02:00
Philippe Teuwen
c2fa73b404 acr122_usb: retry a few times if init failed 2013-06-14 23:28:03 +02:00
Philippe Teuwen
f0471ebc89 acr122_usb: capture more specifically the expected error SW=637f 2013-06-13 21:01:08 +02:00
Philippe Teuwen
7638e9ea87 mifare_classic_block_manufacturer: clearer struct members
Fixes issue 250
2013-06-13 20:14:22 +02:00
Romuald Conty
af7eef0c54 acr122_usb: check received Status Word (Touchatag)
Test if SW1 is 0x61 (means more bytes have to be read) before using SW2 as length.

Update issue 251
The driver now check that Status Word (SW1) is equals to 0x61 (more data available) before using SW2 as length.
If SW is not as expected, it show SW1 and SW2.
2013-06-13 15:56:39 +02:00
Romuald Conty
5757fafe0c acr122_usb: check if received frame is long enough (Touchatag)
This prevents from potential out-of-memory read.
2013-06-13 15:49:48 +02:00
Romain Tartière
27c43e8b8a Improve a bit shell scripts portability.
- Use /bin/sh: bash is not required here;
  - Avoid Perl regexp in grep(1): this is a GNU extension;
  - While here, make ReadNavigo.sh fail earlier if pn53x-tamashell
    fails at first invocation.

Reported by:	Ganael Laplanche <martymac@FreeBSD.org>
2013-05-25 13:29:38 +02:00
Ludovic Rousseau
16a5fc419c Use PKG_PROG_PKG_CONFIG
Remove ad-hoc code and use the standard macro instead.

Closes issue #249
2013-05-24 20:30:23 +02:00
Romain Tartière
0a5199a737 Avoid clash with system's htole32 if it exists.
Fix build on FreeBSD.

Reported by:    Ganael Laplanche
2013-05-20 17:02:24 +02:00
Romain Tartière
c1db25c05b Include <stdlib.h>, required for getenv(3).
Fix build if -Werror is set, avoid coredumping at runtime otherwise.

Reported by:	Ganael Laplanche
2013-05-20 17:01:49 +02:00
Romuald Conty
936210c076 pn53x: only create a current target when at least one have been found. 2013-05-13 09:43:46 +02:00
Romuald Conty
07dfed8a08 Debian: update symbols which changed in rc7 2013-05-13 09:41:45 +02:00
Romuald Conty
205aef9739 Add missing thanks to ChangeLog 2013-05-13 09:41:07 +02:00
Philippe Teuwen
c97c70f5d5 Fix typo in libnfc.conf.sample
Fixes issue 247
2013-04-30 21:48:33 +02:00
Philippe Teuwen
41ec6d49f6 Add ISO14443-4 chaining support for RX (MI) 2013-04-28 23:52:15 +02:00
Romuald Conty
b84ac324ff pn532_uart: fix 'operation abort' feature with this driver 2013-04-18 13:49:10 +02:00
Philippe Teuwen
0841a94c65 nfc-mfclassic: allow option f for read operation too 2013-04-09 23:42:55 +02:00
Philippe Teuwen
29c7ef19a9 Debian: rc6 -> rc7 2013-04-05 16:18:12 +02:00
Romuald Conty
27f3c4973d Prepare release candidate 1.7.0 RC7 2013-04-05 16:01:36 +02:00
Philippe Teuwen
b950eacfdf drivers USB: check usb_open() result
Fixes issue 245
2013-04-05 15:42:57 +02:00
Philippe Teuwen
9cb9e0e6da Fix cppcheck warning: The scope of the variable X can be reduced. 2013-04-05 14:38:03 +02:00
Philippe Teuwen
fc144fe389 nfc-anticol: add option -t for timed exchanges 2013-04-05 14:33:16 +02:00
Philippe Teuwen
d319e87ff8 HACKING: refer to make cppcheck 2013-04-05 11:43:47 +02:00
Philippe Teuwen
a3475cc896 make cppcheck: add PN532_SPI 2013-04-05 11:42:57 +02:00
Romuald Conty
e6ab66037d Better support for some special chinese cards
Fixes issue 190
2013-04-05 11:29:31 +02:00
Romuald Conty
c958201148 New custom "make cppcheck" target: run a cppcheck with usual args 2013-04-05 11:12:39 +02:00
Ludovic Rousseau
7d986844c4 Fix compiler warnings
doc/quick_start_example1.c:24: warning: unused parameter ‘argc’
doc/quick_start_example2.c:21: warning: unused parameter ‘argc’
2013-04-03 17:55:40 +02:00
Ludovic Rousseau
a57793fe5a Do not build pn532_spi if spi is not available
Check if the include file linux/spi/spidev.h is available and, only if
the header file is present, add the driver pn532_spi for "default" and
"all" driver configuration.

This Linux header file is not present on Mac OS X for example.
2013-04-03 16:08:34 +02:00
Alex Lian
8b8b8d49a7 Windows packaging improvement
- Stepped away from NSIS, to just be a plain zip file
- Fixed a bug (though when trying NSIS) of dealing with slashes in windows paths
- Had package add .lib file instead of .dll.a file, since lib files tend to be more useful for Windows developers
2013-04-03 01:06:03 -04:00
Ludovic Rousseau
a8f91c05d2 Fix autoreconf warning
libnfc/buses/Makefile.am:16: warning: EXTRA_DIST multiply defined in
condition TRUE ...
libnfc/buses/Makefile.am:9: ... 'EXTRA_DIST' previously defined here
2013-04-01 18:26:23 +02:00
Philippe Teuwen
0625544cc3 Merge branch 'pn532_spi'
* pn532_spi:
  SPI: remove dead code
  SPI: add 1ms sleep in wakeup()
  SPI: update NEWS & Changelog
  Add connstring example for SPI on RPi
  Add PN532 SPI driver to CMake
  spi: fix doc typos
  spi: remove spi_posix.c, exotic platform implementations will have to be done in their respective contrib subdir
  Only include SPI related files when (at least) one SPI driver is enabled
  pn532_spi: missing malloc() checks, spi_close(), nfc_device_close() on some error handling branches
  pn532_spi: fix missing free(ndd.port)
  pn532_spi: fix double free() of spi port info
  Add pn532_spi author to AUTHORS
  Unify copyright notices
  pn532_spi: use new connstring_decode()
  Fix cppcheck warning "Non reentrant function 'readdir' called"
  Fix cppcheck warning "scanf without field width limits can crash with huge input data"
  Fix cppcheck warning "Obsolete function 'usleep' called"
  spi driver: remove compilation warnings
  make style
  Adding a SPI driver for pn532
2013-04-01 13:24:28 +02:00
Philippe Teuwen
0b1bf105be Revert 1c67c3f92a4399d5a6e914e4b27be3552d4f77ef
Fixes issue 244
errorlibnfc.driver.acr122_usbToo small reply
2013-03-30 17:51:06 +01:00
Philippe Teuwen
1b45bd4ee1 SPI: remove dead code 2013-03-28 00:20:03 +01:00
Philippe Teuwen
f9bd5d79d2 SPI: add 1ms sleep in wakeup()
Without this delay I had troubles with a Raspberry-Pi:
With debug enabled I could go as high as 7.8MHz but without debug I had to go lower than 500kHz otherwise I got following error:
  errorlibnfc.driver.pn532_spiUnable to wait for SPI data. (RX)
  pn53x_check_communication: Timeout
It could work occassionally faster but very unreliable.
So the delay introduced by printf() was enough to "fix" the problem, therefore this little extra sleep() in wakeup().
2013-03-28 00:19:29 +01:00
Philippe Teuwen
c8e50b6852 SPI: update NEWS & Changelog 2013-03-27 23:33:02 +01:00
Philippe Teuwen
f991771128 Add connstring example for SPI on RPi 2013-03-27 23:29:59 +01:00
Philippe Teuwen
7c2f8b4cb0 Add PN532 SPI driver to CMake 2013-03-27 23:25:43 +01:00
Philippe Teuwen
dcc527df7b Merge branch 'master' into pn532_spi
* master:
  CMake: enable same set of default drivers as for autotools
  pn532_uart: Unify copyright notices & update authors lists (somehow this file was forgotten)
2013-03-27 23:13:19 +01:00
Philippe Teuwen
3eb1ee3b9c CMake: enable same set of default drivers as for autotools 2013-03-27 23:12:59 +01:00
Philippe Teuwen
7df8fdd0f6 spi: fix doc typos 2013-03-27 22:58:59 +01:00
Philippe Teuwen
12b756e97a spi: remove spi_posix.c, exotic platform implementations will have to be done in their respective contrib subdir 2013-03-27 17:40:22 +01:00
Philippe Teuwen
fc420d58af Only include SPI related files when (at least) one SPI driver is enabled 2013-03-27 16:58:01 +01:00
Philippe Teuwen
1ab282d43c pn532_spi: missing malloc() checks, spi_close(), nfc_device_close() on some error handling branches 2013-03-27 16:27:25 +01:00
Philippe Teuwen
f1a9a8ee38 pn532_uart: Unify copyright notices & update authors lists (somehow this file was forgotten) 2013-03-27 16:12:18 +01:00
Philippe Teuwen
794fcdc1ad pn532_spi: fix missing free(ndd.port) 2013-03-27 12:06:37 +01:00
Philippe Teuwen
87a3dd7067 pn532_spi: fix double free() of spi port info 2013-03-27 12:06:33 +01:00
Philippe Teuwen
1417bdc164 Merge branch 'master' into pn532_spi
* master: (28 commits)
  Update Changelog
  Add missing windows files in archive
  Move log implementation for Windows in dedicated directory
  Move UART implementation for Windows in dedicated directory
  CMake: only compile usbbus.c when (at least) one USB driver is enabled
  CMake: only include UART related files when (at least) one UART driver is enabled
  Only include UART related files when (at least) one UART driver is enabled
  Fix environment vars usage when compiling with CMake
  Remove unsed code section in log.c (was commented)
  pn53x_current_target_new() now returns null ptr upon malloc() error
  fix missing tests on malloc() return
  pn53x_data_new() now returns null ptr upon malloc() error
  uart drivers: missing pn53x_data_free() on some error handling branches
  uart drivers: missing nfc_device_free() on some error handling branches
  uart drivers: missing uart_close() on some error handling branches
  uart drivers: fix missing free(ndd.port)
  config parser: missing fclose()
  UART drivers: fix double free() of serial port info
  Fix cmake build failure under linux
  quick_start_example1.c: avoid using warnx() to remove err.h dependency
  ...

Conflicts:
	libnfc/buses/Makefile.am
2013-03-27 11:44:29 +01:00
Philippe Teuwen
eb515a6952 Update Changelog 2013-03-27 11:33:03 +01:00
Romuald Conty
542622a2f5 Add missing windows files in archive 2013-03-19 00:00:46 +01:00
Romuald Conty
2be00e7615 Move log implementation for Windows in dedicated directory 2013-03-18 23:53:01 +01:00
Romuald Conty
cb3452db7b Move UART implementation for Windows in dedicated directory 2013-03-18 23:46:14 +01:00
Romuald Conty
a422ae2211 CMake: only compile usbbus.c when (at least) one USB driver is enabled 2013-03-18 23:32:07 +01:00
Romuald Conty
b6b356b948 CMake: only include UART related files when (at least) one UART driver is enabled 2013-03-18 23:27:23 +01:00
Romuald Conty
699e9123ea Only include UART related files when (at least) one UART driver is enabled 2013-03-18 23:07:19 +01:00
Romuald Conty
f3f2ec1c0f Fix environment vars usage when compiling with CMake 2013-03-18 15:26:15 +01:00
Romuald Conty
e898e5f73b Remove unsed code section in log.c (was commented) 2013-03-18 15:25:07 +01:00
Philippe Teuwen
890f028b0c pn53x_current_target_new() now returns null ptr upon malloc() error 2013-03-18 01:00:41 +01:00
Philippe Teuwen
69c435f348 fix missing tests on malloc() return 2013-03-18 00:46:31 +01:00
Philippe Teuwen
06d5b54308 pn53x_data_new() now returns null ptr upon malloc() error 2013-03-18 00:21:08 +01:00
Philippe Teuwen
af57df532b uart drivers: missing pn53x_data_free() on some error handling branches 2013-03-18 00:21:03 +01:00
Philippe Teuwen
5f70bdc699 uart drivers: missing nfc_device_free() on some error handling branches 2013-03-17 23:52:54 +01:00
Philippe Teuwen
2e801a62d5 uart drivers: missing uart_close() on some error handling branches 2013-03-17 23:52:43 +01:00
Philippe Teuwen
c1372a009f uart drivers: fix missing free(ndd.port) 2013-03-17 22:54:15 +01:00
Philippe Teuwen
77838b894c config parser: missing fclose() 2013-03-17 22:19:49 +01:00
Philippe Teuwen
ca7477e935 UART drivers: fix double free() of serial port info
Fixes issue 242
2013-03-16 12:25:28 +01:00
Julien Schueller
8485996f13 Fix cmake build failure under linux
The LIBUSB_FOUND variable was used before the libusb detection was performed.
Fixes issue 240.
2013-03-12 20:54:50 +01:00
Philippe Teuwen
ecc12d28aa quick_start_example1.c: avoid using warnx() to remove err.h dependency
err.h is not available under Windows and the goal of this example is not to learn how to get around that problem ;)
2013-03-12 17:46:04 +01:00
Philippe Teuwen
e70a3314bf Update ChangeLog & make style 2013-03-12 17:07:09 +01:00
Philippe Teuwen
20e51e9752 nfc-mfclassic: add option to allow using keyfile from another card 2013-03-12 15:39:57 +01:00
Philippe Teuwen
16161e1a68 nfc-mfclassic: detect 2K MFP via RATS 2013-03-12 14:15:04 +01:00
Philippe Teuwen
d019f9729d nfc-anticol: fix ATS length 2013-03-12 12:23:15 +01:00
Philippe Teuwen
56ea2e65dc nfc-mfclassic: use smaller files for cards < 4k 2013-03-12 10:56:57 +01:00
Philippe Teuwen
94617366a7 nfc-mfclassic: abort if expected UID is not matching real card 2013-03-12 10:56:20 +01:00
Philippe Teuwen
bb7b05681e nfc-mfclassic: fix reporting of processed blocks number 2013-03-12 10:55:45 +01:00
Philippe Teuwen
a3f4145a2e Add pn532_spi author to AUTHORS 2013-03-10 16:33:53 +01:00
Philippe Teuwen
dd209460b1 Update ChangeLog 2013-03-10 16:32:28 +01:00
Philippe Teuwen
baa0f9ae36 Unify copyright notices 2013-03-10 16:18:22 +01:00
Philippe Teuwen
d683a98065 Merge branch 'master' into pn532_spi
* master:
  Unify copyright notices & update authors lists
  Update ChangeLog
2013-03-10 16:17:59 +01:00
Philippe Teuwen
bf164220ee Unify copyright notices & update authors lists 2013-03-10 16:15:23 +01:00
Philippe Teuwen
a4a531068f Update ChangeLog 2013-03-10 00:32:05 +01:00
Philippe Teuwen
ec99e9033a pn532_spi: use new connstring_decode()
Fix cppcheck warning "Non reentrant function 'strtok' called"
2013-03-10 00:29:01 +01:00
Philippe Teuwen
759cd106e5 Merge branch 'master' into pn532_spi
* master:
  New connstring_decode() fix cppcheck warning "Non reentrant function 'strtok' called"
  Update Changelog
  Update NEWS & Changelog
  Forgot to commit new log internal header file
  Remove log-printf from CMakefile
  Add log_internal.h to Makefile
  Creating log_internal.h for log_*put_internal() prototypes
  log_win32: declare log_output_debug() static
  Merge log-printf.c into log.c, inline with prototypes in log.h & platform files log_*.c
2013-03-10 00:22:27 +01:00
Philippe Teuwen
cc03f84636 New connstring_decode() fix cppcheck warning "Non reentrant function 'strtok' called" 2013-03-10 00:20:52 +01:00
Philippe Teuwen
59271d27e9 Update Changelog 2013-03-09 16:33:51 +01:00
Philippe Teuwen
e7f4d0778e Update NEWS & Changelog 2013-03-09 11:27:56 +01:00
Philippe Teuwen
38966cb2fb Forgot to commit new log internal header file 2013-03-09 10:56:51 +01:00
Philippe Teuwen
ad8b338a7b Remove log-printf from CMakefile 2013-03-09 10:41:25 +01:00
Philippe Teuwen
a9e3365d98 Add log_internal.h to Makefile 2013-03-09 10:41:07 +01:00
Philippe Teuwen
6a110b3849 Creating log_internal.h for log_*put_internal() prototypes
Fixed warning "no previous prototype for function" in log_posix.c
2013-03-09 01:00:21 +01:00
Philippe Teuwen
7e26aa368d log_win32: declare log_output_debug() static 2013-03-09 00:47:21 +01:00
Philippe Teuwen
f19d233fad Merge log-printf.c into log.c, inline with prototypes in log.h & platform files log_*.c 2013-03-09 00:46:45 +01:00
Philippe Teuwen
262555d568 Fix cppcheck warning "Non reentrant function 'readdir' called" 2013-03-08 23:50:03 +01:00
Philippe Teuwen
8e2effdc53 Fix cppcheck warning "scanf without field width limits can crash with huge input data" 2013-03-08 23:43:41 +01:00
Philippe Teuwen
ff11c8ac87 Fix cppcheck warning "Obsolete function 'usleep' called" 2013-03-08 23:30:21 +01:00
Philippe Teuwen
05b9cde966 Merge branch 'master' into pn532_spi
* master: (43 commits)
  Windows: workaround as libusb is not automatically detected by CMake
  Add usbbus to Makefile.am EXTRA_DIST
  make style
  Add log_posix to Makefile.am
  Split logging internals so that platforms may choose additional or alternate spew mechanisms
  More explicitely ignoring return value as suggested by Ludovic
  Windows: Clean up all compiler warnings and link warnings
  API change
  make style
  pn53x-sam: fix print_nfc_target
  Convert by value passing of nfc_target to pointer for str_nfc_target and nfc_initiator_target_is_present
  Windows: Fix bug when compiling without libusb: skip usbbus.c
  Windows: Fix compilation due to new usbbus file
  Fix bug when compiling without libusb: skip usbbus.c
  Fix scan-build warning: cast increases required alignment from 1 to 4
  Fix cppcheck warning "Obsolete function 'usleep' called"
  Avoid warning about ignoring return value of 'read'
  Fix cppcheck warning "Non reentrant function 'readdir' called"
  conf.h: make it more standard
  uart_posix.c: remove redundant include
  ...
2013-03-08 23:00:44 +01:00
Philippe Teuwen
3ac1d64b4f Windows: workaround as libusb is not automatically detected by CMake
Fixes issue 238
2013-03-08 08:15:40 +01:00
Philippe Teuwen
5704b668b7 Add usbbus to Makefile.am EXTRA_DIST 2013-03-08 00:35:36 +01:00
Philippe Teuwen
fef6517e27 make style 2013-03-08 00:35:04 +01:00
Philippe Teuwen
37cf7554d9 Add log_posix to Makefile.am 2013-03-08 00:34:14 +01:00
Alex Lian
b3c6ea86ad Split logging internals so that platforms may choose additional or alternate spew mechanisms
In the case of windows, allow for the OutputDebugString call in addition to logging to stderr.
Useful for the dll scenario and debugging in Visual Studio.
2013-03-07 10:36:33 +01:00
Philippe Teuwen
563054d2a2 More explicitely ignoring return value as suggested by Ludovic 2013-03-07 10:34:17 +01:00
Alex Lian
7b917f9a8b Windows: Clean up all compiler warnings and link warnings
- Fixed the suppression of the auto-fixup for linking against MS built libs
- Fixed all the formatting warnings by shifting to inttypes.h specifiers
- shifted to %lu for DWORD printf
2013-03-07 09:37:36 +01:00
Philippe Teuwen
bd961222a3 API change 2013-03-07 09:27:45 +01:00
Philippe Teuwen
d8a93217ff make style 2013-03-07 09:17:27 +01:00
Philippe Teuwen
181cd914d5 pn53x-sam: fix print_nfc_target 2013-03-07 09:17:11 +01:00
Alex Lian
c72846e3c6 Convert by value passing of nfc_target to pointer for str_nfc_target and nfc_initiator_target_is_present
This becomes more consistent with all other pass by pointer of most structures.
Additionally, this should lessen stack memory usage, as building strings with str_nfc_target would push the target (283 bytes) plus then a copy of the info objects (up to 275) onto the stack as it dives into the sprintf functions.

Lastly, this makes my attempt at a .NET wrapper easier, as I can make passing by pointer work, but passing by value seems to bomb on the interop right now.
2013-03-07 09:16:33 +01:00
Philippe Teuwen
a262be5633 Windows: Fix bug when compiling without libusb: skip usbbus.c 2013-03-07 08:09:32 +01:00
Alex Lian
f8d8052866 Windows: Fix compilation due to new usbbus file 2013-03-07 08:05:31 +01:00
Philippe Teuwen
008158090c Fix bug when compiling without libusb: skip usbbus.c 2013-03-07 00:43:35 +01:00
Philippe Teuwen
1c67c3f92a Fix scan-build warning: cast increases required alignment from 1 to 4
acr122_usb.c:562:20: warning: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align]
  uint32_t *pu32 = (uint32_t *)u8;
                   ^~~~~~~~~~~~~~
2013-03-06 23:22:02 +01:00
Philippe Teuwen
048ed88e16 Fix cppcheck warning "Obsolete function 'usleep' called"
It is recommended to use the 'nanosleep' or 'setitimer' function instead.
2013-03-06 21:43:36 +01:00
Philippe Teuwen
fdd5bd3523 Avoid warning about ignoring return value of 'read' 2013-03-06 21:13:39 +01:00
Philippe Teuwen
7fb538737d Fix cppcheck warning "Non reentrant function 'readdir' called"
For threadsafe applications it is recommended to use the reentrant replacement function 'readdir_r'.
2013-03-06 20:59:41 +01:00
Philippe Teuwen
90622f52b7 conf.h: make it more standard 2013-03-06 19:36:32 +01:00
Philippe Teuwen
b81519c6a9 uart_posix.c: remove redundant include 2013-03-06 19:34:57 +01:00
Philippe Teuwen
a0b859b2a1 Fix cppcheck warning "Non reentrant function 'readdir' called"
For threadsafe applications it is recommended to use the reentrant replacement function 'readdir_r'.
2013-03-06 15:20:15 +01:00
Philippe Teuwen
4dafd70b64 Fix cppcheck warning "Statements following return will never be executed" 2013-03-06 12:42:39 +01:00
Philippe Teuwen
1d5f9956fb Fix cppcheck warning "buffer may not be null-terminated after call to strncpy()" 2013-03-06 12:38:59 +01:00
Philippe Teuwen
3e773ab494 Edit HACKING: cppcheck: add --inconclusive 2013-03-06 12:30:10 +01:00
Philippe Teuwen
a3facbdc7d sprint_nfc_target() => snprint_nfc_target()
And all sub-functions in target_subr.c
2013-03-06 12:17:33 +01:00
Philippe Teuwen
658ec4585a Fix cppcheck warning "scanf without field width limits can crash with huge input data" 2013-03-06 11:42:35 +01:00
Philippe Teuwen
f0d5896140 Fix cppcheck style: "The scope of the variable can be reduced" 2013-03-06 11:02:47 +01:00
Philippe Teuwen
0aa1ff309e Fix cppcheck warning "Variable is assigned a value that is never used" 2013-03-06 10:56:12 +01:00
Philippe Teuwen
f152aaffa3 Edit HACKING: cppcheck v1.58 2013-03-06 10:54:54 +01:00
Philippe Teuwen
9632f3ef35 Edit HACKING & introduce cppcheck
Still a few todo according to cppcheck:

[examples/pn53x-tamashell.c:165]:
(style) Found obsolete function 'usleep'. It is recommended that new applications use the 'nanosleep' or 'setitimer' function

[libnfc/buses/uart_posix.c:343]:
(portability) Found non reentrant function 'readdir'. For threadsafe applications it is recommended to use the reentrant replacement function 'readdir_r'

[libnfc/drivers/acr122_pcsc.c:206]:
[libnfc/drivers/acr122_pcsc.c:219]:
[libnfc/drivers/acr122s.c:412]:
[libnfc/drivers/acr122s.c:425]:
[libnfc/drivers/acr122s.c:434]:
[libnfc/drivers/arygon.c:181]:
[libnfc/drivers/arygon.c:194]:
[libnfc/drivers/arygon.c:203]:
[libnfc/drivers/pn532_uart.c:158]:
[libnfc/drivers/pn532_uart.c:171]:
[libnfc/drivers/pn532_uart.c:180]:
(portability) Found non reentrant function 'strtok'. For threadsafe applications it is recommended to use the reentrant replacement function 'strtok_r'
2013-03-06 01:09:57 +01:00
Philippe Teuwen
c37d1742c3 Fix cppcheck style: scope of variable can be reduced
Fix the following cppcheck warnings:
[libnfc/chips/pn53x.c:617]: (style) The scope of the variable 'res' can be reduced
2013-03-06 00:54:49 +01:00
Philippe Teuwen
d577fda412 Fix cppcheck warning "scanf without field width limits can crash with huge input data"
Fix following warnings:
[examples/pn53x-tamashell.c:162]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/acr122_pcsc.c:261]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/acr122s.c:441]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/arygon.c:210]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/arygon.c:522]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/pn532_uart.c:187]: (warning) scanf without field width limits can crash with huge input data
[utils/nfc-relay-picc.c:176]: (warning) scanf without field width limits can crash with huge input data
2013-03-06 00:52:08 +01:00
Philippe Teuwen
4769392157 Fix cppcheck style: scope of variable can be reduced
Fix the following cppcheck warnings:
[libnfc/drivers/pn532_uart.c:492]: (style) The scope of the variable 'res' can be reduced
[libnfc/chips/pn53x.c:320]: (style) The scope of the variable 'res' can be reduced
[libnfc/chips/pn53x.c:616]: (style) The scope of the variable 'res' can be reduced
[libnfc/nfc.c:356]: (style) The scope of the variable '_device_found' can be reduced
[utils/nfc-mfclassic.c:178]: (style) The scope of the variable 'key_index' can be reduced
2013-03-06 00:35:36 +01:00
Philippe Teuwen
3f5a3fd58f nfc-read-forum-tag3 & nfc-relay-picc: remove unused variable
Fix cppcheck warnings
[utils/nfc-read-forum-tag3.c:281]: (style) Variable 'len' is assigned a value that is never used
[utils/nfc-relay-picc.c:392]: (style) Variable 'res' is assigned a value that is never used
2013-03-06 00:30:38 +01:00
Philippe Teuwen
4822bb3e42 Fix bug introduced in some signal traps where context was not declared 2013-03-05 23:58:35 +01:00
Philippe Teuwen
03bc30f116 Fix "Possible null pointer dereference" error 2013-03-05 23:56:38 +01:00
Philippe Teuwen
e55efd6db0 examples/utils: add nfc_exit() to signal traps
and one missing nfc_abort_command()
2013-03-05 22:50:37 +01:00
Philippe Teuwen
73b5c9d0af nfc_init() return rather than exit on malloc error, examples fixed accordingly 2013-03-05 22:24:59 +01:00
Philippe Teuwen
ae6062e5ba nfc_context_new(): replace err() by return, problem still in nfc_init()!!
Not a good idea to call exit() from a library...
Problem is now moved to
void nfc_init() calling exit()
This requires a change in API to return error rather than exiting...
2013-03-05 20:03:19 +01:00
Philippe Teuwen
09ef2e3927 nfc_device_new(): replace err() by return
Not a good idea to call exit() from a library...
2013-03-05 19:58:32 +01:00
Philippe Teuwen
bece73faaf Error conditions in utils & examples: fix leaks, unify style (see details)
* in main():
** errx()/err()/return -> exit()
** return values -> EXIT_SUCCESS & EXIT_FAILURE

* out of main:
** err()/errx()/exit() -> return
** change retval from size_t to int to allow returning errors
** don't use EXIT_SUCCESS / EXIT_FAILURE as retvals

* add nfc_close() & nfc_exit() to exit() on errors
* add missing fclose() on errors
* add missing test if (pnd == NULL)
* unify style if (pnd == / != NULL)
* remove goto's
* few related fixes
* remove if(pnd!=NULL) test on nfc_close() calls
2013-03-05 19:44:59 +01:00
Philippe Teuwen
232930c3d5 Fix resource leaks detected by cppcheck
[examples/pn53x-tamashell.c:94]: (error) Resource leak: input
[utils/nfc-mfultralight.c:264]: (error) Resource leak: pfDump
2013-03-04 01:06:16 +01:00
Ludovic Rousseau
1de1832562 Add lintian options
More options for more warnings or mode details.
2013-03-03 18:49:39 +01:00
Philippe Teuwen
b0f216b3b2 spi driver: remove compilation warnings
spi_posix.c:141:1: warning: no previous prototype for 'bit_reversal' [-Wmissing-prototypes]
=> set bit_reversal() static

pn532_spi.c:258:48: warning: unused parameter 'timeout' [-Wunused-parameter]
=> remove timeout in pn532_spi_read_spi_status() params
2013-03-03 16:24:10 +01:00
Philippe Teuwen
cd98a4ac87 make style 2013-03-03 16:14:58 +01:00
Philippe Teuwen
2ac7963076 Merge branch 'master' into pn532_spi 2013-03-03 16:10:11 +01:00
Philippe Teuwen
9a20430bfc Prepare release 1.7.0 RC6 2013-03-03 15:34:35 +01:00
Philippe Teuwen
d143eba7ad Edit ChangeLog 2013-03-03 01:04:01 +01:00
Philippe Teuwen
b68a37b835 Replace usb_set_debug() in utils by new group in LIBNFC_LOG_LEVEL
To use it: (NFC_LOG_PRIORITY_DEBUG * 2 ^ NFC_LOG_GROUP_LIBUSB)
LIBUSB_LOG_LEVEL=12288
2013-03-02 23:43:37 +01:00
Philippe Teuwen
b1448f6785 nfc-mfclassic: add option to tolerate RW errors & other enhancements
Reconciliate read & write operations.
Add option to tolerate or not RW failures.
Print success/failure for each block as ACL is per block.
2013-03-02 22:29:10 +01:00
Philippe Teuwen
ddd7cabda8 Edit HACKING & introduce clang (thanks Ludovic!) 2013-03-02 19:46:17 +01:00
Philippe Teuwen
2334adc8bd Fix compilation warnings: values never read
Fixes:
pn53x.c:523:11: warning: Value stored to 'pbtRawData' is never read
          pbtRawData += szRawData - 8;
          ^             ~~~~~~~~~~~~~
pn53x.c:544:7: warning: Value stored to 'pbtRawData' is never read
      pbtRawData += 2;
      ^             ~
pn53x.c:532:7: warning: Value stored to 'pbtRawData' is never read
      pbtRawData += 8;
      ^             ~
pn53x.c:3085:3: warning: Value stored to 'buflen' is never read
  buflen -= res;
  ^         ~~~
pn53x.c:3080:3: warning: Value stored to 'buf' is never read
  buf += res;
  ^      ~~~
target-subr.c:466:7: warning: Value stored to 'dst' is never read
      dst += sprintf(dst, "* Unknown card, sorry\n");
      ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:480:3: warning: Value stored to 'dst' is never read
  dst += sprint_hex(dst, nfi.abtSysCode, 2);
  ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:490:3: warning: Value stored to 'dst' is never read
  dst += sprint_hex(dst, nji.btId, 4);
  ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:546:7: warning: Value stored to 'dst' is never read
      dst += sprintf(dst, "\n");
      ^      ~~~~~~~~~~~~~~~~~~
target-subr.c:571:5: warning: Value stored to 'dst' is never read
    dst += sprint_hex(dst, nii.abtAtr, nii.szAtrLen);
    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:580:3: warning: Value stored to 'dst' is never read
  dst += sprint_hex(dst, nsi.abtUID, 8);
  ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:593:3: warning: Value stored to 'dst' is never read
  dst += sprintf(dst, "           Fab Code: %02X\n", nci.btFabCode);
  ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:608:5: warning: Value stored to 'dst' is never read
    dst += sprint_hex(dst, ndi.abtGB, ndi.szGB);
    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-03-02 19:39:20 +01:00
Philippe Teuwen
70b0dffca7 acr122_usb: fix compiler warnings & check return value
acr122_usb.c:570:3: warning: Null pointer passed as an argument to a 'nonnull' parameter
  memcpy(DRIVER_DATA(pnd)->apdu_frame.apdu_payload, data, data_len);
  ^                                                 ~~~~
acr122_usb.c:738:3: warning: Value stored to 'offset' is never read
  offset += len;
  ^         ~~~
acr122_usb.c:753:3: warning: Value stored to 'res' is never read
  res = acr122_usb_bulk_write(DRIVER_DATA(pnd), (unsigned char *) & (DRIVER_DATA(pnd)->tama_frame), res, 1000);
  ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-03-02 19:25:36 +01:00
Ludovic Rousseau
bd8a9fe96e Remove dead code
The local variable bFailure is set before a return.

nfc-mfclassic.c:319:11: warning: Value stored to 'bFailure' is never read
          bFailure = true;
          ^          ~~~~
2013-03-02 13:24:12 +01:00
Philippe Teuwen
f07d784b8b make style 2013-03-02 13:17:57 +01:00
Ludovic Rousseau
999631588d closedir() only if opendir() succeeds
Fix compiler warning:
conf.c:186:3: warning: Null pointer passed as an argument to a 'nonnull' parameter
  closedir(d);
  ^        ~
2013-03-02 13:11:30 +01:00
Ludovic Rousseau
aee56b9255 Initialize variables
Fix compiler warnings and potential bug

pn53x.c:1526:19: warning: The right operand of '<' is a garbage value
    for (i = 0; i < sz; i++) {
                  ^ ~~
pn53x.c:1621:19: warning: The right operand of '<' is a garbage value
    for (i = 0; i < sz; i++) {
                  ^ ~~
2013-03-02 13:09:23 +01:00
Philippe Teuwen
abf54c7598 Debian: remove non-exported symbol 2013-03-02 12:55:43 +01:00
Philippe Teuwen
ae571941c5 usbbus: make usb_initialized static 2013-03-02 12:43:15 +01:00
Philippe Teuwen
1f0b0e5b81 Fix zealous double free 2013-03-02 12:26:24 +01:00
Ludovic Rousseau
e7290de83b Fix compiler warning
nfc.c:121: warning: function declaration isn't a prototype
nfc.c: In function 'nfc_drivers_init':
nfc.c:121: warning: old-style function definition
2013-03-02 11:30:24 +01:00
Romuald Conty
3aadb45988 Ease diff between both libusb based drivers: acr122_usb and pn53x_usb 2013-03-02 10:59:37 +01:00
Philippe Teuwen
b2b1d2a2a2 make style 2013-03-02 02:52:07 +01:00
Philippe Teuwen
a6c405a5d5 malloc/free: some more cleaning & checking malloc errors 2013-03-02 02:51:33 +01:00
Philippe Teuwen
0708279215 malloc/free: some cleaning & checking malloc errors 2013-03-02 02:25:13 +01:00
Philippe Teuwen
35b08dc5cc Add new symbols from usbbus.c 2013-03-02 01:39:59 +01:00
Philippe Teuwen
d7e7abb061 Fix mem leak in config file parser (opendir)
This fixes the following leaks:

==30517== 32,808 bytes in 1 blocks are definitely lost in loss record 11 of 12
==30517==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==30517==    by 0x50F4B2A: __alloc_dir (opendir.c:186)
==30517==    by 0x4E34998: conf_devices_load.constprop.1 (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==30517==    by 0x4E36350: nfc_context_new (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==30517==    by 0x4E34D98: nfc_init (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
2013-03-02 01:21:13 +01:00
Philippe Teuwen
3d9ebb5044 Fix mem leak in config file parser
This fixes the following leaks:

==18690== 256 bytes in 1 blocks are definitely lost in loss record 75 of 100
==18690==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==18690==    by 0x511613F: regcomp (regcomp.c:487)
==18690==    by 0x4E34313: conf_parse_file (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E349F5: conf_devices_load.constprop.1 (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E362C0: nfc_context_new (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E34D08: nfc_init (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==
==18690== 32,068 (224 direct, 31,844 indirect) bytes in 1 blocks are definitely lost in loss record 98 of 100
==18690==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==18690==    by 0x4C28D6F: realloc (vg_replace_malloc.c:632)
==18690==    by 0x5115DF3: re_compile_internal (regcomp.c:760)
==18690==    by 0x51161AB: regcomp (regcomp.c:506)
==18690==    by 0x4E34313: conf_parse_file (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E349F5: conf_devices_load.constprop.1 (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E362C0: nfc_context_new (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E34D08: nfc_init (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
2013-03-02 01:09:47 +01:00
Philippe Teuwen
9dcf7378b6 Fix mem leak with libusb by introducing buses/usbbus.c
Now call only once usb_init(); usb_find_busses(); usb_find_devices()
instead of multiple calls in several scan() then open()

This fixes the following leaks:

==1159== 8 bytes in 1 blocks are definitely lost in loss record 9 of 102
==1159==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==1159==    by 0x53D9931: usb_parse_configuration (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x53DB8B1: usb_os_find_devices (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x53D8FDC: usb_find_devices (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x4E41D79: pn53x_usb_scan (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==1159==
==1159== 8 bytes in 1 blocks are definitely lost in loss record 10 of 102
==1159==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==1159==    by 0x53D9931: usb_parse_configuration (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x53DB8B1: usb_os_find_devices (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x53D8FDC: usb_find_devices (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x4E42CC7: pn53x_usb_open (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==1159==    by 0x4E351E6: nfc_open (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
2013-03-02 01:08:07 +01:00
Romuald Conty
59227c3dd3 Adds missing version.rc.in file in tarball (for Windows users) 2013-03-01 17:11:16 +01:00
Romuald Conty
2506ee35f6 Fixes invalid example in nfc-scan-device manpage 2013-03-01 17:07:40 +01:00
Romuald Conty
3e87abe88a Uses new email for bugs, reports, etc. 2013-03-01 17:07:40 +01:00
Romuald Conty
e070decd3c Updates ChangeLog with recent fixes 2013-03-01 17:07:22 +01:00
Romuald Conty
3dd58e872a Missing release date in ChangeLog 2013-03-01 17:07:22 +01:00
Eugeny Boger
d9fd9155ea Adding a SPI driver for pn532
The driver seems to work well.
I tested it on Linux with i.mx233-based board using hardware SPI.
I tried to modify the build files as well, but it's probably a little messy.
I'm not sure whether it will work on other *nix OSes,
so it's probably better to limit the driver to Linux only using build system.
2013-02-28 23:24:42 +01:00
Philippe Teuwen
a0ebd8ba15 Fix warning in tests: Variable might get clobbered by 'longjmp' or 'vfork' 2013-02-22 22:30:44 +01:00
Philippe Teuwen
7e3549819e Split --disable-conf into --disable-conffiles & --disable-envvars 2013-02-22 21:53:16 +01:00
Ahti Legonkov
fd6d4db5b7 Make it possible to disable conf.
Now the configure script has --disable-conf command-line argument
that can be used to turn off environment variables and use of
configuration files.
2013-02-22 21:09:46 +01:00
Philippe Teuwen
72b10c5d9b Fix warnings: ignoring return value of 'pipe' & discarding const qualifier 2013-02-21 23:20:28 +01:00
Philippe Teuwen
24e1edd858 make style 2013-02-21 22:39:39 +01:00
Philippe Teuwen
5ced93fcbf Makefile.am: move header files from noinst_HEADERS to _SOURCES
Ensures proper recompilation when a header file is edited.
cf https://www.gnu.org/software/automake/manual/html_node/Headers.html
2013-02-21 22:37:20 +01:00
Philippe Teuwen
7af127ac0d pn53x-tamashell: allow larger commands up to full extended frame (264 bytes)
It was arbitrarily limited to MAX_FRAME_LEN-10 probably because of bug in LOG_HEX() fixed in previous commit
2013-02-21 22:36:23 +01:00
Philippe Teuwen
9935095a36 Fix stack smash bug in LOG_HEX() macro
Fixes issue 232
2013-02-21 22:31:19 +01:00
Romuald Conty
7e26869b68 Fixes nfc_drivers memory leak 2013-02-21 19:58:40 +01:00
Romuald Conty
1e16795341 'make style' and align some #preprocessor directives 2013-02-19 00:43:20 +01:00
Romuald Conty
ef5c39bd7b Allow aware developer to change nfc_connstring size
/!\ Warning: be sure what you are doing if you custom this value...
2013-02-19 00:43:20 +01:00
Philippe Teuwen
911bbfa38d Debian: Fix symbols 2013-02-16 22:19:55 +01:00
Philippe Teuwen
09ce0e822c nfc_free(): fix related doc 2013-02-16 22:18:00 +01:00
Romuald Conty
95179e7894 Debian: rc4->rc5 2013-02-16 15:46:44 +01:00
Romuald Conty
fc233c1775 Releases 1.7.0 RC5 2013-02-16 15:29:10 +01:00
Romuald Conty
f8601886fd Adds nfc_free() function to freed allocated buffers
Fixes issue 228 (Thanks to Alex Lian)
2013-02-16 14:20:37 +01:00
Romuald Conty
ffd5928dc6 Adds missing windows files in generated tarball 2013-02-16 14:08:44 +01:00
Romuald Conty
360365ca84 Preserves error code while setting parameters
It now returns a more precise error code while using pn53x_set_property_bool() with NP_AUTO_ISO14443_4 flag.
2013-02-15 09:38:26 +01:00
Romuald Conty
3584338d85 Adds libnfc.conf.sample file to archive 2013-02-14 15:33:47 +01:00
Alex Lian
4487fd768e Windows: Shift files from libnfc/windows to libnfc/contrib/win32
- Fixes the fact files were missed in package
2013-02-14 15:33:47 +01:00
Philippe Teuwen
0203ade66c Debian control: misc:Pre-Depends is only for packages providing a shared library
Fixes warnings:
dpkg-gencontrol: warning: Pre-Depends field of package libnfc-dev: unknown substitution variable ${misc:Pre-Depends}
dpkg-gencontrol: warning: Pre-Depends field of package libnfc4-dbg: unknown substitution variable ${misc:Pre-Depends}
2013-02-06 15:16:40 +01:00
Philippe Teuwen
f961452cf8 Debian: add nfc_register_driver() to symbol list 2013-02-06 15:08:30 +01:00
Philippe Teuwen
43a1e57a62 Add nfc_register_driver() to NEWS & Changelog 2013-02-06 15:08:20 +01:00
Philippe Teuwen
73992041b4 Merge remote-tracking branch 'ahti/issue-137' into master
* ahti/issue-137:
  Add nfc_register_driver.

Fixes issue 225
Helps issue 137
2013-02-06 15:07:18 +01:00
Philippe Teuwen
487c8050ef Debian: rc3->rc4 2013-02-06 15:06:50 +01:00
Ludovic Rousseau
4e89c61813 Use git(1) only if present
The GIT_REVISION is set as the result of 'git describe'.
If git is not installed the old code generated an error:
$ dh_autoreconf -a
sh: 1: git: not found
sh: 1: git: not found

Thanks to Thomas Hood for the bug report
https://groups.google.com/d/msg/nfc-tools-devel/Skd03b1wUcg/xnQThAPXPCYJ
2013-02-05 19:39:45 +01:00
Romuald Conty
c2fe7673dd Releases 1.7.0 RC4 2013-02-04 11:38:57 +01:00
Romuald Conty
d6dce20302 Merge branch 'master' of https://code.google.com/p/libnfc 2013-02-04 10:34:42 +01:00
Nobuhiro Iwamatsu
c980c52aca Update libnfc4.symbols to 1.7.0~rc3
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-02-04 10:33:59 +01:00
Philippe Teuwen
414d00529e debian .gitignore gardening 2013-02-04 10:33:04 +01:00
Romuald Conty
89b177c58a Merge Alex Lian branch 2013-02-04 10:16:32 +01:00
Romuald Conty
d5b6a7c4d1 Resolves conflict between Alex Lian and master branch 2013-02-04 10:14:34 +01:00
Ludovic Rousseau
5753d1e320 Build-Depends: debhelper (>= 9)
debian/compat is set to 9 to use multiarch. We must then depend on the
correct version of debhelper.
2013-02-02 11:51:55 +01:00
Philippe Teuwen
6b140bef11 debian: fix multiarch issues 2013-02-02 11:45:01 +01:00
Philippe Teuwen
4d0ee443d1 Fix crash in nfc-relay-picc -i/-t if fd3 or fd4 is missing 2013-02-01 21:55:29 +01:00
Philippe Teuwen
386e08d8b3 Fix nfc_initiator_select_passive_target() in several utils if tag is missing 2013-02-01 20:52:49 +01:00
Alex Lian
54e0bdb62f Windows: Build updates
- Generate rc files from version.rc.in + CMake variable information in CMakeLists files
- Add step to generate .lib file for windows developers
- Re-structure tool flag usage, apparently ADD_DEFINTIONS adds them to _ALL_ tools. This is bad for rc files with the windres tool.

Needs other platform testing, as the flags have changed to fix Windows rc file generation.
2013-02-01 10:19:02 -05:00
Alex Lian
eddc46fd78 Windows: Update readme for requirement for PCRE 2013-02-01 10:17:20 -05:00
Alex Lian
726f729aba Windows: Update def file for consideration of proper lib file generation
- Aligned to latest nfc.h for function name exports
2013-02-01 10:15:46 -05:00
Alex Lian
cb70044510 Windows: Remove rc files in favor of generated rcs 2013-02-01 10:15:01 -05:00
Alex Lian
a0e6422c5f Windows: Remove old msi package creation
- Utilized only by recently removed Makefile
- Unused
2013-02-01 09:28:34 -05:00
Alex Lian
5a401f42a3 Windows: Remove unused Makefile
Removing in favor of standardizing on CMake usage
2013-02-01 09:27:35 -05:00
Alex Lian
3cd5c71052 Windows: Remove unused header/stub
- Likely from before proper libusb reference
2013-02-01 09:24:48 -05:00
lego
225094e2c8 Add nfc_register_driver. Issue 137.
The nfc_register_driver allows users of the library to write their
own device drivers without needing to resort to hacking libnfc itself.
2013-02-01 14:40:40 +02:00
Romuald Conty
90451a16b9 Merge branch 'master' into alex 2013-02-01 12:46:12 +01:00
Romuald Conty
8127a2ca63 Merge branch 'master' of https://code.google.com/p/libnfc 2013-02-01 11:46:26 +01:00
Romuald Conty
b5f8ce91c7 Uses configurable path for libnfc's configuration files 2013-02-01 11:11:39 +01:00
Romuald Conty
cf9e02879a Enables logging by default when using CMake 2013-02-01 10:32:44 +01:00
Alex Lian
caa09db5fc Merge remote-tracking branch 'refs/remotes/libnfc/master'
Conflicts:
	contrib/windows.h
	libnfc/CMakeLists.txt
	libnfc/log-printf.c
	utils/CMakeLists.txt
2013-01-31 22:17:33 -05:00
Nobuhiro Iwamatsu
50f5c610a1 Add man of nfc-emulate-forum-tag2 to the installation
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-02-01 01:57:47 +01:00
Nobuhiro Iwamatsu
40fadb8d2c Update to 1.7.0~rc3
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-02-01 01:56:41 +01:00
Nobuhiro Iwamatsu
15be4b885c install nfc-emulate-forum-tag2.1 to libnfc-examples
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-02-01 01:56:36 +01:00
Nobuhiro Iwamatsu
cf2c6ef966 Add support libnfc4-dbg package
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-02-01 01:56:31 +01:00
Nobuhiro Iwamatsu
3f6024cd64 Update package description
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-02-01 01:56:11 +01:00
Nobuhiro Iwamatsu
e81aaf5390 Add symbols file for libnfc4
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-02-01 01:54:21 +01:00
Philippe Teuwen
06bfed11b9 Various typos 2013-01-31 21:58:29 +01:00
Romuald Conty
93e26b1475 Releases libnfc 1.7.0 RC3 2013-01-31 17:53:00 +01:00
Philippe Teuwen
fff6a092ab Fix Readme for drivers reqs 2013-01-31 16:44:37 +01:00
Romuald Conty
d26c5b248e Adds windows files to tarball 2013-01-31 16:17:37 +01:00
Romuald Conty
519dd8f8e2 make style 2013-01-31 16:12:14 +01:00
Romuald Conty
acdde1088c Renames contrib/win32/nfc_win32.c to contrib/win32/stdlib.c 2013-01-31 16:09:41 +01:00
Romuald Conty
c01b961be0 Fixes CMake under GNU/Linux 2013-01-31 16:04:47 +01:00
Romuald Conty
3fff5985fc Moves Windows conditional code to dedicated files 2013-01-31 15:58:20 +01:00
Alex Lian
87182b5a65 Windows: Fix nfc-scan-device to compile by linking in contrib/nfc_win32.c
Re-factored the executable call with a list that is created, so that its easier to modify per tool.
2013-01-31 15:52:40 +01:00
Alex Lian
9eeaf33b94 Windows: getopt usage in nfc-read-forum-tag3 fixed by referencing correct header 2013-01-31 15:52:39 +01:00
Alex Lian
3c9d9a872c Fix all utils compilation on windows.
- As nfc-utils now references str_nfc_target from the lib itself, so the static lib was not properly referencing the libnfc itself, so the final utility link would fail.
- Simply added the libnfc as a target for the static nfcutils library internal to cmake
2013-01-31 15:52:39 +01:00
Alex Lian
ef33827f04 Fix setenv/unsetenv link errors by implementing a local version using Windows SetEnvironmentVariable.
Untested, and does not comply with the error returns per setenv.
2013-01-31 15:52:39 +01:00
Alex Lian
9f682cc52b Fix enabling of LIBNFC_DEBUG_OUTPUT
- inclusion of log-printf.c didn't align with needed preprocessor definitions
- Added extra #error as well as preprocessor protection
- fixed CMakeList to specify -DLOG as appropriate per the header log.h usage
2013-01-31 15:52:39 +01:00
Alex Lian
eb90c5a8db Add CMake options for Win32 to require PCRE 2013-01-31 15:52:39 +01:00
Alex Lian
ef82a1e4d4 For Windows MinGW address the "ISO C99 requires rest arguments to be used" error 2013-01-31 15:52:39 +01:00
Philippe Teuwen
8bc7a1c291 call idle() from driver-dependent close() rather than from nfc_close() as some driver still need to do an ack() before 2013-01-31 01:18:23 +01:00
Philippe Teuwen
683505f39b pn53x_idle: call driver-dependent PowerDown & do InRelease first, skip redundant InDeselect 2013-01-31 01:16:37 +01:00
Philippe Teuwen
1682a86166 Add driver-dependent PowerDown 2013-01-31 01:15:03 +01:00
Philippe Teuwen
db8033622a acr122_pcsc: fix log category 2013-01-31 01:08:23 +01:00
Philippe Teuwen
f7010faf18 Changelog 2013-01-31 01:05:28 +01:00
Philippe Teuwen
5446242094 acr122_usb: remove pn53x_idle support. Fixes issue #217 2013-01-30 01:27:18 +01:00
Romuald Conty
a303b9e33c Updates ChangeLog 2013-01-30 01:15:41 +01:00
Romuald Conty
98948172b4 Fixes pn53x_usb timeout while bulk write.
Thanks to Tredger for reporting.

Fixes issue 223.
2013-01-30 00:57:06 +01:00
Romuald Conty
cd2b03a08a Add timeout parameter to nfc_emulate_target() function.
Fixes issue 219.

Thanks to raidolinja.
2013-01-30 00:10:24 +01:00
Philippe Teuwen
b675db73be nfc-scan-device: fix option -i 2013-01-29 13:52:53 +01:00
Romuald Conty
4b97700352 Removes exit() calls
Fixes issue 220

exit() was used to run abort-driven development while API changed, I forgot to remove them, sorry for that :-)
2013-01-28 13:57:40 +01:00
Alex Lian
88fd42a89d Windows: Fix nfc-scan-device to compile by linking in contrib/nfc_win32.c
Re-factored the executable call with a list that is created, so that its easier to modify per tool.
2013-01-27 23:24:03 -05:00
Alex Lian
3c9cfc5036 Windows: getopt usage in nfc-read-forum-tag3 fixed by referencing correct header 2013-01-27 23:22:35 -05:00
Alex Lian
5aab7513cf Fix all utils compilation on windows.
- As nfc-utils now references str_nfc_target from the lib itself, so the static lib was not properly referencing the libnfc itself, so the final utility link would fail.
- Simply added the libnfc as a target for the static nfcutils library internal to cmake
2013-01-27 23:08:22 -05:00
Alex Lian
fa3ca0ab62 Fix setenv/unsetenv link errors by implementing a local version using Windows SetEnvironmentVariable.
Untested, and does not comply with the error returns per setenv.
2013-01-27 22:34:58 -05:00
Alex Lian
1e184f95e4 Fix enabling of LIBNFC_DEBUG_OUTPUT
- inclusion of log-printf.c didn't align with needed preprocessor definitions
- Added extra #error as well as preprocessor protection
- fixed CMakeList to specify -DLOG as appropriate per the header log.h usage
2013-01-27 21:55:34 -05:00
Alex Lian
21302147a9 Add CMake options for Win32 to require PCRE 2013-01-26 18:43:58 -05:00
Alex Lian
ebab43d532 For Windows MinGW address the "ISO C99 requires rest arguments to be used" error 2013-01-26 18:42:56 -05:00
Philippe Teuwen
3d580dc3ec Missing ref to nfc-scan-device.1 in debian/libnfc-bin.install 2013-01-25 16:09:27 +01:00
Ludovic Rousseau
2faa532826 Fix a typo detected by lintian(1)
unkown -> unknown
2013-01-25 14:41:33 +01:00
Nobuhiro Iwamatsu
df51859d74 Add debian's changelog
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Nobuhiro Iwamatsu
2bcca34a59 Add myself to copyright
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Nobuhiro Iwamatsu
8d32b00af2 Change Maintainer filed to myself
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Nobuhiro Iwamatsu
c0b10139e2 Fix package version for debian/changelog
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Nobuhiro Iwamatsu
edf540bb71 Remove *.la from debian/libnfc-dev.install
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Nobuhiro Iwamatsu
103a67fb75 Remove libusb-0.1-4 from Depends
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Nobuhiro Iwamatsu
2db7087041 Add support multiarch
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Nobuhiro Iwamatsu
c8e2d39cbc Update debhelper version to 8
This is not update to 9. Because I think about backport and use in
Squeeze (Debian 6.0).

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Nobuhiro Iwamatsu
09e9a532d9 Enable varbose build log
If we enable varbose build log, hardening checking is easy.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Nobuhiro Iwamatsu
a6301e4310 Update Standards-Version to 3.9.4
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2013-01-25 14:26:49 +01:00
Ludovic Rousseau
109d496222 Compilation: Change the order of arguments
Put the -lnfc at the end of the command lie to avoid undefined
references on Ubuntu 12.04.

Close #219
2013-01-25 14:18:28 +01:00
Philippe Teuwen
5876e33e49 Fix returned value ((res=f()<0)) => ((res=f())<0); this solves a bug in nfc-relay-picc 2013-01-22 00:56:34 +01:00
Philippe Teuwen
0ac3b26982 nfc-relay-picc: Fix received bytes count 2013-01-22 00:54:47 +01:00
Philippe Teuwen
9815ac728f nfc-emulate-uid: fix BCC 2013-01-22 00:45:42 +01:00
Romuald Conty
49d7ce61f3 Debian package uses the default configure script 2013-01-20 17:00:57 +01:00
Romuald Conty
ca7d01ade3 Enables pn532_uart driver by default 2013-01-20 17:00:21 +01:00
Philippe Teuwen
edacadbce6 make style 2013-01-20 15:48:32 +01:00
Philippe Teuwen
ea05559fa5 Prepare for version 1.7.0-RC2 2013-01-20 15:45:57 +01:00
Philippe Teuwen
84af758877 Add /etc/nfc/devices.d/ example in NEWS 2013-01-20 15:41:53 +01:00
Philippe Teuwen
532b30a2cd Merge branch 'test_user_defined_device_optional'
* test_user_defined_device_optional:
  Fix double malloc
  Allow device.optional=true to tolerate missing device
2013-01-20 15:36:29 +01:00
Philippe Teuwen
bcd53a7cdc Fix double malloc 2013-01-20 15:24:03 +01:00
Philippe Teuwen
4576bad369 Fix ISO14443B' ATS broken by updated API 2013-01-19 00:14:19 +01:00
Philippe Teuwen
04a7d2a3ba Allow device.optional=true to tolerate missing device 2013-01-18 22:54:44 +01:00
Philippe Teuwen
24fed18590 Require cutter >=1.1.7 rather than >=1.1.8 2013-01-18 22:48:24 +01:00
Romuald Conty
2d53208082 Fix unit tests
This commit bring tests to life!

New issue
Summary: test_dep_states test fails
When first device is idle, the second one states  "RF Transmission Error" instead of simply not found any available device.
Full cutter log here:

debug   libnfc.chip.pn53x       InJumpForDEP
debug   libnfc.chip.pn53x       Timeout values: 300
debug   libnfc.bus.uart TX: 00  00  ff  05  fb  d4  56  00  00  00  d6  00
debug   libnfc.bus.uart RX: 00  00  ff  00  ff  00
debug   libnfc.chip.pn53x       PN53x ACKed
debug   libnfc.bus.uart Timeout!
debug   libnfc.chip.pn53x       InJumpForDEP
debug   libnfc.chip.pn53x       Timeout values: 300
debug   libnfc.bus.uart TX: 00  00  ff  05  fb  d4  56  00  00  00  d6  00
debug   libnfc.bus.uart RX: 00  00  ff  00  ff  00
debug   libnfc.chip.pn53x       PN53x ACKed
debug   libnfc.bus.uart RX: 00  00  ff  03  fd
debug   libnfc.bus.uart RX: d5  57
debug   libnfc.bus.uart RX: 01
debug   libnfc.bus.uart RX: d3  00
debug   libnfc.chip.pn53x       Chip error: "Timeout" (01), returned error: "RF Transmission Error" (-20))
F
===============================================================================
Failure: test_dep_states
Problem with nfc_idle
<0 == res>
expected: <0>
  actual: <-20>

diff:
? -20

./test_device_modes_as_dep.c:171: initiator_thread(): cut_assert_equal_int(0, res, cut_test_context_set_current_result_user_message( cut_test_context_current_peek(), cut_test_context_take_printf(cut_test_context_current_peek(), "Problem with nfc_idle")))
===============================================================================
2013-01-18 18:28:45 +01:00
Romuald Conty
443f70dd65 Fix wrong condition to display a warning when user disables autoscan 2013-01-18 18:14:59 +01:00
Romuald Conty
cbdac66fa4 Add quick start examples compliation to "make check" 2013-01-18 16:05:43 +01:00
Romuald Conty
9a3a43cdba Ignore generated files into test/ directory 2013-01-18 14:36:35 +01:00
Philippe Teuwen
2fbf5ab741 Fix debian/control for new API version libnfc3->libnfc4 2013-01-16 08:16:10 +01:00
Romuald Conty
085fb60777 Fix version fetch using make_release.sh 2013-01-15 18:16:56 +01:00
Romuald Conty
6b5cd55fbf Always add newer files when releasing 2013-01-15 14:28:34 +01:00
Romuald Conty
f2be582cd5 Fix timeout documentation 2013-01-15 14:22:21 +01:00
Romuald Conty
5d45718fe1 Fix Debian package for 1.7.0-RC1 2013-01-15 14:21:19 +01:00
Romuald Conty
945e1d140d Bump API version 2013-01-15 13:45:48 +01:00
Romuald Conty
50401c5bf6 Fix CMake build 2013-01-15 13:45:28 +01:00
Philippe Teuwen
0458c8e24e debian/rules: don't enable debug by default anymore as it can be done easily at runtime with LIBNFC_LOG_LEVEL 2013-01-10 23:57:12 +01:00
Romuald Conty
ff3d8f708d Debian package update 2012-12-23 20:09:26 +01:00
Romuald Conty
de62e4c011 Prepare 1.7.0 release candidate 1 2012-12-23 20:04:34 +01:00
Romuald Conty
82c41b4fc1 Fixes style: make style 2012-12-09 20:09:55 +01:00
Romuald Conty
007b78cbb4 Uses less ambiguous include when compiles for Windows platform 2012-12-09 19:27:46 +01:00
Romuald Conty
8d9d6a5696 Add ttyAMA* to radix list from UART scanning
It allows a PN532 UART connected on raspberry pi to be detected when intrusive scan allowed (e.g. with nfc-scan-device -i)
2012-12-09 19:10:35 +01:00
Romuald Conty
484dd5dfa5 Improves mingw-cross-configure.sh script using patch provided by Frank Morgner, thanks! 2012-12-05 18:27:40 +01:00
Romuald Conty
0af58b1cdd Attempt to build libnfc under for Windows target.
This commit fixes some issues related to the new log system, but libnfc can not build on Windows in this stage since regex.h have been introduced for configuration file parsing and regex.h is not available in Windows.

New issue
Summary: Update Windows port
Due to the recent configuration file parsing introduction, libnfc can not be built under Windows: regex.h is missing.
Google says there is a port of PCRE for Windows which contains a compiliant regex.h.
Contribution are welcome as nobody from currently active team use Windows as OS.
2012-12-05 18:22:27 +01:00
Romuald Conty
8f015c4369 Suppress warnings: "ISO C99 requires rest arguments to be used" 2012-12-05 16:53:43 +01:00
Romuald Conty
08f428fbdf Fix CMake build. 2012-12-05 16:47:08 +01:00
Romuald Conty
53349c8c20 Prevent from segfault if user add too many devices in configuration file(s) 2012-12-05 16:41:44 +01:00
Romuald Conty
a3a3fa2848 Enhance messages display 2012-12-05 16:40:52 +01:00
Romuald Conty
995368cffa Update quick_start_examples 2012-12-05 02:05:16 +01:00
Philippe Teuwen
6be0b2396c Fix typos 2012-12-05 01:32:45 +01:00
Romuald Conty
5b0e276572 Examples and utils are now updated to use the requiered nfc_context 2012-12-05 00:51:13 +01:00
Romuald Conty
dc949c257e Removes nfc_get_default_device() function.
The nfc_get_default_device() is not needed anymore since the first element from returned nfc_connstring list of nfc_list_devices() function.
Plus, nfc_open() can be use with NULL nfc_connstring which will select automatically the first available device (ie. the default one).
2012-12-05 00:51:13 +01:00
Romuald Conty
03e5611d14 New feature: search in a directory for devices configuration files. 2012-12-05 00:51:13 +01:00
Romuald Conty
84dc268781 New feature: user can define a device by conf file. 2012-12-05 00:51:13 +01:00
Romuald Conty
0fd3c9fab3 Provides modprobe configuration file and instructions for PN533 and Linux >3.1 users. 2012-12-05 00:51:13 +01:00
Philippe Teuwen
cf6d843c18 Fix pseudo-logging API when no logging is used 2012-12-04 19:14:37 +01:00
Philippe Teuwen
2651cdce2e Remove last SVN cruft 2012-11-27 18:56:54 +01:00
Philippe Teuwen
ac1d05328b update NEWS to reflect API change for nfc_initiator_transceive_*() 2012-11-27 18:50:00 +01:00
Romuald Conty
9b3947b8ed Improves log feature:
* Add --disable-log
  * Add a log level filter, configurable using conf file (ie. /etc/nfc/libnfc.conf) or environment var LIBNFC_LOG_LEVEL
2012-11-26 21:02:03 +01:00
Romuald Conty
d6c879083c git ignore more generated files. 2012-11-24 20:14:09 +01:00
Romuald Conty
4722b7dd97 SVN_REVISION is not relevant anymore, use GIT_REVISION (git describe) instead. 2012-11-24 20:11:12 +01:00
Romuald Conty
7963fdfc3b Import code to load configuration from file.
WARNING: This commit do not contains a fully cleaned code:
 - Only nfc-list have been tested
 - Some -commented- code is not used ATM
 - Some printf-as-debug remain in this commit
... but that a bit usable so... happy hacking ;-)
2012-11-24 13:10:52 +01:00
Romuald Conty
3ee77eb79e Fix *transceive*() calls from examples and utils (bug introduced in previous commit) 2012-11-24 13:00:23 +01:00
Romuald Conty
6650105174 Add some functions parameters documentation. 2012-11-23 16:58:10 +01:00
Romuald Conty
c239873634 Add missing NFC_EMFCAUTHFAIL error string. 2012-11-23 16:55:45 +01:00
Romuald Conty
dd451da4a5 Change *transceive*() API to be closer to *transceive_bytes.
Warning: only prototypes have been changed, implementation does not take care about buffer size.

New issue
Summary: Implement buffer overflow protection on all *transceive*() functions
*transceive*() functions do have an argument for rx buffer but some of them dont use it to protect user from buffer overflow.
2012-11-23 16:54:38 +01:00
Philippe Teuwen
7437f76007 simplify quick_start_example1 and add quick_start_example2 2012-11-16 12:25:27 +01:00
Philippe Teuwen
fda8d60ce0 Adapt *transmit_bytes_timed API to be closer to *transmit_bytes 2012-11-12 16:54:03 +01:00
Philippe Teuwen
6c7c0a6e63 ReadMobib: make it compatible with Basic card 2012-11-10 17:11:48 +01:00
Romuald Conty
9f90a04a84 nfc_initiator_transceive_bytes() returns NFC_EMFCAUTHFAIL when AUTH command failed on a Mifare Classic 2012-11-01 01:27:06 +01:00
Romuald Conty
3629219a3b Caller expect nfc_initiator_deselect_target() to be 0 on success. (Fixes Issue 209)
Thanks to Frank Morgner.
2012-10-30 23:22:22 +01:00
Romuald Conty
e4ebfccc54 Debian package: nfc-probe have been renamed, nfc-read-forum-tag3 man page added (Fixes Issue 210).
Thanks to UNFORGiVEN512.
2012-10-30 23:11:34 +01:00
Romuald Conty
bbf0d819f6 Debian package: remove invalid email address 2012-10-30 23:09:55 +01:00
Romuald Conty
86b49d14ea Ignore generated files in Git repo 2012-10-30 23:09:04 +01:00
Romuald Conty
56f9de23be Autotools now distributes nfc-read-forum-tag3 man page in tarball 2012-10-30 22:59:43 +01:00
Romuald Conty
d6c97cb974 Fixes CMake build (Fixes Issue 211).
Thanks to Alex Lian
2012-10-30 22:29:13 +01:00
Romuald Conty
f1b55b5390 debian/rules: no more --enable-serial-probe option 2012-10-21 14:12:14 +00:00
Romuald Conty
bed1d4ba5e Add -i option to nfc-scan-device to allow intrusive scan and add a manpage for this util. 2012-10-21 14:12:04 +00:00
Romuald Conty
397222c33f Removes --enable-serial-autoprobe option at compile and replace this feature by LIBNFC_INTRUSIVE_SCAN environment variable at run time. 2012-10-21 14:11:38 +00:00
Romuald Conty
b5aa91fd62 Use a more appropriated term regarding device detection: from probe to scan
- Rename nfc-probe to nfc-scan-device
 - Rename internal drivers function prototypes: _probe to _scan
 - Revamp _scan function prototype: it now returns device found count
2012-10-21 14:11:17 +00:00
Romuald Conty
6bc9d64fbb Remove unused prototypes in drivers/*.h 2012-10-21 14:10:43 +00:00
Romuald Conty
9afa3c6598 Use copyright format recommended by GNU project.
http://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html
2012-10-21 14:09:16 +00:00
Romuald Conty
6fd29775b2 acr122_usb: Fix compilation and length offset (bug introduced in r1461) 2012-10-04 15:28:30 +00:00
Romuald Conty
2078135c07 README: Add few words about device permissions and udev/devd rules available in package. 2012-10-04 10:12:53 +00:00
Romuald Conty
b27f8634d6 acr122_usb: Fixes CCID reply decoding. 2012-10-04 09:35:47 +00:00
Romuald Conty
26dabba7ac Add Touchatag support for experimental acr122_usb driver; Thanks to Gregoire Sage for its contribution. (Fixes Issue 201) 2012-10-03 16:21:11 +00:00
Romuald Conty
88a57a50b3 Fix error code when no reply is not ISO14443B2CT compliant 2012-10-03 16:21:02 +00:00
Romuald Conty
91ce008d62 Removes a FIXME: not relevant anymore 2012-10-03 16:20:50 +00:00
Philippe Teuwen
2a1558fb32 Deleting manpage present already twice 2012-09-28 09:16:30 +00:00
Romuald Conty
1f0ec1b43a Remove unused macro. (Fixes Issue 192) 2012-09-27 07:36:02 +00:00
Romuald Conty
921d64dadc Support FTDI dongle under MacOS 2012-09-27 07:35:55 +00:00
Philippe Teuwen
6e7fdb1c80 Adds nfc-emulate-forum-tag2 man page 2012-09-19 10:25:33 +00:00
Romuald Conty
310d7eba07 New str_nfc_target() function in API.
This allow to convert a nfc_target struct into allocated string.
2012-09-17 13:47:54 +00:00
Romuald Conty
82e3416619 minor header clean up 2012-09-17 13:47:43 +00:00
Romuald Conty
de827ab583 nfc_device_get_information_about() now allocates returned string.
Note: must be freed by free().
2012-09-17 13:47:30 +00:00
Romuald Conty
2aba0f962a documentation: add missing group description 2012-09-17 13:47:18 +00:00
Romuald Conty
3cd6015c81 minor header cleanup 2012-09-17 13:47:11 +00:00
Ludovic Rousseau
4288cd3c33 Add example path so that doxygen can find the file 2012-09-14 20:08:01 +00:00
Ludovic Rousseau
e40d857ac5 Touchatag PC/SC reader name has changed
CCID driver version >= 1.4.6 has changed the order of the readers.
Unfortunately the Touchatag reader uses the exact same PID (USB Product
ID) as many other ACS readers:
#0x072F:0x90CC:ACS ACR122U (ACR122U.txt)
#0x072F:0x90CC:ACS ACR 38U-CCID (ACR38U-CCID.txt)
#0x072F:0x90CC:ACS ACR100 (ACS_ACR100.txt)
#0x072F:0x90CC:ACS ACR38 plugin (ACS_ACR38_plugin.txt)
#0x072F:0x90CC:ACS AET65 (ACS_AET65.txt)

And the name for the device 0x072F:0x90CC is now "ACS AET65"

Fixes bug #202
2012-07-31 08:45:14 +00:00
Philippe Teuwen
c87eab4958 Add support for OpenPCD2 2012-07-01 11:22:45 +00:00
Philippe Teuwen
86e92fd2a0 Tolerate older autotools version 2012-06-28 23:11:02 +00:00
Romuald Conty
9f38ae715d pn53x: allow more delay for Card Presence command (tested on PN533 and PN532 in various contexts). 2012-06-12 16:51:47 +00:00
Romuald Conty
ab312299d6 pn53x_reset_settings() now resets CRC, parity, easyframing and crypto1.
These settings are quite specifics and should be reset in other functions that call pn53x_reset_settings() too: i.e. nfc_initiator_init_secure_element()
2012-06-12 16:46:20 +00:00
Philippe Teuwen
4b5b45f14a Add "usb" keyword support to connstring to specify all usb drivers at once 2012-06-06 01:10:05 +00:00
Romuald Conty
b4ef1a3a5d New nfc_initiator_init_secure_element() function to set SAM as wired card (only relevant with a PN532 SAM-equipped) 2012-06-04 00:16:28 +00:00
Romuald Conty
6f10d6e321 pn53x: return all errors when NP_ACTIVATE_FIELD failed 2012-06-04 00:16:17 +00:00
Romuald Conty
f47af31fb7 Indent correctly previous commit (make style) 2012-06-03 21:05:26 +00:00
Romuald Conty
ce443d50ca Rename abtUid from struct mifare_param_auth into abtAuthUid: this is not the UID while using 7-bytes UID MIFARE Classic tags. 2012-06-03 21:02:54 +00:00
Romuald Conty
c973800164 nfc_device_target_is_present() checks if passed target if the current target before sending Card Presence command 2012-06-03 21:02:47 +00:00
Romuald Conty
2b81baa14f Add documentation related to previous commit (NFC_ETGRELEASED on MFC AUTH failure) 2012-06-03 21:02:38 +00:00
Romuald Conty
b7a74931f6 Returns a NFC_ETGRELEASED error when MIFARE Classic's authentication failed (instead of NFC_ECHIP): a MIFARE Classic is halted on AUTH command failure. 2012-06-03 21:02:31 +00:00
Romuald Conty
c7820c6a77 Log an error when user-Rx buffer is too sort to gain data 2012-06-03 21:02:23 +00:00
Romuald Conty
62c4ffd0b7 Raises up default timeout from 250 to 350ms
PN53x sometimes needs more time to compute usual command (ie. with Diagnose/Card Presence when card become unreachable)
2012-05-30 23:02:56 +00:00
Romuald Conty
13e1e054c2 Minor code fix. 2012-05-30 23:02:48 +00:00
Romuald Conty
d7e7979580 Listing passive targets now quit earlier if szTargets count is reached and in that case, leave with the latest tag selected.
That's quite useful when you need to directly use 1 target because in contrast of nfc_initiator_select_passive_target, you don't need to prepare initiator data by hands
2012-05-30 23:02:41 +00:00
Romuald Conty
b5c634cb07 drivers/pn53x_usb: use default timeout command instead of infinite 2012-05-30 23:02:34 +00:00
Ludovic Rousseau
4a52c2ccd1 Add URL for "Vim: How to prevent trailing whitespaces" 2012-05-29 16:02:58 +00:00
Philippe Teuwen
723e2860ae Adding make style 2012-05-29 15:56:02 +00:00
Philippe Teuwen
568317929d astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper --unpad-paren --pad-header --align-pointer=name 2012-05-29 15:55:35 +00:00
Philippe Teuwen
01303fab0d astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper --unpad-paren --pad-header 2012-05-29 15:54:36 +00:00
Philippe Teuwen
562205cc14 astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper 2012-05-29 15:54:00 +00:00
Philippe Teuwen
67522bae65 astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux 2012-05-29 15:53:43 +00:00
Philippe Teuwen
a2cd236441 astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 2012-05-29 15:52:51 +00:00
Philippe Teuwen
26569c2202 Indent manually some comments to prepare astyle 2012-05-29 15:52:29 +00:00
Philippe Teuwen
7da28b87d2 HACKING: document EOL cleaning, thanks Ludovic 2012-05-29 07:59:04 +00:00
Romuald Conty
26865bbc19 Remove extra whitespaces/tabs before EOL.
find . -name '*.[ch]' | xargs perl -pi -e 's/\t+$//; s/ +$//'

Thanks to Ludovic.
2012-05-29 00:33:22 +00:00
Romuald Conty
167238c60d Fix uninitialized variable szTargetsData 2012-05-27 23:25:52 +00:00
Romuald Conty
8f08431ddf New function nfc_initiator_target_is_present() to test is a previously selected target is in the field. 2012-05-27 22:34:21 +00:00
Romuald Conty
2c9275adde nfc_initiator_transceive_bytes() now take a constant size for Rx buffer to have a cleaner API: no more in/out parameters 2012-05-27 21:06:22 +00:00
Ludovic Rousseau
f0e85c027a ./configure shall be re-run to take any CFLAGS changes 2012-05-24 13:33:54 +00:00
Philippe Teuwen
dd12a4dd87 drivers/acr122_pcsc: allow LIBNFC_DEFAULT_DEVICE=acr122_pcsc:N where N is the Nth device accepted by the driver 2012-05-22 23:49:32 +00:00
Philippe Teuwen
912e32ecab Adding HACKING file, draft to be continued 2012-05-22 20:20:53 +00:00
Philippe Teuwen
47e90ee510 drivers/acr122_pcsc: allow LIBNFC_DEFAULT_DEVICE=acr122_pcsc 2012-05-22 17:25:48 +00:00
Ludovic Rousseau
56e44670a5 Log the device name if the open fails 2012-05-22 09:50:12 +00:00
Ludovic Rousseau
b237213f75 Log an error message if opening a device fails 2012-05-22 09:48:43 +00:00
Ludovic Rousseau
5a529ce30d Fix Debian lintian warning
W: libnfc2: package-name-doesnt-match-sonames libnfc3
2012-05-21 14:38:37 +00:00
Ludovic Rousseau
b41c063d4a Fix Debian lintian warning
P: libnfc source: unversioned-copyright-format-uri http://dep.debian.net/deps/dep5
N: 
N:    Format URI of the machine-readable copyright file is not versioned.
N:    
N:    Please use
N:    http://www.debian.org/doc/packaging-manuals/copyright-format/<version>/
N:    as the format URI instead.
2012-05-21 14:33:32 +00:00
Ludovic Rousseau
9deb6a7c6e Fix Debian lintian warning
W: libnfc source: brace-expansion-in-debhelper-config-file debian/libnfc-dev.install
N: 
N:    This debhelper config file appears to use shell brace expansion (such as
N:    {foo,bar}) to specify files. This happens to work due to an accident of
N:    implementation but is not a supported feature. Only ?, *, and [...] are
N:    supported.
2012-05-21 14:12:27 +00:00
Ludovic Rousseau
476eab10a1 Fix Debian lintian warning
I: libnfc source: binary-control-field-duplicates-source field "section" in package libnfc2
2012-05-21 14:10:16 +00:00
Romuald Conty
531702a1fc example/pn532-sam: Fix few bugs in SAM example
- Fix choice input (Dual card mode was not available);
 - Fix segfault when target selection returns no target;
 - Use error label to close the device before exiting;
2012-05-20 23:09:21 +00:00
Philippe Teuwen
ff87cf62b1 Fix segfault in pn53x_initiator_transceive_bytes when pszRx in NULL
Cause was "return *pszRx"
Segfault occured when listing a typeB'
2012-05-18 21:54:55 +00:00
Philippe Teuwen
969102c1a0 utils/nfc-list: always display the card type when a card is found 2012-05-18 21:54:45 +00:00
Ludovic Rousseau
4e5c60411f warning: 'libnfc.la': linking libtool libraries using a non-POSIX
archiver requires 'AM_PROG_AR' in 'configure.ac'
2012-05-18 07:42:25 +00:00
Ludovic Rousseau
beab815ecb warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS') 2012-05-18 07:40:41 +00:00
Ludovic Rousseau
48016fa297 warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS') 2012-05-18 07:38:42 +00:00
Ludovic Rousseau
db2173efdf configure.ac:84: warning: The macro `AC_HELP_STRING' is obsolete.
The new name is AS_HELP_STRING (available since Autoconf 2.58)
2012-05-18 07:33:30 +00:00
Ludovic Rousseau
6d45c804bb Updated by autoupdate 2.69 2012-05-18 07:30:39 +00:00
Philippe Teuwen
4bfd6ac874 fix disruptancies between tools location in src (utils<>examples) and in Debian packages (libnfc-bin<>libnfc-examples) 2012-05-17 19:22:25 +00:00
Ludovic Rousseau
2c5bac191f Remove useless pointer cast 2012-05-17 07:17:10 +00:00
Ludovic Rousseau
551512ad54 Do not cast pointers to different size integers
It will work only on little endian machines.

Fix clang warning
pn53x-tamashell.c:163:40: warning: cast from 'uint8_t *' (aka 'unsigned char *')
      to 'unsigned int *' increases required alignment from 1 to 4
      [-Wcast-align]
      size = sscanf(cmd+offset, "%2x", (unsigned int*)&byte);
                                       ^~~~~~~~~~~~~~~~~~~~
2012-05-17 07:16:02 +00:00
Romuald Conty
cfd95bae2c Fix shadowed declaration warnings 2012-05-17 01:18:24 +00:00
Romuald Conty
e4802de965 Add new public functions to grab information in string format:
- New nfc_device_get_information_about()
 - Moved nfc-utils function str_nfc_baud_rate()
 - New str_nfc_modulation_type()
 - Add new device_get_information_about callback to nfc_driver struct
 - Export new symbols
 - Changed internal pn53x firmware text handling: we now store firmware text for further operations
 - print_nfc_target() now uses str_nfc_* functions
 - nfc-probe util now have a verbose which display information on detected devices (Fix verbose set but not used warning ;-) )
2012-05-17 00:48:47 +00:00
Romuald Conty
6710ca943e Fix ACR122S device detection when no ACR122S device available (endless UART receive) 2012-05-17 00:38:54 +00:00
Romuald Conty
fb50e3b235 Display right driver name while detecting PCSC 2012-05-17 00:37:00 +00:00
Ludovic Rousseau
d98b5d00ab Fix the fix in revision r1322
clang warning:
arygon.c:115:118: warning: data argument not used by format string
      [-Wformat-extra-args]
  ..."%s", "Trying to find ARYGON device on serial port: %s at %d bauds.", acPort,...
     ~~~~                                                                  ^
1 warning generated.
2012-05-16 19:13:16 +00:00
Ludovic Rousseau
cf56496ee9 Fix compiler warning
pn53x-sam.c:120: warning: enumeration value ‘PSM_NORMAL’ not handled in
switch
2012-05-16 19:06:42 +00:00
Romuald Conty
45ef3b43c4 Fix unused result warnings and add a new NFC_ESOFT error. 2012-05-16 18:24:16 +00:00
Romuald Conty
bfcdb1bd4c Fix more warnings while using -Wswitch-enum and -Wshadow on internal libnfc files 2012-05-16 18:08:42 +00:00
Romuald Conty
d6a1249469 current debian package can compile all drivers except acr122_pcsc (PCSC dependencies have already been removed from package) 2012-05-16 18:06:27 +00:00
Romuald Conty
9ea7a9ea27 delete unused log4crc file 2012-05-16 18:02:51 +00:00
Romuald Conty
05acb85372 Use explicit case instead of default in switch()
- Fix warnings while using -Wswitch-enum
 - Fix two minor bugs due to a bad case handle
2012-05-16 17:51:34 +00:00
Romuald Conty
10f24d97aa Any successfull PowerDown command have to change local power mode state 2012-05-16 16:48:06 +00:00
Ludovic Rousseau
782b72e29f Correctly handle PCSC header files on Mac OS X
Fixes Issue #195
2012-05-16 13:34:21 +00:00
Ludovic Rousseau
3737481262 Correctly use the log_put() format
Fix compiler warning:
warning: format not a string literal and no format arguments
2012-05-16 13:17:52 +00:00
Ludovic Rousseau
eb1e6d0cb4 Check log_put() printf-like format
Thanks to Romain Tartière for the patch
http://groups.google.com/group/libnfc-devel/browse_thread/thread/da352d67e6965851
2012-05-16 13:15:34 +00:00
Ludovic Rousseau
d28889c696 Remove now useless #define for getline()
getline() is no more used. So no need to use this ugly hack.

This also solves a compiler warning;
In file included from ../libnfc/log.h:22:0,
                 from ../libnfc/chips/pn53x-internal.h:28,
                 from ../libnfc/chips/pn53x.h:31,
                 from pn53x-tamashell.c:68:
../config.h:153:0: warning: "_XOPEN_SOURCE" redefined [enabled by default]
/usr/include/features.h:165:0: note: this is the location of the previous definition
2012-05-15 07:57:37 +00:00
Romuald Conty
7b82a98b72 Improve acr122_usb frame building and add links to documentations 2012-05-15 07:27:28 +00:00
Philippe Teuwen
028db71d79 utils/nfc-emulate-forum-tag4: add support for v2.0 of the spec 2012-05-14 22:13:19 +00:00
Romuald Conty
a56e5f9cd7 Fix nfc-emulation, now works with utils/nfc-emulate-forum-tag4 and Nexus S 2012-05-14 21:20:26 +00:00
Romuald Conty
9383fa66bf Fix emulation based on nfc-emulation.c 2012-05-14 20:47:41 +00:00
Romuald Conty
769fc63bb0 Fix acr122_pcsc driver name. 2012-05-14 20:40:19 +00:00
Philippe Teuwen
7597055f26 fix typos 2012-05-14 19:44:03 +00:00
Romain Tartiere
e9b2f5729c Fix a bunch of warnings. 2012-05-14 13:47:31 +00:00
Romain Tartiere
2256d5d3dc Fix usage of possibly uninitialized 'result'.
Can't tell how gcc/clang fail to detect this…
2012-05-14 12:50:04 +00:00
Ludovic Rousseau
dfcabf71f0 Fix compiler warning
uart_posix.c:55:1: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
2012-05-14 09:23:18 +00:00
Ludovic Rousseau
1ac1196af6 MIN/MAX are already defined in nfc-utils.h and nfc-internal.h 2012-05-13 19:16:52 +00:00
Ludovic Rousseau
59d47bc7da Add MIN/MAX declarations in nfc-internal.h and nfc-utils.h
Remove the now useless #include <sys/param.h>
2012-05-13 19:15:44 +00:00
Ludovic Rousseau
a14ec0cbaa Fix compiler warnings:
In file included from nfc-internal.c:26:
nfc-internal.h:111:5: warning: "_BYTE_ORDER" is not defined
nfc-internal.h:111:20: warning: "_LITTLE_ENDIAN" is not defined
2012-05-13 15:11:28 +00:00
Ludovic Rousseau
b9e5e96e49 Use "const char *" instead of "char *" for the strings passed to
log_put()

It does not solve any bug but will allow to detect some by the compiler
2012-05-13 14:58:44 +00:00
Ludovic Rousseau
3e678822ce Fix compiler warnings
pn532_uart.c:151: warning: no previous prototype for ‘pn532_connstring_decode’
pn532_uart.c:491: warning: no previous prototype for ‘pn532_uart_abort_command’
2012-05-13 14:51:18 +00:00
Ludovic Rousseau
56f3baf7a9 Fix compiler warnings
pn53x_usb.c:94: warning: no previous prototype for ‘pn53x_usb_bulk_read’
pn53x_usb.c:107: warning: no previous prototype for ‘pn53x_usb_bulk_write’
pn53x_usb.c:139: warning: no previous prototype for ‘pn53x_usb_get_device_model’
pn53x_usb.c:154: warning: no previous prototype for ‘pn53x_usb_get_end_points’
pn53x_usb.c:259: warning: no previous prototype for ‘pn53x_usb_connstring_decode’
pn53x_usb.c:713: warning: no previous prototype for ‘pn53x_usb_set_property_bool’
pn53x_usb.c:742: warning: no previous prototype for ‘pn53x_usb_abort_command’
2012-05-13 14:50:18 +00:00
Ludovic Rousseau
324776353a Fix compiler warnings
arygon.c:174: warning: no previous prototype for ‘arygon_connstring_decode’
arygon.c:360: warning: no previous prototype for ‘arygon_abort’
arygon.c:545: warning: no previous prototype for ‘arygon_abort_command’
2012-05-13 14:48:08 +00:00
Ludovic Rousseau
55322ad802 Fix compiler warnings
acr122s.c:422: warning: no previous prototype for ‘acr122s_connstring_decode’
acr122s.c:703: warning: no previous prototype for ‘acr122s_abort_command’
2012-05-13 14:47:10 +00:00
Ludovic Rousseau
054dc9b7ca Declare internal functions as static
Fixes compiler warnings:
acr122_usb.c:90: warning: no previous prototype for ‘acr122_usb_bulk_read’
acr122_usb.c:107: warning: no previous prototype for ‘acr122_usb_bulk_write’
acr122_usb.c:140: warning: no previous prototype for ‘acr122_usb_get_device_model’
acr122_usb.c:155: warning: no previous prototype for ‘acr122_usb_get_end_points’
acr122_usb.c:252: warning: no previous prototype for ‘acr122_usb_connstring_decode’
acr122_usb.c:306: warning: no previous prototype for ‘acr122_usb_open’
acr122_usb.c:428: warning: no previous prototype for ‘acr122_usb_close’
acr122_usb.c:497: warning: no previous prototype for ‘acr122_build_frame’
acr122_usb.c:660: warning: no previous prototype for ‘acr122_usb_abort_command’
2012-05-13 14:23:44 +00:00
Ludovic Rousseau
a2b022609f Fix some spelling mistakes
Closes Issue #196
2012-05-13 13:10:15 +00:00
Ludovic Rousseau
02cf0b3d60 Fix compiler warning
nfc-list.c:64: warning: no previous prototype for ‘print_usage’
2012-05-13 13:03:47 +00:00
Ludovic Rousseau
55ef86da33 Add a missing #include and fix a compiler warning
iso14443-subr.c:99: warning: no previous prototype for ‘iso14443_cascade_uid’
2012-05-13 13:02:37 +00:00
Ludovic Rousseau
2677dfb161 Add a missing #include and fix a compiler warning
nfc-internal.c:29: warning: no previous prototype for ‘prepare_initiator_data’
2012-05-13 13:01:06 +00:00
Ludovic Rousseau
e80d545b38 Fix compiler warning
mirror-subr.c:64: warning: no previous prototype for ‘mirror_bytes’
2012-05-13 12:58:44 +00:00
Ludovic Rousseau
2e075df1a9 Fix compiler warnings
nfc-emulate-forum-tag4.c:117: warning: no previous prototype for ‘nfcforum_tag4_io’
nfc-emulate-forum-tag4.c:231: warning: no previous prototype for ‘stop_emulation’
nfc-emulate-forum-tag4.c:241: warning: no previous prototype for ‘ndef_message_load’
nfc-emulate-forum-tag4.c:269: warning: no previous prototype for ‘ndef_message_save’
nfc-emulate-forum-tag4.c:285: warning: no previous prototype for ‘usage’
2012-05-13 12:57:49 +00:00
Ludovic Rousseau
7f9ba48018 Fix compiler warnings
nfc-read-forum-tag3.c:63: warning: no previous prototype for ‘print_usage’
nfc-read-forum-tag3.c:70: warning: no previous prototype for ‘stop_select’
nfc-read-forum-tag3.c:80: warning: no previous prototype for ‘build_felica_frame’
nfc-read-forum-tag3.c:91: warning: no previous prototype for ‘nfc_forum_tag_type3_check’
2012-05-13 12:56:41 +00:00
Ludovic Rousseau
0926f8a7c9 Fix compiler warning
nfc-probe.c:64: warning: no previous prototype for ‘print_usage’
2012-05-13 12:55:26 +00:00
Ludovic Rousseau
b5c1f2d619 Fix compiler warning
nfc-dep-initiator.c:54: warning: no previous prototype for ‘stop_dep_communication’
2012-05-13 12:54:37 +00:00
Ludovic Rousseau
b5e688e74a Fix compiler warnings:
nfc-relay-picc.c:76: warning: no previous prototype for ‘intr_hdlr’
nfc-relay-picc.c:85: warning: no previous prototype for ‘print_usage’
nfc-relay-picc.c:96: warning: no previous prototype for ‘print_hex_fd4’
nfc-relay-picc.c:118: warning: no previous prototype for ‘scan_hex_fd3’
nfc-relay-picc.c: In function ‘main’:
nfc-relay-picc.c:190: warning: function declaration isn’t a prototype
2012-05-13 12:53:34 +00:00
Ludovic Rousseau
6abb1c4eab Fix compiler warning
nfc-dep-target.c:53: warning: no previous prototype for ‘stop_dep_communication’
2012-05-13 12:51:57 +00:00
Ludovic Rousseau
edefdf0157 Fix compiler warnings
nfc-emulate-forum-tag2.c:78: warning: no previous prototype for ‘stop_emulation’
nfc-emulate-forum-tag2.c:116: warning: no previous prototype for ‘nfcforum_tag2_io’
2012-05-13 12:50:30 +00:00
Ludovic Rousseau
72ad8f7ad5 Remove an explicit cast and fix a compiler warning
nfc-emulate-uid.c:125: warning: function declaration isn’t a prototype
2012-05-13 12:49:28 +00:00
Ludovic Rousseau
714997fc34 Fix compiler warnings
nfc-emulate-uid.c:70: warning: no previous prototype for ‘intr_hdlr’
nfc-emulate-uid.c:79: warning: no previous prototype for ‘print_usage’
2012-05-13 12:48:28 +00:00
Ludovic Rousseau
96b1643522 Remove an explicit cast and fix a compiler warning
nfc-emulate-tag.c:180: warning: function declaration isn’t a prototype
2012-05-13 12:46:33 +00:00
Ludovic Rousseau
a7325ffded Fix compiler warnings:
nfc-emulate-tag.c:65: warning: no previous prototype for ‘intr_hdlr’
nfc-emulate-tag.c:76: warning: no previous prototype for ‘target_io’
nfc-emulate-tag.c:139: warning: no previous prototype for ‘nfc_target_emulate_tag’
2012-05-13 12:44:13 +00:00
Ludovic Rousseau
b65c133f80 stdin is already defined by stdio.h
Fix compiler warnings:

pn53x-tamashell.c: In function ‘main’:
pn53x-tamashell.c:79: warning: nested extern declaration of ‘__stdinp’
pn53x-tamashell.c:79: warning: redundant redeclaration of ‘__stdinp’
/usr/include/stdio.h:164: warning: previous declaration of ‘__stdinp’
was here
2012-05-13 12:42:51 +00:00
Ludovic Rousseau
e60f4ef870 Fix compiler warning
pn53x-tamashell.c:106: warning: initialization discards qualifiers from
pointer target type
2012-05-13 12:41:17 +00:00
Ludovic Rousseau
b3e21fecd2 Fix compiler warnings
nfc-poll.c:57: warning: no previous prototype for ‘stop_polling’
nfc-poll.c:67: warning: no previous prototype for ‘print_usage’
2012-05-13 12:39:17 +00:00
Ludovic Rousseau
da25554128 Remove an explicit cast and fix a compiler warning
nfc-relay.c:107: warning: function declaration isn’t a prototype
2012-05-13 12:38:18 +00:00
Ludovic Rousseau
43569e22e4 Fix compiler warnings
nfc-relay.c:65: warning: no previous prototype for ‘intr_hdlr’
nfc-relay.c:73: warning: no previous prototype for ‘print_usage’
2012-05-13 12:36:59 +00:00
Ludovic Rousseau
61ba0478cd Fix compiler warning
pn53x-sam.c:56: warning: no previous prototype for ‘wait_one_minute’
2012-05-13 12:32:30 +00:00
Ludovic Rousseau
5c82158a5d Declare internal functions as static
Fixes compiler warnings:
pn53x.c:565: warning: no previous prototype for ‘pn53x_ReadRegister’
pn53x.c:591: warning: no previous prototype for ‘pn53x_WriteRegister’
pn53x.c:748: warning: no previous prototype for ‘pn53x_int_to_timeout’
pn53x.c:1003: warning: no previous prototype for ‘pn53x_initiator_select_passive_target_ext’
pn53x.c:1334: warning: no previous prototype for ‘__pn53x_init_timer’
pn53x.c:1355: warning: no previous prototype for ‘__pn53x_get_timer’
2012-05-13 12:29:39 +00:00
Ludovic Rousseau
59b8ffcdb1 Declare internal functions as static
Fixes compiler warnings:
acr122_pcsc.c:106: warning: no previous prototype for ‘acr122_pcsc_get_scardcontext’
acr122_pcsc.c:118: warning: no previous prototype for ‘acr122_pcsc_free_scardcontext’
acr122_pcsc.c:198: warning: no previous prototype for ‘acr122_pcsc_connstring_decode’
2012-05-13 12:23:42 +00:00
Romuald Conty
851d035588 drivers/pn532_uart: flush uart input on error to resync uart port 2012-05-10 19:37:55 +00:00
Philippe Teuwen
896fa54ece nfc-utils: some changes on the newly introduced fingerprinting method, see log for details
* avoid hardcoded list sizes in #define
* merge card_link data into const_ca
* indexes start at 0, not 1, and use -1 as marker rather than 0
* fix bug in DESFire ATQA
* remove CL1 entries for double size UIDs, in practice we'll always get the latest SAK of the cascade
* remove CL2 tags, cf previous point
* compact const_cs considering the previous points
* keep const_cs strings only where they are informative
* premature halt of inner loop if there is no more SAK index to treat
* change atqa & sak types to uint16_t & uint8_t

* skip redundant matches in the old fingerprinting method
2012-05-02 23:48:06 +00:00
Philippe Teuwen
b10de698dd nfc-utils: new fingerprinting method closer to AN10833, patch proposed by Balazs Bucsay (thanks!) 2012-05-02 23:47:57 +00:00
Philippe Teuwen
93157dd30d nfc-utils.h: rename function oddparity_bytes_ts() to be coherent with nfc-utils.c 2012-05-02 21:18:46 +00:00
Philippe Teuwen
1cf9154296 nfc-utils: fix bug (remaining calls to old OddParity table) 2012-05-02 21:18:31 +00:00
Philippe Teuwen
b84e3d0f20 nfc-utils: smaller oddparity code 2012-05-02 10:02:56 +00:00
Romuald Conty
4990f57df8 debug messages are sent in stderr stream (Thanks to Spock) 2012-05-02 01:46:44 +00:00
Romuald Conty
8549bc1e4c share some traces with USB devices (Thank to yobibe) 2012-05-01 23:17:24 +00:00
Romuald Conty
82b2cfa883 Smart merge of acr122_usb branch: add acr122_usb driver without removing acr122_pcsc support. 2012-05-01 23:09:57 +00:00
Romain Tartiere
2f9bc90a95 Don't return pointer on freed memory on error.
PR:		http://code.google.com/p/nfc-tools/issues/detail?id=87
Submitted by:	jkmalinen@gmail.com
2012-03-05 07:28:45 +00:00
Romain Tartiere
68a1d5c450 Fix another warning for files not compiled in the default configuration. 2012-03-01 14:01:08 +00:00
Romuald Conty
e7f85811a1 fix *get_supported_modulation and *get_supported_baud_rate protos in nfc_driver and public ones. 2012-03-01 13:52:51 +00:00
Romuald Conty
f98437c377 fix pn53x_get_supported_modulation() and pn53x_get_supported_baud_rate() functions 2012-03-01 13:43:04 +00:00
Romain Tartiere
05789e5a68 Fix a couple warnings. 2012-03-01 13:33:13 +00:00
Romuald Conty
3eba0e9b54 Prepare libnfc 1.6.0-rc1 2012-03-01 12:00:23 +00:00
Romuald Conty
03d185b536 Prepare libnfc 1.6.0-rc1 2012-03-01 11:37:16 +00:00
Romuald Conty
9720bc45b4 Prepare libnfc 1.6.0-rc1 2012-03-01 11:24:59 +00:00
Romuald Conty
4878361d27 drivers/acr122s: fix ACR122S initialization (Fixes Issue 185) 2012-02-27 14:10:47 +00:00
Audrey Diacre
4cc3c72b31 add nfc_device_get_supported_modulation() and nfc_device_get_supported_baud_rate() documentation. 2012-02-20 08:36:15 +00:00
Audrey Diacre
5a5bdf1d66 add nfc_device_get_supported_modulation() and nfc_device_get_supported_baud_rate() functions. 2012-02-17 12:09:56 +00:00
Romuald Conty
75e776ffd0 utils/nfc-mfclassic: remove non-conscistent "extract payload" option in nfc-mfclassic and use MIFARE instead of Mifare typo (Thanks to Thomas Hood) 2012-02-15 13:41:38 +00:00
Audrey Diacre
e9bd9e4b67 documentation: exclude some files. 2012-01-31 15:35:13 +00:00
Audrey Diacre
983d4932f3 documentation: add utils and examples and hide internal files. 2012-01-31 14:28:45 +00:00
Audrey Diacre
908fa416bf documentation 2012-01-31 10:02:38 +00:00
Audrey Diacre
3d393e58a9 add some Doxygen documentation. 2012-01-31 09:49:43 +00:00
Audrey Diacre
17c4a09c8f add modules in documentation. 2012-01-30 11:00:02 +00:00
Audrey Diacre
0f20377541 add some API documentations. 2012-01-30 09:43:58 +00:00
Romuald Conty
70484509af libnfc-1.5-acr122-usb> support for ACR122U only (not Touchatag) 2012-01-27 14:38:14 +00:00
Romuald Conty
24e298626a libnfc-1.5-acr122-usb> fix minor bugs and apply pn53x_usb's patch to be used under FreeBSD too 2012-01-26 21:36:08 +00:00
Romuald Conty
e49eb6c660 libnfc-1.5-acr122-usb> import partial work on "ACR122 without PCSC" driver 2012-01-26 15:23:11 +00:00
Audrey Diacre
26245add73 Merge libnfc-1.5-new-api branch to trunk (r1168:1303). 2012-01-25 09:56:05 +00:00
Audrey Diacre
1f3b995c2a add iso14443a_crc as symbol to expose for libfreefare. 2012-01-24 08:42:47 +00:00
Audrey Diacre
5a475cf074 add some whitespaces 2012-01-20 09:17:38 +00:00
Audrey Diacre
838faa8d7e define symbols to expose (Fixes Issue 183). 2012-01-19 11:50:15 +00:00
Romuald Conty
a3a0002f8d fix miss-returned error code (ETGREL -> NFC_ETGRELEASED). 2012-01-18 18:08:39 +00:00
Audrey Diacre
4c011279ff add context to nfc_init(), nfc_exit(), nfc_open() and nfc_list_devices() functions. 2012-01-18 16:22:06 +00:00
Audrey Diacre
86c8ce536b acr122.c: apply changes done in r1296. 2012-01-18 14:44:57 +00:00
Romain Tartiere
3aa31abe18 Add missing header. 2012-01-18 13:21:06 +00:00
Romuald Conty
b366b8c027 add nfc_device_get_connstring() function and nfc-probe example to show devices connection strings 2012-01-18 13:17:01 +00:00
Romain Tartiere
39216f9d7c Do not rely on int to locate USB bus and devices: FreeBSD's libusb use path of
devices in /dev for bus (/dev/usb) and devices (e.g. /dev/ugen0.3) so directly
Compare strings.
2012-01-18 13:13:36 +00:00
Audrey Diacre
207199dc34 examples, test and utils use now nfc_exit() function. 2012-01-18 11:36:18 +00:00
Audrey Diacre
1d55b6f8c6 examples, test and utils use now nfc_init() function. 2012-01-18 11:09:01 +00:00
Audrey Diacre
d1b0e93e8e add initialization and deinitialization. 2012-01-18 09:53:45 +00:00
Romuald Conty
38bdfe3281 pn53x_usb: minor code clean up. 2012-01-18 09:39:33 +00:00
Audrey Diacre
324af418db rename nfc_connect() function to nfc_open(). 2012-01-17 15:21:56 +00:00
Audrey Diacre
9eb37b3eee rename nfc_disconnect() function to nfc_close(). 2012-01-17 14:52:39 +00:00
Audrey Diacre
9d3ca39a44 remove _t suffix from nfc_driver_t type. 2012-01-17 14:17:01 +00:00
Romain Tartiere
ba58138aa9 PRIu32 is defined in inttypes.h. 2012-01-17 13:51:58 +00:00
Romain Tartiere
2d393bff91 Make these function accept no argument (instead of any). 2012-01-15 11:06:24 +00:00
Audrey Diacre
84a864f8d3 test/test_device_modes_as_dep: increase duration of sleep() between nfc_idle() and nfc_target_init() to wait for the end of nfc_initiator_poll_dep_target(). 2012-01-13 14:41:27 +00:00
Audrey Diacre
bd0de9bd61 test: rename test_dep to test_device_modes_as_dep and improve it. 2012-01-13 09:58:47 +00:00
Audrey Diacre
0e2c60d0fa fix some last_error with result of previous function. 2012-01-12 13:52:48 +00:00
Audrey Diacre
cc8d4f68ab tests: add test_dep which tests states of 2 devices. 2012-01-12 08:49:19 +00:00
Audrey Diacre
f9a464e256 nfc_perror() function displays now LIBNFC_ERROR. 2012-01-11 08:47:14 +00:00
Romuald Conty
e86d08218b add nfc_initiator_poll_dep_target() 2012-01-10 14:17:18 +00:00
Romuald Conty
efa86f0e35 fix various minor mistakes, ajust timeouts 2012-01-10 14:10:44 +00:00
Audrey Diacre
1ec504e163 nfc_list_devices() function returns now the number of devices found. 2012-01-10 10:35:36 +00:00
Audrey Diacre
00818e048c rx buffer size parameter of nfc_target_init() function is now a const size_t. 2012-01-09 11:26:57 +00:00
Audrey Diacre
5e796e0a26 rx buffer size parameter of pn53x_TgInitAsTarget() function is now a const size_t. 2012-01-09 10:47:35 +00:00
Audrey Diacre
c10b473361 rx buffer size parameter of pn53x_transceive() function is now a const size_t. 2012-01-09 10:24:00 +00:00
Romuald Conty
7df3bb5aeb various minor fixes/enhancements 2012-01-06 13:08:16 +00:00
Audrey Diacre
e15f2eedbb rename lastCommand by last_command. 2012-01-06 13:07:37 +00:00
Romuald Conty
48e92149e4 drop log4c support 2012-01-06 13:05:10 +00:00
Audrey Diacre
b41edfb0b4 rename ui8LastCommand by lastCommand. 2012-01-06 09:20:55 +00:00
Audrey Diacre
3b8598dde8 libnfc/test: fix some forgotten modifications due to the last revision. 2012-01-06 08:36:24 +00:00
Romuald Conty
22bea8d99b nfc_target_receive_*() need to know rx buffer size 2012-01-05 21:35:02 +00:00
Audrey Diacre
601105ef79 fix bad cast done in last revision. 2012-01-05 17:03:38 +00:00
Audrey Diacre
642f9a38f7 nfc_target_receive_bytes() function does not now use pszRx as parameter because this function returns it. 2012-01-05 16:33:55 +00:00
Audrey Diacre
7e7ee3299e nfc_target_receive_bits() function does not now use pszRxBits as parameter because this function returns it. 2012-01-05 15:50:07 +00:00
Audrey Diacre
239fd750c4 add timeout on nfc_target_init() and this function returns now received bytes count on success. 2012-01-05 15:10:11 +00:00
Audrey Diacre
c80ebdca25 nfc_abort_command() function returns now 0 on success and libnfc error code on failure and fix some warnings. 2012-01-05 14:49:02 +00:00
Audrey Diacre
8b07a5f4c7 libnfc/drivers: pn53x_usb_init() function returns now 0 on success and libnfc error code on failure. 2012-01-05 14:05:43 +00:00
Audrey Diacre
5d4f22c548 libnfc/drivers: pn532_uart_ack() and arygon_reset_tama() functions return now libnfc error code on failure. 2012-01-05 13:56:12 +00:00
Audrey Diacre
c30e9eed36 send/receive callbacks from internal chip io return now libnfc error code on failure. 2012-01-05 13:24:41 +00:00
Audrey Diacre
81d76c8c70 check result of nfc_disconnect() function in examples/nfc-dep-initiator.c 2012-01-05 10:56:36 +00:00
Audrey Diacre
5a1f0c2115 check result of nfc_initiator_init() function in examples/ and utils/ 2012-01-05 10:33:50 +00:00
Audrey Diacre
331234713d nfc_idle() function returns now 0 on success and libnfc error code on failure. 2012-01-05 08:57:16 +00:00
Audrey Diacre
6ad07c3efb pn53x_writeback_register() function returns now 0 on success and libnfc error code on failure. 2012-01-05 08:42:22 +00:00
Romuald Conty
93b34fa70b enhance new error handling
- add accessor to last error occured
- add new public error NFC_ETGRELEASED (Target Released)
2012-01-05 01:39:10 +00:00
Romuald Conty
125553c72e verbose option back for nfc-list, and newly implemented in nfc-poll 2012-01-04 21:29:43 +00:00
Romuald Conty
af22d34d57 fix some return codes and error checkings 2012-01-04 20:50:05 +00:00
Romuald Conty
254053b940 fix few minor bugs:
- timeout values handling in pn53x_transceive()
- check error code after filling it in pn53x_transceive()
- fix pn53x_check_communication() return code
- lower timeout default values
- fix arygon_abort() return code
2012-01-04 20:02:51 +00:00
Audrey Diacre
52c72383f1 pn53x_build_frame() function returns now 0 on success and libnfc error code on failure. 2012-01-04 16:44:40 +00:00
Audrey Diacre
e87241184a pn53x_check_ack_frame() and pn53x_check_error_frame() functions return now 0 on success and libnfc error code on failure. 2012-01-04 16:32:16 +00:00
Audrey Diacre
4b373263e4 pn53x_idle() returns now 0 on success and libnfc error code on failure. 2012-01-04 16:26:57 +00:00
Audrey Diacre
7e1c776bc1 pn53x_check_communication() returns now 0 on success and libnfc error code on failure. 2012-01-04 16:19:24 +00:00
Audrey Diacre
240cdcddab pn53x_decode_target_data() returns now 0 on success and libnfc error code on failure. 2012-01-04 16:11:30 +00:00
Audrey Diacre
d4c5476652 pn53x_get_firmware_version() returns now 0 on success and libnfc error code on failure.. 2012-01-04 16:07:57 +00:00
Audrey Diacre
c1faa48f54 fix nfc_target_init(). 2012-01-04 15:59:34 +00:00
Audrey Diacre
a41b2b0da8 nfc_initiator_transceive_bytes_timed() function does not now use pszRx as parameter because this function returns it. 2012-01-04 15:53:41 +00:00
Audrey Diacre
b699743973 nfc_initiator_transceive_bits_timed() function does not now use pszRxBits as parameter because this function returns it. 2012-01-04 15:43:08 +00:00
Audrey Diacre
6e7092b160 nfc_initiator_transceive_bits() function does not now use pszRxBits as parameter because this function returns it. 2012-01-04 15:30:42 +00:00
Audrey Diacre
61c3e5b814 pn53x_wrap_frame() and pn53x_unwrap_frame() functions return now frame length in bits on success and libnfc error code on failure. 2012-01-04 14:59:16 +00:00
Audrey Diacre
0de1136037 nfc_target_receive_bits() function returns now received bits count on success and libnfc error code on failure. 2012-01-04 13:33:53 +00:00
Audrey Diacre
951dde8143 nfc_target_send_bits() function returns now sent bits count on success and libnfc error code on failure. 2012-01-04 13:27:15 +00:00
Audrey Diacre
1c49329ffa nfc_initiator_transceive_bits_timed() function returns now received bits count on success and libnfc error code on failure. 2012-01-04 13:18:11 +00:00
Audrey Diacre
d02da0db64 nfc_initiator_transceive_bytes_timed() function returns now received bytes count on success and libnfc error code on failure. 2012-01-04 11:54:55 +00:00
Audrey Diacre
61074f3497 nfc_initiator_transceive_bits() function returns now received bits count on success and libnfc error code on failure. 2012-01-04 11:46:07 +00:00
Romuald Conty
d6477df7a6 doc: quick start example minor fix (make distcheck OK) 2011-12-22 17:40:22 +00:00
Audrey Diacre
9c1371dcca nfc_target_send_bytes() function returns now sent bytes count on success and libnfc error code on failure. 2011-12-22 15:59:08 +00:00
Audrey Diacre
ac6f652368 nfc_target_receive_bytes() function returns now received bytes count on success and libnfc error code on failure. 2011-12-22 15:39:51 +00:00
Audrey Diacre
a40e63ab9d test/tes_dep_*: now check there is one or more selected dep target. 2011-12-22 14:16:12 +00:00
Audrey Diacre
658fceb7fc nfc_initiator_select_dep_target() function returns now selected D.E.P targets count on success. 2011-12-22 13:28:41 +00:00
Audrey Diacre
b864215d63 pn53x_initiator_poll_target() function returns now polled targets count on success. 2011-12-22 11:16:27 +00:00
Audrey Diacre
340e80d7a8 pn53x_initiator_select_passive_target_ext() function now does not return error when there is no target. 2011-12-21 11:52:02 +00:00
Audrey Diacre
f93bc59504 nfc_initiator_select_passive_target() function returns now the selected passive targets count on success. 2011-12-21 11:33:21 +00:00
Audrey Diacre
ff066e394d nfc_initiator_deselect__target() function returns now libnf error code. 2011-12-21 09:53:16 +00:00
Audrey Diacre
c41d7de8ca nfc_initiator_select_dep_target() function returns nox libnf error code and fix some uses of nfc_initiator_transceive_bytes() function. 2011-12-21 09:15:44 +00:00
Audrey Diacre
0f5cc5683d nfc_initiator_poll_target() function returns now libnfc error code. 2011-12-20 15:46:35 +00:00
Audrey Diacre
42276ccd14 the following functions now return libnfc error code:
_ pn53x_set_tx_bits
_ pn53x_read_register
_ pn53x_InAutoPoll
_ pn53x_TgInitAsTarget
_pn53x_init
2011-12-20 14:41:17 +00:00
Audrey Diacre
c5f05f0592 pn53x_set_parameters() function returns now libnfc error code. 2011-12-20 13:37:54 +00:00
Audrey Diacre
9c5ec3c4e1 the following functions now return libnfc error code:
_pn53x_write_register()
_pn53x_WriteRegister()
_pn53x_transceive()
_pn53x_SAMConfiguration()
_pn53x_PowerDown()
 _pn53x_InListPassiveTarget()
_pn53x_InDeselect()
_pn53x_InRelease()
_pn53x_RFConfiguration__*
2011-12-20 11:25:33 +00:00
Audrey Diacre
103485518c nfc_initiator_select_passive_target() function returns now libnfc error code. 2011-12-19 16:27:50 +00:00
Audrey Diacre
ba2a7cfe2e nfc_target_init() function returns now 0 on succes and libnfc error code on failure. 2011-12-19 15:35:37 +00:00
Audrey Diacre
145cc4b2ad nfc_initiator_transceive_bytesfunction now returns libnfc error code on failure and received bytes count on success. 2011-12-19 14:37:22 +00:00
Audrey Diacre
31f67be83e add some forgotten NFC_SUCCESS returns in pn53x_set_property_bool function and fix some return types in test/ 2011-12-19 14:05:02 +00:00
Audrey Diacre
6eb2499aa8 test/* uses the new nfc_device_get_name() function. 2011-12-19 09:15:42 +00:00
Romuald Conty
bf7c36d9bb less structs and defines publicly exposed
- nfc_device is now an opaque type;
 - PN53x specific errors are not public anymore;
 - nfc_device_name() renamed to nfc_device_get_name() for the sake of consistency;
 - examples/*, utils/* uses the new nfc_device_get_name() function instead of access directly to struct's content;
 - new error defined: NFC_ERFTRANS for notifying about RF transmission error, its used by mifare.c to detect permissions error on mifare;
 - drivers initiator_transceive_bytes() function now returns libnfc's error code on failure (<0), and received bytes count on success (>=0);
 - remove some unused errors.
2011-12-19 00:23:21 +00:00
Romuald Conty
9bdc20353c nfc_device struct is not exposed as public API anymore (partial commit)
- split libnfc's errors and chip's errors
 - fix nfc_property enum
2011-12-15 16:02:38 +00:00
Audrey Diacre
98355d36a7 nfc_initiator_init returns now error code and nfc_initiator_list_passive_targets returns now the number of targets found or error code. 2011-12-15 11:46:14 +00:00
Audrey Diacre
a615d969fd nfc_properties replace now nfc_options and nfc_configure is replaced by nfc_device_set_property_bool which returns error code. 2011-12-14 16:01:00 +00:00
Romuald Conty
c181cb35ec set correctly default timeout values 2011-12-14 15:03:29 +00:00
Romuald Conty
26b9c28f48 new properties to tune timeouts:
- add nfc_properties (will replace nfc_options)
 - introduce some error codes
 - rework functions to use the new timeout_command value
2011-12-14 13:27:11 +00:00
Audrey Diacre
8b76d55fdc test/test_dep_active: fix multiple active DEP baudrates. 2011-12-14 10:31:08 +00:00
Audrey Diacre
9906e11572 oups: forgot to uncomment a line. 2011-12-09 16:36:29 +00:00
Romuald Conty
b3b14a3fb8 debian: udev rules file renamed 2011-12-09 16:14:50 +00:00
Romuald Conty
2ac8df2b28 contrib: move udev and devd files into contrib/ 2011-12-09 16:13:32 +00:00
Audrey Diacre
1e66caecd6 test/test_dep_active: add new DEP active test 2011-12-09 13:55:35 +00:00
Audrey Diacre
cc2622c49f test/test_dep*: rename test_dep to test_dep_passive and add new 106kbps pass. 2011-12-09 13:41:51 +00:00
Romuald Conty
90c05c7d13 Add a printf-based logging when log4c is not available (I experiemented some bugs using log4c) 2011-12-07 14:59:40 +00:00
Romuald Conty
c286eec920 DEP enhancements:
- Add timeout on InJumpForDEP (pn53x) and initiator_select_dep (libnfc API)
- test_dep now works again (except 424Kbps)
- Fix ndi.ndm feeling when select a DEP target
Important: test_dep does not work on PN53x_USB devices after running previous tests
2011-12-06 10:05:35 +00:00
Audrey Diacre
3b657ee547 quick_start_example1 is now compiled when running make check or distcheck (Fixes Issue 178) 2011-11-30 11:21:01 +00:00
Romuald Conty
e76e531d2d pn53x_usb: clean timeout handling. 2011-11-25 16:13:40 +00:00
Audrey Diacre
297a8566a0 Oups, too quick replacement commited in r1183 2011-11-25 15:47:24 +00:00
Audrey Diacre
52bc5853d8 Remove whitespace after star symbol for pointers 2011-11-25 15:21:10 +00:00
Audrey Diacre
5a9a778879 Remove whitespace after star symbol for pointers 2011-11-25 13:32:29 +00:00
Audrey Diacre
90b5961b40 Rename fixed_timeout to timeout_tv and cleam useless allocation. 2011-11-25 13:30:13 +00:00
Audrey Diacre
5c7454a2f7 Timeout is now integer. 2011-11-25 11:37:30 +00:00
Audrey Diacre
dad3603936 Remove whitespace after star symbol for pointers 2011-11-24 16:45:27 +00:00
Audrey Diacre
9e67423cff Fix some warnings in test. 2011-11-24 11:12:01 +00:00
Audrey Diacre
784a2f86a2 Change byte_t type to uint8_t (Fixes Issue 147) 2011-11-24 10:54:42 +00:00
Audrey Diacre
ce846931bc Move nfc-emulate-forum-tag2 from utils to examples. 2011-11-24 10:27:02 +00:00
Audrey Diacre
322eec6fb1 Define macro to cast to serial_port_unix. 2011-11-24 10:20:36 +00:00
Audrey Diacre
c718fafee7 Massive code clean up: (Fixes Issue 161)
- Remove typedef from internal structs
- Remove _t suffix from types
- Fix tests using connstrings
2011-11-23 15:55:40 +00:00
Anugrah Redja Kusuma
136cfdf48d Implement driver for ACR122S device 2011-11-23 03:05:12 +00:00
Audrey Diacre
54b6827971 add missing manpages. 2011-11-22 15:23:18 +00:00
Romuald Conty
63f168440b Provide a (poor) logging capability when log4c is not available but DEBUG is enabled. 2011-10-27 15:14:18 +00:00
Romuald Conty
2e2d091bfd nfc-list: continue to attempt to reach devices after a connection failure. 2011-10-27 13:46:13 +00:00
Romuald Conty
6752951084 Refresh quick_start_example1.c according to new API 2011-10-18 16:07:13 +00:00
Philippe Teuwen
789cb13dec Avoid readline auto-detection when cross-compiling. Still feasible to use readline if you specify the path to it. 2011-10-18 13:28:01 +00:00
Romuald Conty
b4ebb4510d Removes libusb types workaround (r200) as it seems to not be needed anymore but may disturb compiler. 2011-10-18 11:03:54 +00:00
Romuald Conty
b7f928a24c Update ChangeLog 2011-10-17 16:40:24 +00:00
Romuald Conty
b6c23c7c0e FixBundle.cmake.in was missing from released archives. (Thanks to GruGue from the libnfc forum) 2011-10-17 13:11:37 +00:00
Romuald Conty
55daa29a7c Allow to connect to a device using a connection string:
- Provide a nfc_get_default_device() that allow to grab the connstring stored
   in LIBNFC_DEFAULT_DEVICE environnement variable or returns the first
   available device if not set;
 - nfc_connect(NULL) now takes the default device (see
   nfc_get_default_device());
 - Removes nfc_driver_desc_t from public types
 - Defines nfc_connstring as char[1024]
 - examples/*: use nfc_connstring
 - examples/nfc-poll: now uses only the default device (instead of all devices
   availables)
 - Removes parse_args() from nfc-utils.[hc]
2011-10-17 13:03:56 +00:00
Romuald Conty
47f4883444 configure now checks for int16_t 2011-10-17 12:32:16 +00:00
Romuald Conty
dc842a844c examples/nfc-read-forum-tag3: add new example to read a NFC Forum Tag Type 3 2011-10-10 00:40:34 +00:00
Romuald Conty
57db10acf0 m4/libusb: search for "libusb-legacy" module if "libusb" module is not found 2011-10-09 19:54:25 +00:00
Romuald Conty
1372c1df19 ECONNABORTED is not defined under windows 2011-10-05 22:42:55 +00:00
Romuald Conty
b24191a9b9 Fix compilation using cmake 2011-10-04 21:43:05 +00:00
Romuald Conty
8fa83ac70f Fix infinite software polling 2011-10-04 21:42:06 +00:00
Romuald Conty
ace9fb27b1 Fix indent in cmake/modules/FindLIBUSB.cmake 2011-10-04 21:41:15 +00:00
Romuald Conty
dccfd65c80 Add software polling for non-PN532 equipped device (Fixes Issue 136) 2011-10-03 11:19:08 +00:00
Romuald Conty
66e3ea6146 nfc-relay-picc.1 was missing from tarball 2011-10-03 11:16:42 +00:00
Romuald Conty
b1a30e3e3b drivers/pn53x_usb: fix timeout computing 2011-10-03 08:59:21 +00:00
Romuald Conty
a2eb6a1f49 Update ChangeLog 2011-10-02 21:52:05 +00:00
Romuald Conty
b2666dea15 windows port improved:
- PCSC headers/libs are not a requierement sif you dont select ACR122 driver
 - uart_win32 implementation now handles timeouts
2011-10-01 14:50:53 +00:00
Romuald Conty
d286a3c4b7 make distcheck OK 2011-10-01 13:29:18 +00:00
Romuald Conty
ea0ffa615a Remove (g)indent references.
Unfortunately, there is no automatic way that is good to indent the code. Developers need to take care about indent themself ;) (Fixes Issue 84)
2011-10-01 12:33:11 +00:00
Romuald Conty
03a6f5e29c Update examples and utils manpages.(Fixes Issue 159) 2011-10-01 12:26:11 +00:00
Romuald Conty
5ecf382dfc windows: Oups... timeout is a pointer... 2011-10-01 09:59:27 +00:00
Romuald Conty
afd015f1b7 Attempt to provide a Windows implementation of timeouts handling in UART 2011-09-30 14:02:51 +00:00
Romuald Conty
8c7b61eaba move some examples to utils/ since they are not examples anymore :) (Fixes Issue 164) 2011-09-30 11:33:31 +00:00
Romain Tartiere
311d12feef Make a copy of the provided timeout before calling select(2). 2011-09-29 15:01:48 +00:00
Romuald Conty
8f7834c625 drivers/arygon,pn532_uart,pn53x_usb: all PN53x commands are now cancelable 2011-09-29 14:53:52 +00:00
Romuald Conty
49ab6a7f31 raise up loggin level when PCSC context is not found (e.g. under POSIX system, pcscd is not running) 2011-09-29 11:59:34 +00:00
Romuald Conty
590e3910de Document new timeout parameter 2011-09-29 09:49:08 +00:00
Romuald Conty
a12574e095 Add a special mention to be sure pcscd is running when using ACR122 driver... 2011-09-29 09:10:14 +00:00
Romuald Conty
87c13825af drivers/pn53x_usb: rework timeout usage 2011-09-22 16:21:22 +00:00
Romain Tartiere
481fb4943f - Add timeout capablities to nfc_initiator_transceive_bytes(), nfc_target_send_bytes() and nfc_target_receive_bytes();
- Bump version to 1.5.1.
2011-09-22 13:03:47 +00:00
Romain Tartiere
e94513fdb7 libpcsclite is not really required. 2011-09-22 10:01:37 +00:00
Romuald Conty
f6b582cf2b windows: Remove DGB/WARN/ERROR obsolete macros usage. 2011-09-21 06:54:53 +00:00
Romuald Conty
e4524bc810 chips/pn53x: add RFConfiguration wrappers 2011-09-20 22:43:45 +00:00
Romuald Conty
b33fb81234 logging: fix LOG_CATEGORY and show the last command status. 2011-09-20 18:22:47 +00:00
Romuald Conty
cf99796a77 Removes semaphore.h depends. 2011-09-20 16:23:48 +00:00
Romuald Conty
ca8bd1df91 logging: remove semaphore usage since libnfc is not threaded and log4c does handle threaded cases itself. (Should ease Windows compiling) 2011-09-20 14:07:40 +00:00
Romuald Conty
c4b45cd390 debian: add nfc-mfsetuid and nfc-emulate-nfcforum-tag2 to libnfc-example package. 2011-09-13 13:12:54 +00:00
Romuald Conty
0f3b733239 directory include/nfc does not have iso7816.h file. 2011-09-12 19:50:21 +00:00
Romain Tartiere
f6fc637d77 Soooo fragile :-)))) 2011-09-12 17:05:00 +00:00
Romuald Conty
e8eec583ed Enhance logging system:
* Removes internal DBG/WARN/ERR macros (but keep them in examples);
 * Removes almost all DEBUG define references;
 * Uses the flexible log4c library to log all messages.
2011-09-12 14:50:01 +00:00
Romuald Conty
580768a489 pn53x-diagnose: uses config.h if present 2011-09-12 14:46:58 +00:00
Romuald Conty
aff1a51eb7 Threaded tests need cutter >= 1.1.8 2011-09-12 14:33:26 +00:00
Romuald Conty
c30453d176 Add a threaded DEP test to check DEP communication between two local devices 2011-09-12 14:30:59 +00:00
Romuald Conty
d18cae4f06 Enable all drivers under Debian 2011-09-12 14:28:50 +00:00
Adam Laurie
24881bd32d Fix accidental overwrite of Mifare special trailer block in unlocked read 2011-09-07 09:41:04 +00:00
Adam Laurie
028f310576 Unlocked read and format/wipe of special Mifare cards 2011-09-06 21:17:38 +00:00
Adam Laurie
1a07613ce2 -h usage explicitly state Chinese clone cards required for block 0 write 2011-09-06 11:00:01 +00:00
Adam Laurie
8d6f0d7321 Add man page for nfc-mfsetuid 2011-09-06 09:47:50 +00:00
Adam Laurie
e401f4ec4e Write special Mifare 1K cards, including Block 0 / UID 2011-09-05 14:40:56 +00:00
Romuald Conty
fa7084fa77 removes the libusb-win32 workaround: libusb-win32 project released a new stable version which fixes the infinite timeout issue. (Thanks to Ergeerts Glenn) 2011-08-08 10:02:47 +00:00
Romain Tartiere
752c247761 Add cast to fix build on 32bit systems. 2011-07-05 08:00:11 +00:00
Romuald Conty
676477e20c rework the way to determine which command is needed to send/receive a frame as target. 2011-06-30 17:05:59 +00:00
Romuald Conty
3a1cb72681 examples/nfc-emulate-forum-tag2: add new example to emulate a NFC Forum Tag Type 2 2011-06-30 14:59:47 +00:00
Romuald Conty
10d9e30615 examples/nfc-emulate-forum-tag4: add document references. 2011-06-30 14:24:47 +00:00
Romain Tartiere
84918fd075 Fix invalid memory access when a new driver is probing for hardware and the number of requested devices was already reached.
The probing functions assume that at least one device should be found and
passed to the caller, and only after finding such a device they will check that
they should eventually stop looking for more devices.  While we could make each
probing function capable of handling the special-case of finding 0 devices, it
is much more consistent to perform the check from the calling function.
2011-06-30 13:35:40 +00:00
Romuald Conty
fd19773c21 drivers/pn53x_usb: Make valgrind more happy :) 2011-06-28 14:05:40 +00:00
Romuald Conty
eec2794d2d drivers/pn532_uart,arygon: Make valgrind happy with UART-based drivers 2011-06-28 13:16:44 +00:00
Romuald Conty
e6051ceca4 chip/pn53x: clean up SAMConfiguration usage. 2011-06-27 17:12:25 +00:00
Romuald Conty
eb70f3842e Error handling improvement:
- Attempt to sort errors depending their source
 - Rename DE* errors to differenciate Device-Error and Driver-Error
 - Add ENOTIMPL error to raise a error when a feature is not (yet) implemented in libnfc
2011-06-27 16:31:10 +00:00
Romuald Conty
9c314d5652 Shrink InJumpForDEP frame size according to user manual. 2011-06-27 12:33:55 +00:00
Romuald Conty
904f41e0f7 drivers/pn53x*: use shared pn53x_ack_frame[] and pn53x_nack_frame[] instead of local declaration. 2011-06-27 10:33:55 +00:00
Romuald Conty
699e9008d1 Move ISO14443-3 UID cascading in a dedicated function. 2011-06-27 10:19:00 +00:00
Romuald Conty
0b42cbfb8f examples/nfc-emulate-forum-tag4: this example now fails with ENOTSUPP when used with a non-PN532 chip. 2011-06-27 09:14:19 +00:00
Romuald Conty
7b6baafd1d example/nfc-relay-picc: Move windows related code into contrib/win32 2011-06-27 08:56:38 +00:00
Romain Tartiere
4259f595ec Initialize DEP mode (nt.nti.ndi.ndm) to NDM_UNDEFINED. 2011-06-26 14:43:11 +00:00
Romuald Conty
c40319c7b4 Windows: implement automatic uart port detection and input flush (Thanks to Edwin Evans) 2011-06-16 11:50:39 +00:00
Romain Tartiere
a8394caed5 Fix comparison between signed and unsigned. 2011-06-13 21:46:01 +00:00
Romuald Conty
29856a67a0 Rename USB_TIMEOUT to USB_INFINITE_TIMEOUT and use it each time bulk read need to be infinite. (Thanks to Guty) 2011-06-10 10:04:31 +00:00
Romuald Conty
850b3c2375 Improve USB support:
- All USB errors are now reported in text format;
 - USB drivers now relies on libusb-win32 with version >= 1.2.4.x (1.2.4.6 recommended) (Many thanks to Glenn)
2011-06-09 14:00:45 +00:00
Philippe Teuwen
7c88fc27b5 RC-S360, work-in-progress 2011-06-09 08:59:06 +00:00
Philippe Teuwen
082edbf598 More attempt to support Sony RC-S360 reader
Adapt InDeselect & InRelease to RC-S360
nfc-list now supports discovery of several typeA tags properly

Current status of RC-S360 support is:
    - nfc-list          => ok except for B' & 3B
    - nfc-anticol       => fails to send raw frames before select
    - nfc-mfultralight  => ok
    - nfc-mfclassic     => ok
    - pn53x-tamashell   => ok
    - pn53x-diagnose    => ok
    - nfc-dep-initiator => ok
    - nfc-dep-target    => fails in InitAsTarget
    - nfc-emulate-*     => fails in InitAsTarget

Commands momentarily disabled for RC-S360:
    - select_passive_target for B'& 3B
2011-06-08 00:09:57 +00:00
Philippe Teuwen
80a5ad1fd6 More attempt to support Sony S360 reader
Initialisation of RC-S360 in mode 0
Better generic nfc-list, does not rely only on DeSelect to avoid duplicates
Restore SetParameters for RC-S360
Handle Diagnose communication test properly

Tested:
    - nfc-list          => ok except for B' & 3B
    - nfc-anticol       => fails to send raw frames before select
    - nfc-mfultralight  => ok
    - nfc-mfclassic     => ok
    - pn53x-tamashell   => ok
    - pn53x-diagnose    => ok
    - nfc-dep-initiator => ok
    - nfc-dep-target    => fails in InitAsTarget
    - nfc-emulate-*     => fails in InitAsTarget

Commands momentarily disabled for RC-S330:
    - InDeselect
    - InRelease
    - select_passive_target for B'& 3B
2011-06-07 20:36:20 +00:00
Philippe Teuwen
cbbda20018 nfc-anticol: -f option to force RATS 2011-06-07 18:47:20 +00:00
Romain Tartiere
bf5b97f86a Add FreeBSD devd(8) snippet configuration for Sony S330 readers. 2011-06-06 08:46:55 +00:00
Philippe Teuwen
91c46050c0 First attempt to support Sony S330 reader
Tested:
- nfc-list
- nfc-anticol
- nfc-mfultralight
- nfc-mfclassic

Commands momentarily disabled:
- SetParameters
- InDeselect
- InRelease
2011-06-05 22:25:05 +00:00
Philippe Teuwen
f4c3d9d4ed nfc-mfclassic: handle 7-byte UID cards & MFC Mini 2011-05-26 22:49:45 +00:00
Philippe Teuwen
96538d052b Extend max length for firmware description & fix typo 2011-05-25 19:53:45 +00:00
Romuald Conty
17c63aebb5 pn53x_usb: continue to search a available device on usb errors (r1092 reverted then issue fixed). 2011-05-25 12:08:42 +00:00
Romuald Conty
917717c4ca drivers: UART based drivers could now use uart_flush_input() to discard junk bytes on input. 2011-05-25 10:31:19 +00:00
Romuald Conty
22e25a8b1e chips/pn53x: drivers now uses pn53x_data_new() and pn53x_data_free() to handle strcut pn53x_data allocation, initialization and freeing. 2011-05-25 10:25:17 +00:00
Romuald Conty
c45d4e685a pn53x_usb: continue to search a available device on usb errors (ie. Device Busy) 2011-05-25 10:15:18 +00:00
Romuald Conty
78ce62e7b6 Fix ISO/IEC 14443-4 hardware emulation.
NDO_AUTO_ISO14443_4 is now set to _true_ by default with nfc_target_init();
nfc_emulate_target() now fails (return _false_) when emulator->state_machine->io() failed;
Initialize nfc_device_t variables to _false_ in order to send correctly (see notes in nfc-device.c);
nfc_emulate_forum_tag4 prints error when nfc_emulate_target() failed.
2011-05-24 17:10:13 +00:00
Romuald Conty
975cd275d1 minor fixes 2011-05-20 16:09:00 +00:00
Romuald Conty
d8b31dbd46 debian: silent down lintian and add watch file 2011-05-20 15:07:12 +00:00
Romuald Conty
0c2671d7f9 remove duplicate file LICENSE (see COPYING) 2011-05-20 15:06:36 +00:00
Romuald Conty
dc88d6f3aa debian: now use debhelper 7 (dh7) style rules file 2011-05-20 14:40:36 +00:00
Romain Tartiere
4828211e97 Fix crash when usb_bulk_read() fails. 2011-05-18 22:25:09 +00:00
Romain Tartiere
6d66866268 Silent down the compiler. 2011-05-18 18:53:00 +00:00
Romuald Conty
1aadfef363 debian: update copyright 2011-05-18 10:59:27 +00:00
Romuald Conty
70155985f8 debian: use a numbering that allow to have libnfc pre-version and debian package pre-version too. (Thanks to Thomas Hood) 2011-05-18 08:59:07 +00:00
Romuald Conty
da6add3534 drivers/pn53x_usb: make PN53x usb connection more stable:
- move well-know USB problem hack into pn53x_usb_bulk_write()
 - put NACK hack to handle PN533 direct reply case
2011-05-17 10:41:26 +00:00
Romuald Conty
6b5a582386 debian: fix version numbering, fix .install files and remove PPA upload mention (Thanks to Thomas Hood) 2011-05-17 10:32:59 +00:00
Romuald Conty
12095307e5 debian: change name of lib to libnfc2 to match SONAME major version 2 (Thanks to Thomas Hood) 2011-05-16 12:55:44 +00:00
Romuald Conty
224c7b3fc3 debian: the directory debian/patches and its contents gets generated at build time and need not be kept in svn. 2011-05-16 12:52:11 +00:00
Philippe Teuwen
ff7696fffb nfc.c: reformulate comments of prev commit in chip-agnostic way. BTW there is more to do... 2011-05-12 20:51:44 +00:00
Philippe Teuwen
e5601e562f _timed(): now allows indirect control of intern prescaler via max expected cycles count 2011-05-12 20:33:00 +00:00
Romuald Conty
b9bcfaf959 debian: improve debian packaging (Thanks to Thomas Hood) 2011-05-12 14:01:51 +00:00
Philippe Teuwen
b98afced69 Move prescaler to CHIP_DATA struct & remove some compilation warnings 2011-05-11 23:22:52 +00:00
Philippe Teuwen
ab54a37678 list_targets support for ASK CTS512B (no anticol support yet) 2011-05-11 23:00:54 +00:00
Philippe Teuwen
53f1acfdcb _timed() fcts: allow 32b cycles counter & prescaler!=0 2011-05-11 20:56:09 +00:00
Romain Tartiere
520e64c095 Compile unit tests only on demand unless using --enable-debug. 2011-05-11 17:38:11 +00:00
Philippe Teuwen
ca3c5007f6 pn53x _timed fcts now use burst read/write on fifo register 2011-05-10 23:44:36 +00:00
Philippe Teuwen
21dfe81d0b Some optimisations in initialisation of registers 2011-05-10 23:44:27 +00:00
Romuald Conty
2a9f876363 Import BUFFER_* macros from libfreefare and use them in writeback cache 2011-05-10 19:13:08 +00:00
Romuald Conty
2e630f7e0f windows port: fix uart_receive() under Win32 platform 2011-05-10 17:02:33 +00:00
Romuald Conty
d37b917352 chips/pn53x: remove double defines for pn53x registers. 2011-05-10 15:13:19 +00:00
Romuald Conty
e4dfa75045 chips/pn53x: *_timed() functions should prefer pn53x_WriteRegister() to bypass any kind of logical handling (mask, writeback, etc) 2011-05-10 13:53:48 +00:00
Romuald Conty
9e1230bed7 debian: add debian/source/format
From Thomas Hood:
The file that should be present is debian/source/format, containing
the following line "3.0 (quilt)".  This causes dpkg-source to build source
files in the new, recommended, source format.  For details see, e.g.,
http://wiki.debian.org/Projects/DebSrc3.0
2011-05-10 13:43:19 +00:00
Romuald Conty
7bb4f4597d windows port: implement abort mecanism in pn532_uart driver (Based on provided patch: many thanks to Edwin Evans) 2011-05-10 13:26:57 +00:00
Romuald Conty
c808511694 debian: update debian files (Thanks to Thomas Hood) 2011-05-10 12:58:13 +00:00
Philippe Teuwen
0e3357b589 pn53x _timed fcts: safebelts towards new writeback mechanism 2011-05-09 21:08:03 +00:00
Romuald Conty
ef3303839a chips/pn53x: fix memset size on writeback cache, typo and fix a mask problem on data store 2011-05-09 20:42:11 +00:00
Romuald Conty
b3cade2db2 Fix writeback cache size and some typo. 2011-05-09 19:55:22 +00:00
Romuald Conty
009d851771 Implement WriteBack cache (Fixes Issue 155) 2011-05-09 19:34:00 +00:00
Romuald Conty
95914345e1 chips/pn53x: add pn53x_data_new() function to alloc and init pn53x_data structure. 2011-05-09 18:47:48 +00:00
Romuald Conty
ebb352f1f3 Clean up and add some debug msg on ReadRegister/WriteRegister 2011-05-09 15:14:50 +00:00
Romuald Conty
25e2dbec95 chips/pn53x: set ui8LastCommand in chip layer instead of driver layer. 2011-05-09 14:22:12 +00:00
Romuald Conty
902bbfb04c Fix a segfault when abort_p is NULL. 2011-05-09 11:19:01 +00:00
Romuald Conty
921d28d976 Attempt to provide an abort mecanism for windows users... 2011-05-09 11:14:43 +00:00
Romuald Conty
468027ba2b chips/pn53x: PN532 now goes in LowVBat mode when setting idle mode from target mode. 2011-05-09 10:44:44 +00:00
Romuald Conty
be0f0b0828 New function nfc_idle() to set the NFC device in idle mode.
nfc_disconnect() now switch NFC device into idle before disconnecting;
pn53x_data now have a operating_mode enum to know the current running mode (initiator, target or idle);
new pn53x_PowerDown wrapper for PowerDown (PN532) command;

Note: ARYGON idle mode now to be implemented and ACR122 does not support this mode.
2011-05-09 10:09:40 +00:00
Philippe Teuwen
a2a93e7224 nfc-relay: fix UID 2011-05-09 08:51:07 +00:00
Romuald Conty
3a9327d1be document nfc_abort_command() 2011-05-06 23:25:41 +00:00
Philippe Teuwen
d834860965 Add partial support (list) for ISO14443B-3 ST SRx & ASK CTx cards 2011-05-06 19:11:03 +00:00
Romuald Conty
805d738b24 Implement PN53x extended information frames with USB devices. (Fixes Issue 158) 2011-05-06 15:03:08 +00:00
Romuald Conty
11a91af749 Add some SFR registers description, typo in PN53X_REG_CIU_TxMode address. 2011-05-06 14:32:32 +00:00
Romuald Conty
cd6946e751 Add ISO/IEC 14443 B' aka Type B' modulation partial support 2011-05-06 14:14:06 +00:00
Philippe Teuwen
77e522aade chips/pn53x.c: allow null reception buffers for transceive commands 2011-05-05 23:13:49 +00:00
Philippe Teuwen
c0a38e6eb0 drivers: fix bug on receive: all pn53x_transceive after an error were flagged as erroneous 2011-05-05 22:26:51 +00:00
Romuald Conty
cad3dc652d chips/pn53x: print a debug trace when reading PN53x registers. 2011-05-05 18:19:20 +00:00
Romuald Conty
579102bd7b add some manual test reports. 2011-05-05 16:03:09 +00:00
Romuald Conty
04820bea47 chips/pn53x: set some parameters in FeliCa when using DEP mode. 2011-05-05 15:19:46 +00:00
Romuald Conty
80b4cd9767 chips/pn53x: set some parameters in ISO/IEC 14443A when using DEP mode (ie. SAK says ISO/IEC 18092 compliant) 2011-05-05 15:00:34 +00:00
Philippe Teuwen
e276d3e6ba nfc_target_init: drop explicitely the field 2011-05-05 14:58:26 +00:00
Romuald Conty
651d88fd15 examples/nfc-anticol: now use nfc_abort_command() 2011-05-05 14:24:27 +00:00
Philippe Teuwen
8dd8d25ef7 LoGO progressive field: remove hacks, unneeded with revised initializations 2011-05-05 12:45:56 +00:00
Romuald Conty
64b036b129 drivers: InDataExchange is an abortable command too. 2011-05-05 11:49:43 +00:00
Romuald Conty
008f2a8d4c Minor returns fixes. 2011-05-05 11:46:12 +00:00
Philippe Teuwen
eb86efa341 oops typo 2011-05-05 10:14:21 +00:00
Philippe Teuwen
4124dc662d Cleanup of initializations 2011-05-05 10:12:26 +00:00
Romuald Conty
5f890fedcc Remove obsolete callbacks 2011-05-05 09:45:39 +00:00
Romuald Conty
0265515a0c Abort mecanism is now implemented in driver layer:
iAbortFd file descriptor array have been removed from nfc_device_t;
nfc_abort_command() can now failed (return false);
nfc_abort_command() now call abort_command pointer from drivers;
pn532_uart and arygon drivers use a pipe-based mecanism (similar from previous one);
pn53x_usb driver use a boolean flag-based mecanism (the previous one does not work as expected);
pn53x_usb now print smarter messages on error at usb connection;
pn53x_usb now handle a strange case: sometimes, the first sent command is not ACKed by PN53x USB device, a dummy command is now sent.
2011-05-05 09:27:17 +00:00
Romuald Conty
72422e819b examples/nfc-dep-*: disconnect from NFC device on error. 2011-05-05 09:17:38 +00:00
Philippe Teuwen
412c326c3a better fix for timed fcts 2011-05-04 14:14:18 +00:00
Philippe Teuwen
f2cb0eaa6e list_passive_targets: fixed for TypeB on LoGO 2011-05-03 19:22:28 +00:00
Romuald Conty
9231f47123 examples/pn53x-tamashell-scripts: minor enhancements. 2011-05-03 15:10:51 +00:00
Romuald Conty
c7da492872 drivers/pn53x_usb: use progressive field on/off only for ISO14443 Type B target listing. 2011-05-03 13:55:38 +00:00
Philippe Teuwen
8169da3701 pn53x: Fix bug in _timed fcts 2011-05-03 13:55:20 +00:00
Romuald Conty
26071a817b drivers/pn53x_usb: enable progressive field on init to allow pn53x-tamashell to works (note: it does not distrib progressive field enabling when nfc_list_passive_target() is used). 2011-05-03 13:19:03 +00:00
Audrey Diacre
e82e897bd9 pn53x: oups, fix typo. 2011-05-03 12:24:33 +00:00
Audrey Diacre
85a30c0897 pn53x:reorder functions according to header. 2011-05-03 12:08:54 +00:00
Romuald Conty
96358368f5 cast explicitly sz (uint8_t) in size_t 2011-05-02 16:43:03 +00:00
Romuald Conty
517cde2517 Prepare 1.5.0 version 2011-04-29 10:13:57 +00:00
Audrey Diacre
d1b02c878a update manual-test-results.txt 2011-04-29 09:10:16 +00:00
Philippe Teuwen
fc48b7eb89 mfc: removing alpha feature to prepare release 2011-04-28 14:53:44 +00:00
Romuald Conty
59c4e69feb examples/pn53x-diagnose: fix memcmp strings coverage 2011-04-28 13:35:05 +00:00
Romuald Conty
7c274029e7 examples/pn53x-diagnose: fix PN53x commands and report internal error using nfc_perror() 2011-04-28 13:26:47 +00:00
Romuald Conty
6974fb4562 examples/nfc-dep-*: add signal handler to use the abort mecanism. 2011-04-27 15:10:14 +00:00
Romuald Conty
de9255eaea drivers/arygon: enable abort() mecanism on InJumpForDEP command 2011-04-27 15:09:22 +00:00
Romuald Conty
6fc4a5b70a Use a new current target pointer to choose correctly the sending/receiving method (ie. TgSetData/TgGetData or TgResponseToInitiator/TgGetInitiatorCommand). 2011-04-27 14:42:27 +00:00
Romuald Conty
1107b226ac drivers/pn532_uart: enable abort() mecanism on InJumpForDEP command 2011-04-27 14:38:05 +00:00
Romuald Conty
ee718d6f9b drivers/pn53x_usb: do not send ACK when its not needed, enable abort() mecanism on InJumpForDEP command 2011-04-27 14:37:24 +00:00
Romuald Conty
1198a71d64 chip/pn53x: handle PN532 "power down" and "low VBat" power mode instead of a simple "sleep" mode. (Fixes Issue 167) 2011-04-27 13:16:36 +00:00
Romuald Conty
09b18bf6b8 example/nfc-emulate-forum-tag4: add some notes about my experiments. 2011-04-22 17:32:07 +00:00
Romuald Conty
332e4afc31 drivers/arygon: add a debug message when a not supported payload is sent. 2011-04-22 17:30:17 +00:00
Romuald Conty
971d799e39 Arygon driver: append Arygon firmware version to device name. 2011-04-20 14:06:12 +00:00
Romuald Conty
f4f0b38f73 Put a comment on tcflush(), it does not produce the attempted effect. ie. there are remaining bytes from old connections. 2011-04-20 14:03:41 +00:00
Romuald Conty
762f6fb1f3 Windows: install libusb into examples directory using "Bundle" feature from CMake (Thanks to Glenn Ergeerts) 2011-04-20 13:18:38 +00:00
Romuald Conty
d86438db4e Debian: add unstable 1.5.0 trunk version to ease debian compilation. 2011-04-20 12:24:35 +00:00
Romuald Conty
231913fd35 show PRINT_HEX result on stderr in debug mode (that helps to sync with debug msg which are printed on standard error output.) 2011-04-20 12:11:31 +00:00
Romuald Conty
4996d36f5f drivers/arygon: reject too heavy payload (ARYGON does not support extended frame even with PN532 equipped device) 2011-04-14 15:50:04 +00:00
Romuald Conty
fe49ccd701 Implement extended frame send/receive for PN532_UART driver. 2011-04-13 16:39:58 +00:00
Philippe Teuwen
8a77b68b10 mfc fingerprinting: fixing data 2011-04-12 07:45:41 +00:00
Philippe Teuwen
b89eb58257 mfc fingerprinting: more data 2011-04-11 15:23:38 +00:00
Philippe Teuwen
a72e61acbb change exec mode of scripts 2011-04-09 20:01:08 +00:00
Romuald Conty
f65c601dd4 pn53x-tamashell: add a script to read Navigo card. 2011-04-09 14:51:58 +00:00
Romuald Conty
6a8e4b9c4d pn53x-tamashell: add a script to read Mobib card. 2011-04-09 14:51:11 +00:00
Philippe Teuwen
610e5c9513 tamashell example for LoGO LEDs 2011-04-08 19:50:19 +00:00
Philippe Teuwen
9a101943b8 tamashell: now pause in milliseconds 2011-04-08 19:50:09 +00:00
Philippe Teuwen
9c7c4307d4 pn53x_usb: turn off LEDs on LoGO on exit 2011-04-08 19:27:10 +00:00
Philippe Teuwen
ed715056e2 pn53x_usb: add comments on LED switching 2011-04-08 19:11:42 +00:00
Philippe Teuwen
174c916961 nfc-mfclassic: add some more fingerprints 2011-04-08 18:33:48 +00:00
Romuald Conty
0daa5822f5 add SCM SCL3711 led support: the led is now On/Off accordingly to field activation. 2011-04-08 14:42:29 +00:00
Romuald Conty
bd7c9a2b85 Enhance ASK LoGO dedicated code:
- Initialize the device right after pn53x_init() instead of pn53x_initiator_init().
 - Turn on LED1 when initialized
 - Switch On/Off LED2 on Activation/Desactivation of the field.
2011-04-08 14:30:23 +00:00
Romuald Conty
494e0f4474 windows: copy libusb.dll to bin install dir (windows needs it to be alongside the exe or in the path) (Thanks to Gleen Ergeerts) 2011-04-08 14:11:42 +00:00
Romuald Conty
ef92fc6a7b add C++ compatibility in include/nfc/nfc-emulation.h 2011-04-06 21:42:47 +00:00
Philippe Teuwen
55495e1e97 *_timed fcts: proper error codes 2011-04-05 13:44:36 +00:00
Philippe Teuwen
743fa048e1 pn53x: adapt MaxRetries to avoid issue with 2 tags on PN531, using same value as what LoGO does 2011-04-05 13:39:47 +00:00
Philippe Teuwen
fae451d236 mfclassic fingerprinting 2011-04-05 13:30:49 +00:00
Philippe Teuwen
7f2b300dde support crc auto-handling in ...transceive_bytes_timed 2011-04-04 22:23:38 +00:00
Philippe Teuwen
8d70321d80 nfc-list: fix grammatical typo if multiple tags 2011-04-04 19:21:27 +00:00
Philippe Teuwen
ffe2714b28 pn53x: factorize timer code 2011-04-04 19:04:43 +00:00
Romuald Conty
11668f1143 Chip type is filled in pn53x_init(). 2011-04-04 15:21:28 +00:00
Romuald Conty
601081d50a Calibrate PN532_UART and ARYGON drivers. 2011-04-04 15:20:33 +00:00
Philippe Teuwen
93de7fcd5c pn53x drivers: fix timer corrections location 2011-04-04 15:07:39 +00:00
Philippe Teuwen
fb398c387f pn53x: add timed versions of transceive_bytes/bits 2011-04-04 14:16:36 +00:00
Romuald Conty
b21d3c6728 ASK LoGO: enable progressive field feature. 2011-04-04 09:53:33 +00:00
Romuald Conty
71c400ae14 Fix a bug when value is larger than mask. 2011-04-04 09:53:00 +00:00
Philippe Teuwen
93c56a4b44 pn53x_usb: fix description strings 2011-04-04 09:29:14 +00:00
Philippe Teuwen
5600007dd3 pn53x: factorize & generalize CHIP_DATA() usage 2011-04-04 09:26:10 +00:00
Romain Tartiere
7314b7d598 Unbreak build.
Reported by:	yobibe
Pointy hat to:	rconty
2011-04-02 21:16:31 +00:00
Romuald Conty
5db8be908b Windows support contribution:
- Move CMake modules from cmake_modules/ to cmake/modules/
 - CMake now use cmake/config_windows.h.cmake to create config.h on Windows platform
 - contrib/windows.h header is automagically included by config.h
 - Put missing NFC_EXPORT macro on front of emulation API
 - nfc-mfclassic and nfc-mfcultralight examples are now compiled under Windows
Many thanks to Glenn Ergeerts which provide the initial patch.
2011-03-31 13:38:49 +00:00
Romuald Conty
b471f56c52 Windows: add a dummy select.h (should allow to compile pn53x_usb driver) 2011-03-31 09:59:34 +00:00
Romuald Conty
8ed870d886 windows: implement a dynamicly construct list of serial ports (Thanks to Edwin Evans) 2011-03-30 14:19:53 +00:00
Romuald Conty
2c37571a40 Add nfc-emulation source while build using CMake 2011-03-30 09:40:33 +00:00
Romuald Conty
d72d5c536e Add licence and document a bit some files. 2011-03-30 09:39:08 +00:00
Romuald Conty
fb93023401 Windows does not have err() function. 2011-03-30 09:26:23 +00:00
Romain Tartiere
e44af986a0 Unbreak aborting from the pn53X_usb driver. 2011-03-13 20:42:27 +00:00
Romain Tartiere
2d31877aec Fix header protection. 2011-03-13 20:33:00 +00:00
Romain Tartiere
53960c4643 Split user_data and state_machine_data. 2011-03-13 14:40:36 +00:00
Romain Tartiere
0f0fa2b14f Move nfc_emulate_target() from examples to the library. 2011-03-13 14:31:06 +00:00
Romuald Conty
4dad8c2307 Minor manpage improvements. 2011-03-12 16:02:11 +00:00
Romuald Conty
ef7e4c126e Update nfc-emulate-forum-tag4 manpage 2011-03-12 15:56:57 +00:00
Romain Tartiere
03913708db Add write support to nfc-emulate-forum-tag4. 2011-03-12 15:01:04 +00:00
Romain Tartiere
7b95a8a487 Load NDEF message from file if a valid filename is provided. 2011-03-11 19:01:28 +00:00
Philippe Teuwen
35e9696ada pn53x-tamashell properly properly fixed 2011-03-10 14:43:59 +00:00
Philippe Teuwen
5bc113792b pn53x-tamashell properly fixed 2011-03-10 14:38:50 +00:00
Romuald Conty
4d458ec3d6 Attempt to fix Windows port. 2011-03-09 18:41:57 +00:00
Romain Tartiere
e0dead1d7f Rewrite nfc-emulate-forum-tag4 example logic. 2011-03-09 18:17:05 +00:00
Romain Tartiere
2f60e23fd5 Cleanup macro. 2011-03-09 16:13:44 +00:00
Philippe Teuwen
3dc8d6c97c pn53x-sam: fixed with new API 2011-03-09 14:49:38 +00:00
Philippe Teuwen
351f08a54b pn53x-tamashell: fixed with new API 2011-03-09 14:45:22 +00:00
Romain Tartiere
2cca743e07 Return an error when a command is aborted;
Fix aborting with UART devices.
2011-03-09 14:10:40 +00:00
Romain Tartiere
605a5f2db3 Fix nfc_pick_device() when called from nfc_connect with NULL nfc_device_desc_t parameter (Fixes Issue 156) 2011-03-09 13:49:33 +00:00
Romain Tartiere
cfc5273275 Simplify uart_send() on POSIX systems. 2011-03-09 13:42:23 +00:00
Romain Tartiere
ad530f6d02 Various cleanups.
- New functions nfc_device_new(), nfc_device_free();
- Add experimental abort mechanism for the PN53x USB driver;
- Move chip-specific variables from nfc_device_t to pn53x_data (Fixes Issue 124).
2011-03-09 13:37:16 +00:00
Romain Tartiere
8d27768097 Implement abort in the nfc-emulate-forum-tag4 example. 2011-03-09 13:31:12 +00:00
Romuald Conty
544030099e Make libnfc compile under Windows
Apply adapted patch from Glenn (Thanks!)
2011-03-09 09:41:40 +00:00
Romuald Conty
3fb4b0e0ee pn532_uart: Use DRIVER_DATA and CHIP_DATA macros 2011-03-08 15:20:16 +00:00
Romain Tartiere
7ca0aa07c5 Initialise pn53x chip in acr122_connect(). 2011-03-08 15:09:23 +00:00
Romain Tartiere
88bff13b85 Lint the ACR122 driver. 2011-03-08 15:01:07 +00:00
Romain Tartiere
27c28944f2 Check off_t. 2011-03-08 14:36:13 +00:00
Romain Tartiere
61fa081cfe Unbreak support of ACR122.
Only tested w/ a touchatag.
@yobibe: _NO_ LED support yet (OMG!)
2011-03-08 14:33:32 +00:00
Romain Tartiere
854f18be74 Cleanup the Arygon driver. 2011-03-08 10:55:44 +00:00
Romuald Conty
70c2836798 Add some useful comments on ASK LoGO hardware, and define missing registers. 2011-03-07 02:47:21 +00:00
Romuald Conty
c457c45f55 examples/nfc-emulate-tag: minor comments improvements. 2011-03-06 18:48:25 +00:00
Romain Tartiere
3052568597 Document requirements
Update issue 95
Status: WontFix
Driver dependencies are now well documented and fits most users needs.
2011-03-06 12:00:33 +00:00
Romain Tartiere
0abfe60f35 Fix aborting from blocking command with Arygon devices. 2011-03-05 21:28:18 +00:00
Romain Tartiere
29618b7e27 Fix crash when pn53x_TgInitAsTarget() is aborted. 2011-03-05 21:27:10 +00:00
Romain Tartiere
f1f31d1b4c Unbreak and merge PN53x USB drivers.
While here fix some includes that would not work if SRCDIR != BUILDDIR.
2011-03-05 19:54:52 +00:00
Romuald Conty
094db12a1a Implements HAL struct for PN532 UART devices. 2011-03-05 10:58:36 +00:00
Romuald Conty
6d3e5d3899 drivers/arygon: code clean up 2011-03-05 10:56:35 +00:00
Romuald Conty
0efa47880b Hardware abstraction layer for libnfc:
Suppress any PN53x references in nfc.c
Improve nfc_driver_t struct to embedded HAL API
Merge macros from nfc-messages.h into nfc-internal.h
Remove useless files: nfc-messages.h, buses.h and chips.h
Implement HAL for ARYGON driver
Move send/receive callbacks from nfc_driver_t to internal chip io callbacks (since there are dedicated to pn53x framing)
2011-03-05 10:06:52 +00:00
Romuald Conty
9b202d1dbf prefer one-line protypes in API. 2011-03-05 09:09:13 +00:00
Romuald Conty
f1e69a7658 silent warnings in examples/. 2011-03-05 09:07:43 +00:00
Romuald Conty
bd04a1ab9a oops: add missing lines in nfc-utils.h. 2011-03-05 08:55:53 +00:00
Romuald Conty
dba06a555e remove nfc-message.h usage from examples. 2011-03-05 08:53:46 +00:00
Romain Tartiere
a55a52e0a9 Fix pn53x_InAutoPoll() return value on user cancelation (true instead of false). 2011-03-05 01:46:16 +00:00
Romain Tartiere
76a1744d37 Lint returns. 2011-03-05 01:45:49 +00:00
Romain Tartiere
97dd0b63d7 Implement abort for pn532_uart driver. 2011-03-04 20:17:28 +00:00
Romain Tartiere
4b6060aeeb Enable aborting blocking commands (e.g. TgInitAsTarget) and refactor
*_check_communication() as pn53x_check_communication().
2011-03-04 19:59:49 +00:00
Romain Tartiere
7ed71a1501 Merge r912 into trunk. 2011-03-04 15:49:16 +00:00
Romuald Conty
172beccf6c drivers/arygon: do not hard code PN532 chip type: pn53x_init() determine it and ARYGON device seems to not need to be waken up. 2011-03-04 11:26:15 +00:00
Romain Tartiere
fe7ec36fb7 Fix Arygon driver reported name. 2011-03-04 11:23:52 +00:00
Romain Tartiere
4d65868208 Only call pn53x_init() from the drivers initialization functions. 2011-03-04 11:23:20 +00:00
Romain Tartiere
b1521a3bb1 If the current driver name does not match what we are looking for, move to the
next one before retrying.
2011-03-04 11:18:47 +00:00
Romain Tartiere
61a5268d65 Do not coredump if we have an unexpected reply.
If we are speaking to the wrong device, it is very likely we will have an
"unexpected reply" and we should ignore it.
2011-03-04 11:16:18 +00:00
Romuald Conty
f81138b3c7 ARYGON driver works again and PN532_UART improved :)
drivers/pn532_uart: code clean up
chips/pn53x: new fonction to build frames
drivers/arygon: use the new way to drive UART (its far more stable)
2011-03-04 09:28:25 +00:00
Romuald Conty
7ec1080e16 Remove a dummy argument in pn53x_transceive(). 2011-03-02 15:32:52 +00:00
Romuald Conty
2608b3dc55 smart merge of r906 into trunk (Thanks to marko259 from libnfc forum). 2011-03-02 15:18:06 +00:00
Romuald Conty
4b6ba0aa3c Always set the size of Rx buffer (prevent from overflow) 2011-03-02 15:02:30 +00:00
Romuald Conty
5af845cdfc Broke whole the libnfc :-)
use a new way to handle drivers
use absolute include path instead of relative ones
move some nfc_device_t members in a better place
nfc_device_t now embeddeds driver data and chip data pointers (useful to be more generic)
use more readable variables instead of strange coding convention
move PRINT_HEX macro into nfc-internal.h
silent warnings with more strict CFLAGS
chips/pn53x: use the powerful C99 writing to construct PN53x commands
chips/pn53x: remove almost all memcpy()
chips/pn53x: WriteRegister, ReadRegister and SetParameters command wrappers are correctly named
chips/pn53x: introduce chip state (SLEEP, NORMAL or EXECUTE)
chips/pn53x: add SAMConfiguration command wrapper (need to be improved)
chips/pn53x: remove almost all const arrays
chips/pn53x: use human readable defines for commands instead of hex values
chips/pn53x: in debug mode, the PN53x command is shown in human-readable string, awesome isn't it? ;-)
drivers: split transceive() into send() and receive() to be able to handle more cases (differed replies, abort commands, etc) later
drivers: use a const structure of functions instead of -dirty- callbacks array
drivers/pn532_uart: major improvement of UART handling
drivers/pn532_uart: check PN53x frames when received
buses/uart: receive() is now based on expected bytes instead of calculated timeouts..
buses/uart: use a smart way to determine available ports on POSIX systems (tested on Linux and FreeBSD)
2011-03-02 15:00:44 +00:00
Romuald Conty
f1d909ae74 trunk is should now be considered as unstable. 2011-03-01 11:34:07 +00:00
Romuald Conty
979fc1b5f5 examples: fix broken internal pn53x API. 2011-03-01 11:26:00 +00:00
Romuald Conty
4384d27f3e examples: silent some compilation warnings. 2011-02-28 09:47:31 +00:00
Romuald Conty
dbe59f83d9 set more strict CFLAGS to wrote great code ;-) 2011-02-28 09:45:09 +00:00
Romain Tartiere
62736ab48b Rework cleanup to drop code coverage information. 2011-02-26 00:21:27 +00:00
Romain Tartiere
b9dee63467 Update devd(8) rules file for FreeBSD. 2011-02-26 00:19:34 +00:00
Romuald Conty
d2192fb850 nfc-mfclassic: UID was shown reverse-ordered. (Fixes Issue 146) 2011-02-23 15:14:14 +00:00
Romuald Conty
b4d23795de Prepare 1.4.2 version 2011-02-22 14:17:20 +00:00
Philippe Teuwen
5df49391a9 pn53x-tamashell: add pause command & doc 2011-02-18 22:05:36 +00:00
Philippe Teuwen
3af79394b4 Readme typo 2011-02-18 09:01:30 +00:00
Romuald Conty
2ad6591f31 pn532_uart: fix pn532 wakeup response handling 2011-02-15 18:08:35 +00:00
Romuald Conty
695dc75037 uart: fix remaining bytes computation 2011-02-15 18:06:24 +00:00
Romuald Conty
e110a78de7 uart: do not reload static timeout as it is already past (static timeout is used to compensate response delay) 2011-02-14 13:24:42 +00:00
Romuald Conty
555c32015c uart: prevent from retrieving more than buffer length (potential buffer overflow) 2011-02-14 13:23:39 +00:00
Philippe Teuwen
287bbfeea3 pn53x-tamashell: fix bug introduced by r878 2011-02-10 14:29:29 +00:00
Romuald Conty
243100b676 Silent some compilation warnings (Fixes Issue 145) 2011-02-10 10:38:21 +00:00
Romuald Conty
f272e156e8 Add new README-Windows.txt file to distributed archive. 2011-02-07 12:34:13 +00:00
Romuald Conty
d7aa94dc17 Import README-Windows.txt file: thanks to you Glenn, libnfc now have Windows build instructions. 2011-02-07 12:31:08 +00:00
Romuald Conty
ca3efe2517 nfc-mfclassic: fixes a segfault when using only 1 argument (Fixes Issue 142) 2011-02-06 19:46:16 +00:00
Roel Verdult
ffd1eb1875 falling back to POSIX compatible commands, fgets in stead of getline. MacOSX / BSD doesn't come with glibc on default 2011-02-05 20:52:55 +00:00
Romuald Conty
fa4f6ca2ad nfc-emulate-uid: nfc_target_init() needs a emulable UID at first. (Fixes Issue 143) 2011-02-04 17:43:36 +00:00
Romuald Conty
bb1ebea711 debian: only install *.cmd from examples/pn53x-tamashell-scripts/ 2011-02-04 14:32:42 +00:00
Philippe Teuwen
af7d04cd04 tamashell: accepts script as arg, this makes shebang possible 2011-02-03 17:17:29 +00:00
Romuald Conty
8c3caed99f Add missing CMake files to generated tarball. (Thanks to Glenn) 2011-02-03 09:51:38 +00:00
Romuald Conty
25e04988a1 README: if ACS CCID is used the pcsc-lite configuration file is different. 2011-02-02 14:44:38 +00:00
Romuald Conty
6f36352265 README: be more generic on the pcsc-lite configuration file. 2011-02-02 14:20:16 +00:00
Romuald Conty
91419f8ad3 chip/pn53x: set register directly if mask cover whole value. 2011-02-01 21:38:25 +00:00
Romuald Conty
58ad2a5760 Add new supported device: ASK / LoGO. (Thanks to ASK for sending one sample of this device) 2011-02-01 21:20:48 +00:00
Romuald Conty
659d7a9de1 Prepare 1.4.1 version 2011-02-01 09:49:41 +00:00
Romuald Conty
bb1fc9cd87 Remove unrelevant file. 2011-02-01 09:27:27 +00:00
Romuald Conty
200487d172 Fix typo 2011-02-01 09:23:30 +00:00
Emanuele Bertoldi
35188bff25 Removed hard-coded size of ack frame. 2011-01-28 10:22:21 +00:00
Romain Tartiere
cf92bfaeee Fix crash when file cannot be opened for writing. 2011-01-20 15:42:46 +00:00
Emanuele Bertoldi
eae07f1977 Improved UART communication on POSIX systems:
- Added "dynamic timeout" to "uart_send" function.
- Added "static timeout" to each iteration of the while loop (it seems to solve a lot of sync troubles during read operation). 
(Tested with PN532).
2011-01-18 11:35:23 +00:00
Romuald Conty
58c5662f35 Improve Windows platform support (Thanks to Glenn)
* Remove stdint for MSVC since MSVC is not supported anymore;
 * Fix libusb detection under Windows;
 * Fix PCSC detection (mingw-w64 now have PC/SC Winscard interface);
 * Ajust CMake files in order to make it compile (some examples have been disabled).
2011-01-17 13:42:24 +00:00
Romuald Conty
f32013aba5 Define MIN/MAX on Windows platform (Thanks to Glenn) 2011-01-17 13:41:25 +00:00
Romuald Conty
d5c8188e99 Fix missing pn53x-tamashell-scripts in generated tarball. (thanks to usermeister) 2011-01-17 13:31:04 +00:00
Emanuele Bertoldi
b58816df05 Fixed issue #139: serial autoprobe now skips invalid devices but checks all ports in the list. 2011-01-14 16:39:02 +00:00
Roel Verdult
55be1debaf added include for MIN macro, fixed typo in determin buffer size 2011-01-11 12:04:42 +00:00
Romuald Conty
0f8c23bddd Inform user if target UID can be emulated
New error: ETGUIDNOTSUP raised when UID is not 4 bytes long or does not start with 0x08 (Security restriction present in the NXP PN53x chips)
2011-01-07 16:15:18 +00:00
Philippe Teuwen
03963ef535 nfc-emulate-tag: handle HALT & READ 2011-01-07 13:22:39 +00:00
Philippe Teuwen
73561c5c1a nfc-emulate-tag.c: add notes on UID emulation 2011-01-07 12:32:25 +00:00
Romuald Conty
cfa5e9be58 Fix typo. 2011-01-07 10:56:43 +00:00
Romuald Conty
ba1db2f406 chips/pn53x: name commands like user manual 2011-01-06 14:52:45 +00:00
Romuald Conty
d956ffb386 examples/nfc-emulate-tag: switch off easy framing when we are not emulating a ISO14443-4 target 2011-01-06 14:43:41 +00:00
Romuald Conty
88c14f5d4b Oops, revert wrong file commit 2011-01-06 14:06:01 +00:00
Romuald Conty
556918b298 Add some manual tests with ARYGON APDB2UA33. 2011-01-06 14:04:48 +00:00
Romuald Conty
432eff0f7d Fix polling on ARYGON devices 2011-01-06 14:00:05 +00:00
Romuald Conty
dd8ec29bb4 chips/pn53x: prefer pn53x_transceive() when possible. 2011-01-06 13:59:20 +00:00
Romuald Conty
6edb5a3bef Fix reply frame length for InAutoPoll 2011-01-06 13:20:45 +00:00
Romuald Conty
6ca32fbfb9 Fix reply length from transceive bits/bytes functions 2011-01-06 13:07:38 +00:00
Romuald Conty
dcdad1e2e6 debian: enable serial autoprobing (needed for ARYGON devices) 2011-01-06 12:40:51 +00:00
Romuald Conty
1d085f21c9 Improve PN53x frame size calculation.
chips/pn53x: adjust size and defines to better handle reply size;
drivers/arygon: improve attempted reply size, should speed up the connexion;
drivers/pn532_uart: improve attempted reply size, should speed up the connexion;
2011-01-06 12:39:29 +00:00
Romuald Conty
26b26f9783 Comment out debug messages and use MIN() macro from <sys/param.h> 2011-01-06 12:31:31 +00:00
Romuald Conty
1336c73e0c example/nfc-mfultralight: handle lock page writing 2011-01-04 09:55:43 +00:00
Romuald Conty
53c8917353 Attempt fix some UART timeouts, should also allow lower devices to be detected. 2010-12-30 10:01:06 +00:00
Romuald Conty
ba37313cb8 Prevent from stack corruption when using PN533-based device and add errors handling for ReadRegister and WriteRegister. (Fixes Issue 135) 2010-12-29 14:01:14 +00:00
Romuald Conty
84710f266b nfc-mfultralight: remove unused variable 2010-12-29 13:16:30 +00:00
Romuald Conty
59a93eab45 Add register access test. 2010-12-29 13:15:49 +00:00
Romuald Conty
e38636c4ac CMake fixes (Thanks to glenn from libnfc's forum) 2010-12-21 11:06:43 +00:00
Philippe Teuwen
9c3fccb073 README: more troubleshooting info 2010-12-13 13:07:55 +00:00
Romuald Conty
12324873d3 Document ACR122 problem with pcsclite. (Fixes Issue 131) 2010-12-13 11:58:04 +00:00
Philippe Teuwen
3b62d2512c nfc-mfultralight: fix 7byte UID display 2010-12-09 23:40:03 +00:00
Romuald Conty
ca594f3198 Update ChangeLog 2010-11-17 14:44:22 +00:00
Romuald Conty
5e9e177319 Change examples license for the sake of consistency: LGPL covers library, re-usable examples code is now under BSD license. 2010-11-17 14:27:11 +00:00
Romuald Conty
6aa07aa78b Add extra dist to make distcheck pass and force distcheck to compile all drivers 2010-11-17 10:14:26 +00:00
Romuald Conty
66aef98c40 Define strdup under Windows in contrib/windows.h 2010-11-17 10:10:34 +00:00
Romuald Conty
835823809f Split UART implementations: POSIX and Windows
It could ease to port to other system like MiKey and it should be easy to track which is the concerned OS while uart driver is modified.
2010-11-17 08:48:03 +00:00
Romuald Conty
58dcf63e7c MERGE: libnfc-mingw-cross merge with trunk (r805-821) 2010-11-17 08:29:41 +00:00
Romuald Conty
6df612a364 Errors use #define instead of constant values.
Update Issue 84
Current 'ident' command breaks commit-concerned lines.
2010-11-15 18:50:53 +00:00
Philippe Teuwen
779fdd5df6 Tweaks Touchatag detection under MacOSX (Fixes issue 128) 2010-11-15 13:00:07 +00:00
Romuald Conty
6e29450d69 Fix memory leak while using *_pick(). Thanks to frankmorgner (Fixes Issue 130) 2010-11-12 19:24:20 +00:00
Romuald Conty
6e70cfa5ef Fix UART default serial ports under Linux. 2010-11-12 18:38:47 +00:00
Romain Tartiere
ad5959e860 Really fail if pkg-config is not present.
Submitted by:	Amnesia, bigjay via IRC.
2010-11-05 11:36:20 +00:00
Romain Tartiere
4e5d0766e1 Rename append_iso14443a_crc() to iso14443a_crc_append(). 2010-10-29 10:59:26 +00:00
Romuald Conty
af0a47ad2c Upgrade Debian: add pn53x scripts to libnfc-pn53x-examples package 2010-10-26 15:40:34 +00:00
Romuald Conty
f252bec18f Upgrade debian package: split experimental examples from regular ones 2010-10-26 15:35:55 +00:00
Philippe Teuwen
26de9d3a69 nfc-anticol: Computes CRC rather than hardcoded one. psst: r800 \o/ 2010-10-26 15:01:46 +00:00
Romuald Conty
7b29e44698 Updating ChangeLog 2010-10-26 14:43:45 +00:00
Romuald Conty
5f4f7cd45a Bump package version 2010-10-26 14:31:22 +00:00
Romuald Conty
a214974684 Remove INFO macro: display was not clear enough and does not provide a big benefit.
New Issue
Summary: Remove nfc-message.h file from installed ones
nfc-message.h provide some usefull debugging macros but I am not sure that these macros have to be installed with other files.
2010-10-26 14:27:17 +00:00
Philippe Teuwen
1963bb65e4 nfc-anticol: Cascade based on SAK rather than CT, better for educational purpose 2010-10-25 13:48:01 +00:00
Philippe Teuwen
56e37ec309 nfc-anticol: Adds support for CL3 (Fixes issue 126) Thanks. 2010-10-25 13:00:39 +00:00
Romuald Conty
5c8749c63e drivers/arygon: retrieve ARYGON firmware version 2010-10-22 15:21:06 +00:00
Romuald Conty
8798f6bbcd Fix ARYGON driver:
- Does not send any ACK frame at start: my ARYGON does get happy with this frame (see code comments)
 - Send a TAMA reset (for PN532) instead of ACK frame
 - Remove bzero use: its a deprecated function
2010-10-22 14:29:44 +00:00
Romuald Conty
ca8c5cabe1 Fix minor compilation warnings 2010-10-22 14:25:09 +00:00
Romuald Conty
1a320d5577 Adjust uart's timeout from baud rate 2010-10-22 14:10:36 +00:00
Philippe Teuwen
17f79a744b Updating ChangeLog & NEWS 2010-10-20 20:56:12 +00:00
Philippe Teuwen
5a6bb0bbc5 examples: mifare.c fix potential bug when used in non-EasyFraming environment 2010-10-20 18:11:06 +00:00
Romuald Conty
97cf9e925b Attempt to fix ARYGON driver 2010-10-20 16:14:53 +00:00
Philippe Teuwen
0abdf67b8b nfc-anticol: fix bug in long UID display, and some more details 2010-10-20 15:23:09 +00:00
Romuald Conty
72d7b66d2b Handle more corner case during convertion from nfc_* types to available pn53x_* types 2010-10-20 09:28:36 +00:00
Romuald Conty
311471024a Fix printing of 847 kbps baud rate and a minor compil warning 2010-10-20 09:27:34 +00:00
Romuald Conty
dd0c4ad785 Update ChangeLog 2010-10-20 08:34:54 +00:00
Romuald Conty
5538fbd20f Add NBR_847 (used with ISO14443B) and update convert function. 2010-10-20 08:34:06 +00:00
Philippe Teuwen
aba4cec7d6 nfc-utils: more ATQA/SAK fingerprinting 2010-10-19 21:36:43 +00:00
Romuald Conty
ccbd2d83c6 Add NEWS file to summarize important changes (like API ^^) 2010-10-19 15:50:18 +00:00
Philippe Teuwen
838db98400 Examples: more ISO14443A ATQA+SAK possible matches 2010-10-19 13:08:56 +00:00
Philippe Teuwen
2b24a0a7f5 Examples: more ISO14443A info decoding & verbose mode for nfc-list 2010-10-19 12:50:52 +00:00
Romuald Conty
f249af6266 Add ISO14443-4 modulation to hardware polling only when NDO_AUTO_ISO14443_4A have been enabled and document this features and known issues. 2010-10-19 09:34:18 +00:00
Philippe Teuwen
f75d2d3582 Typo 2010-10-18 16:17:01 +00:00
Romuald Conty
f9391ad823 Update some TODOs 2010-10-18 15:47:56 +00:00
Romuald Conty
57560c3290 Document the ACR122 problem.
Update Issue 117
Status: WontFix
ACR122 device support is limited. We can not provide a rock-solid support of emulation on these devices this way (talking directly to PN532).
2010-10-18 15:17:31 +00:00
Romuald Conty
b5d85fc6e1 Decode supported modulation from PN53x 2010-10-18 14:26:49 +00:00
Romuald Conty
bfb49b594f Clean the way to retrieve firmware 2010-10-18 13:19:30 +00:00
Romuald Conty
c6c43afc87 Minor FIXME or XXX removes 2010-10-18 12:22:04 +00:00
Romuald Conty
65da34398d nfc-list: clean up configuration, that now handled by nfc_initiator_list_passive_targets() 2010-10-18 10:12:24 +00:00
Romuald Conty
7d59b6b1a3 Make sure the field is disabled then enabled before listing.
Improve documentation about default configuration values.
2010-10-18 10:11:30 +00:00
Romuald Conty
ecc1eeca8f API documentation improvement: explain a bit what is pbtInitData for nfc_initiator_select_passive_target() 2010-10-18 09:53:14 +00:00
Philippe Teuwen
43f2004b11 nfc-relay-picc: remove unused #define 2010-10-16 09:57:39 +00:00
Romain Tartiere
b8910c5bd5 Sum up recent API changes for the user. 2010-10-15 19:35:53 +00:00
Romuald Conty
1f62e9e2f2 Improve API for target emulation, nfc_target_mode_t does not exist anymore (this mode is computed from nfc_target_t) 2010-10-15 14:32:10 +00:00
Roel Verdult
1e52e1dc9f fixed printf warning 2010-10-15 13:27:18 +00:00
Philippe Teuwen
655460059a nfc-utils: more decoding of ISO14443-4 Tk bytes 2010-10-15 08:57:58 +00:00
Philippe Teuwen
91f73e1802 nfc-utils: More decoding of ISO14443-4 ATS 2010-10-15 08:33:46 +00:00
Philippe Teuwen
33a99288f3 pn53x target_init: fix bug to use Tk; nfc-relay-picc: fix potential segfault 2010-10-14 20:17:58 +00:00
Philippe Teuwen
894d6b8d3b Oops typo 2010-10-14 18:37:10 +00:00
Philippe Teuwen
ffe50562dd Make use of the now available Tk info 2010-10-14 18:33:17 +00:00
Romuald Conty
cbca45e21c Oups it miss some space to handle HB. 2010-10-14 17:43:28 +00:00
Romuald Conty
41758ab63f pn53x_target_init() now takes care of Historical Bytes 2010-10-14 17:38:54 +00:00
Romuald Conty
4a50be27de Add a iso14443a function to extract Historical Bytes from ATS 2010-10-14 17:32:15 +00:00
Romuald Conty
8142e69121 Fix a misunderstood Historical Bytes decoding 2010-10-14 16:28:16 +00:00
Romuald Conty
7c76e1bf32 nfc_target_init() now update nfc_target_t baud rate 2010-10-14 16:27:50 +00:00
Romuald Conty
7294e4fbaf examples/nfc-utils: decode more ATS info 2010-10-14 14:48:59 +00:00
Romuald Conty
507a23b708 Improve nfc_target_init() 2010-10-14 13:31:36 +00:00
Romuald Conty
60c9da598a Support different baud rates for nfc_initiator_select_dep_target() 2010-10-14 13:03:23 +00:00
Romuald Conty
2f267f5463 nfc-relay-picc: Add new example to relay ISO14443-4 communications, with this one it can communicate over network... Enjoy! (Thanks to generous contributor) 2010-10-14 12:27:51 +00:00
Philippe Teuwen
5a5b5d681b Small typos 2010-10-14 11:53:27 +00:00
Romuald Conty
af88da1a9c Replace nfc_target_info_t with nfc_target_t in API function, we now have a coherent struct to handle nfc_target_t, use it! 2010-10-14 11:44:43 +00:00
Romuald Conty
6f3fbcb6bf Fix nfc_dep_mode_t usage in API, fix/improve documentation 2010-10-14 11:12:23 +00:00
Romuald Conty
f559838352 MERGE (less-strange-types): Clean up libnfc's types.
* Old nfc_modulation_t became pn53x_modulation_t (not accessible from API);
  * Old nfc_target_type_t became pn53x_target_type_t (not accessible from API);
  * New nfc_modulation_type_t (NMT_ISO14443A, NMT_ISO14443B, NMT_JEWEL, etc.);
  * New nfc_baud_rate_t (NBR_106, NBR_212, etc.);
  * New nfc_modulation_t that contains a couple { nfc_modulation_type_t, nfc_baud_rate_t };
  * nfc_target_t now have nfc_modulation_t instead of the old strange nfc_target_type_t;
  * Move some pn53x oriented code from nfc.c to chips/pn53x.c (pn53x_initiator_select_passive_target);
  * New nfc_dep_mode_t type to handle ACTIVE/PASSIVE mode of DEP;
  * Split logical part and wrapping part for InAutoPoll;
  * Add conversion functions: nfc types to pn53x types, and vice versa;
  * examples/nfc-utils: Add print_nfc_target() and str_nfc_baud_rate() to display nfc_target_t;
  * Add manual test results.
2010-10-14 10:28:01 +00:00
Philippe Teuwen
dccaaa383f update manual-test-results.txt 2010-10-14 08:59:49 +00:00
Philippe Teuwen
9c23fc1dea Manual tests: doc command to sort easily 2010-10-13 23:22:21 +00:00
Romuald Conty
3146c4c150 update manual-test-results.txt 2010-10-13 22:56:29 +00:00
Romuald Conty
7703c9672d sort manual-test-results.txt 2010-10-13 22:54:17 +00:00
Philippe Teuwen
2db760a2c4 Manual tests: some more results... 2010-10-13 22:49:15 +00:00
Romuald Conty
9c075a98d1 Add manually done test results. 2010-10-13 22:40:42 +00:00
Romuald Conty
d41e7f2ca0 Hack polling modulations in order to have ISO14443-4 with ATS and ISO14443-3 targets 2010-10-13 22:28:29 +00:00
Romuald Conty
3c4972b9a3 Add TODO 2010-10-13 22:26:17 +00:00
Romuald Conty
9d9b5a629e Fix nfc-poll, improve pn53x_target_type_t decoding 2010-10-13 21:40:54 +00:00
Romuald Conty
adba90684d introduce nfc_dep_mode_t type instead of bool in nfc_initiator_select_dep_target() 2010-10-13 19:59:39 +00:00
Romuald Conty
124cc28bac Typo 2010-10-13 19:51:21 +00:00
Romuald Conty
f2a3d51037 Fix a bug introduce in r729, fix a compilation warning 2010-10-13 19:50:43 +00:00
Romuald Conty
ec601f6a00 Fix two bugs introduced in r729, typo. 2010-10-13 19:31:02 +00:00
Romuald Conty
d67527932c Add some FIXME/TODO about PN532 that does not supported B type (ISO14443) 2010-10-13 19:24:24 +00:00
Romuald Conty
979430ecd1 nfc_target_t have now nfc_modulation_t instead of nfc_modulatation_type_t 2010-10-13 19:17:51 +00:00
Romuald Conty
584a18ec11 Remove unused pn53x_modulations 2010-10-13 18:41:48 +00:00
Romuald Conty
d289eabc36 Attempt to provide clean types for API 2010-10-13 17:43:23 +00:00
Romuald Conty
9020014160 Rename nfc_modulation_t as pn53x_modulation_t 2010-10-13 15:39:52 +00:00
Romuald Conty
695e5c2f37 Rename nfc_target_type_t as pn53x_target_type_t 2010-10-13 15:31:48 +00:00
Romuald Conty
c53c512831 Change some nfc_target_type_t to insist on the ISO/IEC 14443-4 compliance 2010-10-13 11:49:34 +00:00
Romuald Conty
0fe30e3db7 Change some nfc_target_mode_t to insist on the restrictions offer these mode 2010-10-13 11:35:28 +00:00
Philippe Teuwen
572499f598 pn53x_usb: remove USB timeout (Fixes issue 122) 2010-10-13 07:21:34 +00:00
Philippe Teuwen
2fb1de34f4 pn53x_usb: try to recover device if usb read fails, solves partly Issue 122 2010-10-12 16:04:40 +00:00
Philippe Teuwen
9d1e72a9f7 pn53x_usb: leave the device in cleaner state (Fixes Issue 123) 2010-10-12 15:51:57 +00:00
Romuald Conty
61b0df5fe9 Minor documentation fix 2010-10-12 15:34:37 +00:00
Romuald Conty
c34be50ef1 For the sake of consistency, rename all szRxLen to szRx and szTxLen to szTx 2010-10-12 14:56:42 +00:00
Romuald Conty
5d753827c1 Add a nfc-utils fonction (not in API) to display nfc_target_type_t as string 2010-10-12 14:05:28 +00:00
Romuald Conty
202c2a7a8b nfc-emulate-uid: fix wrong UID length in initial nfc_target_t 2010-10-12 14:04:30 +00:00
Romuald Conty
d7bffac0e6 Fix const bytes notation, string notation will add EOL ('\0') 2010-10-12 14:02:53 +00:00
Romuald Conty
b333a4b1cf Add FeliCa to emulation capabilities 2010-10-12 09:44:39 +00:00
Romuald Conty
c67d915250 Attempt to fix pcsc-lite detection on MacOS 2010-10-12 08:20:46 +00:00
Romuald Conty
2857b1dd1a Remove a wrong FIXME 2010-10-11 14:53:10 +00:00
Romuald Conty
602787bd03 We can now use an nfc_dep_info_t to specify DEP info as initiator. 2010-10-11 14:49:08 +00:00
Philippe Teuwen
ddb8fe9b1f nfc-relay: fix UID len & doc 2010-10-11 11:35:46 +00:00
Romuald Conty
6e932142f0 arygon: send ACK frame for ARYGON devices too. 2010-10-11 10:54:49 +00:00
Romuald Conty
0bdef6cb2a pn532_uart: send ACK frame to cancel a eventual previous command during nfc_connect() too. 2010-10-11 10:53:24 +00:00
Romuald Conty
49e6fff104 pn532_uart: start with sending an ACK frame to cancel a eventual previous command. 2010-10-11 10:41:03 +00:00
Romuald Conty
08b06c1d03 Emulated DEP targets can now be customized (NFCID3 and General Bytes). 2010-10-08 21:54:59 +00:00
Philippe Teuwen
b72ce3decd Add pn53x-tamashell manpage 2010-10-08 21:31:12 +00:00
Romuald Conty
b8395d9506 Rename nfcip-* examples to nfc-dep-* 2010-10-08 20:36:13 +00:00
Romuald Conty
1e9c390dfa Improve DEP info struct: add more info, and InJumpDEP now fill fully this struct. 2010-10-08 20:25:34 +00:00
Philippe Teuwen
1d0c7fe68e Examples: some more misc fixes 2010-10-08 20:01:47 +00:00
Philippe Teuwen
7128eabfad Examples: misc fixed & enhancements in the doc 2010-10-08 19:24:54 +00:00
Romuald Conty
74a8ebde41 nfcip-*: Add man pages. 2010-10-08 18:28:23 +00:00
Romuald Conty
13d0bb7b0f nfcip-*: code clean up, enhance output to understand what happens. 2010-10-08 18:15:00 +00:00
Romuald Conty
bf1f9c68d3 nfc-list: remove some useless calls to nfc_configure(), these settings are applied by default. 2010-10-08 18:13:18 +00:00
Romuald Conty
aeadaf536c nfc-poll: code clean up, add man page. 2010-10-08 17:05:05 +00:00
Romuald Conty
8ec4c57910 pn53x-diagnose: add man page. 2010-10-08 16:57:09 +00:00
Romuald Conty
9b3dbc272c Update existing man pages. 2010-10-08 16:24:04 +00:00
Romuald Conty
994b119c32 nfc-emulate-forum-tag4 (renamed from nfc-emulate-ndef): add a man page. 2010-10-08 15:37:21 +00:00
Romuald Conty
fd211d53f8 nfc-emulate-tag: improve documentation, add a man page. 2010-10-08 14:45:48 +00:00
Romuald Conty
993a16f17c nfc-emulate-uid: finalize renaming. 2010-10-08 14:10:28 +00:00
Romuald Conty
79ebce2549 examples: rename nfc-emulate to nfc-emulate-uid.
Add some code documentation.
Update man page.
2010-10-08 14:05:10 +00:00
Romuald Conty
69bf5caa9d Enforce sources cleaning before tarball build. 2010-10-08 13:52:19 +00:00
Romuald Conty
1565d540a8 Remove useless FIXME 2010-10-07 13:00:57 +00:00
Romuald Conty
840ff89450 Fix minor warnings 2010-10-07 12:59:12 +00:00
Romuald Conty
814ccad1e3 Only send WriteRegister command if register sent value is different from actual one. 2010-10-07 09:46:21 +00:00
Philippe Teuwen
cb346cf20b nfc-emulate-ndef: some more doc 2010-10-06 21:04:52 +00:00
Philippe Teuwen
b74267901d nfc-emulate-tag: some more doc & Mifare example (not complete) 2010-10-06 20:31:36 +00:00
Romuald Conty
b8d65f9b27 Keep the last byte as \0 to be sure abtFw will be null-terminated. Fixes an issue I have with my ACR122U205: the last char of the firmware string was changing each nfc-list launch. 2010-10-06 17:52:15 +00:00
Romuald Conty
d9505bbbcc Better handling of SetParameters command, use a cache, prevent from double set, adjust comments, remove junk code. 2010-10-06 15:12:33 +00:00
Romuald Conty
623c8bbeef Remove useless FIXME 2010-10-06 10:11:24 +00:00
Romuald Conty
da7a2bc4c6 Add ISO/IEC 14443B baud rates: 212, 424 and 847 kbps. Set a device error when using a not supported modulation baud rate in InListPassive(). 2010-10-06 10:06:12 +00:00
Romuald Conty
e03fb8a916 Minor code clean up. 2010-10-06 10:02:12 +00:00
Romuald Conty
5fdb7ab254 examples: rename nfc-sam to pn53x-sam, it need to made some direct calls to pn53x_* functions. 2010-10-06 09:10:14 +00:00
Romuald Conty
ec3f854a68 nfc-sam: code clean up and fix comments 2010-10-06 09:03:08 +00:00
Philippe Teuwen
69fba08661 acr122u: fixes escape ioctl under linux & make it OS-dependent, to be tested on other OSes! 2010-10-05 13:49:48 +00:00
Philippe Teuwen
d75e25d29d nfc-emulate-ndef now using easy framing & fix timing issues 2010-10-05 10:05:22 +00:00
Philippe Teuwen
2024e5f904 nfc-list: add example how to address directly a USB device by its name 2010-10-05 07:53:19 +00:00
Philippe Teuwen
6eca8843f6 nfc-emulate-ndef: document exchange & remove compil warning 2010-10-04 21:01:11 +00:00
Romuald Conty
98d0f2522f nfc-emulate-tag: add DESELECT command, enhance debug 2010-10-04 19:17:40 +00:00
Romuald Conty
e800765ffc nfc-emulate-ndef: remove one pn53x_set_parameters(). Note: it works a lot better with ARYGON (serial @9600 bauds) than touchatag through PCSC and USB. 2010-10-04 18:12:57 +00:00
Romuald Conty
ad7a8a59a6 nfc-emulate: Use a better const byte_t notation (no \0 EOL character). 2010-10-04 18:00:17 +00:00
Romuald Conty
e9fdccfa63 Fix missing renaming. 2010-10-04 16:34:02 +00:00
Romuald Conty
178f73d98a nfc-sam: NTM_PICC does exist anymore and I dont think thats needed to all but ISO14443-4 initiator in this place. 2010-10-04 13:30:12 +00:00
Romuald Conty
da1de80aa6 nfc-emulate-ndef: use nfc_target_receive_bytes() instead of pn53x_target_receive_bytes(), adjust NTM_PICC new name 2010-10-04 13:28:36 +00:00
Romuald Conty
92cc9a5736 Add non restrictive mode for emulation (NTM_NORMAL), fix comments, rename NTM_PICC to insist on "ISO14443-4" PICC mode. 2010-10-04 13:26:47 +00:00
Romuald Conty
5233fceda7 Improve the target emulation functions (ATM, only ISO14443A), add an example (nfc-emulate-tag), update examples to use the new API. 2010-10-04 12:46:03 +00:00
Romuald Conty
d2d15afa3b examples: minor enhancements 2010-10-04 12:43:22 +00:00
Romuald Conty
afb1c3a0f8 examples: minor enhancements 2010-10-04 12:37:43 +00:00
Philippe Teuwen
80ee446f74 pn53x-tamashell now accepts scripts, see examples 2010-10-04 12:36:29 +00:00
Romuald Conty
f23a8eced3 Fix minor autotools warning 2010-10-04 12:31:55 +00:00
Romuald Conty
17b940c610 Finalize pn53x-tamashell integration (add readline m4, fiw minor warnings, adjust Makefile.am) 2010-10-04 10:24:45 +00:00
Philippe Teuwen
87161b5b7b Examples: pn53x-tamashell
TODO: readline detection via autoconf
2010-10-02 23:35:24 +00:00
Philippe Teuwen
ba4c920af7 pn53x: avoid mix of hardcoded/sizeof values 2010-10-02 20:39:11 +00:00
Philippe Teuwen
eca47b3cff nfc-emulate-ndef: S(DESELECT) is actually auto in this mode 2010-10-01 17:59:23 +00:00
Philippe Teuwen
c937e8d178 pn53x: handle properly ReadRegister of PN533 2010-10-01 17:42:16 +00:00
Romuald Conty
ae522c843c nfc-sam: fix author fields (name and email). 2010-10-01 16:30:38 +00:00
Romuald Conty
f31cb6193b Minor man pages update. 2010-10-01 14:27:39 +00:00
Romuald Conty
4a3a185857 Fix bad indent
Update issue 84
Indent insert some blank lines.
2010-10-01 11:00:27 +00:00
Romuald Conty
bf995b3c4e nfc-emulate-ndef: change Tx/Rx message to prevent from mixing with TX/RX from debug mode, add the first receive datas. 2010-09-30 16:02:02 +00:00
Romuald Conty
b53b623c38 Split pn53x_target_init() into TgInitAsTarget command wrapper and the "logical" part 2010-09-30 12:51:13 +00:00
Romuald Conty
33e42f389a Detect PN53x USB devices before ACR122.
This change is needed by the fact that ACR122 use PCSC framework, and PCSC try to detect more than ACR122 devices, this reduce the connection speed (Plus, one some systems pcscd is not launched at boot time, its launched when some application access to using libpcsclite.)
2010-09-30 10:32:44 +00:00
Romuald Conty
6b679862e7 Fix bad indent.
Update issue 84
Current indent command push these comments the next line.
2010-09-30 10:27:34 +00:00
Romuald Conty
10f9a3d2b0 PN531 and PN533 does not support NTM_PICC mode 2010-09-30 08:37:46 +00:00
Romuald Conty
3c5e815ddd nfc-emulate-ndef: remove minor compilation warnings, add a FIXME to remove pn53x specific code in this example.
New issue
Summary: Remove pn53x specific from nfc* examples
Labels: Priority-Low Milestone-1.4.x
Examples provided by libnfc should show the "right" way to use libnfc and to use pn53x specific (and non public) functions is not a good pratice.
There can be some exceptions only if its really dedicated to one kind of chip and the example name have to follow the format "chip-function" instead of usual "nfc-function". (e.g. pn53x-diagnose)
2010-09-30 08:36:49 +00:00
Romuald Conty
68879ba255 Fix bad indent.
Update issue 84
Status: Reopened
Currently, indent trucate long line which make the code almost unreadable.
2010-09-30 08:14:21 +00:00
Romuald Conty
3cd0860203 nfc-emulate-ndef: minor clean up, improve error debugging. 2010-09-29 15:26:17 +00:00
Romuald Conty
4d880e6ce8 Enhance documentation and fix typo. 2010-09-29 14:26:06 +00:00
Romuald Conty
89971c9036 Update human readable ChangeLog 2010-09-29 12:41:46 +00:00
Romuald Conty
a9b8b84e13 Build nfc-emulate-ndef example 2010-09-29 11:08:06 +00:00
Romuald Conty
2318182c2c Remove minor warning. 2010-09-29 09:59:02 +00:00
Romuald Conty
0c72e7ed1a Workaround to prevent from USB toogle bit issue discussed on Issue 114.
Update issue 114
Status: Fixed
Owner: yobibe
This workaround allow to use PN533 USB (like SCL3711) without toogle bit issue (on OSes that care about this toogle bit: e.g. GNU/Linux, MacOS).
libfreefare tests suite now works as expected, enjoy!
2010-09-29 09:57:50 +00:00
Roel Verdult
e0c01fca01 commented nfcip lines 2010-09-28 16:18:05 +00:00
Roel Verdult
6dfe88113e Added new example, PN53x chips will now emulate NDEF tag! not in build-script yet 2010-09-28 16:15:59 +00:00
Romuald Conty
5efa9e2cdb Jewel/Topaz full UID is 6 bytes long (7 bytes with the manufacturer ID) but during select only the 4 LSB are returned, so we change the display to keep it in mind. (Thanks to Phil) 2010-09-28 15:37:36 +00:00
Romuald Conty
8672c809bd example: Jewel support in nfc-list and nfc-poll. (Many thanks to Phil) 2010-09-28 15:31:31 +00:00
Romuald Conty
cab6d19c5a examples: decode more data from ATQB. (Thanks to Phil) 2010-09-28 15:27:06 +00:00
Romuald Conty
15f3609eaf nfcip-target: add an hack to allow to use two devices on the same machine. (Thanks to Phil) 2010-09-28 15:24:05 +00:00
Romuald Conty
7a7687b3b8 Hack that allow to re-use PN53x (connected in USB) when something goes wrong.
New issue
Summary: Implement the abort mechanism (PCD->PICC ACK)
Currently, this issue is motivated by the need to reconnect to the device after a failure: ie. Issue 114.
BTW, this feature could also be useful to break an infinite polling or to cancel a previously sent command.
2010-09-28 15:15:36 +00:00
Roel Verdult
a0ece60203 let the PN53x functions call it's own configuration, not the main nfc_configure() 2010-09-28 14:48:57 +00:00
Romuald Conty
6d47171bdc Attempt to fix MacOS build. 2010-09-28 09:59:51 +00:00
Roel Verdult
16fd4bc2a0 Typo ;) 2010-09-24 16:51:30 +00:00
Roel Verdult
6f89ad50f8 add key for democards 2010-09-24 16:29:17 +00:00
Romuald Conty
1acf950ce9 Improve ISO14443B display: some protocol information are now decoded to be displayed. 2010-09-23 17:03:19 +00:00
Romuald Conty
2f95fb254b Improve ATQB decoding: "PUPI", "Application Data", and "Protocol Info" is now available as separated fields. 2010-09-23 16:26:06 +00:00
Romuald Conty
ccfd24a682 nfc-anticol now works even after running another program that change the modulation (Fixes Issue 111) (Thanks to Phil for help). 2010-09-23 16:03:05 +00:00
Romuald Conty
868919107a Fix Zero Lenght Packet problem on USB (Thanks to Phil) 2010-09-23 10:28:35 +00:00
Romuald Conty
7e2ddedfc1 Fix ISO14443-B ATTRIB_RES decoding. (Thanks to Phil) 2010-09-23 10:12:10 +00:00
Romuald Conty
c6f074ba96 nfc-poll: fix a potential segfault (Thanks to Phil) 2010-09-23 09:40:23 +00:00
Romuald Conty
e2a2557396 Replace wrong decoded ISO14443-B data by ATTRIB_RES field.
New issue
Summary: Improve ISO 14443-B data (ATTRIB_RES) decoding
Before this revision, pn53x_decode_target_data() wrongly decode ISO14443-B. Currently, whole ATTRIB_RES field is stored in nfc_target_info_t struct.
I do not find the correct documentation to fix it better than this, but at least it now retrieves a correct value.
2010-09-22 19:10:50 +00:00
Romuald Conty
2d6c0f5f1a Decode more targets types from PN53x. 2010-09-22 12:51:32 +00:00
Romuald Conty
bd547418e9 nfc-poll: disconnect from device if error in order to prevent from keep up RF field which have side effects: its power-consumming, device can became warm and it generates useless radiofrequencies. 2010-09-22 12:48:40 +00:00
Romuald Conty
0e37a1e9e9 Fix typo, add a minor XXX 2010-09-22 12:42:14 +00:00
Romuald Conty
0e40b6f7dd nfc-poll: now poll more than ISO14443-A 2010-09-22 12:36:20 +00:00
Romuald Conty
9cf4f5debb Fix Felica listing. (Thanks to the contibutor who provide me this patch) 2010-09-21 16:15:27 +00:00
Romuald Conty
52354daa1e Stop target listing when the maximal wanted target count is reached. 2010-09-21 16:05:24 +00:00
Romuald Conty
dfcb6f6cd3 Minor code cleanup in nfc-anticol 2010-09-20 15:55:55 +00:00
Romuald Conty
0ea9467b56 Minor indentation fixes. 2010-09-20 14:41:41 +00:00
Romuald Conty
362dfb51db API documentation is more clean now: functions order have more sense. 2010-09-10 13:35:25 +00:00
Romuald Conty
5929bc10e7 Minor documentation improvements. 2010-09-08 22:20:09 +00:00
Romuald Conty
7be31d0ba8 Update documentation and associated example. 2010-09-08 09:16:24 +00:00
Romuald Conty
26b9fee648 Copy missing additional-pages.dox from 1.3.4 tag. 2010-09-08 09:13:12 +00:00
Romuald Conty
18cc86a613 Indent whole code using make indent. (Fixes issue 84). 2010-09-07 17:51:03 +00:00
Romuald Conty
f93b4939f4 Set/reset configuration options at nfc_connect() time. (Fixes issue 108) 2010-09-07 17:33:45 +00:00
Romuald Conty
394f637c4e Bump package version for Windows 2010-09-07 17:18:27 +00:00
Romain Tartiere
81a1eb2c6c Don't display authentication errors in examples. 2010-09-07 13:34:48 +00:00
Romain Tartiere
b9cb5b22c8 Fix build on Microsoft Windows. 2010-09-07 09:59:12 +00:00
Romain Tartiere
9629d073cb - Fix missing checks reported by autoscan (we still do nothing on failure but at least the configure output might be more useful in case of problem);
- Lint configure output when libusb detection methods fallback over and over.
2010-09-07 09:01:59 +00:00
Romain Tartiere
ec58634a67 Fix build on Microsoft Windows. 2010-09-07 08:45:03 +00:00
Romuald Conty
5dbdabcec2 Be sure that NDO_AUTO_ISO14443_4 is activated by default. 2010-09-06 11:16:24 +00:00
Romuald Conty
18d31cd672 Reintroduce oddparity() function used by project based on libnfc but in nfc-utils.[ch] to prevent from exporting them in API. 2010-09-06 10:02:19 +00:00
Romuald Conty
190b52c4cd Remove a miss-placed prototypes. 2010-09-06 10:00:41 +00:00
Romuald Conty
43ca2c827b Remove unused file. 2010-09-06 09:27:06 +00:00
Romuald Conty
fbee88b63e Prevent from warning: implicit declaration of function ‘bzero’. 2010-09-06 09:09:52 +00:00
Romain Tartiere
6ff1be2127 Fix build on Microsoft Windows. 2010-09-04 11:14:06 +00:00
Romain Tartiere
2efbccf236 Explicitly enable auto ISO14443-4 mode for nfc-list. 2010-09-04 10:20:02 +00:00
Romain Tartiere
c82e1ff30f Change NDO_EASY_FRAMING value form 0x02 to 0x41.
Update issue 106
Just changed NDO_EASY_FRAMING value as requested.
2010-09-03 16:47:17 +00:00
Romain Tartiere
cbbe559f94 Alse remove nfc_target_receive_dep_bytes() and nfc_target_send_dep_bytes().
Update issue 106
Implement what's described in comment 3, 7 and 8.
2010-09-03 16:45:24 +00:00
Romain Tartiere
a5676ecd94 Remove nfc_initiator_transceive_dep_bytes() and introduce NDO_EASY_FRAMING option.
Always use nfc_initiator_transceive_bytes(). If you where using advanced
features and already relying on nfc_initiator_transceive_bytes(), then your
code has to be updated to unset the NDO_EASY_FRAMING option.  See an example of
such a change in the libfreefare's repository:
http://code.google.com/p/nfc-tools/source/detail?r=566

Updates issue 106
Status: Feedback
Romuald: I am not sure about the option enum values.  I took 0x02 thinking it
would not hurt but am not really sure about that because I can see many 'holes'
in the sequence.
2010-09-03 16:13:36 +00:00
Romain Tartiere
b1f4c38f8f Improve configure's --with-drivers documentation.
- List drivers compiled in the default set;
- Expose the 'all' special-driver;
- Remove some autotools (broken) magic.
    Since it's broken, display "--with-drivers=DRIVERS" on all system and stop
    making my eyes bleeding with "--with-drivers=driver[[,]driver...]" which is
    a complete nonsense when using "recent" autotools.
2010-09-03 08:36:41 +00:00
Romuald Conty
4ac54cf6e1 Prepare 1.3.9 version 2010-08-31 14:28:41 +00:00
Romuald Conty
d49439246c Fix ARYGON driver. 2010-08-31 12:55:45 +00:00
Romuald Conty
16330c2f65 Minor code clean up in pn532_uart 2010-08-31 12:54:59 +00:00
Romain Tartiere
306e51fa72 Remove useless nfc_perror lines from tests.
The endianness problem spoken about in r586 does not exist since the value
in pn53x_get_reg() is in a register so keep the ugly boolean operations to
copy the value: using all endianness conversions macros is a PITA.
2010-08-28 14:40:29 +00:00
Romain Tartiere
1130036bf3 - Detect errors in pn53x_get_reg();
- Add a test case to confirm an endianness problem on little-endian machines.
2010-08-28 14:27:33 +00:00
Romain Tartiere
af291c5a16 Report errors of ACR122 devices in the transceive function. 2010-08-28 14:25:49 +00:00
Romain Tartiere
a676d34e5d Fix build on Microsoft Windows. 2010-08-24 11:03:59 +00:00
Romain Tartiere
cbc3a62db1 Remove extern reference to pn53x-specific commands.
Fixes issue 101.
2010-08-24 10:31:21 +00:00
Romain Tartiere
f8ed119d1b Reset pnd->iLastError in nfc.c. 2010-08-24 10:30:18 +00:00
Romain Tartiere
9b44e3b2b7 Rename some internal API to highlight the PN53x operating mode.
pn53x_select_dep_target    -> pn53x_initiator_select_dep_target
pn53x_transceive_dep_bytes -> pn53x_initiator_transceive_dep_bytes
pn53x_transceive_bits      -> pn53x_initiator_transceive_bits
pn53x_transceive_bytes     -> pn53x_initiator_transceive_bytes
2010-08-24 10:26:56 +00:00
Romain Tartiere
ecb51c3554 New internal API functions: pn53x_target_send_bits(), pn53x_target_send_bytes(). 2010-08-24 10:22:55 +00:00
Romain Tartiere
047f274270 New internal API functions: pn53x_target_receive_bits(), pn53x_target_receive_bytes(). 2010-08-24 10:20:04 +00:00
Romain Tartiere
92a6789013 New internal API function: pn53x_target_init(). 2010-08-24 10:17:38 +00:00
Romain Tartiere
7f698431b7 New internal API function: pn53x_target_send_dep_bytes(). 2010-08-24 10:13:09 +00:00
Romain Tartiere
3d69c8b694 New internal API function: pn53x_target_receive_dep_bytes(). 2010-08-24 10:11:48 +00:00
Romain Tartiere
7a231cfb03 New internal API functions: pn53x_transceive_bits(), pn53x_transceive_bytes(). 2010-08-24 09:59:45 +00:00
Romain Tartiere
3cba76cc6f New internal API function: pn53x_transceive_dep_bytes(). 2010-08-24 09:56:22 +00:00
Romain Tartiere
ca0d73875d New internal API function: pn53x_select_dep_target(). 2010-08-24 09:53:51 +00:00
Romain Tartiere
5055f3d30b New internal API function: pn53x_configure(). 2010-08-24 09:49:59 +00:00
Romain Tartiere
71b3a1ad6e New internal API function: pn53x_get_firmware_version(). 2010-08-24 09:47:03 +00:00
Romain Tartiere
fbcf966d20 Merge r566-569 from the libnfc-error-handling branch.
Fix issue 103
2010-08-24 09:32:42 +00:00
Romain Tartiere
00ad302e32 Fix CMake build. 2010-08-24 09:29:59 +00:00
Romain Tartiere
b6fb5829c0 Fix libnfc version in the Microsoft Windows Makefile.
Also add a note to avoid forgetting it in configure.ac.
2010-08-24 09:25:53 +00:00
Romain Tartiere
32917a9c0a Unbreak nfc-list on windows.
The 'z' format modifier is not portable.  Switch to a basic int and cast the
size_t to an int.
2010-08-24 09:23:48 +00:00
Romain Tartiere
23f84a4e6a Merge the libnfc-error-handling branch into trunk. 2010-08-20 11:08:04 +00:00
Romuald Conty
6a6ae42a97 Fix minor compilation warnings 2010-08-20 10:42:31 +00:00
Romain Tartiere
5b0589c381 Merge r551-563 from trunk. 2010-08-20 10:41:30 +00:00
Romain Tartiere
fd337dd0cc Also detect error frames in pn532_uart (tested) and arygon drivers (not tested). 2010-08-20 10:40:00 +00:00
Romuald Conty
dadaee4cc0 Fix ARYGON compilation 2010-08-20 10:28:11 +00:00
Romuald Conty
bd8a46c3c8 Fix pn532_uart compilation 2010-08-20 10:25:37 +00:00
Romain Tartiere
1e329529a7 Update nfc-poll example to enhance unsupported features detection. 2010-08-20 10:16:52 +00:00
Romuald Conty
084c001c11 Generate an error before sending InAutoPoll command if chip does not support it. 2010-08-20 10:11:06 +00:00
Romain Tartiere
f4aa4edc94 Rework and fix error frames detection.
While here, rename the pn53x_transceive_callback() function to
pn53x_transceive_check_ack_frame_callback() to make it more obvious what it is
supposed to do.
2010-08-20 10:06:19 +00:00
Romain Tartiere
b0737bd1a0 Fix pn53x_InAutoPoll(). 2010-08-20 09:36:38 +00:00
Romain Tartiere
5744c67039 Fix build on Microsoft Windows (not tested, no hardware). 2010-08-19 18:19:40 +00:00
Romuald Conty
040db45ae4 nfc-mfclassic: disable ISO14443-4 auto-switching in order to read devices that emulate Mifare Classic with ISO14443-4 compliance.(e.g. Nokia 6212 Classic) 2010-08-19 10:59:45 +00:00
Romuald Conty
8f19b078ff Add configuration option to enable/disable auto iso14443-4 mode. 2010-08-19 10:58:15 +00:00
Romuald Conty
edba53c5da Fix pn532_uart driver. 2010-08-19 09:01:39 +00:00
Romain Tartiere
eb90b92c12 Detect errors in examples. 2010-08-18 17:22:13 +00:00
Romain Tartiere
076fa3686c Merge r547-550 from trunk. 2010-08-18 17:01:08 +00:00
Romain Tartiere
27b97c0fda Fix build on Microsoft Windows. 2010-08-18 16:55:16 +00:00
Romain Tartiere
0a09c8d8e7 Flag some problems in the examples. 2010-08-18 14:44:40 +00:00
Romain Tartiere
c9f88e17a1 Reset pnd->iLastError in nfc.c. 2010-08-18 14:44:19 +00:00
Romain Tartiere
769eef20f7 Merge r520-546 from trunk. 2010-08-18 14:32:01 +00:00
Romuald Conty
d0fe1f8255 Fix debug trace of pn532_uart driver. 2010-08-18 13:56:31 +00:00
Romuald Conty
6354e94657 mifare function improvement: it now failed when read command does not return a whole block (16 bytes). 2010-08-18 13:53:34 +00:00
Romuald Conty
4b123ab583 nfc-mfclassic now fails ealier when something goes wrong (this allow to prevent from false-success). 2010-08-18 13:20:40 +00:00
Romuald Conty
cf9af4ee49 nfc-list example now use nfc_initiator_list_passive_targets() function. 2010-08-18 13:13:14 +00:00
Romuald Conty
5c206b7815 Improve ISO14443B support of nfc_initiator_list_passive_targets() function. 2010-08-18 13:10:21 +00:00
Romuald Conty
3dd2257b57 Add print_nfc_felica_info() and print_nfc_iso14443b_info() functions to nfc-utils (used by examples) 2010-08-18 12:50:40 +00:00
Romuald Conty
43694183ff Minor documentation improvements. 2010-08-18 12:39:32 +00:00
Romuald Conty
0c19124984 Increase UART timeout to gain in stability. 2010-08-18 08:06:35 +00:00
Romuald Conty
eeaad85151 Add SAK decoding for compliance with ISO/IEC. 2010-08-17 15:24:37 +00:00
Romuald Conty
6e84e757c7 List available drivers in ./configure --help 2010-08-17 14:40:35 +00:00
Romuald Conty
c021a50768 Oups, r534 was not a joke... just a mistake ;-) This commit fix my r534. 2010-08-17 13:50:49 +00:00
Romuald Conty
88002bf977 Code cleaning: driver_connect() is never executed with pndd==NULL. 2010-08-17 13:31:32 +00:00
Romuald Conty
7788c33da8 Default serial-port paths are now fully hardcoded instead of half-hardcoded and soft-expanded. 2010-08-17 13:29:01 +00:00
Romuald Conty
476c05cfb4 Cleanup up nfc_initiator_list_passive_targets(): remove attempts to retrieve ATQA when collision occurs, after a lot of tests by Romain and me we are not able to find a way to retrieve all tags ATQA if different card types are on the nfc device. 2010-08-17 10:08:38 +00:00
Romuald Conty
3c57861d6b Improve pn53x_decode_target_data() function: move code from nfc_initiator_select_passive_target() to the right place (pn53x.c). 2010-08-17 10:01:11 +00:00
Romuald Conty
ae04479968 Move hardware polling function in pn53x.c/h. 2010-08-17 08:24:38 +00:00
Romain Tartiere
f797d737d3 Fix build on Microsoft Windows. 2010-08-16 17:43:48 +00:00
Romuald Conty
41b1455f04 Clean up wrong comments in nfc-poll. 2010-08-16 16:27:50 +00:00
Romain Tartiere
08eb21aa9d Second part of error handling.
- Define two sets of DE<FOOBAR> macros: the first one for 'generic' errors
  which could be encountered regardless of the NFC device the library is acting
  with (0xX000), and ont set for device-dependant errors (0x0X00).
- Make some more functions accept a nfc_device_t* as first argument to have
  access to the iLastError;
- Reset errors when entering public API functions;
- Save errors when applicable;
- Distinguish system-level errors (e.g. I/O error) and operational errors (the
  PCD returns an unexpected value);
- Minor tweaks.

Update issue 65
Status: Feedback

New review:
Owner: rconty@il4p.fr
Cc: rtartiere@il4p.fr
Summary: Review the error-handling code.
Branch: /branches/libnfc-error-handling

For this development, a strong emphasis has been set on making changes that
will not go through our way on the way to libnfc-1.6+.  For this reason, some
constructs are not natural (e.g. error codes defined in two different places),
please keep this in mind when reviewing.
2010-08-15 14:08:29 +00:00
Romain Tartiere
8a75f5b45e Fix wrong comment 2010-08-15 12:42:40 +00:00
Romain Tartiere
655fdb569a Fix nfc_initiator_mifare_cmd() in examples.
In r509, a direct call to pn53x_transceive() was changed into a call to nfc_initiator_transceive_dep_bytes() which is part of the public API. The command to send was updated accordingly, but the code that extracts the response have not.

Update issue 98
This should fix the problem: because the response was not the expected length, the actual card data was not copied to the buffer, so it was always the same 16 uninitialized bytes that where returned for any block.

PR:		Issue 98
Submitted by:	zamby.ing
Pointy hat to:  me
2010-08-13 19:53:13 +00:00
Romain Tartiere
fab08a3951 Fix doxygen comment: the string SHALL NOT be freed (it's const BTW).
Or maybe I would rather have removed the const and called strdup(3)?

New issue
Summary: Sync code and comments
Owner: rconty@il4p.fr
Status: New
Romuald, can you please review this changeset and fix the code if I corrected
the wrong way (i.e. the comment was Okay and the code bogus while I fixed the
comment thinking the cod was right).

Thanks!
2010-08-13 19:10:31 +00:00
Romain Tartiere
d7e0b926ac Rename the only test of the regression test suite to a more explicit name.
- While here, add assertions, enhance slightly the code and decrease the number of loop turns.
2010-08-13 18:34:30 +00:00
Romain Tartiere
57b775bae2 Always ACK on transmission.
New issue
Summary: Make sending ACK on message transmission skipable.
Owner: rtartiere@il4p.fr
Cc: rtartiere@il4p.fr
Status: New
I guess that for performance reasons, some advance users would prefer to skip
sending the non-mandatory ACK on data transmission.  They may also perform a
quicker check of the ACK returned by the chip after sending the command and
before receiving the response (not sure about this one).

It will probably be a ./configure option disabled by default that allows some "shortcuts" to perform NFC hacking.
2010-08-13 16:02:18 +00:00
Romain Tartiere
f4bc39bf41 Mostly revert r521.
It was obviously an April joke: iErrorCode which was renamed iPICCError is
indeed a PCD Error, so I renamed it to iLastError since communications errors are
also to handle at the device driver level (read chip level), although I guess
that some errors would be common to distinct devices.
PICC error are irrelevant because they can either be transmission error
detection (in which case the libnfc should retry the transmission) or
application-level errors the libnfc cannot be aware of.
2010-08-13 09:02:20 +00:00
Romain Tartiere
0502401a29 Minor tweaks.
- Rename the nfc_device_t's struct iErrorCode member to iPICCError (We are
    likely to have both PICC and PCD errors fields to avoid unneeded complexity
    at some point);
  - Make the PN53x error descriptions static;
  - Enhance some comments here and there.
2010-08-13 08:31:16 +00:00
Romain Tartiere
b289784359 Merge r511-519 from trunk. 2010-08-11 16:59:09 +00:00
Romuald Conty
2029e0c66f Remove usb_reset() call: this function always failed. 2010-08-11 16:44:34 +00:00
Romuald Conty
d11e7a1320 Prevent from segfault when nfc_disconnect() on NULL pointer 2010-08-11 16:38:22 +00:00
Romain Tartiere
9cc31f6aad Add a regression test directory. 2010-08-11 16:36:35 +00:00
Romain Tartiere
caa594eba8 Remove deprecated code.
Reported by:	rconty@il4p.fr
2010-08-11 09:46:14 +00:00
Romain Tartiere
f237d44339 Take care of 16-blocks-long sectors of Mifare Classic 4K in the nfc-mfclassic example's blocks counting routine. 2010-08-11 09:26:22 +00:00
Romain Tartiere
ca6b768a67 Fix build on Microsoft Windows. 2010-08-10 21:45:30 +00:00
Romain Tartiere
4a5347e5ae Merge r512 from trunk. 2010-08-10 21:41:42 +00:00
Romain Tartiere
3ec0b9376c Make Mifare example use only the libnfc public API. 2010-08-10 21:36:57 +00:00
Romain Tartiere
dfb82f8893 Merge r499-510 from trunk. 2010-08-10 21:14:13 +00:00
Romain Tartiere
bda739eb8f Hey! r509 also fixed that! 2010-08-10 21:02:26 +00:00
Romain Tartiere
eece496351 Use nfc_initiator_transceive_dep_bytes() instead of pn53x_transceive() in example. 2010-08-10 21:00:08 +00:00
Romain Tartiere
fd0efd4a62 Fix build on Microsoft Windows.
Windows users: I hate you in secret.
2010-08-10 19:50:29 +00:00
Romain Tartiere
8fef257d16 Also use pn53x_transceive_callback() in the arygon driver.
While here, remove unneeded header in pn532_uart.c.
2010-08-08 15:25:06 +00:00
Romain Tartiere
d7c16d6d1a Factorise UART-relative macros definitions. 2010-08-08 09:34:18 +00:00
Romain Tartiere
8e5d235cd2 Implement pn53x_InRelease().
I used it for some experiments and guess that it should be part of the API.
2010-08-06 07:29:57 +00:00
Romain Tartiere
d77c25224a After a bazillion tests, make the Debian-5-year-outdated-and-buggy autotools happy with some weird m4 syntax and hope it will not fail on a much more recent autolol suite. 2010-07-31 15:37:27 +00:00
Romain Tartiere
d0357cf3aa Merge r486-498 from trunk. 2010-07-31 14:23:33 +00:00
Romain Tartiere
79aeaa6287 Factorise code.
Avoid redundant code in PN53x usb and uart drivers.  Since it makes sense to
report errors at the nfc_device_t level, pass it directly to
pn53x_transceive().

Programs using the libnfc MAY use pn53x_transceive() to communicate with a NFC
device, and SHALL not use anymore pnd->pdc->transceive().  Code in the library
itself SHOULD avoid calling pnd->pdc->transceive(), so such construct have been
updated accordingly.
2010-07-31 14:20:15 +00:00
Romain Tartiere
301d692e8a Flag references to deprecated usage of pn53x_transceive().
New issue
Summary: pn53x_transceive() workaround reverences in examples/nfc-poll.c comments
Status: New
Owner: rconty@il4p.fr
Cc: rtartiere@il4p.fr
The source code of nfc-poll has references to no using pn53x_transceive() for
the status-byte workaround reason in a comment.  However this function is not
called in the code.  While I guess that's some comment that should have been
removed and have never reached the svn repo, I prefer to be sure that it can be
removed.  The comments where introduced at the same time of the file, at r353.
2010-07-31 14:02:46 +00:00
Romain Tartiere
b60d045537 Remove another deprecated test that '^#ifdef' did not matched for previous commit. 2010-07-31 13:46:32 +00:00
Romain Tartiere
cd53efb038 Enforce ISO C conformance about empty files.
ISO C forbids empty source files.  Instead of compiling possibly empty source
files depending on the compiler parameters, only compile required files to
build the library as requested at the ./configure stage.

Windows users (and more precisely non-autotools users), you may have to update
whatever you use to build the libnfc to fit your needs.  The Makefile shipped
in the windows directory compiles all drivers as it is written so you should
not notice any difference, but if you don't use _that_ makefile, then you will
have to do some adjustment.

For now, keep the defines in CFLAGS just in case.  Planned for removal in circa
one week.

While here, pet `./configure` output (--help format and summary).
2010-07-31 13:21:56 +00:00
Romain Tartiere
bb06d45a05 Really silent down gcc with -Wextra. 2010-07-31 12:57:02 +00:00
Romain Tartiere
93494aad24 Fix serial string for FreeBSD.
I am sure we don't have /dev/ttyUSB*, and since I use /dev/cuau0 with a
cross-over cable to connect 2 machines and have a serial console, I guess
"/dev/cuau" is the SERIAL_STRING that's expected to work for me.  A quick test
would be cool however, but I don't own a serial NFC device.
2010-07-31 10:13:18 +00:00
Romain Tartiere
d498fcd48e Comment all commands that return a status code in the list. Found a typo at that occasion so s/0x93/0x92/. 2010-07-31 09:50:04 +00:00
Romain Tartiere
fb6d9d2d20 Yes we can... remove all those pnd->pdc->transceive() from nfc.c.
Within the ongoing effort to improve the NFC devices abstraction, and now that
pn53x_transceive() does not fail when it reads a response that has no
status-code, do not call directly pnd->pdc->transceive() from nfc.c.  In a
mid-term future this will be changed again, and calling pn53x_transceive() from
nfc.c will be forbiden, in favor of colling some pnd->transceive() function,
but that's another part of the story.

Of course, it changes the API one more and it's not going to be the last time
in this branch.
2010-07-31 09:40:29 +00:00
Romain Tartiere
705e037b12 Only report status error for commands that provide it in pn53x_transceive().
This is the first step for improving abstraction in libnfc.
2010-07-31 09:19:22 +00:00
Romain Tartiere
36ee32f81a Merge r478-485 from trunk. 2010-07-30 16:34:12 +00:00
Romuald Conty
0afaf656fa Attempt to provide target listing function (WARNING: this function is actually incomplete)
New issue
Summary: Provide a target listing function
Labels: Milestone-1.4.x
Libnfc lacks of target listing function. Actually, applications or libraries based on libnfc have to wrote their own listing function which can provide side effect if two or more of theses libraries are used together in the same application. Plus, some kind of problem could appears during listing multiples targets (i.e. collisions) and this problem should be solved in libnfc (i.e. using NFC chip capabilities), not in applications based on libnfc.
2010-07-30 13:27:03 +00:00
Romuald Conty
7113d1418b Add FIXME to raise an E_NOTSUPPORTED error in future,
New issue
Summary: Catch unsupported command before sending to chip
Labels: Milestone-1.6.x
Actually, libnfc support PN531, PN532 and PN533 NFC chips, but the devices does not the same features. e.g. PN531 does not support ISO14443B modulation.
It should great to catch theses unsuported commands before sending to chip in order to prevent a chip error.
2010-07-30 11:45:59 +00:00
Romuald Conty
5ac580a241 Code cleanup: remove many debug prints, enhance comments and documentation. 2010-07-30 11:30:19 +00:00
Romain Tartiere
daa178b18f Enhance error handeling.
- New API functions: nfc_strerror(), nfc_strerror_r() and nfc_perror();
  - Drivers now have a reference to chips callback methods;
  - Rename -pn53x_err2string to pn53x_strerror and add it to pn53x_callbacks_list.
2010-07-29 14:16:11 +00:00
Romuald Conty
18e6e1bc7c Add documentation for pn53x_InListPassiveTarget() 2010-07-29 12:48:59 +00:00
Romuald Conty
fc15146bf2 Minor code cleanning. 2010-07-29 12:47:51 +00:00
Romain Tartiere
30e715cff0 Merge r470-477 from trunk. 2010-07-29 10:59:52 +00:00
Romain Tartiere
740b5b430d libnfc-error-handling: Remove boring debug stuff. 2010-07-29 10:53:14 +00:00
Romain Tartiere
f01b73ab32 Move usb_reset(3) call.
As the documentation states, and as reported in isssue 81 (fixed in r421),
usb_reset()'s argument is invalid after the call and so usb_close(3) must be
called before usb_reset(3).
2010-07-29 10:47:53 +00:00
Emanuele Bertoldi
f7e8ec0a95 nfc-sam: cleanup and Windows support improvements. 2010-07-29 10:18:19 +00:00
Roel Verdult
5129a37ec8 fixed typo, missed closing bracket ;) 2010-07-28 12:56:40 +00:00
Roel Verdult
20ed5e1a52 fixed wakeup preamble, change PN532 chip to normal mode after wakeup 2010-07-28 12:52:39 +00:00
Romuald Conty
d63157a41d Fix mask to extract "Error Code" from status byte. 2010-07-27 09:29:54 +00:00
Romain Tartiere
9984e1bdcb Start of work on error handling. 2010-07-26 12:41:46 +00:00
Emanuele Bertoldi
9a7ffc38a1 Small improvements to nfc-sam stuff. 2010-07-26 08:55:43 +00:00
Romain Tartiere
af584bd474 Fix packet length checksum computation.
The doc says LCS (aka abtTx[4]) must be set so that the lower byte of LCS+LEN
(aka abtTx[3]) is 0x00.  This has not to be related to the USB buffer size, so
that we can adjust it without breaking down the libnfc.
2010-07-25 16:31:53 +00:00
Romain Tartiere
7f9f907bc2 Silent down compiler. 2010-07-24 18:54:50 +00:00
Romain Tartiere
e6d079d87a Fix a regression introduced at r461.
This prevents the ATR_REQ from being processed and some tags detection fails in
libfreefare.
2010-07-24 17:20:48 +00:00
Romain Tartiere
4ff66d125f Fix a regression introduced at r458.
Both abtInit and szInitLen are initialised using pbtInitData and szInitDataLen,
so we must use them when calling pn53x_InListPassiveTarget().
2010-07-24 16:30:44 +00:00
Romuald Conty
544bda197e Fix minor warning. 2010-07-23 13:31:33 +00:00
Romuald Conty
edb62bd1cb Create pn53x_InDeselect function. 2010-07-23 13:30:06 +00:00
Romuald Conty
7eeb46ab68 Minor indentation fix. 2010-07-23 12:48:30 +00:00
Romuald Conty
7dd1053d03 Fix incorrect selected targets size in pn53x_InListPassive(). 2010-07-23 12:45:21 +00:00
Romuald Conty
3f17e5e032 Minor indentation fix. 2010-07-23 12:41:29 +00:00
Romuald Conty
aca1eb40a8 Comment out extern symbol related to PN53x in nfc.c; The goal is to remove all of them from nfc.c 2010-07-22 16:24:24 +00:00
Romuald Conty
d932cd8450 Move some PN53x related code from nfc.c to pn53x.c 2010-07-22 16:21:59 +00:00
Romuald Conty
424a48714f Minor documentation improvements. 2010-07-22 16:16:37 +00:00
Romuald Conty
c4bb23631b Do not export nfc_parse_device_desc() in libnfc API. 2010-07-22 16:13:02 +00:00
Emanuele Bertoldi
4bc522cd1e First prototype of argument parsing for device description (issue #87). 2010-07-22 13:41:20 +00:00
Romain Tartiere
7945dd18fa Enhance 'make indent'.
- Complete indent(1)'s arguments list;
  - Ensure files to be indented have no local edit;
  - Hide indent command-line details.  Since everything is static, no need for V=1 support.
2010-07-21 22:32:02 +00:00
Romain Tartiere
67fb1330f8 Rework the indent target.
- Check indent is present at ./configure stage;
  - If gindent(1) is installed, use it instead of indent(1);
2010-07-21 13:09:48 +00:00
Romuald Conty
2688de6500 API change: nfc_initiator_select_tag() is now nfc_initiator_select_passive_target() AND nfc_initiator_deselect_tag() is now nfc_initiator_deselect_target() 2010-07-21 10:37:37 +00:00
Romuald Conty
d97876714c Add indent directive in root Makefile. 2010-07-20 13:38:58 +00:00
Romuald Conty
0a87c18e7e nfc-mfultralight: we now can write OTP bytes if user want to. 2010-06-30 15:06:59 +00:00
Romuald Conty
379066f069 nfc-mfultralight: on write failure, continue if authenticate works. 2010-06-30 14:54:34 +00:00
Romain Tartiere
d8f12035fc Add missing carriage return at EOF (yes, I have nothing better to do ATM). 2010-06-26 21:56:32 +00:00
Romuald Conty
596733bacc nfc-mfultralight: Fix messages, we read/write pages not blocks. 2010-06-24 11:04:05 +00:00
Romuald Conty
688ebe2324 Re-ident examples/nfc-mfultralight.c using "indent -br -ce --line-length120 -nut -i2 -ppi 2" command line. 2010-06-24 10:19:01 +00:00
Romuald Conty
470dd8be05 nfc-mfultralight: Fix read and write counters. Code cleanup. 2010-06-24 10:16:09 +00:00
Romuald Conty
2e1fa09166 Set svn:ignore property on nfc-sam example. 2010-06-16 12:12:31 +00:00
Emanuele Bertoldi
e6d96333f7 nfc-sam: added some config operations. 2010-06-16 11:40:23 +00:00
Emanuele Bertoldi
f748ec1c59 nfc-sam: added FIXME notes. 2010-06-16 11:34:55 +00:00
Emanuele Bertoldi
391d066095 nfc-sam: improved output and error messages. 2010-06-16 11:32:16 +00:00
Emanuele Bertoldi
3f6109af52 Cleanup. 2010-06-16 11:23:13 +00:00
Emanuele Bertoldi
b2089e8bb0 nfc-sam: better connection management. 2010-06-16 11:21:27 +00:00
Emanuele Bertoldi
d593a8e4c9 Added use of nfc-messages. 2010-06-16 09:48:26 +00:00
Romuald Conty
f7c31885f5 Move all Mifare related code from libnfc API to examples: NFC is capable of Mifare, but Mifare is not NFC. 2010-06-15 15:33:22 +00:00
Romuald Conty
db735ab224 Prevent from sources files being executable. 2010-06-15 15:32:58 +00:00
Emanuele Bertoldi
4b5d3913d9 Cleanup. 2010-06-15 15:10:11 +00:00
Emanuele Bertoldi
8e4bef9c90 Added draft of a new libnfc-based example: nfc-sam.
It tests the comunication with a connected SAM (Secure Access Module).
2010-06-15 15:05:40 +00:00
Romuald Conty
ec48f04dd8 Bump package version to 1.3.9 since trunk looks like 1.4.x series. 2010-06-07 13:33:33 +00:00
Romuald Conty
d171562002 Re-ident examples/nfc-poll.c using "indent -br -ce --line-length120 -nut -i2 -ppi 2 " command line. 2010-06-07 09:51:31 +00:00
Romuald Conty
3c1a61349f Re-ident nfc-mfclassic.c using "indent -br -ce --line-length120 -nut -i2 -ppi 2 " command line. 2010-06-07 09:05:35 +00:00
Romuald Conty
8bac5355dd This should fix Issue 83. 2010-06-07 08:16:27 +00:00
Romuald Conty
2e39e56e17 Return value of pn53x_usb_list_devices() must bool, not void* 2010-05-28 09:55:13 +00:00
Romuald Conty
b05ab6285d Import some files that allow to build a correct libnfc's DLL on Windows platform. (Thanks to Roger Brown from Snapper) 2010-05-28 09:48:15 +00:00
Romuald Conty
07a779c880 Add a small example to diagnose basic elements (communication, rom and ram) of pn53x. 2010-05-28 09:09:36 +00:00
Romuald Conty
ac663d02a1 Use pn53x_decode_target_data() to decode target data in nfc_initiator_select_tag(). Fix Issue 82. 2010-05-18 10:57:38 +00:00
Romuald Conty
cf0c2dd9f2 Fix ATS lenght in pn53x_decode_target_data(). 2010-05-18 10:55:18 +00:00
Romuald Conty
8c1815fbea Move variable declarations in order to compile using non-C99 compiler. Fix Issue 80. 2010-05-18 08:27:50 +00:00
Romuald Conty
404dfba6e8 usb_release() must be called before usb_reset(). Fix Issue 81 (Thanks to thaolx). 2010-05-18 08:13:26 +00:00
Romain Tartiere
9941191cfc Fix build when configured with --enable-debug. 2010-04-28 12:55:00 +00:00
Romuald Conty
1b7a7a4be1 Fix Issue 79. Libtool now handle library creation. 2010-04-27 15:28:41 +00:00
Romuald Conty
6fd2ea41c5 Next release will not install extra headers. (Programs that depends on should copy theses files into their sources. 2010-04-27 15:22:26 +00:00
Romuald Conty
a98cd3837b CMake: fix win32 paths and remove hardcoded definitions. 2010-04-26 14:50:52 +00:00
Romuald Conty
6f04f3cb92 Windows zip archive with manual makefile is not generated anymore. 2010-04-26 13:40:42 +00:00
Romuald Conty
c2cead7089 Remove "manual" Windows makefile: Windows users should now use CMake. 2010-04-26 13:38:17 +00:00
Romuald Conty
693389ac10 Move additionnal files (for Windows) in contrib/ 2010-04-26 13:36:41 +00:00
Romain Tartiere
16786c61e3 Remove bitutils I reverted instead of removing in r412. 2010-04-26 13:20:57 +00:00
Romain Tartiere
b28abd77b0 Merge the libnfc-less-bitutils-more-ponies branch into trunk. 2010-04-26 13:13:13 +00:00
Romain Tartiere
00af8b7ae1 Fix ${DRIVERS_SOURCES} modifications. 2010-04-26 13:05:21 +00:00
Romuald Conty
e45a0943e8 Change to way to handle DRIVERS_SOURCES in CMake. 2010-04-26 13:00:41 +00:00
Romuald Conty
27ccf67503 Reorganize CMake sections. 2010-04-26 12:59:23 +00:00
Romuald Conty
194faf56fb make_release: Add a cleaning section. 2010-04-26 12:58:17 +00:00
Romuald Conty
854cfe15ec Fix ARYGON detection. Rename acConnect to acPort. Now use snprintf and strncpy (see Issue 78) 2010-04-22 10:22:41 +00:00
Romuald Conty
3e16031877 Fix ARYGON driver build (missing comma). 2010-04-22 09:01:22 +00:00
Romuald Conty
367e14dcc0 Prevent from potential buffer-overflows. 2010-04-21 10:58:04 +00:00
Romuald Conty
fa1f9a1ff6 Fix device name: snprintf could not be used to append something to source string. 2010-04-21 10:50:29 +00:00
Romuald Conty
d9ec086beb Replace some sprintf with snprintf to prevent from buffer-overflow. 2010-04-21 10:23:11 +00:00
Romuald Conty
ce6f7f2c84 Fix potential UART speed problem while autoprobing. Extract communication test from pn532_uart_wakeup(). 2010-04-21 10:19:26 +00:00
Romuald Conty
67fd8ecd0e Unix-like system's developer should use 'autoreconf -vis' instead of './autogen.sh'. 2010-04-20 20:23:14 +00:00
Romuald Conty
f05e432df8 Fix autogen.sh usage on MacOS X. 2010-04-20 20:20:27 +00:00
Romuald Conty
942dcfa631 PN532_UART: prevent from blocking when device doesn't reply correctly to wakeup command. 2010-04-20 15:05:57 +00:00
Romuald Conty
e3ff11eb46 Fix warnings "no previous prototype for ..." on bitutils.[hc] 2010-04-20 09:44:27 +00:00
Romuald Conty
9abb29f1d1 nfc-mfultralight: fix warnings about prototypes. Fix Issue 77. 2010-04-20 09:28:19 +00:00
Romuald Conty
7762814eda nfc-mfclassic: fix warnings about prototypes. Fix Issue 76. 2010-04-20 09:25:18 +00:00
Romuald Conty
75cc48e460 nfc-mfclassic: fix warnings "no previous prototype for...". Fix Issue 75. 2010-04-20 09:05:23 +00:00
Romuald Conty
03eec8fab6 nfc-anticol: fix warnings "no previous prototype for...". Fix Issue 74. 2010-04-20 09:04:20 +00:00
Romuald Conty
2ab522950f Remove uart_cts() since the function is defined but never used. Fix Issue 71 2010-04-20 08:48:41 +00:00
Romuald Conty
778ac87b37 Add drivers selection to CMake build. Fix Issue 70 2010-04-20 08:45:31 +00:00
Romain Tartiere
204130477e (libnfc-less-bitutils-more-ponies) MFT 2010-04-17 13:45:00 +00:00
Romain Tartiere
be3f152d3c Fix a few more warnings. 2010-04-17 13:42:08 +00:00
Romain Tartiere
086e24c407 (libnfc-less-bitutils-more-ponies) Fix build on windows:
- do not depends on byte swapping functions / macros;
  - add basic err.h functionalities.
2010-04-16 22:38:45 +00:00
Romain Tartiere
3e8e1c8844 Fix build on Windows (using cmake and nmake). 2010-04-16 20:39:56 +00:00
Romain Tartiere
3820c34f28 (libnfc-less-bitutils-more-ponies) MFT 2010-04-16 19:27:49 +00:00
Romain Tartiere
0e6719908b (libnfc-less-bitutils-more-ponies) Update CMakeLists.txt. 2010-04-16 17:42:00 +00:00
Romain Tartiere
3dccc218df Enable drivers in cmake again (disabled implicitly in r375). 2010-04-16 17:35:00 +00:00
Romain Tartiere
39761badb7 Fix cmake breakage introduced in r360:
undefined reference to `print_nfc_iso14443a_info'
2010-04-16 17:20:22 +00:00
Romain Tartiere
5e452dbb13 Fix cmake breakage introduced in r352:
error: 'for' loop initial declaration used outside C99 mode
2010-04-16 17:10:08 +00:00
Romain Tartiere
10baef235f (libnfc-less-bitutils-more-ponies) Get rid of bitutils.[hc] (part 1).
- New API function append_iso14443a_crc();
  - Add a PRINT_HEX macro for driver debugging (replaces print_hex function from bitutils.c);
  - Move bit-mirroring related functions to libnfc/mirror-subr.[hc];
  - Move iso14443 related functions to libnfc/iso14443-subr.c;
  - Move libnfc/bitutils.c hex-dumping code to examples/nfc-utils.c;
  - Replace calls to swap_endian32() and swap_endian64() functions with calls to bswap32() and bswap64 provided by endian.h.

And while I am here:
  - Fix the DBG macro so that it does not throw warning at compile time.
2010-04-16 16:38:57 +00:00
Romain Tartiere
5302930b09 Avoid using a 'comma pasting' GNU extension (non-portable, reported my clang).
This is not a 'complete' fix since the DBG macro is still using it; but more globally, this file should not be part of the libnfc installed files.  We should rely on error codes and maybe some logging mechanism (e.g. syslog() on POSIX compliant systems and RegisterEventSource() / ReportEvent() on Windows).
2010-04-16 14:50:48 +00:00
Romain Tartiere
0b301d8ff6 Add missing documentation lines. 2010-04-16 13:00:33 +00:00
Romain Tartiere
7b65174856 Remove deprecated DEBUG_CFLAGS. 2010-04-16 12:58:29 +00:00
Romain Tartiere
4dbeff47db Fix warnings on 32bit systems:
- format '%ld' expects type 'long int', but argument 2 has type 'unsigned int';
  - format '%ld' expects type 'long int', but argument 2 has type 'size_t'.

Tested on FreeBSD arm.
2010-04-15 23:11:36 +00:00
Romuald Conty
d74e68a3fd Add nfc-utils.h to generated tarball. (make distcheck OK) 2010-04-15 17:36:43 +00:00
Romuald Conty
b55400a0d5 configure.ac rework
- Put libusb and PC/SC check in m4 macros.
- Suppress --disable-pcsclite and --disable-libusb
- Add --with-drivers option: we now could choose which driver to build. without this option a default set is build (ATM all drivers except PN532_UART)
2010-04-15 14:41:13 +00:00
Romuald Conty
b747573dc7 PN532_UART readers could now poll using PN532 hardware feature. This commit should fix Issue 56 too. 2010-04-14 13:28:24 +00:00
Romuald Conty
064b7c4b41 Revert libnfc/drivers.h (from r371), this file should not have been commited (in r372).
Second pointy hat to: me again
2010-04-14 10:44:12 +00:00
Romuald Conty
0a08ef00c2 Fix recently changed wakeup function for pn532_uart driver.
Pointy hat to: me ;)
2010-04-14 10:39:18 +00:00
Romuald Conty
a3f68b566d Raise up timeout value in UART, this is tricky (ugly?) hack to allow low speed UART device to run nfc-emulate. 2010-04-13 14:36:02 +00:00
Romuald Conty
2766cd8822 ARYGON readers could now poll using PN532 hardware feature. 2010-04-13 14:11:10 +00:00
Romuald Conty
332eed3596 nfc-poll: raise polling duration from 1500ms to 6000ms. 2010-04-13 14:07:29 +00:00
Romuald Conty
24e7b20d04 Add debug output when pnd->pdc->tranceive() failed. 2010-04-13 12:48:52 +00:00
Romuald Conty
29fad31ee5 Update ARYGON driver, it now support probing as PN532_UART. Communication should be faster (delays removed).
Note: ARYGON APPB2UA33 oem reader now works.
2010-04-12 14:51:50 +00:00
Romuald Conty
a4d1c53ed3 Add wake up function for PN532 UART and run a communication test to know if device correctly respond. 2010-04-12 14:48:03 +00:00
Romuald Conty
1ba436041b Report found device number in debug mode. 2010-04-12 14:43:19 +00:00
Romuald Conty
f693040ced Disable compiler code optimizations and turn on gdb support when --enable-debug is passed to configure. 2010-04-09 23:41:35 +00:00
Romuald Conty
e886ef4f48 nfc-poll: Warn user when hardware does not support polling. 2010-04-09 23:38:05 +00:00
Romuald Conty
c9370e6fac Prevent from running polling on hardware that does not support it. 2010-04-09 23:11:20 +00:00
Romuald Conty
71341b871e Minor comments added. 2010-04-09 23:09:20 +00:00
Romain Tartiere
ae99d155b5 Make nfc-list rely on the libnfcutils.a convenience library and call nfc_initiator_select_tag(). 2010-04-09 22:08:17 +00:00
Romain Tartiere
b8630c4230 Fix various warnings:
- format '%d' expects type 'int', but argument 2 has type 'long unsigned int';
  - format '%d' expects type 'int', but argument 2 has type 'size_t';
  - unused variable 'nti';
  - unused parameter 'argc'.
2010-04-09 22:03:52 +00:00
Romain Tartiere
ee3715e267 Add convenience library infrastructure and move the print_nfc_iso14443a_info() function away from bitutils. 2010-04-09 21:57:03 +00:00
Romuald Conty
2714180227 Add new example to show how to use new polling function. 2010-04-09 16:21:25 +00:00
Romuald Conty
40f230d6f0 New API function (experimental): nfc_initiator_poll_targets() which allow to use hardware polling function. Warning: ATM, it only support ISO14443a targets. 2010-04-09 16:20:47 +00:00
Romuald Conty
4128b23f86 Add new function pn53x_decode_target_data() that fill nfc_target_info_t with TargetData byte stream. 2010-04-09 16:18:42 +00:00
Romuald Conty
bc4c34f851 Add two new types: nfc_target_type_t and nfc_target_t. 2010-04-09 16:16:17 +00:00
Romuald Conty
af9f744390 Add a simple function to print nfc_iso14443a_info_t structure. 2010-04-09 16:11:21 +00:00
Romuald Conty
e9451f71f2 Add details on nfc_initiator_select_dep_target() fct params (enhance documentation). 2010-04-09 15:11:42 +00:00
Romuald Conty
495de91e13 Fix documentation build. 2010-04-09 15:08:36 +00:00
Romuald Conty
25b49f7879 Fix mis-initialized ATS field when filling-in nfc_target_info_t structure (wrong source address in memcpy()) 2010-04-08 16:20:03 +00:00
Romuald Conty
ab028ab4e2 Add FIXME related to Issue 61. 2010-04-08 16:13:12 +00:00
Romuald Conty
9c43e75691 Redo r336. (Missed at r340) 2010-04-07 16:30:16 +00:00
Romain Tartiere
5473befa13 Fix a brunch of -Wextra warnings:
- 'static' is not at beginning of declaration;
  - unused parameter;
  - comparison between signed and unsigned.
2010-04-07 15:08:04 +00:00
Romuald Conty
3a0d05d15a Minor headers ajustments. 2010-04-07 14:47:53 +00:00
Romuald Conty
bedaf12b0e Fix releaser script according to the new sources tree. 2010-04-07 14:46:46 +00:00
Romain Tartiere
c7d77d7664 Rearrange source code. 2010-04-07 14:37:19 +00:00
Romuald Conty
be1639b452 Prepare libnfc 1.3.4 (ChangeLog) 2010-04-06 21:19:40 +00:00
Romain Tartiere
c4c7fa236a Attempt to be able to compile using manual makefile AND with CMake (missing parts from r332) 2010-04-06 17:55:12 +00:00
Romain Tartiere
09d2fff619 Add another missing CMakeLists.txt in autotooled tarball. 2010-04-03 12:06:50 +00:00
Romain Tartiere
22d4ea3207 Add missing CMakeLists.txt in autotooled tarball. 2010-04-03 12:03:24 +00:00
Romuald Conty
02a29920fc Prepare libnfc 1.3.4 2010-03-31 14:07:13 +00:00
Romuald Conty
d3796b6531 Attempt to be able to compile using manual makefile AND with CMake 2010-03-31 14:03:12 +00:00
Romuald Conty
12e4d3c822 Minor tweak in make_release.sh script 2010-03-31 13:54:31 +00:00
Romuald Conty
23f2adb433 Fix missing ";".
Pointy hat to Romain ;-)
2010-03-31 10:16:26 +00:00
Romuald Conty
a78cae1c15 Export ISO14443A CRC function. Thanks to Romain Tartière. 2010-03-31 10:09:06 +00:00
Romain Tartiere
667ba72dbd Strip CT (Cascade Tag) from UIDs in nfc_initiator_select_tag(). 2010-03-30 16:05:01 +00:00
Romuald Conty
1214f31d2c Fix CT (Cascade Tag) byte when using 10 bytes long UID. 2010-03-30 15:17:18 +00:00
Romuald Conty
85afbd40ca Fix nfc-types documentation. 2010-03-25 19:12:31 +00:00
Romuald Conty
ba5dbb05d5 Put an annoying message in debug mode only. 2010-03-25 14:55:28 +00:00
Romuald Conty
17dda85c71 Add README for Windows compilation using win32/Makefile.
Rename README-Windows.txt (compilation using CMake) into CMake-Windows.txt
2010-03-25 09:28:09 +00:00
Romuald Conty
b3c055fa5f Typo. 2010-03-25 09:03:41 +00:00
Romain Tartiere
f20a681315 Prevent the Windows installer from installing manual pages. 2010-03-23 10:00:48 +00:00
Romain Tartiere
f372104163 Fix build on Windows when using CMake (Tested on Windows XP SP3 with WinSDK 7) 2010-03-22 20:34:02 +00:00
Romain Tartiere
b3b3f47876 - Sync libnfc version in CMake with the one in the autotools;
- Only add gcc-specific options when using gcc.
2010-03-22 20:28:30 +00:00
Romuald Conty
c203ce837c Prevent from annoying message when probing nfc devices. 2010-03-11 14:42:58 +00:00
Romain Tartiere
e223b93d91 The obsolete function usleep(3) also needs _XOPEN_SOURCE >= 500. 2010-02-20 13:01:43 +00:00
265 changed files with 36105 additions and 8832 deletions

64
.gitignore vendored Normal file
View File

@ -0,0 +1,64 @@
**/.deps/
**/.libs/
**/Makefile
**/Makefile.in
*.exe
*.la
*.lo
*.o
*~
.vs/
CMakeSettings.json
Doxyfile
INSTALL
aclocal.m4
ar-lib
autom4te.cache/
build
compile
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
debian/
depcomp
examples/nfc-anticol
examples/nfc-dep-initiator
examples/nfc-dep-target
examples/nfc-emulate-forum-tag2
examples/nfc-emulate-tag
examples/nfc-emulate-uid
examples/nfc-mfsetuid
examples/nfc-poll
examples/nfc-relay
examples/pn53x-diagnose
examples/pn53x-sam
examples/pn53x-tamashell
examples/quick_start_example1
examples/quick_start_example2
install-sh
libnfc.pc
libtool
ltmain.sh
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
missing
stamp-h1
test-driver
test/run-test.sh.log
test/run-test.sh.trs
test/test-suite.log
utils/nfc-emulate-forum-tag4
utils/nfc-jewel
utils/nfc-list
utils/nfc-mfclassic
utils/nfc-mfultralight
utils/nfc-read-forum-tag3
utils/nfc-relay-picc
utils/nfc-scan-device

81
.travis.yml Normal file
View File

@ -0,0 +1,81 @@
language: c
matrix:
include:
- os: windows
compiler:
- clang
before_install:
- mkdir build && cd build && wget "https://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/libusb-win32-bin-1.2.6.0.zip" && 7z x libusb-win32-bin-1.2.6.0.zip -o"$PROGRAMFILES" && mv "$PROGRAMFILES/libusb-win32-bin-1.2.6.0" "$PROGRAMFILES/libusb-win32"
install:
choco install doxygen.install ninja
script:
cmake -GNinja .. && cmake --build .
- os: linux
dist: bionic
compiler:
- clang
addons:
apt:
packages:
- libusb-dev
- doxygen
- cmake
script:
- mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=~/.local .. && make -j2 && make install
- os: linux
dist: bionic
compiler:
- clang
addons:
apt:
packages:
- libusb-dev
- doxygen
script:
- autoreconf -vfi && mkdir build && cd build && ../configure --prefix=$HOME/.local/ && make -j2 && make install
- os: linux
dist: bionic
compiler:
- gcc
addons:
apt:
packages:
- libusb-dev
- doxygen
- cmake
script:
- mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=~/.local .. && make -j2 && make install
- os: linux
dist: bionic
compiler:
- gcc
addons:
apt:
packages:
- libusb-dev
- doxygen
script:
- autoreconf -vfi && mkdir build && cd build && ../configure --prefix=$HOME/.local/ && make -j2 && make install
- os: osx
osx_image: xcode12
compiler:
- clang
before_install:
- brew install doxygen libusb-compat
script:
- mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=~/.local .. && make -j2 && make install
- os: osx
osx_image: xcode12
compiler:
- clang
before_install:
- brew install doxygen libusb-compat m4
script:
- autoreconf -vfi && mkdir build && cd build && ../configure --prefix=$HOME/.local/ && make -j2 && make install

47
AUTHORS
View File

@ -1,2 +1,49 @@
# Alphabetical cleaned output of "git shortlog -s -e|cut -c 8-" :
Adam Laurie <adam@algroup.co.uk>
Ahti Legonkov <ahti.legonkov@gmail.com>
Alex Lian <alian@alum.mit.edu>
Alexander Inyukhin <shurick@sectorb.msk.ru>
Anugrah Redja Kusuma <anugrah.redja@gmail.com>
Audrey Diacre <adiacre@il4p.fr>
Boris Moiseev <cyberbobs@gmail.com>
Christoph Gritschenberger <christoph.gritschenberger@gmail.com>
Dario Carluccio <dario.carluccio@gmail.com>
David Kreitschmann <david@kreitschmann.de>
Emanuele Bertoldi <emanuele.bertoldi@gmail.com>
Emmanuel Dreyfus <manu@netbsd.org>
Eugeny Boger <eugenyboger@gmail.com>
Francois Kooman <fkooman@tuxed.net>
Frank Morgner <frankmorgner@gmail.com>
Frédéric Bourgeois <bourgeoislab@gmail.com>
Hidde Wieringa <hidde@hiddewieringa.nl>
Jairo Andres Suarez <andres4005@gmail.com>
Jiapeng Li <gapleehit@gmail.com>
Jim Anastassiou <jim.anastassiou@gmail.com>
John Galt <centromere@users.noreply.github.com>
Julien Ehrhart <julien.ehrhart@live.com>
Julien Schueller <julien.schueller@gmail.com>
Laurent Latil <laurent@latil.nom.fr>
Ludovic Rousseau <ludovic.rousseau@gmail.com>
Marcello Morena <marcello.morena@gmail.com>
Marcos Vives Del Sol <socram8888@gmail.com>
Mati Vait <mativait@gmail.com>
Maxim Martyanov <llorephie@gmail.com>
Mike Auty <mike.auty@gmail.com>
Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Olliver Schinagl <oliver@schinagl.nl>
Paul Menzel <paul.menzel@giantmonkey.de>
Peter Meerwald <pmeerw@pmeerw.net>
Philippe Teuwen <yobibe@gmail.com>
Pim 't Hart <pimmeyproductions@gmail.com>
Ray Lee <rayleesky@outlook.com>
Roel Verdult <roel@libnfc.org>
Romain Tartiere <romain.tartiere@gmail.com>
Romuald Conty <romuald@libnfc.org>
Simon Yorkston <simon.yorkston@gmail.com>
bhack <s.fabri@email.it>
lego <lego@debian-fresh.prx>
quantum-x <simon.yorkston@gmail.com>
timzi <developers@make-gadget.ru>
xantares <xantares09@hotmail.com>
xaqq <kapp.arno@gmail.com>
yerzhanm <yerzhan.mukhamejan@gmail.com>

View File

@ -1,8 +1,14 @@
PROJECT(libnfc C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
cmake_minimum_required (VERSION 2.6)
if (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
endif ()
project (libnfc C)
SET(VERSION_MAJOR "1")
SET(VERSION_MINOR "3")
SET(VERSION_PATCH "2")
SET(VERSION_MINOR "8")
SET(VERSION_PATCH "0")
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
@ -10,26 +16,65 @@ SET(PACKAGE_NAME "libnfc")
SET(PACKAGE_VERSION ${VERSION})
SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
IF(NOT MSVC)
# config.h
IF(WIN32)
SET(LIBNFC_SYSCONFDIR "./config" CACHE PATH "libnfc configuration directory")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_windows.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32)
IF(NOT MINGW)
SET(CMAKE_C_FLAGS "-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE ${CMAKE_C_FLAGS}")
ENDIF(NOT MINGW)
ELSE(WIN32)
SET(_XOPEN_SOURCE 600)
ENDIF(NOT MSVC)
SET(SYSCONFDIR "/etc" CACHE PATH "System configuration directory")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_posix.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
ENDIF(WIN32)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
# make it easy to locate CMake modules for finding libraries
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")
# Options
option (LIBNFC_LOG "Enable log facility (errors, warning, info and debug messages)" ON)
IF(LIBNFC_LOG)
ADD_DEFINITIONS(-DLOG)
ENDIF(LIBNFC_LOG)
option (LIBNFC_ENVVARS "Enable envvars facility" ON)
IF(LIBNFC_ENVVARS)
ADD_DEFINITIONS(-DENVVARS)
ENDIF(LIBNFC_ENVVARS)
SET(LIBNFC_DEBUG_MODE OFF CACHE BOOL "Debug mode")
IF(LIBNFC_DEBUG_MODE)
ADD_DEFINITIONS(-DDEBUG)
SET(CMAKE_C_FLAGS "-g3 ${CMAKE_C_FLAGS}")
SET(WIN32_MODE "debug")
SET(CMAKE_RC_FLAGS "-D_DEBUG ${CMAKE_RC_FLAGS}")
ELSE(LIBNFC_DEBUG_MODE)
SET(WIN32_MODE "release")
ENDIF(LIBNFC_DEBUG_MODE)
option (LIBNFC_CONFFILES_MODE "Enable configuration files" ON)
IF(LIBNFC_CONFFILES_MODE)
ADD_DEFINITIONS(-DCONFFILES)
ENDIF(LIBNFC_CONFFILES_MODE)
option (BUILD_EXAMPLES "build examples ON/OFF" ON)
option (BUILD_UTILS "build utils ON/OFF" ON)
option (BUILD_DEBPKG "build debian package ON/OFF" OFF)
# Doxygen
SET(builddir "${CMAKE_BINARY_DIR}")
SET(top_srcdir "${CMAKE_SOURCE_DIR}")
INCLUDE(UseDoxygen)
SET(LIBNFC_DEBUG_OUTPUT OFF CACHE BOOL "Debug output of communication with the NFC chip")
SET(LIBNFC_PCSC ON CACHE BOOL "Enable PC/SC support (ACR122)")
SET(LIBNFC_USB ON CACHE BOOL "Enable direct USB communication support (PN531 and PN533)")
SET(LIBNFC_SERIAL_AUTOPROBE_ENABLED OFF CACHE BOOL "Allow serial ports to be probed (can seriously disturb connected serial devices)")
IF(DEFINED CMAKE_INSTALL_LIBDIR)
SET(libdir ${CMAKE_INSTALL_LIBDIR})
ELSE(DEFINED CMAKE_INSTALL_LIBDIR)
@ -48,52 +93,213 @@ IF(NOT DEFINED SHARE_INSTALL_PREFIX)
SET(SHARE_INSTALL_PREFIX share)
ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX)
IF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
ADD_DEFINITIONS("-DSERIAL_AUTOPROBE_ENABLED")
ENDIF(LIBNFC_SERIAL_AUTOPROBE_ENABLED)
IF(LIBNFC_DEBUG_OUTPUT)
ADD_DEFINITIONS(-DDEBUG -g3)
ENDIF(LIBNFC_DEBUG_OUTPUT)
# CMake have config.h generation, so we must define this
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
# Make sure we will not miss some warnings ;)
ADD_DEFINITIONS(-Wall -pedantic -std=c99)
# Additonnal GCC flags
IF(CMAKE_COMPILER_IS_GNUCC)
# Make sure we will not miss some warnings ;)
SET(CMAKE_C_FLAGS "-Wall -pedantic -std=c99 ${CMAKE_C_FLAGS}")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
# Workarounds for libusb in C99
ADD_DEFINITIONS(-Du_int8_t=uint8_t -Du_int16_t=uint16_t)
IF(NOT MSVC)
IF(MINGW)
IF (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
# force MinGW-w64 in 32bit mode
SET(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
SET(CMAKE_MODULE_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
SET(CMAKE_RC_FLAGS "--target=pe-i386 --output-format=coff ${CMAKE_RC_FLAGS}")
ELSE(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
# force MinGW-w64 in 32bit mode
MESSAGE("Building 32-bit Windows DLL")
#SET(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
#SET(CMAKE_MODULE_LINKER_FLAGS "--Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
#SET(CMAKE_SHARED_LINKER_FLAGS "--Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
#SET(CMAKE_EXE_LINKER_FLAGS "--Wl,--enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
SET(CMAKE_RC_FLAGS "--target=pe-i386 --output-format=coff ${CMAKE_RC_FLAGS}")
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
MESSAGE("Building 64-bit Windows DLL")
SET(CMAKE_RC_FLAGS "--target=pe-x86-64 --output-format=coff ${CMAKE_RC_FLAGS}")
ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
MESSAGE(FATAL_ERROR "Unknown Processor: ${CMAKE_SYSTEM_PROCESSOR}")
ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
ENDIF(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
FIND_PROGRAM(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH)
IF (NOT DLLTOOL)
MESSAGE(FATAL_ERROR "Could not find dlltool command")
ENDIF (NOT DLLTOOL)
ENDIF(MINGW)
IF(NOT WIN32)
# Set some pkg-config variables
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(exec_prefix ${CMAKE_INSTALL_PREFIX})
SET(PACKAGE "libnfc")
IF(LIBNFC_USB)
IF(LIBNFC_DRIVER_PN53X_USB)
SET(PKG_REQ ${PKG_REQ} "libusb")
ENDIF(LIBNFC_USB)
IF(LIBNFC_PCSC)
ENDIF(LIBNFC_DRIVER_PN53X_USB)
IF(LIBNFC_DRIVER_ACR122_USB)
SET(PKG_REQ ${PKG_REQ} "libusb")
ENDIF(LIBNFC_DRIVER_ACR122_USB)
IF(LIBNFC_DRIVER_PCSC)
SET(PKG_REQ ${PKG_REQ} "libpcsclite")
ENDIF(LIBNFC_PCSC)
ENDIF(LIBNFC_DRIVER_PCSC)
IF(LIBNFC_DRIVER_ACR122_PCSC)
SET(PKG_REQ ${PKG_REQ} "libpcsclite")
ENDIF(LIBNFC_DRIVER_ACR122_PCSC)
# CMake lists are separated by a semi colon, replace with colon
STRING(REPLACE ";" "," PKG_CONFIG_REQUIRES "${PKG_REQ}")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libnfc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
ENDIF(NOT MSVC)
ENDIF(NOT WIN32)
ADD_SUBDIRECTORY(src)
INCLUDE(LibnfcDrivers)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF(I2C_REQUIRED)
# Inspired from http://cmake.3232098.n2.nabble.com/RFC-cmake-analog-to-AC-SEARCH-LIBS-td7585423.html
INCLUDE (CheckFunctionExists)
INCLUDE (CheckLibraryExists)
CHECK_FUNCTION_EXISTS (clock_gettime HAVE_CLOCK_GETTIME)
IF (NOT HAVE_CLOCK_GETTIME)
CHECK_LIBRARY_EXISTS (rt clock_gettime "" HAVE_CLOCK_GETTIME_IN_RT)
IF (HAVE_CLOCK_GETTIME_IN_RT)
SET(LIBRT_FOUND TRUE)
SET(LIBRT_LIBRARIES "rt")
ENDIF (HAVE_CLOCK_GETTIME_IN_RT)
ENDIF (NOT HAVE_CLOCK_GETTIME)
ENDIF(I2C_REQUIRED)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF(PCSC_INCLUDE_DIRS)
INCLUDE_DIRECTORIES(${PCSC_INCLUDE_DIRS})
LINK_DIRECTORIES(${PCSC_LIBRARY_DIRS})
ENDIF(PCSC_INCLUDE_DIRS)
IF(LIBUSB_INCLUDE_DIRS)
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS})
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS})
SET(LIBUSB_FOUND TRUE)
ENDIF(LIBUSB_INCLUDE_DIRS)
# version.rc for Windows
IF(WIN32)
# Date for filling in rc file information
IF (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
MACRO (GET_CURRENT_YEAR RESULT)
EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
STRING(REGEX REPLACE "\n" "" ${RESULT} ${${RESULT}})
STRING(REGEX REPLACE ".*(..)/(..)/(....).*" "\\3" ${RESULT} ${${RESULT}})
ENDMACRO (GET_CURRENT_YEAR)
ELSE(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
MACRO (GET_CURRENT_YEAR RESULT)
EXECUTE_PROCESS(COMMAND "date" "+%Y" OUTPUT_VARIABLE ${RESULT})
STRING(REGEX REPLACE "\n" "" ${RESULT} ${${RESULT}})
ENDMACRO (GET_CURRENT_YEAR)
ENDIF(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
GET_CURRENT_YEAR(CURRENT_YEAR)
MESSAGE("Year for copyright is " ${CURRENT_YEAR})
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(RC_COMMENT "${PACKAGE_NAME} library")
SET(RC_INTERNAL_NAME "${PACKAGE_NAME} ${WIN32_MODE}")
SET(RC_ORIGINAL_NAME ${PACKAGE_NAME}.dll)
# RC_FILE_TYPE: VFT_DLL
SET(RC_FILE_TYPE 0x00000002L)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/windows/libnfc.rc @ONLY)
ENDIF(WIN32)
ADD_SUBDIRECTORY(libnfc)
ADD_SUBDIRECTORY(include)
if (BUILD_UTILS)
add_subdirectory (utils)
endif ()
if (BUILD_EXAMPLES)
add_subdirectory (examples)
endif ()
if (NOT MSVC)
# config script install path
if ( NOT DEFINED LIBNFC_CMAKE_CONFIG_DIR )
set ( LIBNFC_CMAKE_CONFIG_DIR lib${LIB_SUFFIX}/cmake/libnfc )
endif ()
set ( LIBNFC_INCLUDE_DIR ${includedir} )
set ( LIBNFC_INCLUDE_DIRS ${LIBNFC_INCLUDE_DIR} )
list ( APPEND LIBNFC_INCLUDE_DIRS ${LIBUSB_INCLUDE_DIRS} )
set ( LIBNFC_LIBRARY nfc )
set ( LIBNFC_LIBRARIES ${LIBNFC_LIBRARY} )
list ( APPEND LIBNFC_LIBRARIES ${LIBUSB_LIBRARIES} )
set ( LIBNFC_LIBRARY_DIRS ${libdir} )
set ( LIBNFC_ROOT_DIR ${prefix} )
set ( LIBNFC_VERSION_STRING ${VERSION} )
set ( LIBNFC_VERSION_MAJOR ${VERSION_MAJOR} )
set ( LIBNFC_VERSION_MINOR ${VERSION_MINOR} )
set ( LIBNFC_VERSION_PATCH ${VERSION_PATCH} )
set ( LIBNFC_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIBNFC_CMAKE_CONFIG_DIR}/UseLibNFC.cmake )
if(CMAKE_VERSION VERSION_LESS 2.8.8)
configure_file ( cmake/LibNFCConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfig.cmake @ONLY )
configure_file ( cmake/LibNFCConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfigVersion.cmake @ONLY )
else ()
include(CMakePackageConfigHelpers)
configure_package_config_file (
cmake/LibNFCConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfig.cmake
INSTALL_DESTINATION ${LIBNFC_CMAKE_CONFIG_DIR}
PATH_VARS
LIBNFC_USE_FILE
LIBNFC_ROOT_DIR
LIBNFC_INCLUDE_DIR
LIBNFC_INCLUDE_DIRS
LIBNFC_LIBRARY_DIRS
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file (
LibNFCConfigVersion.cmake
VERSION ${LIBNFC_VERSION_STRING}
COMPATIBILITY AnyNewerVersion
)
endif ()
install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfigVersion.cmake
cmake/UseLibNFC.cmake
DESTINATION ${LIBNFC_CMAKE_CONFIG_DIR}
)
endif ()
# Binary Package
IF(MSVC)
SET(CPACK_GENERATOR "NSIS")
ELSE(MSVC)
IF(WIN32)
SET(CPACK_GENERATOR "ZIP")
ELSE(WIN32)
SET(CPACK_GENERATOR "TBZ2")
ENDIF(MSVC)
IF(BUILD_DEBPKG)
SET(CPACK_GENERATOR "DEB")
ENDIF(BUILD_DEBPKG)
ENDIF(WIN32)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Near Field Communication (NFC) library")
SET(CPACK_PACKAGE_VENDOR "Roel Verdult")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_CONTACT "Roel Verdult <roel@libnfc.org>")
#Readme file
IF(WIN32)
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README-Windows.md")
ELSE(WIN32)
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
ENDIF(WIN32)
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "libnfc")
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
@ -101,19 +307,22 @@ SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "NFC Library")
SET(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example Applications")
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Development Headers")
SET(CPACK_COMPONENT_MANUALS_DISPLAY_NAME "Example Applications Manuals")
IF(NOT WIN32)
SET(CPACK_COMPONENT_MANUALS_DISPLAY_NAME "Example Applications Manuals")
SET(CPACK_COMPONENT_MANUALS_DISABLED TRUE)
SET(CPACK_COMPONENT_MANUALS_DEPENDS examples)
ENDIF(NOT WIN32)
SET(CPACK_COMPONENT_HEADERS_DISABLED TRUE)
SET(CPACK_COMPONENT_MANUALS_DISABLED TRUE)
SET(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries)
SET(CPACK_COMPONENT_MANUALS_DEPENDS examples)
# Source Package
IF(MSVC)
IF(WIN32)
SET(CPACK_SOURCE_GENERATOR "ZIP")
ELSE(MSVC)
ELSE(WIN32)
SET(CPACK_SOURCE_GENERATOR "ZIP;TBZ2")
ENDIF(MSVC)
ENDIF(WIN32)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "libnfc-${VERSION}")
SET(CPACK_SOURCE_IGNORE_FILES "~$" "/\\\\.svn/" "bin/")
SET(CPACK_SOURCE_IGNORE_FILES "~$" "/\\\\.git/" "bin/")
INCLUDE(CPack)

682
ChangeLog
View File

@ -1,3 +1,680 @@
May 22, 2020 - 1.8.0
--------------------
Fixes:
- Restore nfc_modulation_type enum order to keep compatibility with libnfc 1.7.1
Changes:
- Bump revision due to changes in API introduced in v1.7.2
- Bump library version to 6.0.0
May 21, 2020 - 1.7.2 (avoid using it, incompatible with 1.7.1)
--------------------
Fixes:
- Remove unreachable code
- nfc_emulate_uid: cleaner exit on interrupt
- Fix reporting of modulations and baud rates by nfc-scan-device -v
- Fix out-of-bounds access in nfc-mfultralight
- Several Cygwin compilation fixes
- Fix comparison when nfc_initiator_target_is_present() with a specified target
- Fix nfc_initiator_poll_target without tag on PN532
- Export iso14443b* symbols
- Fix udev rule which was executed too early
- Fix improper device name initialization
- Fix setenv()/unsetenv() for Windows
- Fix win32/nfc.def according to nfc.h
- Fix missing timeout in pn53x_initiator_select_passive_target()
- nfc-mfclassic: fix option to tolerate write errors
- nfc-poll: fix card removing check
- nfc-relay-picc: fix wrong open mode for file descriptor
Improvements:
- Allow ISO14443A to be used at higher baud rates
- nfc_initiator_select_passive_target() now checks against
reported modulations and baud rates for current device
- More serial devices on MAC OS X
- Add section to README to help to configure libnfc
- Various cmake improvements
- Drop PCRE dependency on Windows
- Remove deprecated readdir_r
- Markdown conversion of the text files
- Use hardcoded PN533 descriptors to be more robust on Windows
- Add support for SCL3712
- Add support for ACR1222U-C1
- Add support for NetBSD
- Add support for PN532 on RPi3 UART
- Add support for cross-compilation of 32b & 64b versions of the library for Windows
- Add pn533_usb to the kernel modules blacklist
- Add support for pn71xx NXP's NFC Controllers through Linux Libnfc-nci (untested)
- Add support for contactless PC/SC readers (only as initiator)
- Add support for Feitian R502 and bR500 into pcsc driver
- Add support for HID iClass (Picopass) support (nfc-iclass tool in external nfc-tools repo)
- Allows for sending empty data in nfc_initiator_transceive_bits
- driver i2c: respect proper timing specifications
- driver i2c: add retry on error mechanism
- nfc-mfclassic: improvements fo magic cards
- nfc-mfclassic: add option to specify UID
- nfc-mfclassic/nfc-mfsetuid: add support for new gen (1b) of magic 4K cards
- nfc-mfclassic: Add RATS support indicator
- nfc-mfsetuid: allow to write complete Block0, instead of only UID
- nfc-mfultralight: add automatic modes and --check-magic
- nfc-mfultralight: add support for magic gen2 cards
- nfc-mfultralight: add option to specify UID
- nfc-mfultralight: add support for Ultralight NTAG213/215/216
- nfc-barcode: new command to read and decode NFC Barcodes (Tag-Talks-First)
Changes:
- nfc_device_get_supported_baud_rate() takes now a "mode" parameter
- New nfc_device_get_supported_baud_rate_target_mode()
- New NFC modulation type NMT_BARCODE and nfc_barcode_info struct to support Thinfilm NFC Barcode protocol
- New NFC modulation type NMT_ISO14443BICLASS and NMT_ISO14443BICLASS struct to support HID iClass (Picopass)
- pn53x_transceive() is now part of public API
Special thanks to:
- Jim Anastassiou, Frédéric Bourgeois, Dario Carluccio, Emmanuel Dreyfus,
Julien Ehrhart, S. Fabri, John Galt, Christoph Gritschenberger,
Alexander Inyukhin, Arnaud Kapp, David Kreitschmann, Adam Laurie, Ray Lee,
Maxim Martyanov, Paul Menzel, Boris Moiseev, Yerzhan Mukhamejan,
Olliver Shinagl, Jairo Andres Suarez, Mati Vait, Marcos Vives Del Sol,
Hidde Wieringa, Simon Yorkston, timzi, usk-johnny-s, xantares, Hanno
Heinrichs, jgeslin, Mikolaj Stawiski, rstular, Khem Raj, Frank Morgner, jpwidera,
Feitian Technologies
Feb 24, 2014 - 1.7.1
--------------------
Fixes:
- Fix several issues reported by Coverity Scan
(mem leaks, buff overflows, reuse after free, etc)
- More robust when several conflicting uart drivers are in the config
- Fix racing condition with uart_flush_input()
- Silent pn53x_check_communication error messages when scanning
- Fix nfc_target_init(), was returning success in case of timeout
- Windows: fix several compilation issues
- On tag selection, save current target info also for ISO14443B*
- nfc-read-forum-tag3: fix incomplete NDEF retrieval and size of output file
Improvements:
- nfc-list: New option to choose which technologies to poll for
- UART: drivers now supported under kFreeBSD
- New LIBNFC_DEVICE env var to use one reader and exclude all other readers
while LIBNFC_DEFAULT_DEVICE only prepends it to the configured devices list
- New LIBNFC_AUTO_SCAN env var to enable(default)/disable auto scan
- On tag selection, save current target info even if pnt=NULL
- On tag selection, grant NP_INFINITE_SELECT also for ISO14443B*
- Save & restore NP_INFINITE_SELECT status when changing it internally
- nfc-mfclassic: add format/wipe command (thanks to Adam Laurie)
- nfc-jewel: new utility to read/write Topaz/Jewel tags (thanks to Pim 't Hart)
- nfc_initiator_select_passive_target() provides defaults if pbtInitData=NULL
- nfc-read-forum-tag3: add -q option, add full parsing of NDEF Attribute Block
Fixes & improvements specific to nfc_initiator_target_is_present():
- Supports fully PN532 & PN533, not tested on other chips
- Fix usage after nfc_initiator_poll_target()
- Set correctly last_error
- Fix issue when there was no saved target
- Allow NULL pointer to tag
- Fix issues in case of tear off conditions
- Now works with:
* MFUL, MFC, MFC Mini, MFC 7-byte (re-selection: you'll need to auth again)
* ISO14443-4A, ISO14443-4B
* ISO14443-4B', ASK CTx, ST SRx
* Jewel
* FeliCa
Sep 03, 2013 - 1.7.0
--------------------
Fixes:
- pn53x: only create a current target when at least one have been found
- pn532_uart: fix 'operation abort' feature with this driver
- pn532_uart: let more time to PN532 to wake-up, this fix some specific cases
where PN532 shown one of two runs (Thanks to Marcello Morena)
- nfc-mfclassic: allow option f for read operation too
- Avoid clash with system's htole32 if it exists
- Include <stdlib.h>, required for getenv(3)
- usb: fix USB enumeration issue (Thanks to Mike Auty)
- acr122_pcsc: fix compilation on Mac OSX 10.8.4
- Fix pn53x_initiator_transceive_bytes_timed() measures for TypeB
- Various minor fixes: warnings, style, etc.
Improvements:
- New PN532 over I2C driver, see contrib/libnfc/pn532_i2c_on_rpi.conf.sample
- ACR122/Touchatag: misc improvements
- ReadMobib/ReadNavigo: improve shell script portability
- Add ISO14443-4 chaining support for RX (MI)
- UART: add support for BeagleBone serial ports (Thanks to Johan Henselmans)
- nfc-mfultralight: allow setting of UID for special 'chinese' ultralight cards
Special thanks to:
- Laurent Latil (new pn532_i2c driver for linux)
- Nobuhiro Iwamatsu (warning fixes and debian package)
Apr 05, 2013 - 1.7.0-rc7 (release candidate)
--------------------------------------------
Fixes:
- Fix bug when compiling without libusb
- Fix several memory leaks in error handling conditions
- Remove calls to exit() from the library
- Create safer snprint_nfc_*() instead of sprint_nfc_*() functions
- Fix warnings returned by cppcheck & clang/scan-build
- Obsolete function 'usleep' => nanosleep()
- Non reentrant function 'readdir' => readdir_r()
- Non reentrant function 'strtok' => new connstring_decode()
- Buffer may not be null-terminated after call to strncpy()
- scanf without field width limits can crash with huge input data
- Resource leaks: missing fclose()
- Dead code, unused vars & vars scopes warnings
- Unify copyright notices & update authors lists
- Windows: Fix compilation due to new usbbus file
- Windows: Clean up compiler/linker warnings
- Fixed the suppression of the auto-fixup for linking against MS built libs
- Fixed all the formatting warnings by shifting to inttypes.h specifiers
- shifted to %lu for DWORD printf
- nfc-anticol: fix ATS length
- nfc-mfclassic: fix reporting of processed blocks total
- nfc-mfclassic: detect MIFARE Plus 2K as 2K instead of 1K
- pn53x_usb/acr122_usb: check usb_open() returns before using it
Improvements:
- New PN532 over SPI driver, see contrib/libnfc/pn532_spi_on_rpi.conf.sample
- Devels HACKING file: introduce clang/scan-build & cppcheck for better code
- Better internal dependencies handling (bus <> drivers)
- Cleaner handling of portability patches
- Windows: logging via OutputDebugString(), ease debugging
- nfc-mfclassic: use smaller files for cards < 4k
- nfc-mfclassic: by defaut don't authorise wrong keyfile, use "f" to force
- quick_start_example1.c: remove err.h dependency, easier for Windowsians
- nfc-mfclassic: support some new magic cards with writeable sector #0
- nfc-anticol: add -t option to use timed functions
Changes:
- Upon malloc error, nfc_init() doesn't force exit() anymore
so now you should test if context != NULL after nfc_init() call
- API: nfc_initiator_target_is_present() & str_nfc_target()
now take a pointer to nfc_target as argument instead of passing by value
Special thanks to:
- Eugeny Boger (new pn532_spi driver for linux)
Mar 03, 2013 - 1.7.0-rc6 (release candidate)
--------------------------------------------
Fixes:
- Fix several memory leaks (nfc_drivers, libusb, config parser)
- Fix stack smash while displaying long data transmission (LOG_HEX)
- pn53x-tamashell: allow larger commands up to full extended frame
- Add missing windows file in archive (version.rc.in)
- Fix compilation warnings & potential bugs
- Fix documentation
- Fix missing malloc() calls checks
- Fix missing free() calls in some error handlers
Improvements:
- Allow to disable conffils & envvar supports on embedded platforms
- Add option to nfc-mfclassic to tolerate RW errors
Changes:
- Replace usb_set_debug() in applications by LIBNFC_LOG_LEVEL libusb group
Feb 16, 2013 - 1.7.0-rc5 (release candidate)
--------------------------------------------
Fixes:
- Add missing sample configuration file in archive
- Add missing windows files in archive
- Preserve error code while using pn53x_set_property_bool() with
NP_AUTO_ISO14443_4 flag
Improvements:
- New nfc_register_driver() function allowing to hook custom drivers
- New nfc_free() function to free allocated buffers
Special thanks to:
- Ahti Legonkov (new nfc_register_driver())
Feb 04, 2013 - 1.7.0-rc4 (release candidate)
--------------------------------------------
Fixes:
- Fix tag selection for nfc-mfclassic, nfc-mfultralight, nfc-read-forum-tag3
and nfc-relay-picc
- Fix crash in nfc-relay-picc -i/-t if fd3 or fd4 is missing
Improvements:
- Windows support build with CMake
Changes:
- Configuration directory (ie. libnfc.conf) can now be set a compile-time
- Log can be enabled/disabled using CMake
Special thanks to:
- Alex Lian (Windows support improvements)
- Nobuhiro Iwamatsu (Debian package improvements)
Jan 31, 2013 - 1.7.0-rc3 (release candidate)
--------------------------------------------
Fixes:
- Fix pn53x_usb bulk write timeout
- Fix BCC in nfc-emulate-uid example
- Fix nfc-relay-picc example
- Fix a miss returned value within some internal functions (user program could
be affected)
- Fix nfc-scan-device -i option
- Remove wrong exit() calls in library
- Fix issue in driver acr122_usb affecting Touchatag
- Reenable some idle in all drivers, add selectively PowerDown when possible
Changes:
- nfc_emulate_target() now takes timeout parameter
Special thanks to:
- Alex Lian (Windows support refresh)
Jan 20, 2013 - 1.7.0-rc2 (release candidate)
--------------------------------------------
Fixes:
- Fix API version in debian files
- Fix wrong condition to display a warning when user disables autoscan
- Fix unit tests
- Fix ISO14443B' ATS
Improvements:
- Allow device.optional=true to tolerate missing device
Changes:
- pn532_uart driver is now enabled by default
Dec 09, 2012 - 1.7.0-rc1 (release candidate)
--------------------------------------------
Fixes:
- nfc_initiator_deselect_target() now returns 0 on success (as expected by caller)
- example/pn532-sam: Fix few bugs
- Fix ACR122S device detection when no ACR122S device available (endless UART receive)
- Suppress a lot of compiler warnings !.. which fixes many potential bugs
- Display right driver name while detecting PCSC
- Correctly handle PCSC header files on Mac OS X
- Fix nfc-emulation (now works with utils/nfc-emulate-forum-tag4 and Nexus S)
Improvements:
- New nfc_initiator_init_secure_element() function to set SAM as wired card (only relevant with a PN532 SAM-equipped)
- New str_nfc_target(), str_nfc_modulation_type(), str_nfc_baud_rate() function to convert some libnfc's types into allocated string
- New nfc_device_target_is_present() to check if passed target is in the field
- --enable-serial-autoprobe option at compile time to replace it with some run-time options
- New -i option to nfc-scan-device to allow intrusive scan
- New feature, libnfc now uses configuration files:
* main configuration file can be used to set options (ie. intrusive, autoscan, log-level)
* main configuration file can contains a device as default device, HIGHLY recommended for UART devices users
* multiple devices files can be used to declare multiple devices and ordered them
- UART port scan now includes ttyAMA* to detect UART-devices connected on Raspberry Pi (e.g. `nfc-scan-device -i`)
- Support for OpenPCD2 (with a dedicated firmware)
- Support for FTDI dongle under MacOS
- Enhance messages display
- Provides modprobe configuration file and instructions for Linux >3.1 with PN533 users.
- Greatly improve log facility with log level filter, configurable using conf file (ie. /etc/nfc/libnfc.conf) or environment var LIBNFC_LOG_LEVEL
- New man page for nfc-read-forum-tag3 utility (Thanks to UNFORGiVEN512)
- New man page for nfc-scan-device utility
- New man page for nfc-emulate-forum-tag2 example
- README: Add few words about device permissions and udev/devd rules available in package
- utils/nfc-emulate-forum-tag4: add support for v2.0 of the spec
- New "make style" command to have a beautiful code
- Code cleanup (indentation, white spaces, etc.)
Changes:
- New nfc_device_get_information_about() now allocates returned string
- No more in/out paramaters in nfc_initiator_transceive_*() functions
- Rename nfc-probe to nfc-scan-device
- Rename abtUid from struct mifare_param_auth into abtAuthUid: this is not the UID while using 7-bytes UID MIFARE Classic tags.
- utils/nfc-list: always display the card type when a card is found
- nfc-utils: new fingerprinting method closer to AN10833, (Thanks to Balazs Bucsay)
See NEWS file for major changes (ie. API changes)
Special thanks to:
- Ludovic Rousseau (Code cleanup, tests under MacOS, etc.)
- Frank Morgner
Feb 27, 2012 - 1.6.0-rc1 (release candidate)
--------------------------------------------
Fixes:
- utils/nfc-mfclassic: use MIFARE instead of Mifare typo
- utils/nfc-list: continue to attempt to reach devices after a connection failure
- libnfc: avoid readline auto-detection when cross-compiling
- driver/pn53x_usb: fix path usage for FreeBSD
- doc: quick_start_example1.c fixed
- utils/*: verbose option back for nfc-list, and newly implemented in nfc-poll
Improvements:
- libnfc: enhanced documentation
- libnfc: debug facility back without external depends
- libnfc: add nfc_device_get_supported_modulation() and nfc_device_get_supported_baud_rate() functions
- libnfc: enhanced code indent
- drivers: implement driver for ACR122S device
- utils/nfc-mfclassic: remove non-conscistent "extract payload" option in nfc-mfclassic
- utils/nfc-emulate-forum-tag2: add missing manpage
- utils/nfc-read-forum-tag3: add missing manpage
- tests/*: fix some warnings in test
- tests/test_dep*: add some DEP tests (Active/Passive in several baud rates)
- doc: quick_start_example1 is now compiled when running make check or distcheck
- libnfc: a printf-based logging replaces log4c
- libnfc: various minor fixes/enhancements
- utils/*: nfc-probe example added to show devices connection strings
Changes:
- PN53x specific errors are not public anymore;
- Timeouts are now integers instead of timeval structure
- Removes libusb types workaround (r200) as it seems to not be needed anymore but may disturb compiler
- Removes parse_args() from nfc-utils.[hc]
- Move nfc-emulate-forum-tag2 from utils to examples.
- contrib: move udev and devd files into contrib/
- debian: udev rules file renamed
See NEWS file for major changes (ie. API changes)
Special thanks to:
- Thomas Hood (Debian packages and various fixes/contributions)
- Anugrah Redja (ACR122S driver)
Oct 17, 2011 - 1.5.1 (unstable)
-------------------------------
Fixes:
- libnfc: fix invalid memory access when a new driver is probing for hardware and the number of requested devices was already reached
- chips/pn53x: fix bug in _timed fcts
- drivers/pn53x_usb: fix crash when usb_bulk_read() fails.
- drivers/pn53x_usb: continue to search a available device on usb errors (ie. Device Busy)
- drivers/pn53x_usb: make PN53x usb connection more stable
- examples/nfc-relay: fix UID problem
- windows: fix uart_receive() under Win32 platform
Improvements:
- libnfc: add logging facility using log4c.
- libnfc: abort mecanism is now implemented in driver layer, so it can use pipe-based mecanism (as PN532_UART or ARYGON driver does under POSIX system) or flag-based mecanism.
- libnfc: add ISO/IEC 14443 B' aka Type B' modulation partial support
- libnfc: add partial support (list) for ISO14443B-3 ST SRx & ASK CTx cards
- libnfc: compile unit tests only on demand unless using --enable-debug.
- libnfc: error handling improvements
- libnfc: new function nfc_idle() to set the NFC device in idle mode
- libnfc: add partial support for Sony S360 reader
- libnfc: some manual test reports have been added
- libnfc: list_targets support for ASK CTS512B (no anticol support yet)
- libnfc: nfc_disconnect() now switches NFC device into idle before disconnecting
- libnfc: nfc_initiator_poll_target() is now available for all devices
- libnfc: implement software polling for non-PN532 equipped device
- chips/pn53x: add pn53x_data_new() function to alloc and init pn53x_data structure
- chips/pn53x: add some SFR registers description
- chips/pn53x: implement WriteBack cache
- chips/pn53x: new pn53x_PowerDown wrapper for PowerDown (PN532) command
- chips/pn53x: prints a debug trace when reading PN53x registers
- chips/pn53x: set some parameters in ISO/IEC 14443A when using DEP mode (ie. SAK says ISO/IEC 18092 compliant) (Android NFC stack now detects the target as DEP)
- chips/pn53x: some optimisations in registers initialisation
- chips/pn53x: list_passive_targets() fixed for TypeB on LoGO
- chips/pn53x: pn53x_data now have a operating_mode enum to know the current running mode (initiator, target or idle)
- drivers/*: all commands are now abortable
- drivers/pn532_uart,arygon: make valgrind happy with UART-based drivers
- drivers/pn53x*: use shared pn53x_ack_frame[] and pn53x_nack_frame[] instead of local declaration
- drivers/pn53x_usb: all USB errors are now reported in text format
- drivers/pn53x_usb: enable progressive field on init to allow pn53x-tamashell to works (note: it does not distrib progressive field enabling when nfc_list_passive_target() is used)
- drivers/pn53x_usb: implement PN53x extended information frames with USB devices
- drivers/pn53x_usb: use progressive field on/off only for ISO14443 Type B target listing
- buses/uart: now provides an abort mecanism for windows users
- buses/uart: UART based drivers could now use uart_flush_input() to discard junk bytes on input.
- examples/nfc-anticol: add -f option to force RATS
- examples/nfc-mfclassic: handle 7-byte UID cards & MFC Mini
- examples/nfc-anticol: now use nfc_abort_command()
- examples/nfc-dep-*: disconnect from NFC device on error.
- examples/nfc-emulate-forum-tag2: add new example to emulate a NFC Forum Tag Type 2
- examples/nfc-emulate-forum-tag4: add document references.
- examples/nfc-emulate-forum-tag4: this example now fails with ENOTSUPP when used with a non-PN532 chip.
- examples/nfc-mfclassic: write special Mifare 1K cards, including Block 0 / UID
- examples/nfc-mfsetuid: add a new example to set UID of special Mifare 1K cards
- examples/nfc-read-forum-tag3: add new example to read a NFC Forum Tag Type 3
- examples/pn53x-tamashell-scripts: minor enhancements
- tests/test-dep: add a threaded DEP test to check DEP communication between two local devices
- debian: enable all drivers at compile time
- debian: improve debian packaging (Thanks to Thomas Hood)
- debian: use a numbering that allow to have libnfc pre-version and debian package pre-version too. (Thanks to Thomas Hood)
- freebsd: add FreeBSD devd(8) snippet configuration for Sony S330 readers.
- windows: implement abort mecanism in pn532_uart driver (Based on provided patch: many thanks to Edwin Evans)
- windows: USB drivers now relies on libusb-win32 with version >= 1.2.4.x (1.2.4.6 recommended) (Many thanks to Glenn)
- windows: implement automatic uart port detection and input flush (Thanks to Edwin Evans)
Changes:
- libnfc: add 'struct timeval *timeout' parameter for pn53x_transceive(), pn53x_target_receive_bytes() and pn53x_target_send_bytes().
Apr 29, 2011 - 1.5.0 (unstable)
-------------------------------
Fixes:
- libnfc: silent warnings with more strict CFLAGS
- libnfc: update devd(8) rules file for FreeBSD
- libnfc: make libnfc compile under Windows
- libnfc: fix nfc_pick_device() when called from nfc_connect with NULL nfc_device_desc_t parameter
- chips/pn53x: fix a bug when value is larger than mask when using WriteRegister
- chips/pn53x: adapt MaxRetries to avoid issue with 2 tags on PN531
- examples/nfc-mfclassic: UID was shown reverse-ordered
Improvements:
- libnfc: use a new way to handle drivers, introduce a real HAL
- libnfc: use absolute include path instead of relative ones
- libnfc: move some nfc_device_t members in a better place
- libnfc: improve nfc_driver_t struct to embedded HAL API
- libnfc: nfc_device_t now embeddeds driver data and chip data pointers (useful to be more generic)
- libnfc: use more readable variables instead of strange coding convention
- libnfc: move PRINT_HEX macro into nfc-internal.h
- libnfc: introduce an abort mecanism
- libnfc: suppress any PN53x references in nfc.c
- libnfc: nfc-mfclassic and nfc-mfcultralight examples are now compiled under Windows
- chips/pn53x: use the powerful C99 writing to construct PN53x commands
- chips/pn53x: remove almost all memcpy()
- chips/pn53x: WriteRegister, ReadRegister and SetParameters command wrappers are correctly named
- chips/pn53x: introduce chip state (SLEEP, NORMAL or EXECUTE)
- chips/pn53x: add SAMConfiguration command wrapper (need to be improved)
- chips/pn53x: remove almost all const arrays
- chips/pn53x: use human readable defines for commands instead of hex values
- chips/pn53x: in debug mode, the PN53x command is shown in human-readable string, awesome isn't it? ;-)
- chips/pn53x: try to determine IC version instead of hardcode it.
- chips/pn53x: new fonction to build frames instead of build them in each driver
- chips/pn53x: enable aborting blocking commands (e.g. TgInitAsTarget) and refactor *_check_communication() as pn53x_check_communication().
- chips/pn53x: add timed versions of transceive_bytes/bits, allow to detect emulated/non-emulated tags and more...
- chips/pn53x: support CRC auto-handling in ...transceive_bytes_timed
- drivers/pn53x_usb: ASK LoGO: enable progressive field feature.
- drivers/pn532_uart: major improvement of UART handling
- drivers/pn532_uart: check PN53x frames when received
- drivers/pn53x_usb: enhance ASK LoGO dedicated code
- drivers/pn53x_usb: add LEDs support for ASK LoGO and SCL3711
- drivers/pn532_uart: implement extended frame send/receive for PN532_UART driver.
- drivers/arygon: use the new way to drive UART (its far more stable)
- drivers/arygon: do not hard code PN532 chip type: pn53x_init() determine it and ARYGON device seems to not need to be waken up.
- drivers/arygon: reject too heavy payload (ARYGON does not support PN53x extended frame even with PN532 equipped device)
- drivers/pn532_uart & arygon: now runs almost twice faster than the previous stable release
- buses/uart: receive() is now based on expected bytes instead of calculated timeouts..
- buses/uart: simplify uart_send() on POSIX systems.
- examples/nfc-emulate-tag: minor comments improvements.
- examples: remove nfc-message.h usage from examples.
- examples/nfc-emulate-forum-tag4: fully reworked example: it now support all NFC-Forum device in read and write mode
- examples/pn53x-tamashell: add an example for LoGO LEDs
- examples/pn53x-tamashell: add a script to read Mobib card.
- examples/pn53x-tamashell: add a script to read Navigo card.
Changes:
- libnfc: merge macros from nfc-messages.h into nfc-internal.h
- libnfc: remove useless files: nfc-messages.h, buses.h and chips.h
- API: new nfc_emulate_target() that ease target emulation for developer
- macros: show PRINT_HEX result on stderr in debug mode (that helps to sync with debug msg which are printed on standard error output.)
- drivers: split transceive() into send() and receive() to be able to handle more cases (differed replies, abort commands, etc) later
- drivers: use a const structure of functions instead of -dirty- callbacks array
- drivers/pn53x_usb: pn531_usb and pn533_usb drivers are now merged and use the pn53x IC version autodetection
- buses/uart: use a smart way to determine available ports on POSIX systems (tested on Linux and FreeBSD)
Feb 21, 2011 - 1.4.2
--------------------
Fixes:
- libnfc: fgets instead of getline, bring MacOSX / BSD without glibc alive
- libnfc: add missing CMake files to generated tarball needed by windows users (Thanks to Glenn)
- drivers/pn532_uart: fix pn532 wakeup response handling
- buses/uart: prevent from retrieving more than buffer length (potential buffer overflow)
- buses/uart: intent to speed up interface
- nfc-emulate-uid: use a correct UID
- nfc-mfclassic: fixes a segfault when using only 1 argument
Improvements:
- libnfc: silent some compilation warnings
- drivers/pn533_usb: support new device: ASK / LoGO. (Thanks to ASK for sending one sample)
- chips/pn53x: set register directly if mask cover whole value.
- pn53x-tamashell: accepts script as arg, this makes shebang possible
- pn53x-tamashell: add pause command & doc
- documentation: add a README-Windows.txt file
- documentation: add more pcsc-lite related instruction in README
Feb 1, 2011 - 1.4.1
-------------------
Fixes:
- libnfc: fix missing pn53x-tamashell-scripts in generated tarball. (Thanks to usermeister)
- buses/uart: improved UART communication on POSIX systems: slower devices can be detected and high speed devices works better
- buses/uart: serial autoprobe now skips invalid devices but checks all ports in the list
- drivers/pn53x_usb: prevent from stack corruption when using PN533-based device and add errors handling for ReadRegister and WriteRegister
- drivers/arygon: fix polling on ARYGON devices
- examples/nfc-emulate-tag: switch off easy framing when we are not emulating a ISO14443-4 target
- examples/nfc-mfclassic: fix crash when file cannot be opened for writing
- examples/nfc-mfultralight: fix 7 bytes UID display
Improvements:
- libnfc: add a "troubleshooting" section in README to document ACR122 problems with pcsclite.
- libnfc: inform user if target UID can not be emulated
- example/nfc-mfultralight: handle lock page writing
- examples/nfc-emulate-tag: handle HALT & READ
- tests: add register access test
Experimental: Windows platform support (Thanks to Glenn Ergeerts)
Nov 17, 2010 - 1.4.0
--------------------
Fixes:
- libnfc: fix Felica listing
- libnfc: fix storage of ISO14443B targets data
- libnfc: fix MacOS build
- libnfc: fix some errors string (ie. well-known "Invalid Parameter")
- libnfc: fix memory leak while using *_pick()
- drivers/pn53x_usb: fix ZLP USB issue
- drivers/pn53x_usb: workaround for PN532 toggle bit USB bug
- drivers/pn53x_usb: fix timeout problem in emulation mode
- drivers/pn53x_usb,pn532_uart,arygon: more robust recovery from unstable states such as interrupted emulation modes
- drivers/acr122: fix escape ioctl under Linux
- buses/uart: fix UART default serial ports under Linux.
- examples/nfc-anticol: fix bug preventing to run nfc-anticol after some other programs
- examples/nfc-anticol: fix display of UID
- ... and many other minor fixes
Improvements:
- libnfc: major emulation improvements: libnfc can now be used to emulate ISO/IEC 14443 type A tag (MIFARE, ISO14443-4), FeliCa and D.E.P. target
- libnfc: documentation improvements
- libnfc: decode select/initialization datas for almost all supported target types (ISO14443 A/B, Jewel/Topaz, FeliCa)
- libnfc: add ISO/IEC 14443B baud rates: 212, 424 and 847 kbps
- libnfc: cache some chip registers for faster communication
- libnfc: greatly improved D.E.P. support
- buses/uart: adjust UART's timeouts from baud rate: faster communication at high speed and more reliable at low speed (affect pn532_uart and arygon drivers)
- drivers/arygon: retrieve ARYGON µC firmware version
- examples/nfc-anticol: adds support for CL3
- examples/nfc-anticol: cascade based on SAK rather than CT, better for educational purpose
- examples/nfc-anticol: Computes CRC rather than hardcoded one.
- examples/nfc-utils: print_iso14443b_info() now displays many decoded information in verbose mode
- examples/nfc-utils: print_iso14443a_info() now displays many decoded information and shows attempt to determine tag name in verbose mode
- examples/nfc-list: new option -v for verbose mode
- examples/nfc-list: now support for Jewel/Topaz too
- examples/nfc-poll: now poll using all supported modulations
- examples/nfc-dep-target: add hack to allow to use two devices on the same machine (for tests/debug purpose)
- examples/pn53x-tamashell: New PN53x TAMA communication demonstration shell (support scripting)
- examples/nfc-relay-picc: New tool to relay ISO14443-4 communications (even over network... Enjoy!)
- examples/nfc-emulate-forum-tag4: New example to emulate a NFC Forum tag type 4
- examples/nfc-emulate-tag: New example to emulate tags
- examples: add missing man pages
- ... and many other minor improvements
Changes:
- API: Many changes, see NEWS file for more info how to migrate
- buses/uart: split UART implementations: one file for POSIX and another one for Windows
- examples: nfcip-* renamed to nfc-dep-*
- examples: nfc-sam renamed to pn53x-sam
- examples: nfc-emulate renamed to nfc-emulate-uid
- examples: change examples license for the sake of consistency: LGPL covers library, re-usable examples code is now under BSD license.
Aug 31, 2010 - 1.3.9
--------------------
Fixes:
- libnfc: fix ATS
- pn53x_usb: fix USB issues
- nfc-mfultralight: fix read and write counters
Improvments:
- libnfc: rearrange source code
- libnfc: enhance documentation
- libnfc: add regression tests (not as much as expected but its here!)
- build: configure script now supports --with-drivers option instead of --disable-pcsclite and --disable-libusb (see --help)
- nfc-mfultralight: we now can write OTP bytes if user want to
Changes:
- API: nfc_initiator_select_tag() is now nfc_initiator_select_passive_target()
- API: nfc_initiator_deselect_tag() is now nfc_initiator_deselect_target()
- API: new function nfc_initiator_list_passive_targets() to list available targets in field
- API: new nfc_perror(), nfc_strerror() and nfc_strerror_r() functions to handle errors
- API: new types: nfc_target_type_t and nfc_target_t
- API: new configuration option NDO_AUTO_ISO14443_4 to enable/disable auto iso14443-4 mode.
- API: new configuration option NDO_EASY_FRAMING to enable/disable auto frames encapsulation and chaining
- API: nfc_initiator_transceive_dep_bytes(), nfc_target_receive_dep_bytes() and nfc_target_send_dep_bytes() have been removed (unset NDO_EASY_FRAMING instead of these functions)
- API: (experimental) new nfc_initiator_poll_targets() which allow to use hardware polling function
- examples: add draft of a new example: nfc-sam. It tests the comunication with a connected SAM (Secure Access Module)
- examples: add new example to show how to use new polling function
- examples: add new example to diagnose basic elements (communication, rom and ram) of pn53x
- nfc-mfultralight: on write failure, continue if authenticate works.
- nfc-mfclassic: take care of 16-blocks-long sectors of Mifare Classic 4K in the nfc-mfclassic example's blocks counting routine.
- nfc-mfclassic: now fails ealier when something goes wrong (this allow to prevent from false-success).
- nfc-mfclassic: disable ISO14443-4 auto-switching in order to read devices that emulate Mifare Classic with ISO14443-4 compliance.(e.g. Nokia 6212 Classic)
Note: This release will not install extra headers (like mifare.h), programs that depends on should copy theses files into their sources.
Apr 6, 2010 - 1.3.4
--------------------
Fixes:
- Fix CT (Cascade Tag) byte when using 10 bytes long UID.
- Strip CT (Cascade Tag) from UIDs in nfc_initiator_select_tag().
- Fix CMake build (mainly on Windows related stuff)
- Minors fixes in documentation.
- Suppress almost all compilation warnings.
Changes:
- API: Provide ISO14443A CRC function.
- Remove annoying info message when probing uart devices while serial autoprobing is disabled.
- Rename README-Windows.txt (compilation using CMake) into CMake-Windows.txt
- Add README for Windows compilation using win32/Makefile.
Note: Windows users could now take main tarball using CMake to build or Windows specific archive using MinGW GNU/Make.
Feb 17, 2010 - 1.3.3
--------------------
@ -5,7 +682,7 @@ Fixes:
- libnfc: Attempt to fix build on Windows using CMake;
- libnfc: Fix build on NetBSD;
- libnfc: Fix build on MacOS X;
- nfc-relay: fix usage of two device using the same driver.
- nfc-relay: fix usage of two devices that use the same driver.
@ -46,7 +723,7 @@ Fixes:
- libnfc: Fix tag re-selection with UID length > 4 bytes (like DESFire or Ultralight);
- nfc-mfclassic: Fix authenticated only with KEYA;
Improvments:
Improvements:
- build: Build on FreeBSD;
- build: Add alternative build system (CMake);
- build: Add new files usefull for desktop GNU/Linux users: some rules for udev to allow non-root access to PN53x USB devices;
@ -127,3 +804,4 @@ Feb 12, 2009 - 1.0.0
- Initial release

File diff suppressed because it is too large Load Diff

68
HACKING.md Normal file
View File

@ -0,0 +1,68 @@
Hello hackers!
General remarks about contributing
----------------------------------
Contributions to the libnfc are welcome!
Here are some directions to get you started:
1. Follow style conventions
The source code of the library trend to follow some conventions so that it
is consistent in style and thus easier to read.
Look around and respect the same style.
Don't use tabs. Increment unit is two spaces.
Don't leave dandling spaces or tabs at EOL.
Helper script to get some uniformity in the style:
$ make style
If you use vim see the [Vim: How to prevent trailing whitespaces](http://www.carbon-project.org/Vim__How_to_prevent_trailing_whitespaces.html).
2. Chase warnings: no warning should be introduced by your changes
Depending what you touch, you can check with:
2.1 When using autotools
$ autoreconf -Wall -vis
2.2 When compiling
2.2.1 Using extra flags:
$ export CFLAGS="-Wall -g -O2 -Wextra -pipe -funsigned-char -fstrict-aliasing \
-Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wunused \
-Wuninitialized -Wpointer-arith -Wredundant-decls -Winline -Wformat \
-Wformat-security -Wswitch-enum -Winit-self -Wmissing-include-dirs \
-Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition \
-Wbad-function-cast -Wnested-externs -Wmissing-declarations"
$ ./configure
$ make clean
$ make
2.2.2 Using clang:
You can use same CFLAGS but also `-Wunreachable-code`
$ scan-build ./configure
$ make clean
$ scan-build make
2.2.3 Using `cppcheck` (v1.58 or higher):
$ make cppcheck
2.3 When Debianizing
$ lintian --info --display-info --display-experimental *deb
or (shorter version)
$ lintian -iIE *deb
3. Preserve cross-platform compatibility
The source code should remain compilable across various platforms,
including some you probably cannot test alone so keep it in mind.
Supported platforms:
- Linux
- FreeBSD
- Mac OS X
- Windows with MinGW

165
LICENSE
View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,19 +1,61 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src cmake_modules
AM_CFLAGS = $(LIBNFC_CFLAGS)
SUBDIRS = libnfc utils
if EXAMPLE_ENABLED
SUBDIRS += examples
endif
SUBDIRS += include contrib cmake test
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnfc.pc
EXTRA_DIST = Doxyfile pn53x.conf pn53x.rules CMakeLists.txt config.h.cmake LICENSE
CLEANFILES = Doxygen.log
EXTRA_DIST = \
CMakeLists.txt \
Doxyfile \
HACKING.md \
NEWS.md \
README.md \
README-Windows.md \
libnfc.conf.sample \
mingw-cross-compile.sh
if DOC_ENABLED
clean-local:
CLEANFILES = Doxygen.log coverage.info libnfc.pc
clean-local: clean-local-doc clean-local-coverage
.PHONY: clean-local-coverage clean-local-doc doc style
clean-local-coverage:
-rm -rf coverage
clean-local-doc:
rm -rf doc
doc : Doxyfile
@DOXYGEN@ $(builddir)/Doxyfile
.PHONY: doc
endif
DISTCHECK_CONFIGURE_FLAGS="--with-drivers=all"
style:
find . -name "*.[ch]" -exec perl -pi -e 's/[ \t]+$$//' {} \;
find . -name "*.[ch]" -exec astyle --formatted --mode=c --suffix=none \
--indent=spaces=2 --indent-switches --indent-preprocessor \
--keep-one-line-blocks --max-instatement-indent=60 \
--style=linux --pad-oper --unpad-paren --pad-header \
--align-pointer=name {} \;
cppcheck:
cppcheck --quiet \
-I include -I libnfc -I libnfc/buses -I libnfc/chips -I libnfc/drivers \
--check-config .
cppcheck --quiet --enable=all --std=posix --std=c99 \
-I include -I libnfc -I libnfc/buses -I libnfc/chips -I libnfc/drivers \
-DLOG -D__linux__ \
-DDRIVER_PN53X_USB_ENABLED -DDRIVER_ACR122_PCSC_ENABLED \
-DDRIVER_ACR122_USB_ENABLED -DDRIVER_ACR122S_ENABLED \
-DDRIVER_PN532_UART_ENABLED -DDRIVER_ARYGON_ENABLED \
-DDRIVER_PN532_SPI_ENABLED -DDRIVER_PN532_I2C_ENABLED \
--force --inconclusive .

0
NEWS
View File

394
NEWS.md Normal file
View File

@ -0,0 +1,394 @@
New in 1.8.0:
API Changes:
- Restore nfc_modulation_type enum order to keep compatibility with libnfc 1.7.1
- Bump library version to 6.0.0
New in 1.7.2:
Drivers:
* New driver for pn71xx NXP's NFC Controllers through Linux Libnfc-nci (untested)
* New driver for contactless PC/SC readers (only as initiator)
API Changes:
* nfc_device_get_supported_baud_rate() now takes also "mode" as argument
* New nfc_device_get_supported_baud_rate_target_mode()
* New NFC modulation type NMT_BARCODE and nfc_barcode_info struct to support Thinfilm NFC Barcode protocol
* New NFC modulation type NMT_ISO14443BICLASS and NMT_ISO14443BICLASS struct to support HID iClass (Picopass)
* pn53x_transceive() is now part of public API
New in 1.7.1:
API Changes:
* nfc_initiator_select_passive_target() provides defaults if pbtInitData=NULL
* nfc_initiator_target_is_present() allow NULL pointer to tag
New in 1.7.0:
Drivers:
* New PN532 over I2C driver, see contrib/libnfc/pn532_i2c_on_rpi.conf.sample
API Changes:
* New function iso14443b_crc_append()
New in 1.7.0-rc7:
Drivers:
* New PN532 over SPI driver, see contrib/libnfc/pn532_spi_on_rpi.conf.sample
API Changes:
* Functions
- nfc_initiator_target_is_present() & str_nfc_target():
now take a pointer to nfc_target as argument
- nfc_init(): upon malloc error, doesn't force exit() anymore
so now you should test if context != NULL after nfc_init() call
New in 1.7.0-rc5:
API Changes:
* Functions
- New nfc_register_driver() function allowing to hook custom drivers.
New in 1.7.0-rc3:
API Changes:
* Functions
- Add timeout param to nfc_emulate_target()
New in 1.7.0-rc2:
Configuration:
libnfc can now use a configuration file for special setups, or features
activation. This file (/etc/nfc/libnfc.conf under GNU/Linux systems)
supports already some keywords:
- "allow_autoscan" to enable/disable device auto-detection feature;
- "allow_intrusive_scan" to enable/disable intrusive auto-detection
(ie. serial port probing);
- "log_level" to select library verbosity;
- "device.name" and "device.connstring" to define a user device,
this is the recommended method if user has a not easily detectable
device (ie. a serial one).
It is also possible to define devices using dedicated configuration files and
put them into device search directory (/etc/nfc/devices.d under GNU/Linux).
Example for the OpenPCD2: create /etc/nfc/devices.d/openpcd2.conf with:
name = "OpenPCD2"
connstring = "pn532_uart:/dev/ttyACM0"
optional = true
The keyword "optional" does not mandate the device to be present always
(it detects if the reader is indeed present before using it)
API Changes:
* Types
- New NFC_ESOFT error to handle software errors (allocations, pipe
creation, etc.)
* Functions
- Remove nfc_get_default_device() function: the default device is now the
first in nfc_list_devices() or could be open using NULL connstring with
nfc_open() function.
- New enum-to-string converter functions str_nfc_modulation_type() and
str_nfc_baud_rate()
- New str_nfc_target() to convert nfc_target struct into allocated string
- New nfc_device_get_information_about() function to retreive some device's
information
- No more in/out function parameter: nfc_initiator_transceive_*() now
take a constant size for Rx buffer
- New nfc_initiator_target_is_present() to test is the previously selected
target is available in the field
- nfc_initiator_transceive_bytes() returns NFC_EMFCAUTHFAIL when AUTH
command failed on a Mifare Classic
- New nfc_initiator_init_secure_element() to initiate a connection with
secure element (Only supported with a PN532 with SAM equipped)
New in 1.6.0-rc1:
API Changes:
* Types
- '_t' suffix removed from all types (e.g. nfc_device_t is now nfc_device)
- All errors removed in flavour of NFC_EIO, NFC_EINVARG, NFC_EDEVNOTSUPP,
NFC_ENOTSUCHDEV, NFC_EOVFLOW, NFC_ETIMEOUT, NFC_EOPABORTED, NFC_ENOTIMPL,
NFC_ETGRELEASED, NFC_ERFTRANS, NFC_ECHIP and NFC_SUCCESS
- nfc_device_desc_t replaced by nfc_connstring: libnfc now uses connection
strings to describe a device
- byte_t typedef removed, libnfc now uses uint8_t from C99
- nfc_device is now an opaque type
- nfc_properties replaces nfc_options
* Functions
- New nfc_get_default_device() function that allows to grab the connstring
stored in LIBNFC_DEFAULT_DEVICE environnement variable or returns the
first available device if not set
- New nfc_device_get_connstring() accessor function to know the device
connstring
- New nfc_device_set_property_bool() function that replace nfc_configure()
- New nfc_device_set_property_int() function to set integer property
- nfc_device_name() renamed to nfc_device_get_name() for the sake of
consistency
- New nfc_device_get_last_error() function, an accessor to last error occured
- Whole libnfc's functions now return 0 (NFC_SUCCESS) or positive value if
appropriated on success and libnfc's error code on failure
- nfc_connect(), nfc_disconnect() renamed to nfc_open(), nfc_close()
respectively
- Add 2 new functions: initialization and deinitialization functions:
nfc_init() and nfc_exit()
- New nfc_device_get_supported_modulation() and
nfc_device_get_supported_baud_rate() functions
* Dependencies
- log4c is not anymore used for debugging facility. It was a bad choice,
sorry for inconvenience.
New in 1.5.1:
API Changes
* Types
- Communication-level errors DEIO and DETIMEOUT are now know as ECOMIO,
ECOMTIMEOUT respectively
- Common device-level errors DEINVAL and DEABORT are now know as EINVALARG,
EOPABORT respectively
- New errors: EFRAACKMISMATCH, EFRAISERRFRAME, EDEVNOTSUP and ENOTIMPL
* Functions
- nfc_abort_command() returns a boolean
- timeout (struct timeval) pointer added to
nfc_initiator_transceive_bytes(), nfc_target_send_bytes() and
nfc_target_receive_bytes()
- timed functions nfc_initiator_transceive_bytes_timed() and
nfc_initiator_transceive_bits_timed() now takes uint32_t as cycles
pointer
- nfc_initiator_poll_targets() renamed to nfc_initiator_poll_target() and
only return one target
New in 1.5.0:
Installed files
- nfc-message.h have been removed, internal macros are not part of API.
- New nfc-emulation.h file offers a middle level API to handle emulation (see
nfc-emulate-forum-tag4 example)
API Changes
* Types
- New error: DEABORT raised when operation is aborted by user (using
nfc_abort_command())
- nfc_chip_t type removed from public API (have been renamed to pn53x_type
in chips/pn53x)
- nfc_device_spec_t removed, each driver can use his own way to keep a
connection pointer
* Structures
- nfc_device_t now have a nfc_driver_t struct pointer (named .driver) and
void pointer (.driver_data) to handle device specific wrapping
- nfc_device_t now have a void pointer (.chip_data) to keep some chip
specific data
- nfc_device_t now have an file descriptor array to manage to abort request
- nfc_device_t does have .nc member (nfc_chip_t) anymore (different chips
handling in now in chip level)
- nfc_device_t does have .nds member (nfc_device_spec_t) anymore, each
driver handle its communication using driver_data pointer
- nfc_device_t does have .bActive member (bool) anymore, this variable was
almost not used and was not efficient
- nfc_device_t does have chip's register caches anymore, this is handle in
chip level (using chip_data pointer)
- driver_callbacks structure have been removed from public API
- New nfc_emulator structure used by the new emulation API (see
nfc_emulate_target())
- New nfc_emulation_state_machine structure used by the new emulation API,
it handles an I/O function and data pointer to create a software based
state-machine.
* Functions
- New nfc_abort_command() function to abort current running command.
- New nfc_initiator_transceive_bits_timed() and
nfc_initiator_transceive_bytes_timed() to transceive bits/bytes and
measure the time to have a reply
- New nfc_emulate_target() function to start a target emulation using an
nfc_emulator structure (it contains a custom state-machine
(nfc_emulation_state_machine struct) and a custom target (nfc_target_t)
(see nfc-emulate-forum-tag4 to have a look on how-to use it)
New in 1.4.1:
API Changes
* Types
- New error: ETGUIDNOTSUP raised when UID is not 4 bytes long or does not
start with 0x08 (Security restriction present in the NXP PN53x chips)
New in 1.4.0:
API Changes
* Types
- New nfc_device_option value (enum): NDO_FORCE_ISO14443_A to force the
chip to switch in ISO14443-A
- New nfc_dep_mode_t (enum) for DEP mode:
NDM_UNDEFINED, NDM_PASSIVE, NDM_ACTIVE
- New nfc_modulation_type_t (enum) that lists modulation types:
NMT_ISO14443A, NMT_ISO14443B, NMT_FELICA, NMT_JEWEL, NMT_DEP
- New nfc_baud_rate_t (enum): list of baud rates:
NBR_UNDEFINED, NBR_106, NBR_212, NBR_424, NBR_847
- nfc_target_type_t have been removed from API (use nfc_modulation_t
instead)
* Structures
- nfc_device_t now have a boolean bAutoIso14443_4 to keep the locally the
state of NDO_AUTO_ISO14443_4 (should not be directly set, use
nfc_configure() with NDO_AUTO_ISO14443_4)
- nfc_device_t now have an uint8_t ui8Parameters to cache PN53x parameters
- nfc_device_t now have a byte_t btSupportByte to cache supported
modulations
- nfc_dep_info_t have completely changed, please see API documentation
- nfc_iso14443b_info_t have completely changed, please see API
documentation
- nfc_modulation_t have completely changed: it now contains a
nfc_modulation_type_t and nfc_baud_rate_t couple. Initialization example:
nfc_modulation_t nm = {
.nmt = NMT_ISO14443A,
.nbr = NBR_106,
};
- nfc_target_t now contains new nfc_modulation_t instead of
nfc_target_type_t. Initialization example:
nfc_target_t nt = {
.nm.nmt = NMT_ISO14443A,
.nm.nbr = NBR_UNDEFINED,
.nti.nai.abtAtqa = { 0x03, 0x44 },
.nti.nai.abtUid = { 0x08, 0xab, 0xcd, 0xef },
.nti.nai.btSak = 0x20,
.nti.nai.szUidLen = 4,
.nti.nai.abtAts = { 0x75, 0x77, 0x81, 0x02, 0x80 },
.nti.nai.szAtsLen = 5,
};
* Functions
- nfc_initiator_select_passive_target() now use new nfc_modulation_t and
nfc_target_t instead of nfc_target_info_t
- nfc_initiator_list_passive_targets() now use new nfc_modulation_t and
nfc_target_t instead of nfc_target_info_t
- nfc_initiator_poll_targets() use new nfc_modulation_t instead of
nfc_target_type_t
- nfc_initiator_select_dep_target() completely changed, use now
nfc_dep_mode_t, nfc_baudrate_t, nfc_dep_info_t and nfc_target_t, please
see API documentation
- nfc_target_init() have an additional argument: nfc_target_t to describe
the wanted target
- append_iso14443a_crc() was renamed to iso14443a_crc_append()
- New iso14443a_locate_historical_bytes() to locate historical bytes in ATS
New in 1.3.9 (since 1.3.4):
Installed files
- mifaretag.h and mifareultag.h are removed, Mifare features are not a part
of libnfc API anymore (these features are always available in examples/)
API Changes
* Types
- New nfc_device_option_t value (enum): NDO_AUTO_14443_4, an option to
enable/disable auto-switching to ISO/IEC 14443-4 if device is compliliant
- New nfc_device_option_t value (enum): NDO_EASY_FRAMING, an option to
enable/disable automatic frames encapsulation and chaining
- New nfc_target_type_t (enum), with values like NTT_MIFARE,
NTT_ISO14443B_106, NTT_DEP_ACTIVE_424, etc.
- Mifare related types have been removed from API: mifare_cmd,
mifare_param_auth, mifare_param_data, mifare_param_value, mifare_param
* Structures
- nfc_device_t now have boolean bEasyFraming to enable/disable "easy
framing" feature (should not be directly set, use nfc_configure() with
NDO_EASY_FRAMING)
- nfc_device_t now have integer iLastError to handle last error
- New chip_callbacks to handle error lookup per chip
- driver_callbacks now have a pointer to chip_callbacks
- New nfc_target_t that contains nfc_target_info_t and nfc_target_type_t
* Functions
- nfc_initiator_select_tag() became nfc_initiator_select_passive_target()
- New nfc_initiator_list_passive_targets() returns a list of detected
target on desired modulation
- (experimental) New nfc_initiator_poll_targets() returns targets that are
detected during hardware polling (available only with PN532)
- nfc_initiator_transceive_dep_bytes(), nfc_target_receive_dep_bytes() and
nfc_target_send_dep_bytes() have been removed from API, use
NDO_EASY_FRAMING option to switch from raw mode to "easy framing"
- nfc_initiator_mifare_cmd() have been removed: no more Mifare related
stuff in libnfc's API
- New nfc_strerror(), nfc_strerror_r() and nfc_perror() to report errors
- New append_iso14443a_crc() to append iso14443a_crc() to a string
New in 1.3.4 (since 1.2.1):
Installed files
- Headers are now installed in include/nfc instead of include/libnfc
- libnfc.h have been renamed to nfc.h
- defines.h and types.h have been merge into nfc-types.h
- bitutils.h is not installed anymore, some functions are now in
examples/nfc-utils.c
- devices.h, dev_acr122.h, dev_arygon.h, dev_pn531.h, dev_pn533.h and rs232.h
are not installed anymore
- New header mifareultag.h, like mifaretag.h for Mifare UltraLight
- New header nfc-messages.h with messages macros (DBG, ERR, INFO)
API Changes
* Types
- uint32_t which was used as size now are size_t
- chip_type became nfc_chip_t (enum)
- init_modulation became nfc_modulation_t (enum), and now have
NM_ACTIVE_DEP and NM_PASSIVE_DEP modulation values added
* Structures
- dev_info became nfc_device_t
- dev_config_option became nfc_device_option_t
- New nfc_device_desc_t to describe the way to access to a NFC device.
Initialisation example:
nfc_device_desc_t ndd = {
ndd.pcDriver = "ARYGON";
ndd.pcPort = "/dev/ttyUSB0";
ndd.uiSpeed = 115200;
};
- dev_callbacks became driver_callbacks and now have two function pointers
more: pick_device() and list_devices()
- New nfc_dep_info_t to handle DEP targets info
- tag_info_iso14443a became nfc_iso14443a_info_t
- tag_info_iso14443b became nfc_iso14443b_info_t
- tag_info_felica became nfc_felica_info_t
- tag_info_jewel became nfc_jewel_info_t
- tag_info became nfc_target_info_t, and now have extended union to
nfc_dep_info_t
* Functions
- nfc_connect() now takes 1 nfc_devive_desc_t argument (can be NULL)
- New nfc_list_devices(), it find available NFC devices using all know
drivers
- (experimental) New nfc_initiator_select_dep(), it looks for DEP targets
- (experimental) New nfc_initiator_transceive_dep_bytes(), like
nfc_initiator_transceive_bytes() for DEP targets
- (experimental) New nfc_target_receive_dep_bytes() and
nfc_target_send_dep_bytes(), to receive/send bytes to DEP target
(configured as initiator) while local NFC device is configured as target
- New nfc_device_name() returns the device's name
- New iso14443a_crc() computes CRC as described in ISO/IEC 14443
- New nfc_version() returns the actual version of libnfc (with SVN
revision, if available)

24
README
View File

@ -1,24 +0,0 @@
------------------------------------------------------------------------
Public platform independent Near Field Communication (NFC) library
Copyright (C) 2009, Roel Verdult
------------------------------------------------------------------------
Welcome to the developers community of libnfc.
Since it is hard to keep all information up to date
we decided to only maintain the online documentation.
Please visit the official website for more info:
http://www.libnfc.org
If you have questions, remarks, bug-reports, we encourage you to
post this in the developers community:
http://www.libnfc.org/community
------------------------------------------------------------------------
Proprietary Notes:
FeliCa is s registered trademark of the Sony Corporation. MIFARE is a
trademark of NXP Semiconductors. Jewel Topaz is a trademark of Innovision
Research & Technology. All other trademarks are the property of their
respective owners.

70
README-Windows.md Normal file
View File

@ -0,0 +1,70 @@
*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* Additional contributors of Windows-specific parts:
* Copyright (C) 2010 Glenn Ergeerts
* Copyright (C) 2013 Alex Lian
-*
Requirements
============
- MinGW-w64 compiler toolchain [1]
- LibUsb-Win32 1.2.5.0 (or greater) [2]
- CMake 2.8 [3]
This was tested on Windows 7 64 bit, but should work on Windows Vista and
Windows XP and 32 bit as well.
Only the ACS ACR122 and the ASK Logo readers are tested at the moment, so any feedback about other devices is very welcome.
Community forum: http://www.libnfc.org/community/
Building
========
To build the distribution the MinGW Makefiles generator of CMake was used. Here
is an example of how to generate a distribution with the above mentioned
requirements fulfilled (it is assumed the CMake binaries are in the system
path, this is optional during installation of CMake):
- Add the following directories to your PATH:
c:\MinGW64\bin;c:\MinGW64\x86_64-w64-mingw32\lib32;c:\MinGW64\x86_64-w64-mingw32\include
- Now it is possible to run CMake and mingw32-make:
C:\dev\libnfc-read-only> mkdir ..\libnfc-build
C:\dev\libnfc-read-only> cd ..\libnfc-build
C:\dev\libnfc-build> cmake-gui .
Now you can configure the build. Press "Configure", specify "MinGW32 Makefiles"
and then you have the opportunity to set some configuration variables. If you
don't want a Debug build change the variable CMAKE_BUILD_TYPE to "Release".
If a non-GUI solution is preferred one can use:
C:\dev\libnfc-build> cmake -G "MinGW Makefiles"
-DCMAKE_BUILD_TYPE=Release ..\libnfc-read-only
Now run mingw32-make to build:
C:\dev\libnfc-read-only\bin> mingw32-make
The build will create a shared library for Windows (nfc.dll) to link your applications against. It will compile
the tools against this shared library.
References
==========
[1] the easiest way is to use the TDM-GCC installer.
Make sure to select MinGW-w64 in the installer, the regular MinGW does not contain headers for PCSC.
http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm64-gcc-4.5.1.exe/download
[2] http://sourceforge.net/projects/libusb-win32/files/
[3] http://www.cmake.org

View File

@ -1,116 +0,0 @@
Requirements - Running
======================
In order to use the library and run included examples, at least this
dependency should be installed:
- Microsoft Visual C++ 2008 SP1 Redistributable Package [1]
These C++ 2008 SP1 libraries are also part of "Microsoft .NET Framework 3.5
Service Pack 1 and .NET Framework 3.5 Family" which can be obtained through
Windows Update.
There are two versions of the redistributable package (one for x86 and one for
x64). Be sure which one is needed.
An optional requirement is:
- LibUsb-Win32 0.1.12.2 [2]
In case support for the PN531USB and PN533USB is needed. LibUsb has serious issues
on Windows systems newer than Windows XP (and on 64 bit). See LibUsb support
mailing lists for more information.
Requirements - Development
==========================
This project uses CMake for creating a Visual Studio project from the
source files.
The following software was used to create the libnfc distribution:
- CMake 2.6.4 [3]
- Microsoft Windows SDK for Windows 7 (7.0) [4]
- Microsoft .NET framework 3.5 SP1 (Windows Update)
- LibUsb-Win32 0.1.12.2 (only on Windows XP builds) [2]
- NSIS 2.45 (to create the installer) [5]
- 7-Zip 4.65 (for generating source archive) [6]
This was tested on Windows XP SP3, but should work on Windows Vista and
Windows 7 as well. Even on 64 bit systems.
Building
========
To build the distribution the NMake Makefiles generator of CMake was used. Here
is an example of how to generate a distribution with the above mentioned
requirements fulfilled (it is assumed the CMake binaries are in the system
path, this is optional during installation of CMake):
- Start -> Programs -> Microsoft Windows SDK v7.0 -> CMD shell
- Now it is possible to run CMake and NMake:
C:\Program Files\Microsoft SDKs\Windows\v7.0> cd c:\dev\libnfc-read-only
C:\dev\libnfc-read-only> mkdir bin
C:\dev\libnfc-read-only> cd bin
C:\dev\libnfc-read-only\bin> cmake-gui ..
Now you can configure the build. Press "Configure", specify "NMake Makefiles"
and then you have the opportunity to set some configuration variables. If you
don't want a Debug build change the variable CMAKE_BUILD_TYPE to "Release".
If a non-GUI solution is preferred one can use:
C:\dev\libnfc-read-only\bin> cmake -G "NMake Makefiles"
-DCMAKE_BUILD_TYPE=Release ..
Now run NMake:
C:\dev\libnfc-read-only\bin> nmake package
To create the binary package, or:
C:\dev\libnfc-read-only\bin> nmake package_source
To create the source archive.
NMake will create a shared library for Windows (nfc.dll), and
a library file (nfc.lib) to link your applications against. It will compile
the tools against this shared library. The installer will install the
DLL file in the same directory as the tools as our goal was to be able to
run and install libnfc as a standard user. In a system wide installation
the DLL should be placed in "windows\system32" or any other directory in
the (system) path.
If you want your own tools to use libnfc you have to link them with "nfc.lib"
which can be found in the "lib" directory under the installation root. The
header files can be found under "include" in the installation root.
In a "normal" Windows install this would be:
- "C:\Program Files\libnfc-x.x.x\lib"
- "C:\Program Files\libnfc-x.x.x\include"
You also need to copy the "nfc.dll" file to the same directory as your
application, or install it somewhere in the system path (see above).
CMake can also be used to create the MSVC [7] project files instead of NMake
Makefiles, after which MSVC can be used to compile the project, create an
installer, etc.
Building 64 Bit
===============
Building on native 64 bit should work "out of the box".
It is also possible to "cross compile" for 64 bit systems on a 32 bit system.
This can be accomplished by using the "setenv" command from the shell opened
in the previous section. Try "setenv /?" to see what is available. When cross
compiling the name of the binary installer package generated is not correct,
because CMake does not notice it is cross compiling. It should work fine
however.
References
==========
[1] http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2
[2] http://libusb-win32.sourceforge.net/
[3] http://www.cmake.org
[4] http://msdn.microsoft.com/en-us/windows/bb980924.aspx
[5] http://nsis.sourceforge.net/Main_Page
[6] http://http://www.7-zip.org/
[7] http://www.microsoft.com/express/vc/

250
README.md Normal file
View File

@ -0,0 +1,250 @@
```
*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2015 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* Additional contributors:
* See AUTHORS file
-*
```
General Information
===================
libnfc is a library which allows userspace application access to NFC devices.
The official web site is:
http://www.nfc-tools.org/
The official forum site is:
http://www.libnfc.org/community/
The official development site is:
https://github.com/nfc-tools/libnfc
Important note: this file covers POSIX systems, for Windows please read README-Windows.md
Requirements
============
Some NFC drivers depend on third party software:
* pn53x_usb & acr122_usb:
- libusb-0.1 http://libusb.sf.net
* acr122_pcsc:
- pcsc-lite https://pcsclite.apdu.fr/
- pcsc:
- Support build with pcsc driver, which can be using all compatible readers, Feitian R502 and bR500 already passed the test.
The regression test suite depends on the cutter framework:
http://cutter.sf.net
Building
========
Note: If working directly from a git clone of the repository, some of the files need to be generated first. To do this run
`autoreconf -vis`
Alternatively use a .tar.bz2 version of a packaged release (which already contains ./configure):
https://github.com/nfc-tools/libnfc/releases/
The build should be as simple as running these commands:
./configure
make
To build with specific driver(s), see option `--with-drivers=...` detailed in `./configure --help`.
Installation
============
make install
You may need to grant permissions to your user to drive your device.
Under GNU/Linux systems, if you use udev, you could use the provided udev rules.
e.g. under Debian, Ubuntu, etc.
sudo cp contrib/udev/93-pn53x.rules /lib/udev/rules.d/
Under FreeBSD, if you use devd, there is also a rules file: contrib/devd/pn53x.conf.
Configuration
=============
In order to change the default behavior of the library, the libnfc uses a
configuration file located in sysconfdir (as provided to ./configure).
A sample commented file is available in sources: libnfc.conf.sample
If you have compiled using:
./configure --prefix=/usr --sysconfdir=/etc
you can make configuration directory and copy the sample file:
sudo mkdir /etc/nfc
sudo cp libnfc.conf.sample /etc/nfc/libnfc.conf
To configure multiple devices, you can either modify libnfc.conf or create a
file per device in a nfc/devices.d directory:
sudo mkdir -p /etc/nfc/devices.d
printf 'name = "My first device"\nconnstring = "pn532_uart:/dev/ttyACM0"\n' | sudo tee /etc/nfc/devices.d/first.conf
printf 'name = "My second device"\nconnstring = "pn532_uart:/dev/ttyACM1"\n' | sudo tee /etc/nfc/devices.d/second.conf
Environment Variables
=====================
You can override certain configuration options at runtime using the following environment variables:
+ `LIBNFC_DEFAULT_DEVICE=<connstring>`: `LIBNFC_DEFAULT_DEVICE=pn532_uart:/dev/ttyACM0` will use pn532 on /dev/ttyACM0 as default device
+ `LIBNFC_DEVICE=<connstring>` will ignore all devices in the config files and use only the one defined in the variable
+ `LIBNFC_AUTO_SCAN=<true|false>` overrides `allow_autoscan` option in the config file
+ `LIBNFC_INTRUSIVE_SCAN=<true|false>` overrides `allow_intrusive_scan` option in the config file
+ `LIBNFC_LOG_LEVEL=<0|1|2|3>` overrides `log_level` option in the config file
To obtain the connstring of a recognized device, you can use `nfc-scan-device`: `LIBNFC_AUTO_SCAN=true nfc-scan-device` will show the names & connstrings of all found devices.
How to report bugs
==================
To report a bug, visit https://github.com/nfc-tools/libnfc/issues and fill
out a bug report form.
If you have questions, remarks, we encourage you to post this in the developers
community:
http://www.libnfc.org/community
Please make sure to include:
* The version of libnfc
* Information about your system. For instance:
- What operating system and version
- For Linux, what version of the C library
And anything else you think is relevant.
* A trace with debug activated.
Reproduce the bug with debug, e.g. if it was:
$ nfc-list -v
run it as:
$ LIBNFC_LOG_LEVEL=3 nfc-list -v
* How to reproduce the bug.
Please include a short test program that exhibits the behavior.
As a last resort, you can also provide a pointer to a larger piece
of software that can be downloaded.
* If the bug was a crash, the exact text that was printed out
when the crash occured.
* Further information such as stack traces may be useful, but
is not necessary.
Patches
=======
Patches can be posted to https://github.com/nfc-tools/libnfc/issues
If the patch fixes a bug, it is usually a good idea to include
all the information described in "How to Report Bugs".
Troubleshooting
===============
Touchatag/ACR122:
-----------------
If your Touchatag or ACR122 device fails being detected by libnfc, make sure
that PCSC-lite daemon (`pcscd`) is installed and is running.
If your Touchatag or ACR122 device fails being detected by PCSC-lite daemon
(`pcsc_scan` doesn't see anything) then try removing the bogus firmware detection
of libccid: edit libccid_Info.plist configuration file (usually
`/etc/libccid_Info.plist`) and locate `<key>ifdDriverOptions</key>`, turn
`<string>0x0000</string>` value into `0x0004` to allow bogus devices and restart
pcscd daemon.
ACR122:
-------
Using an ACR122 device with libnfc and without tag (e.g. to use NFCIP modes or
card emulation) needs yet another PCSC-lite tweak: You need to allow usage of
CCID Exchange command. To do this, edit `libccid_Info.plist` configuration file
(usually `/etc/libccid_Info.plist`) and locate `<key>ifdDriverOptions</key>`,
turn `<string>0x0000</string>` value into `0x0001` to allow CCID exchange or
`0x0005` to allow CCID exchange and bogus devices (cf previous remark) and
restart pcscd daemon.
Warning: if you use ACS CCID drivers (acsccid), configuration file is located
in something like: `/usr/lib/pcsc/drivers/ifd-acsccid.bundle/Contents/Info.plist`
SCL3711:
--------
Libnfc cannot be used concurrently with the PCSC proprietary driver of SCL3711.
Two possible solutions:
* Either you don't install SCL3711 driver at all
* Or you stop the PCSC daemon when you want to use libnfc-based tools
PN533 USB device on Linux >= 3.1:
---------------------------------
Since Linux kernel version 3.1, a few kernel-modules must not be loaded in order
to use libnfc : "nfc", "pn533" and "pn533_usb".
To prevent kernel from loading automatically these modules, you can blacklist
them in a modprobe conf file. This file is provided within libnfc archive:
sudo cp contrib/linux/blacklist-libnfc.conf /etc/modprobe.d/blacklist-libnfc.conf
FEITIAN bR500 and R502:
-----------------------
Libnfc can work with PCSC proprietary driver of bR500 and R502, which is already available on most Linux setups.
To activate the PCSC support: `./configure --with-drivers=pcsc`.
Readers known to work:
- Feitian bR500
- Feitian R502 Dual interface reader
- Feitian R502 CL(Contactless) reader
These readers are support by CCID since v1.4.25, make sure your CCID driver version higher or equal to 1.4.25.
On MacOS, you can check your CCID version with the following command, and if required, you can install latest CCID driver from [https://github.com/martinpaljak/osx-ccid-installer/releases](https://github.com/martinpaljak/osx-ccid-installer/releases)
```
grep -A 1 CFBundleShortVersionString /usr/local/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist
```
On Linux, you can check your CCID version with the following command, and if required, you can install latest CCID driver from [https://ccid.apdu.fr/](https://ccid.apdu.fr/)
```
grep -A 1 CFBundleShortVersionString /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist
```
Proprietary Notes
=================
FeliCa is a registered trademark of the Sony Corporation.
MIFARE is a trademark of NXP Semiconductors.
Jewel Topaz is a trademark of Innovision Research & Technology.
All other trademarks are the property of their respective owners.

View File

@ -1,34 +0,0 @@
#!/bin/sh
rm -rf autom4te.cache
rm -f aclocal.m4 ltmain.sh
touch README
LIBTOOLIZE=libtoolize
case `uname -s` in
Darwin)
LIBTOOLIZE=glibtoolize
ACLOCAL_ARGS="-I /opt/local/share/aclocal/"
# SKIP_PCSC="1"
;;
FreeBSD)
ACLOCAL_ARGS="-I /usr/local/share/aclocal/"
;;
esac
ACLOCAL_TITLE=`aclocal --version | head -n 1`
AUTOHEADER_TITLE=`autoheader --version | head -n 1`
AUTOCONF_TITLE=`autoconf --version | head -n 1`
LIBTOOLIZE_TITLE=`$LIBTOOLIZE --version | head -n 1`
AUTOMAKE_TITLE=`automake --version | head -n 1`
echo "Running $ACLOCAL_TITLE..." ; aclocal $ACLOCAL_ARGS || exit 1
echo "Running $AUTOHEADER_TITLE..." ; autoheader || exit 1
echo "Running $AUTOCONF_TITLE..." ; autoconf || exit 1
echo "Running $LIBTOOLIZE_TITLE..." ; $LIBTOOLIZE --copy --automake || exit 1
echo "Running $AUTOMAKE_TITLE..." ; automake --add-missing --copy --gnu || exit 1
if [ -z "$NOCONFIGURE" ]; then
./configure "$@"
fi

11
cmake/FixBundle.cmake.in Normal file
View File

@ -0,0 +1,11 @@
INCLUDE(BundleUtilities)
# set bundle to the full path of the executable already existing in the install tree
SET(bundle "${CMAKE_INSTALL_PREFIX}/bin/nfc-list@CMAKE_EXECUTABLE_SUFFIX@")
# set other_libs to a list of additional libs that cannot be reached by dependency analysis
SET(other_libs "")
SET(dirs "@LIBUSB_LIBRARY_DIR@")
fixup_bundle("${bundle}" "${other_libs}" "${dirs}")

View File

@ -0,0 +1,34 @@
# -*- cmake -*-
# Use the following variables to compile and link against LibNFC:
# LIBNFC_FOUND - True if LibNFC was found on your system
# LIBNFC_USE_FILE - The file making LibNFC usable
# LIBNFC_DEFINITIONS - Definitions needed to build with LibNFC
# LIBNFC_INCLUDE_DIR - Directory where nfc/nfc.h can be found
# LIBNFC_INCLUDE_DIRS - List of directories of LibNFC and it's dependencies
# LIBNFC_LIBRARY - LibNFC library location
# LIBNFC_LIBRARIES - List of libraries to link against LibNFC library
# LIBNFC_LIBRARY_DIRS - List of directories containing LibNFC' libraries
# LIBNFC_ROOT_DIR - The base directory of LibNFC
# LIBNFC_VERSION_STRING - A human-readable string containing the version
# LIBNFC_VERSION_MAJOR - The major version of LibNFC
# LIBNFC_VERSION_MINOR - The minor version of LibNFC
# LIBNFC_VERSION_PATCH - The patch version of LibNFC
set ( LIBNFC_FOUND 1 )
set ( LIBNFC_USE_FILE "@LIBNFC_USE_FILE@" )
set ( LIBNFC_DEFINITIONS "@LIBNFC_DEFINITIONS@" )
set ( LIBNFC_INCLUDE_DIR "@LIBNFC_INCLUDE_DIR@" )
set ( LIBNFC_INCLUDE_DIRS "@LIBNFC_INCLUDE_DIRS@" )
set ( LIBNFC_LIBRARY "@LIBNFC_LIBRARY@" )
set ( LIBNFC_LIBRARIES "@LIBNFC_LIBRARIES@" )
set ( LIBNFC_LIBRARY_DIRS "@LIBNFC_LIBRARY_DIRS@" )
set ( LIBNFC_ROOT_DIR "@LIBNFC_ROOT_DIR@" )
set ( LIBNFC_VERSION_STRING "@LIBNFC_VERSION_STRING@" )
set ( LIBNFC_VERSION_MAJOR "@LIBNFC_VERSION_MAJOR@" )
set ( LIBNFC_VERSION_MINOR "@LIBNFC_VERSION_MINOR@" )
set ( LIBNFC_VERSION_PATCH "@LIBNFC_VERSION_PATCH@" )

View File

@ -0,0 +1,31 @@
# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
# The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "@LIBNFC_VERSION_STRING@")
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
math(EXPR installedBits "8 * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

9
cmake/Makefile.am Normal file
View File

@ -0,0 +1,9 @@
SUBDIRS = modules
EXTRA_DIST = \
FixBundle.cmake.in \
config_posix.h.cmake \
config_windows.h.cmake \
LibNFCConfig.cmake.in \
LibNFCConfigVersion.cmake.in \
UseLibNFC.cmake

5
cmake/UseLibNFC.cmake Normal file
View File

@ -0,0 +1,5 @@
# -*- cmake -*-
add_definitions ( ${LIBNFC_DEFINITIONS} )
include_directories ( ${LIBNFC_INCLUDE_DIRS} )
link_directories ( ${LIBNFC_LIBRARY_DIRS} )

View File

@ -2,3 +2,4 @@
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
#cmakedefine _XOPEN_SOURCE @_XOPEN_SOURCE@
#cmakedefine SYSCONFDIR "@SYSCONFDIR@"

View File

@ -0,0 +1,6 @@
#include "contrib/windows.h"
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
#cmakedefine LIBNFC_SYSCONFDIR "@LIBNFC_SYSCONFDIR@"

View File

@ -0,0 +1,63 @@
# This CMake script wants to use libusb functionality, therefore it looks
# for libusb include files and libraries.
#
# Operating Systems Supported:
# - Unix (requires pkg-config)
# Tested with Ubuntu 9.04 and Fedora 11
# - Windows (requires MinGW)
# Tested with Windows XP/Windows 7
#
# This should work for both 32 bit and 64 bit systems.
#
# Author: F. Kooman <fkooman@tuxed.net>
#
# FreeBSD has built-in libusb since 800069
IF(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
EXEC_PROGRAM(sysctl ARGS -n kern.osreldate OUTPUT_VARIABLE FREEBSD_VERSION)
SET(MIN_FREEBSD_VERSION 800068)
IF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION})
SET(LIBUSB_FOUND TRUE)
SET(LIBUSB_INCLUDE_DIRS "/usr/include")
SET(LIBUSB_LIBRARIES "usb")
SET(LIBUSB_LIBRARY_DIRS "/usr/lib/")
ENDIF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION})
ENDIF(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
IF(NOT LIBUSB_FOUND)
IF(WIN32)
IF(MINGW)
FIND_PATH(LIBUSB_INCLUDE_DIRS lusb0_usb.h "${CMAKE_CURRENT_BINARY_DIR}/LibUSB-Win32/include" NO_SYSTEM_ENVIRONMENT_PATH)
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "${CMAKE_CURRENT_BINARY_DIR}/LibUSB-Win32/lib/gcc")
SET(LIBUSB_LIBRARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/LibUSB-Win32/bin/x86/")
ELSE(MINGW)
FIND_PATH(LIBUSB_INCLUDE_DIRS lusb0_usb.h "$ENV{ProgramW6432}/libusb-win32/include" NO_SYSTEM_ENVIRONMENT_PATH)
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramW6432}/libusb-win32/lib/msvc_x64")
SET(LIBUSB_LIBRARY_DIR "$ENV{ProgramW6432}/libusb-win32/bin/amd64/")
ENDIF(MINGW)
# Must fix up variable to avoid backslashes during packaging
STRING(REGEX REPLACE "\\\\" "/" LIBUSB_LIBRARY_DIR ${LIBUSB_LIBRARY_DIR})
ELSE(WIN32)
# If not under Windows we use PkgConfig
FIND_PACKAGE (PkgConfig)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(LIBUSB REQUIRED libusb)
ELSE(PKG_CONFIG_FOUND)
MESSAGE(FATAL_ERROR "Could not find PkgConfig")
ENDIF(PKG_CONFIG_FOUND)
ENDIF(WIN32)
IF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES)
SET(LIBUSB_FOUND TRUE)
ENDIF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES)
ENDIF(NOT LIBUSB_FOUND)
IF(LIBUSB_FOUND)
IF(NOT LIBUSB_FIND_QUIETLY)
MESSAGE(STATUS "Found LIBUSB: ${LIBUSB_LIBRARIES} ${LIBUSB_INCLUDE_DIRS}")
ENDIF (NOT LIBUSB_FIND_QUIETLY)
ELSE(LIBUSB_FOUND)
IF(LIBUSB_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find LIBUSB")
ENDIF(LIBUSB_FIND_REQUIRED)
ENDIF(LIBUSB_FOUND)

View File

@ -0,0 +1,31 @@
# - Try to find the PC/SC smart card library
# Once done this will define
#
# PCSC_FOUND - system has the PC/SC library
# PCSC_INCLUDE_DIRS - the PC/SC include directory
# PCSC_LIBRARIES - The libraries needed to use PC/SC
#
# Author: F. Kooman <fkooman@tuxed.net>
# Version: 20101019
#
FIND_PACKAGE (PkgConfig)
IF(PKG_CONFIG_FOUND)
# Will find PC/SC library on Linux/BSDs using PkgConfig
PKG_CHECK_MODULES(PCSC libpcsclite)
# PKG_CHECK_MODULES(PCSC QUIET libpcsclite) # IF CMake >= 2.8.2?
ENDIF(PKG_CONFIG_FOUND)
IF(NOT PCSC_FOUND)
# Will find PC/SC headers both on Mac and Windows
FIND_PATH(PCSC_INCLUDE_DIRS WinSCard.h)
# PCSC library is for Mac, WinSCard library is for Windows
FIND_LIBRARY(PCSC_LIBRARIES NAMES PCSC libwinscard)
ENDIF(NOT PCSC_FOUND)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCSC DEFAULT_MSG
PCSC_LIBRARIES
PCSC_INCLUDE_DIRS
)
MARK_AS_ADVANCED(PCSC_INCLUDE_DIRS PCSC_LIBRARIES)

View File

@ -0,0 +1,78 @@
SET(LIBNFC_DRIVER_PCSC OFF CACHE BOOL "Enable PC/SC reader support (Depends on PC/SC)")
SET(LIBNFC_DRIVER_ACR122_PCSC OFF CACHE BOOL "Enable ACR122 support (Depends on PC/SC)")
SET(LIBNFC_DRIVER_ACR122_USB ON CACHE BOOL "Enable ACR122 support (Direct USB connection)")
SET(LIBNFC_DRIVER_ACR122S ON CACHE BOOL "Enable ACR122S support (Use serial port)")
SET(LIBNFC_DRIVER_ARYGON ON CACHE BOOL "Enable ARYGON support (Use serial port)")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(LIBNFC_DRIVER_PN532_I2C ON CACHE BOOL "Enable PN532 I2C support (Use I2C bus)")
SET(LIBNFC_DRIVER_PN532_SPI ON CACHE BOOL "Enable PN532 SPI support (Use SPI bus)")
ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(LIBNFC_DRIVER_PN532_I2C OFF CACHE BOOL "Enable PN532 I2C support (Use I2C bus)")
SET(LIBNFC_DRIVER_PN532_SPI OFF CACHE BOOL "Enable PN532 SPI support (Use SPI bus)")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(LIBNFC_DRIVER_PN532_UART ON CACHE BOOL "Enable PN532 UART support (Use serial port)")
SET(LIBNFC_DRIVER_PN53X_USB ON CACHE BOOL "Enable PN531 and PN531 USB support (Depends on libusb)")
IF(LIBNFC_DRIVER_PCSC)
FIND_PACKAGE(PCSC REQUIRED)
ADD_DEFINITIONS("-DDRIVER_PCSC_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pcsc")
ENDIF(LIBNFC_DRIVER_PCSC)
IF(LIBNFC_DRIVER_ACR122_PCSC)
FIND_PACKAGE(PCSC REQUIRED)
ADD_DEFINITIONS("-DDRIVER_ACR122_PCSC_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122_pcsc")
ENDIF(LIBNFC_DRIVER_ACR122_PCSC)
IF(LIBNFC_DRIVER_ACR122_USB)
FIND_PACKAGE(LIBUSB REQUIRED)
ADD_DEFINITIONS("-DDRIVER_ACR122_USB_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122_usb")
ENDIF(LIBNFC_DRIVER_ACR122_USB)
IF(LIBNFC_DRIVER_ACR122S)
ADD_DEFINITIONS("-DDRIVER_ACR122S_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122s")
SET(UART_REQUIRED TRUE)
ENDIF(LIBNFC_DRIVER_ACR122S)
IF(LIBNFC_DRIVER_ARYGON)
ADD_DEFINITIONS("-DDRIVER_ARYGON_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/arygon")
SET(UART_REQUIRED TRUE)
ENDIF(LIBNFC_DRIVER_ARYGON)
IF(LIBNFC_DRIVER_PN532_I2C)
ADD_DEFINITIONS("-DDRIVER_PN532_I2C_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_i2c")
SET(I2C_REQUIRED TRUE)
ENDIF(LIBNFC_DRIVER_PN532_I2C)
IF(LIBNFC_DRIVER_PN532_SPI)
ADD_DEFINITIONS("-DDRIVER_PN532_SPI_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_spi")
SET(SPI_REQUIRED TRUE)
ENDIF(LIBNFC_DRIVER_PN532_SPI)
IF(LIBNFC_DRIVER_PN532_UART)
ADD_DEFINITIONS("-DDRIVER_PN532_UART_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_uart")
SET(UART_REQUIRED TRUE)
ENDIF(LIBNFC_DRIVER_PN532_UART)
IF(LIBNFC_DRIVER_PN53X_USB)
FIND_PACKAGE(LIBUSB REQUIRED)
ADD_DEFINITIONS("-DDRIVER_PN53X_USB_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn53x_usb")
SET(USB_REQUIRED TRUE)
ENDIF(LIBNFC_DRIVER_PN53X_USB)
IF(LIBNFC_DRIVER_ACR122_USB)
FIND_PACKAGE(LIBUSB REQUIRED)
ADD_DEFINITIONS("-DDRIVER_ACR122_USB_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122_usb")
SET(USB_REQUIRED TRUE)
ENDIF(LIBNFC_DRIVER_ACR122_USB)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/libnfc/drivers)

View File

@ -0,0 +1,6 @@
EXTRA_DIST = \
COPYING-CMAKE-SCRIPTS \
FindLIBUSB.cmake \
FindPCSC.cmake \
UseDoxygen.cmake \
LibnfcDrivers.cmake

View File

@ -91,8 +91,7 @@ if(DOXYGEN_FOUND AND DOXYFILE_IN)
configure_file(${DOXYFILE_IN} Doxyfile ESCAPE_QUOTES IMMEDIATE @ONLY)
get_target_property(DOC_TARGET doc TYPE)
if(NOT DOC_TARGET)
if(NOT TARGET doc)
add_custom_target(doc)
endif()

View File

@ -1,61 +0,0 @@
# This CMake script wants to use libusb functionality, therefore it looks
# for libusb include files and libraries.
#
# Operating Systems Supported:
# - Unix (requires pkg-config)
# Tested with Ubuntu 9.04 and Fedora 11
# - Windows (requires MSVC)
# Tested with Windows XP
#
# This should work for both 32 bit and 64 bit systems.
#
# Author: F. Kooman <fkooman@tuxed.net>
#
# FreeBSD has built-in libusb since 800069
IF(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
EXEC_PROGRAM(sysctl ARGS -n kern.osreldate OUTPUT_VARIABLE FREEBSD_VERSION)
SET(MIN_FREEBSD_VERSION 800068)
IF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION})
SET(LIBUSB_FOUND TRUE)
SET(LIBUSB_INCLUDE_DIRS "/usr/include")
SET(LIBUSB_LIBRARIES "usb")
SET(LIBUSB_LIBRARY_DIRS "/usr/lib/")
ENDIF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION})
ENDIF(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
IF(NOT LIBUSB_FOUND)
IF(MSVC)
# Windows with Microsoft Visual C++
FIND_PATH(LIBUSB_INCLUDE_DIRS usb.h "$ENV{ProgramFiles}/LibUSB-Win32/include")
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x64")
# on x64 (win64)
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramFiles}/LibUSB-Win32/lib/msvc_x64")
ELSE(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x64")
# on x86 (win32)
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramFiles}/LibUSB-Win32/lib/msvc")
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x64")
ELSE(MSVC)
# If not MS Visual Studio we use PkgConfig
FIND_PACKAGE (PkgConfig)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(LIBUSB REQUIRED libusb)
ELSE(PKG_CONFIG_FOUND)
MESSAGE(FATAL_ERROR "Could not find PkgConfig")
ENDIF(PKG_CONFIG_FOUND)
ENDIF(MSVC)
IF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES)
SET(LIBUSB_FOUND TRUE)
ENDIF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES)
ENDIF(NOT LIBUSB_FOUND)
IF(LIBUSB_FOUND)
IF(NOT LIBUSB_FIND_QUIETLY)
MESSAGE(STATUS "Found LIBUSB: ${LIBUSB_LIBRARIES}")
ENDIF (NOT LIBUSB_FIND_QUIETLY)
ELSE(LIBUSB_FOUND)
IF(LIBUSB_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find LIBUSB")
ENDIF(LIBUSB_FIND_REQUIRED)
ENDIF(LIBUSB_FOUND)

View File

@ -1,41 +0,0 @@
# This CMake script wants to use PC/SC functionality, therefore it looks
# for PC/SC include files and libraries.
#
# Operating Systems Supported:
# - Unix (requires pkg-config)
# Tested with Ubuntu 9.04 and Fedora 11
# - Windows (requires MSVC)
# Tested with Windows XP
#
# This should work for both 32 bit and 64 bit systems.
#
# Author: F. Kooman <fkooman@tuxed.net>
#
IF(MSVC)
# Windows with Microsoft Visual C++
FIND_PATH(PCSC_INCLUDE_DIRS WinSCard.h "$ENV{INCLUDE}")
FIND_LIBRARY(PCSC_LIBRARIES NAMES WinSCard PATHS "$ENV{LIB}")
ELSE(MSVC)
# If not MS Visual Studio we use PkgConfig
FIND_PACKAGE (PkgConfig)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(PCSC REQUIRED libpcsclite)
ELSE(PKG_CONFIG_FOUND)
MESSAGE(FATAL_ERROR "Could not find PkgConfig")
ENDIF(PKG_CONFIG_FOUND)
ENDIF(MSVC)
IF(PCSC_INCLUDE_DIRS AND PCSC_LIBRARIES)
SET(PCSC_FOUND TRUE)
ENDIF(PCSC_INCLUDE_DIRS AND PCSC_LIBRARIES)
IF(PCSC_FOUND)
IF(NOT PCSC_FIND_QUIETLY)
MESSAGE(STATUS "Found PCSC: ${PCSC_LIBRARIES}")
ENDIF(NOT PCSC_FIND_QUIETLY)
ELSE(PCSC_FOUND)
IF(PCSC_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find PCSC")
ENDIF(PCSC_FIND_REQUIRED)
ENDIF(PCSC_FOUND)

View File

@ -1 +0,0 @@
EXTRA_DIST = COPYING-CMAKE-SCRIPTS FindLIBUSB.cmake FindPCSC.cmake UseDoxygen.cmake

View File

@ -1,100 +1,145 @@
# General init
AC_INIT(libnfc, 1.3.3, info@libnfc.org)
# /!\ Don't forget to update 'CMakeLists.txt' too /!\
AC_INIT([libnfc],[1.8.0],[nfc-tools@googlegroups.com])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADER(config.h)
# SVN revison
define([svn_revision], esyscmd([sh -c "svnversion -n"]))
SVN_REVISION=svn_revision
AC_DEFINE_UNQUOTED([SVN_REVISION], ["$SVN_REVISION"], [SVN revision])
# GIT revison
GIT_REVISION=`which git > /dev/null && git describe`
if test x"$GIT_REVISION" != x""; then
AC_DEFINE_UNQUOTED([GIT_REVISION], ["$GIT_REVISION"], [GIT revision])
fi
AM_INIT_AUTOMAKE
AM_INIT_AUTOMAKE(subdir-objects dist-bzip2 no-dist-gzip foreign)
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_LANG_C
AC_LANG([C])
AC_PROG_CC
AC_PROG_MAKE_SET
WITH_POSIX_ONLY_EXAMPLES=1
# Libtool
AC_PROG_LIBTOOL
LT_INIT
case "$host" in
*-pc-linux-gnu)
AC_MSG_RESULT([Fixing libtool for -rpath problems.])
sed -i -r 's/(hardcode_into_libs)=.*$/\1=no/' libtool
*-pc-linux-gnu)
AC_MSG_RESULT([Fixing libtool for -rpath problems.])
sed -i -r 's/(hardcode_into_libs)=.*$/\1=no/' libtool
;;
*-pc-mingw32msvc)
WITH_POSIX_ONLY_EXAMPLES=0
AC_MSG_RESULT([Disable extended examples due to target Windows system.])
# Undefine __STRICT_ANSI__ to allow to use strdup, putenv, etc. without warnings
CFLAGS="$CFLAGS -U__STRICT_ANSI__"
;;
esac
AM_CONDITIONAL(POSIX_ONLY_EXAMPLES_ENABLED, [test "$WITH_POSIX_ONLY_EXAMPLES" = "1"])
AC_PATH_PROG(PKG_CONFIG, pkg-config, [AC_MSG_ERROR([pkg-config not found.])])
PKG_PROG_PKG_CONFIG
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([stdio.h stdlib.h stdint.h stddef.h stdbool.h])
AC_CHECK_FUNCS(strdup, [AC_DEFINE([_XOPEN_SOURCE], [600], [Enable POSIX extensions if present])])
AC_CHECK_HEADERS([fcntl.h limits.h stdio.h stdlib.h stdint.h stddef.h stdbool.h sys/ioctl.h sys/param.h sys/time.h termios.h])
AC_CHECK_HEADERS([linux/spi/spidev.h], [spi_available="yes"])
AC_CHECK_HEADERS([linux/i2c-dev.h], [i2c_available="yes"])
AC_CHECK_HEADERS([linux_nfc_api.h], [nfc_nci_available="yes"])
AC_CHECK_FUNCS([memmove memset select strdup strerror strstr strtol usleep],
[AC_DEFINE([_XOPEN_SOURCE], [600], [Enable POSIX extensions if present])])
AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
# Note: malloc function should be tested but it produces some error while cross-compiling with MinGW
# AC_FUNC_MALLOC
# Checks for types
AC_TYPE_SIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_OFF_T
LIBNFC_CFLAGS='-I$(top_srcdir)/src/lib -I$(top_builddir)/src/include -I$(top_srcdir)/src/include'
LIBNFC_CFLAGS='-I$(top_srcdir)/libnfc -I$(top_builddir)/include -I$(top_srcdir)/include'
AC_SUBST(LIBNFC_CFLAGS)
# Debug support (default:no)
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Enable debug output]),[enable_debug=$enableval],[enable_debug="no"])
# Log support (default:yes)
AC_ARG_ENABLE([log],AS_HELP_STRING([--disable-log],[Disable any logs]),[enable_log=$enableval],[enable_log="yes"])
AC_MSG_CHECKING(for log flag)
AC_MSG_RESULT($enable_log)
AM_CONDITIONAL([WITH_LOG], [test "$enable_log" != "no"])
if test x"$enable_log" = "xyes"
then
AC_DEFINE([LOG], [1], [Enable log])
fi
# Conffiles support (default:yes)
AC_ARG_ENABLE([conffiles],AS_HELP_STRING([--disable-conffiles],[Disable use of config files]),[enable_conffiles=$enableval],[enable_conffiles="yes"])
AC_MSG_CHECKING(for conffiles flag)
AC_MSG_RESULT($enable_conffiles)
AM_CONDITIONAL([WITH_CONFFILES], [test "$enable_conffiles" != "no"])
if test x"$enable_conffiles" = "xyes"
then
AC_DEFINE([CONFFILES], [1], [Enable conffiles])
fi
# Envvars support (default:yes)
AC_ARG_ENABLE([envvars],AS_HELP_STRING([--disable-envvars],[Disable use of environment variables]),[enable_envvars=$enableval],[enable_envvars="yes"])
AC_MSG_CHECKING(for envvars flag)
AC_MSG_RESULT($enable_envvars)
AM_CONDITIONAL([WITH_ENVVARS], [test "$enable_envvars" != "no"])
if test x"$enable_envvars" = "xyes"
then
AC_DEFINE([ENVVARS], [1], [Enable envvars])
fi
# Debug support (default:no)
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Enable debug mode]),[enable_debug=$enableval],[enable_debug="no"])
AC_MSG_CHECKING(for debug flag)
AC_MSG_RESULT($enable_debug)
AM_CONDITIONAL([WITH_DEBUG], [test "$enable_debug" != "no"])
if test x"$enable_debug" = "xyes"
then
CFLAGS="$CFLAGS -g -Wall -DDEBUG -pedantic"
AC_DEFINE([DEBUG], [1], [Enable debug flag])
CFLAGS="$CFLAGS -g -O0 -ggdb"
fi
AC_SUBST([DEBUG_CFLAGS])
# Serial autoprobing support (default:no)
AC_ARG_ENABLE([serial-autoprobe],AS_HELP_STRING([--enable-serial-autoprobe],[Allow serial ports to be probed (can seriously disturb connected serial devices)]),[enable_serial_autoprobe=$enableval],[enable_serial_autoprobe="no"])
AC_MSG_CHECKING(for serial autoprobe flag)
AC_MSG_RESULT($enable_serial_autoprobe)
# Handle --with-drivers option
LIBNFC_ARG_WITH_DRIVERS
if test x"$enable_serial_autoprobe" = "xyes"
# Enable UART if
AM_CONDITIONAL(UART_ENABLED, [test x"$uart_required" = x"yes"])
# Enable SPI if
AM_CONDITIONAL(SPI_ENABLED, [test x"$spi_required" = x"yes"])
# Enable I2C if
AM_CONDITIONAL(I2C_ENABLED, [test x"$i2c_required" = x"yes"])
if test x"$i2c_required" = x"yes"
then
CFLAGS="$CFLAGS -DSERIAL_AUTOPROBE_ENABLED"
AC_SEARCH_LIBS([clock_gettime], [rt])
fi
# PCSC-lite support (default: yes)
AC_ARG_ENABLE([pcsc-lite],AS_HELP_STRING([--disable-pcsc-lite],[Disable PCSC-lite dependency (removes ACR122 support)]),[enable_pcsc_lite=$enableval],[enable_pcsc_lite="yes"])
AC_MSG_CHECKING(for pcsc-lite support)
AC_MSG_RESULT($enable_pcsc_lite)
if test x"$enable_pcsc_lite" = "xno"
# Enable Libnfc-NCI if required
if test x"$nfc_nci_required" = x"yes"
then
WITH_PCSC=0
PKG_CHECK_MODULES([LIBNFC_NCI], [libnfc-nci],
[AC_MSG_NOTICE([libnfc-nci present])],
[AC_MSG_ERROR([libnfc-nci not present but required for some drivers configuration])]
)
CFLAGS="$CFLAGS $LIBNFC_NCI_CFLAGS"
fi
AM_CONDITIONAL(PCSC_LITE_ENABLED, [test x"$enable_pcsc_lite" = xyes])
# libusb support (default: yes)
AC_ARG_ENABLE([libusb],AS_HELP_STRING([--disable-libusb],[Disable libusb dependency (removes PN531USB and PN533USB support)]),[enable_libusb=$enableval],[enable_libusb="yes"])
AC_MSG_CHECKING(for libusb support)
AC_MSG_RESULT($enable_libusb)
if test x"$enable_libusb" = "xno"
then
WITH_LIBUSB=0
fi
AM_CONDITIONAL(LIBUSB_ENABLED, [test x"$enable_libusb" = xyes])
# Documentation (default: no)
AC_ARG_ENABLE([doc],AS_HELP_STRING([--enable-doc],[Enable documentation generation.]),[enable_doc=$enableval],[enable_doc="no"])
@ -112,75 +157,40 @@ then
fi
AM_CONDITIONAL(DOC_ENABLED, [test x"$enable_doc" = xyes])
# Example build (default: yes)
AC_ARG_ENABLE([example],AS_HELP_STRING([--enable-example],[Enable example build.]),[enable_example=$enableval],[enable_example="yes"])
AC_MSG_CHECKING(for example build)
AC_MSG_RESULT($enable_example)
AM_CONDITIONAL(EXAMPLE_ENABLED, [test x"$enable_example" = xyes])
# Dependencies
PKG_CONFIG_REQUIRES=""
## libusb
if test "x$enable_libusb" = "xyes"; then
WITH_USB=0
# Search using pkg-config
if test x"$PKG_CONFIG" != "x"; then
PKG_CHECK_MODULES([LIBUSB], [libusb], [WITH_USB=1], [WITH_USB=0])
if test x"$WITH_USB" = "x1"; then
if test x"$PKG_CONFIG_REQUIRES" != x""; then
PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES,"
fi
PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES libusb"
fi
fi
# Search using libusb-config
if test x"$WITH_USB" = "x0"; then
AC_PATH_PROG(LIBUSB_CONFIG,libusb-config)
if test x"$LIBUSB_CONFIG" != "x" ; then
LIBUSB_CFLAGS=`$LIBUSB_CONFIG --cflags`
LIBUSB_LIBS=`$LIBUSB_CONFIG --libs`
WITH_USB=1
fi
fi
# Search the library and headers directly (last chance)
if test x"$WITH_USB" = "x0"; then
AC_CHECK_HEADER(usb.h, [], [AC_MSG_ERROR([The libusb headers are missing])])
AC_CHECK_LIB(usb, libusb_init, [], [AC_MSG_ERROR([The libusb library is missing])])
LIBUSB_LIBS="-lusb"
WITH_USB=1
fi
if test x"$WITH_USB" = "x0"; then
AC_MSG_ERROR([libusb is mandatory.])
fi
AC_SUBST(LIBUSB_LIBS)
AC_SUBST(LIBUSB_CFLAGS)
fi
## libpcsclite
if test "x$enable_pcsc_lite" = "xyes"; then
case "$host" in
*darwin*)
AC_MSG_WARN(Using darwin PCSC Framework)
LIBPCSCLITE_LIBS="-Wl,-framework,PCSC"
LIBPCSCLITE_CFLAGS="-I/System/Library/Frameworks/PCSC.framework/Headers"
;;
*)
PKG_CHECK_MODULES([LIBPCSCLITE], [libpcsclite], [WITH_PCSC=1], [WITH_PCSC=0])
if test x"$WITH_PCSC" = "x0" ; then
AC_MSG_ERROR([libpcsclite is mandatory.])
fi
if test x"$PKG_CONFIG_REQUIRES" != x""; then
PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES,"
fi
PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES libpcsclite"
;;
esac
AC_SUBST(LIBPCSCLITE_LIBS)
AC_SUBST(LIBPCSCLITE_CFLAGS)
fi
LIBNFC_CHECK_LIBUSB
LIBNFC_CHECK_PCSC
AC_SUBST(PKG_CONFIG_REQUIRES)
AM_CONDITIONAL(LIBUSB_ENABLED, [test "$HAVE_LIBUSB" = "1"])
AM_CONDITIONAL(PCSC_ENABLED, [test "$HAVE_PCSC" = "1"])
CUTTER_REQUIRED_VERSION=1.1.7
m4_ifdef([AC_CHECK_CUTTER], [AC_CHECK_CUTTER([>= $CUTTER_REQUIRED_VERSION])], [ac_cv_use_cutter="no"])
if test x$ac_cv_with_cutter = xyes -a x$ac_cv_use_cutter = xno; then
AC_MSG_ERROR([cutter >= $CUTTER_REQUIRED_VERSION is mandatory.])
fi
AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"])
if test x"$enable_example" = "xyes"
then
AC_CHECK_READLINE
fi
# Help us to write great code ;-)
CFLAGS="$CFLAGS -Wall -pedantic -Wextra"
# Defines and C flags
CFLAGS="$CFLAGS -std=c99"
@ -188,18 +198,32 @@ CFLAGS="$CFLAGS -std=c99"
CFLAGS="$CFLAGS -Du_int8_t=uint8_t -Du_int16_t=uint16_t"
AC_CONFIG_FILES([
Makefile
src/include/Makefile
src/include/nfc/Makefile
src/lib/chips/Makefile
src/lib/buses/Makefile
src/lib/drivers/Makefile
src/lib/Makefile
src/examples/Makefile
src/Makefile
cmake_modules/Makefile
libnfc.pc
Doxyfile
Makefile
cmake/Makefile
cmake/modules/Makefile
contrib/Makefile
contrib/devd/Makefile
contrib/libnfc/Makefile
contrib/linux/Makefile
contrib/udev/Makefile
contrib/win32/Makefile
contrib/win32/sys/Makefile
contrib/win32/libnfc/Makefile
contrib/win32/libnfc/buses/Makefile
examples/Makefile
examples/pn53x-tamashell-scripts/Makefile
include/Makefile
include/nfc/Makefile
libnfc.pc
libnfc/Makefile
libnfc/buses/Makefile
libnfc/chips/Makefile
libnfc/drivers/Makefile
test/Makefile
utils/Makefile
])
AC_OUTPUT
LIBNFC_DRIVERS_SUMMARY

9
contrib/Makefile.am Normal file
View File

@ -0,0 +1,9 @@
SUBDIRS = \
devd \
libnfc \
linux \
udev \
win32
EXTRA_DIST = \
windows.h

2
contrib/devd/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
EXTRA_DIST = \
pn53x.conf

View File

@ -20,3 +20,17 @@ attach 110 {
action "/usr/bin/chgrp nfc /dev/$device-name";
action "/bin/chmod g+rw /dev/$device-name";
};
attach 110 {
match "vendor" "0x1fd3";
match "product" "0x0608";
action "/usr/bin/chgrp nfc /dev/$device-name";
action "/bin/chmod g+rw /dev/$device-name";
};
attach 110 {
match "vendor" "0x054c";
match "product" "0x02e1";
action "/usr/bin/chgrp nfc /dev/$device-name";
action "/bin/chmod g+rw /dev/$device-name";
};

View File

@ -0,0 +1,7 @@
EXTRA_DIST = \
arygon.conf.sample \
pn532_i2c_on_rpi.conf.sample \
pn532_spi_on_rpi.conf.sample \
pn532_uart_on_rpi_3.conf.sample \
pn532_uart_on_rpi.conf.sample \
pn532_via_uart2usb.conf.sample

View File

@ -0,0 +1,3 @@
## Typical configuration file for Arygon/IDentive device (with Arygon-MCU on board)
name = "IDentive"
connstring = arygon:/dev/ttyS0

View File

@ -0,0 +1,12 @@
## Typical configuration file for PN532 device on R-Pi connected using I2C
## Note: to use SPI port on R-Pi, you have to load kernel modules i2c-bcm2708 and i2c-dev:
## Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist i2c-bcm2708
## Edit /etc/modules and add a new line: i2c-dev
name = "PN532 board via I2C"
connstring = pn532_i2c:/dev/i2c-0
# Note: If you have an R-Pi revision 2.0, the I2C bus #1 is now routed to connector P1
# (instead of the I2C bus #0 routed on same connector on initial board revision), so
# the configuration to use would probably be:
# connstring = pn532_i2c:/dev/i2c-1

View File

@ -0,0 +1,5 @@
## Typical configuration file for PN532 device on R-Pi connected using SPI
## Note: to use SPI port on R-Pi, you have to load kernel module spi-bcm2708:
## Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist spi-bcm2708
name = "PN532 board via SPI"
connstring = pn532_spi:/dev/spidev0.0:500000

View File

@ -0,0 +1,5 @@
## Typical configuration file for PN532 device on R-Pi connected using UART
## Note: to use UART port on R-Pi, you have to disable linux serial console:
## http://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/freeing-uart-on-the-pi
name = "PN532 board via UART"
connstring = pn532_uart:/dev/ttyAMA0

View File

@ -0,0 +1,22 @@
## Typical configuration file for PN532 device on R-Pi 3 connected using miniUART
## Note: Changes have been made to R-Pi 3 with the addition of Bluetooth LE
## The UART is now being used by the BLE module. Instead of disabling it, you can
## use the PN532 device with the "mini UART", which is still hijacked by the linux kernel
## as a serial console
##
## Tested recipe with PN532 breakout from Adafruit
##
## To enable uart on GPIO, add this line to bottom of /boot/config.txt
## enable_uart=1
##
## Stop and disable serial console:
## $ sudo systemctl stop serial-getty@ttyS0.service
## $ sudo systemctl disable serial-getty@ttyS0.service
##
## Remove console from /boot/cmdline.txt by removing:
## console=serial0,115200 Save and reboot for changes to take effect.
##
name = "PN532 board via UART"
connstring = pn532_uart:/dev/ttyS0
allow_intrusive_scan = true

View File

@ -0,0 +1,3 @@
## Typical configuration file for PN532 board (ie. microbuilder.eu / Adafruit) device
name = "Adafruit PN532 board via UART"
connstring = pn532_uart:/dev/ttyUSB0

View File

@ -0,0 +1,2 @@
EXTRA_DIST = \
blacklist-libnfc.conf

View File

@ -0,0 +1,3 @@
blacklist nfc
blacklist pn533
blacklist pn533_usb

View File

@ -11,5 +11,12 @@ ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0193", MODE="0664", GROUP="plugdev"
# PN533
ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="2533", MODE="0664", GROUP="plugdev"
ATTRS{idVendor}=="04e6", ATTRS{idProduct}=="5591", MODE="0664", GROUP="plugdev"
ATTRS{idVendor}=="04e6", ATTRS{idProduct}=="5594", MODE="0664", GROUP="plugdev"
ATTRS{idVendor}=="1fd3", ATTRS{idProduct}=="0608", MODE="0664", GROUP="plugdev"
ATTRS{idVendor}=="054c", ATTRS{idProduct}=="02e1", MODE="0664", GROUP="plugdev"
# ACR122 / Touchatag
ATTRS{idVendor}=="072f", ATTRS{idProduct}=="2200", MODE="0664", GROUP="plugdev"
ATTRS{idVendor}=="072f", ATTRS{idProduct}=="90cc", MODE="0664", GROUP="plugdev"
LABEL="pn53x_rules_end"

2
contrib/udev/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
EXTRA_DIST = \
93-pn53x.rules

View File

@ -0,0 +1,8 @@
SUBDIRS = libnfc sys .
EXTRA_DIST = \
err.h \
nfc.def \
stdlib.c \
unistd.h \
version.rc.in

870
contrib/win32/dirent.h Normal file
View File

@ -0,0 +1,870 @@
/*
* Dirent interface for Microsoft Visual Studio
*
* Copyright (C) 2006-2012 Toni Ronkko
* This file is part of dirent. Dirent may be freely distributed
* under the MIT license. For all details and documentation, see
* https://github.com/tronkko/dirent
*/
#ifndef DIRENT_H
#define DIRENT_H
/*
* Include windows.h without Windows Sockets 1.1 to prevent conflicts with
* Windows Sockets 2.0.
*/
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
/* Indicates that d_type field is available in dirent structure */
#define _DIRENT_HAVE_D_TYPE
/* Indicates that d_namlen field is available in dirent structure */
#define _DIRENT_HAVE_D_NAMLEN
/* Entries missing from MSVC 6.0 */
#if !defined(FILE_ATTRIBUTE_DEVICE)
# define FILE_ATTRIBUTE_DEVICE 0x40
#endif
/* File type and permission flags for stat(), general mask */
#if !defined(S_IFMT)
# define S_IFMT _S_IFMT
#endif
/* Directory bit */
#if !defined(S_IFDIR)
# define S_IFDIR _S_IFDIR
#endif
/* Character device bit */
#if !defined(S_IFCHR)
# define S_IFCHR _S_IFCHR
#endif
/* Pipe bit */
#if !defined(S_IFFIFO)
# define S_IFFIFO _S_IFFIFO
#endif
/* Regular file bit */
#if !defined(S_IFREG)
# define S_IFREG _S_IFREG
#endif
/* Read permission */
#if !defined(S_IREAD)
# define S_IREAD _S_IREAD
#endif
/* Write permission */
#if !defined(S_IWRITE)
# define S_IWRITE _S_IWRITE
#endif
/* Execute permission */
#if !defined(S_IEXEC)
# define S_IEXEC _S_IEXEC
#endif
/* Pipe */
#if !defined(S_IFIFO)
# define S_IFIFO _S_IFIFO
#endif
/* Block device */
#if !defined(S_IFBLK)
# define S_IFBLK 0
#endif
/* Link */
#if !defined(S_IFLNK)
# define S_IFLNK 0
#endif
/* Socket */
#if !defined(S_IFSOCK)
# define S_IFSOCK 0
#endif
/* Read user permission */
#if !defined(S_IRUSR)
# define S_IRUSR S_IREAD
#endif
/* Write user permission */
#if !defined(S_IWUSR)
# define S_IWUSR S_IWRITE
#endif
/* Execute user permission */
#if !defined(S_IXUSR)
# define S_IXUSR 0
#endif
/* Read group permission */
#if !defined(S_IRGRP)
# define S_IRGRP 0
#endif
/* Write group permission */
#if !defined(S_IWGRP)
# define S_IWGRP 0
#endif
/* Execute group permission */
#if !defined(S_IXGRP)
# define S_IXGRP 0
#endif
/* Read others permission */
#if !defined(S_IROTH)
# define S_IROTH 0
#endif
/* Write others permission */
#if !defined(S_IWOTH)
# define S_IWOTH 0
#endif
/* Execute others permission */
#if !defined(S_IXOTH)
# define S_IXOTH 0
#endif
/* Maximum length of file name */
#if !defined(PATH_MAX)
# define PATH_MAX MAX_PATH
#endif
#if !defined(FILENAME_MAX)
# define FILENAME_MAX MAX_PATH
#endif
#if !defined(NAME_MAX)
# define NAME_MAX FILENAME_MAX
#endif
/* File type flags for d_type */
#define DT_UNKNOWN 0
#define DT_REG S_IFREG
#define DT_DIR S_IFDIR
#define DT_FIFO S_IFIFO
#define DT_SOCK S_IFSOCK
#define DT_CHR S_IFCHR
#define DT_BLK S_IFBLK
#define DT_LNK S_IFLNK
/* Macros for converting between st_mode and d_type */
#define IFTODT(mode) ((mode) & S_IFMT)
#define DTTOIF(type) (type)
/*
* File type macros. Note that block devices, sockets and links cannot be
* distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
* only defined for compatibility. These macros should always return false
* on Windows.
*/
#if !defined(S_ISFIFO)
# define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
#endif
#if !defined(S_ISDIR)
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif
#if !defined(S_ISREG)
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#endif
#if !defined(S_ISLNK)
# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
#endif
#if !defined(S_ISSOCK)
# define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
#endif
#if !defined(S_ISCHR)
# define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
#endif
#if !defined(S_ISBLK)
# define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
#endif
/* Return the exact length of the file name without zero terminator */
#define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
/* Return the maximum size of a file name */
#define _D_ALLOC_NAMLEN(p) ((PATH_MAX)+1)
#ifdef __cplusplus
extern "C" {
#endif
/* Wide-character version */
struct _wdirent {
/* Always zero */
long d_ino;
/* File position within stream */
long d_off;
/* Structure size */
unsigned short d_reclen;
/* Length of name without \0 */
size_t d_namlen;
/* File type */
int d_type;
/* File name */
wchar_t d_name[PATH_MAX+1];
};
typedef struct _wdirent _wdirent;
struct _WDIR {
/* Current directory entry */
struct _wdirent ent;
/* Private file data */
WIN32_FIND_DATAW data;
/* True if data is valid */
int cached;
/* Win32 search handle */
HANDLE handle;
/* Initial directory name */
wchar_t *patt;
};
typedef struct _WDIR _WDIR;
/* Multi-byte character version */
struct dirent {
/* Always zero */
long d_ino;
/* File position within stream */
long d_off;
/* Structure size */
unsigned short d_reclen;
/* Length of name without \0 */
size_t d_namlen;
/* File type */
int d_type;
/* File name */
char d_name[PATH_MAX+1];
};
typedef struct dirent dirent;
struct DIR {
struct dirent ent;
struct _WDIR *wdirp;
};
typedef struct DIR DIR;
/* Dirent functions */
static DIR *opendir (const char *dirname);
static _WDIR *_wopendir (const wchar_t *dirname);
static struct dirent *readdir (DIR *dirp);
static int readdir_r(
DIR *dirp, struct dirent *entry, struct dirent **result);
static int closedir (DIR *dirp);
static int _wclosedir (_WDIR *dirp);
/* For compatibility with Symbian */
#define wdirent _wdirent
#define WDIR _WDIR
#define wopendir _wopendir
#define wreaddir _wreaddir
#define wclosedir _wclosedir
#define wrewinddir _wrewinddir
/* Internal utility functions */
static WIN32_FIND_DATAW *dirent_first (_WDIR *dirp);
static WIN32_FIND_DATAW *dirent_next (_WDIR *dirp);
static int dirent_mbstowcs_s(
size_t *pReturnValue,
wchar_t *wcstr,
size_t sizeInWords,
const char *mbstr,
size_t count);
static int dirent_wcstombs_s(
size_t *pReturnValue,
char *mbstr,
size_t sizeInBytes,
const wchar_t *wcstr,
size_t count);
static void dirent_set_errno (int error);
/*
* Open directory stream DIRNAME for read and return a pointer to the
* internal working area that is used to retrieve individual directory
* entries.
*/
static _WDIR*
_wopendir(
const wchar_t *dirname)
{
_WDIR *dirp = NULL;
int error;
/* Must have directory name */
if (dirname == NULL || dirname[0] == '\0') {
dirent_set_errno (ENOENT);
return NULL;
}
/* Allocate new _WDIR structure */
dirp = (_WDIR*) malloc (sizeof (struct _WDIR));
if (dirp != NULL) {
DWORD n;
/* Reset _WDIR structure */
dirp->handle = INVALID_HANDLE_VALUE;
dirp->patt = NULL;
dirp->cached = 0;
/* Compute the length of full path plus zero terminator
*
* Note that on WinRT there's no way to convert relative paths
* into absolute paths, so just assume it is an absolute path.
*/
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
n = wcslen(dirname);
# else
n = GetFullPathNameW (dirname, 0, NULL, NULL);
# endif
/* Allocate room for absolute directory name and search pattern */
dirp->patt = (wchar_t*) malloc (sizeof (wchar_t) * n + 16);
if (dirp->patt) {
/*
* Convert relative directory name to an absolute one. This
* allows rewinddir() to function correctly even when current
* working directory is changed between opendir() and rewinddir().
*
* Note that on WinRT there's no way to convert relative paths
* into absolute paths, so just assume it is an absolute path.
*/
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
wcsncpy_s(dirp->patt, n+1, dirname, n);
# else
n = GetFullPathNameW (dirname, n, dirp->patt, NULL);
# endif
if (n > 0) {
wchar_t *p;
/* Append search pattern \* to the directory name */
p = dirp->patt + n;
if (dirp->patt < p) {
switch (p[-1]) {
case '\\':
case '/':
case ':':
/* Directory ends in path separator, e.g. c:\temp\ */
/*NOP*/;
break;
default:
/* Directory name doesn't end in path separator */
*p++ = '\\';
}
}
*p++ = '*';
*p = '\0';
/* Open directory stream and retrieve the first entry */
if (dirent_first (dirp)) {
/* Directory stream opened successfully */
error = 0;
} else {
/* Cannot retrieve first entry */
error = 1;
dirent_set_errno (ENOENT);
}
} else {
/* Cannot retrieve full path name */
dirent_set_errno (ENOENT);
error = 1;
}
} else {
/* Cannot allocate memory for search pattern */
error = 1;
}
} else {
/* Cannot allocate _WDIR structure */
error = 1;
}
/* Clean up in case of error */
if (error && dirp) {
_wclosedir (dirp);
dirp = NULL;
}
return dirp;
}
/*
* Close directory stream opened by opendir() function. This invalidates the
* DIR structure as well as any directory entry read previously by
* _wreaddir().
*/
static int
_wclosedir(
_WDIR *dirp)
{
int ok;
if (dirp) {
/* Release search handle */
if (dirp->handle != INVALID_HANDLE_VALUE) {
FindClose (dirp->handle);
dirp->handle = INVALID_HANDLE_VALUE;
}
/* Release search pattern */
if (dirp->patt) {
free (dirp->patt);
dirp->patt = NULL;
}
/* Release directory structure */
free (dirp);
ok = /*success*/0;
} else {
/* Invalid directory stream */
dirent_set_errno (EBADF);
ok = /*failure*/-1;
}
return ok;
}
/* Get first directory entry (internal) */
static WIN32_FIND_DATAW*
dirent_first(
_WDIR *dirp)
{
WIN32_FIND_DATAW *datap;
/* Open directory and retrieve the first entry */
dirp->handle = FindFirstFileExW(
dirp->patt, FindExInfoStandard, &dirp->data,
FindExSearchNameMatch, NULL, 0);
if (dirp->handle != INVALID_HANDLE_VALUE) {
/* a directory entry is now waiting in memory */
datap = &dirp->data;
dirp->cached = 1;
} else {
/* Failed to re-open directory: no directory entry in memory */
dirp->cached = 0;
datap = NULL;
}
return datap;
}
/*
* Get next directory entry (internal).
*
* Returns
*/
static WIN32_FIND_DATAW*
dirent_next(
_WDIR *dirp)
{
WIN32_FIND_DATAW *p;
/* Get next directory entry */
if (dirp->cached != 0) {
/* A valid directory entry already in memory */
p = &dirp->data;
dirp->cached = 0;
} else if (dirp->handle != INVALID_HANDLE_VALUE) {
/* Get the next directory entry from stream */
if (FindNextFileW (dirp->handle, &dirp->data) != FALSE) {
/* Got a file */
p = &dirp->data;
} else {
/* The very last entry has been processed or an error occurred */
FindClose (dirp->handle);
dirp->handle = INVALID_HANDLE_VALUE;
p = NULL;
}
} else {
/* End of directory stream reached */
p = NULL;
}
return p;
}
/*
* Open directory stream using plain old C-string.
*/
static DIR*
opendir(
const char *dirname)
{
struct DIR *dirp;
int error;
/* Must have directory name */
if (dirname == NULL || dirname[0] == '\0') {
dirent_set_errno (ENOENT);
return NULL;
}
/* Allocate memory for DIR structure */
dirp = (DIR*) malloc (sizeof (struct DIR));
if (dirp) {
wchar_t wname[PATH_MAX + 1];
size_t n;
/* Convert directory name to wide-character string */
error = dirent_mbstowcs_s(
&n, wname, PATH_MAX + 1, dirname, PATH_MAX + 1);
if (!error) {
/* Open directory stream using wide-character name */
dirp->wdirp = _wopendir (wname);
if (dirp->wdirp) {
/* Directory stream opened */
error = 0;
} else {
/* Failed to open directory stream */
error = 1;
}
} else {
/*
* Cannot convert file name to wide-character string. This
* occurs if the string contains invalid multi-byte sequences or
* the output buffer is too small to contain the resulting
* string.
*/
error = 1;
}
} else {
/* Cannot allocate DIR structure */
error = 1;
}
/* Clean up in case of error */
if (error && dirp) {
free (dirp);
dirp = NULL;
}
return dirp;
}
/*
* Read next directory entry.
*/
static struct dirent*
readdir(
DIR *dirp)
{
struct dirent *entry;
/*
* Read directory entry to buffer. We can safely ignore the return value
* as entry will be set to NULL in case of error.
*/
(void) readdir_r (dirp, &dirp->ent, &entry);
/* Return pointer to statically allocated directory entry */
return entry;
}
/*
* Read next directory entry into called-allocated buffer.
*
* Returns zero on success. If the end of directory stream is reached, then
* sets result to NULL and returns zero.
*/
static int
readdir_r(
DIR *dirp,
struct dirent *entry,
struct dirent **result)
{
WIN32_FIND_DATAW *datap;
/* Read next directory entry */
datap = dirent_next (dirp->wdirp);
if (datap) {
size_t n;
int error;
/* Attempt to convert file name to multi-byte string */
error = dirent_wcstombs_s(
&n, entry->d_name, PATH_MAX + 1, datap->cFileName, PATH_MAX + 1);
/*
* If the file name cannot be represented by a multi-byte string,
* then attempt to use old 8+3 file name. This allows traditional
* Unix-code to access some file names despite of unicode
* characters, although file names may seem unfamiliar to the user.
*
* Be ware that the code below cannot come up with a short file
* name unless the file system provides one. At least
* VirtualBox shared folders fail to do this.
*/
if (error && datap->cAlternateFileName[0] != '\0') {
error = dirent_wcstombs_s(
&n, entry->d_name, PATH_MAX + 1,
datap->cAlternateFileName, PATH_MAX + 1);
}
if (!error) {
DWORD attr;
/* Length of file name excluding zero terminator */
entry->d_namlen = n - 1;
/* File attributes */
attr = datap->dwFileAttributes;
if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
entry->d_type = DT_CHR;
} else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
entry->d_type = DT_DIR;
} else {
entry->d_type = DT_REG;
}
/* Reset dummy fields */
entry->d_ino = 0;
entry->d_off = 0;
entry->d_reclen = sizeof (struct dirent);
} else {
/*
* Cannot convert file name to multi-byte string so construct
* an erroneous directory entry and return that. Note that
* we cannot return NULL as that would stop the processing
* of directory entries completely.
*/
entry->d_name[0] = '?';
entry->d_name[1] = '\0';
entry->d_namlen = 1;
entry->d_type = DT_UNKNOWN;
entry->d_ino = 0;
entry->d_off = -1;
entry->d_reclen = 0;
}
/* Return pointer to directory entry */
*result = entry;
} else {
/* No more directory entries */
*result = NULL;
}
return /*OK*/0;
}
/*
* Close directory stream.
*/
static int
closedir(
DIR *dirp)
{
int ok;
if (dirp) {
/* Close wide-character directory stream */
ok = _wclosedir (dirp->wdirp);
dirp->wdirp = NULL;
/* Release multi-byte character version */
free (dirp);
} else {
/* Invalid directory stream */
dirent_set_errno (EBADF);
ok = /*failure*/-1;
}
return ok;
}
/* Convert multi-byte string to wide character string */
static int
dirent_mbstowcs_s(
size_t *pReturnValue,
wchar_t *wcstr,
size_t sizeInWords,
const char *mbstr,
size_t count)
{
int error;
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Microsoft Visual Studio 2005 or later */
error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
#else
/* Older Visual Studio or non-Microsoft compiler */
size_t n;
/* Convert to wide-character string (or count characters) */
n = mbstowcs (wcstr, mbstr, sizeInWords);
if (!wcstr || n < count) {
/* Zero-terminate output buffer */
if (wcstr && sizeInWords) {
if (n >= sizeInWords) {
n = sizeInWords - 1;
}
wcstr[n] = 0;
}
/* Length of resulting multi-byte string WITH zero terminator */
if (pReturnValue) {
*pReturnValue = n + 1;
}
/* Success */
error = 0;
} else {
/* Could not convert string */
error = 1;
}
#endif
return error;
}
/* Convert wide-character string to multi-byte string */
static int
dirent_wcstombs_s(
size_t *pReturnValue,
char *mbstr,
size_t sizeInBytes, /* max size of mbstr */
const wchar_t *wcstr,
size_t count)
{
int error;
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Microsoft Visual Studio 2005 or later */
error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count);
#else
/* Older Visual Studio or non-Microsoft compiler */
size_t n;
/* Convert to multi-byte string (or count the number of bytes needed) */
n = wcstombs (mbstr, wcstr, sizeInBytes);
if (!mbstr || n < count) {
/* Zero-terminate output buffer */
if (mbstr && sizeInBytes) {
if (n >= sizeInBytes) {
n = sizeInBytes - 1;
}
mbstr[n] = '\0';
}
/* Length of resulting multi-bytes string WITH zero-terminator */
if (pReturnValue) {
*pReturnValue = n + 1;
}
/* Success */
error = 0;
} else {
/* Cannot convert string */
error = 1;
}
#endif
return error;
}
/* Set errno variable */
static void
dirent_set_errno(
int error)
{
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Microsoft Visual Studio 2005 and later */
_set_errno (error);
#else
/* Non-Microsoft compiler or older Microsoft compiler */
errno = error;
#endif
}
#ifdef __cplusplus
}
#endif
#endif /*DIRENT_H*/

19
contrib/win32/err.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef _ERR_H_
#define _ERR_H_
#include <stdlib.h>
#define warnx(...) do { \
fprintf (stderr, __VA_ARGS__); \
fprintf (stderr, "\n"); \
} while (0)
#define errx(code, ...) do { \
fprintf (stderr, __VA_ARGS__); \
fprintf (stderr, "\n"); \
exit (code); \
} while (0)
#define err errx
#endif /* !_ERR_H_ */

106
contrib/win32/getopt.c Normal file
View File

@ -0,0 +1,106 @@
#include "getopt.h" // make sure you construct the header file as dictated above
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 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 POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <string.h>
#include <stdio.h>
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
/*
* getopt --
* Parse argc/argv argument vector.
*/
int getopt(int nargc, char * const nargv[], const char *ostr)
{
static char *place = EMSG; /* option letter processing */
const char *oli; /* option letter list index */
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (-1);
}
if (place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return (-1);
}
} /* option letter okay? */
if ((optopt = (int)*place++) == (int)':' ||
!(oli = strchr(ostr, optopt))) {
/*
* if the user didn't specify '-' as an option,
* assume it means -1.
*/
if (optopt == (int)'-')
return (-1);
if (!*place)
++optind;
if (opterr && *ostr != ':')
(void)printf("illegal option -- %c\n", optopt);
return (BADCH);
}
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if (!*place)
++optind;
}
else { /* need an argument */
if (*place) /* no white space */
optarg = place;
else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (*ostr == ':')
return (BADARG);
if (opterr)
(void)printf("option requires an argument -- %c\n", optopt);
return (BADCH);
}
else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
return (optopt); /* dump back option letter */
}

13
contrib/win32/getopt.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef GETOPT_H
#define GETOPT_H
extern int opterr; /* if error message should be printed */
extern int optind; /* index into parent argv vector */
extern int optopt; /* character checked for validity */
extern int optreset; /* reset getopt */
extern char *optarg; /* argument associated with option */
int getopt(int nargc, char * const nargv[], const char *ostr);
#endif

View File

@ -0,0 +1,4 @@
SUBDIRS = buses .
EXTRA_DIST = \
log-internal.c

View File

@ -0,0 +1,2 @@
EXTRA_DIST = \
uart.c

View File

@ -0,0 +1,284 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
/**
* @file uart.c
* @brief Windows UART driver
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include "uart.h"
#include <nfc/nfc.h>
#include "nfc-internal.h"
#include <inttypes.h>
#include "log.h"
#define LOG_GROUP NFC_LOG_GROUP_COM
#define LOG_CATEGORY "libnfc.bus.uart_win32"
// Handle platform specific includes
#include "contrib/windows.h"
#define delay_ms( X ) Sleep( X )
struct serial_port_windows {
HANDLE hPort; // Serial port handle
DCB dcb; // Device control settings
COMMTIMEOUTS ct; // Serial port time-out configuration
};
serial_port
uart_open(const char *pcPortName)
{
char acPortName[255];
struct serial_port_windows *sp = malloc(sizeof(struct serial_port_windows));
if (sp == 0)
return INVALID_SERIAL_PORT;
// Copy the input "com?" to "\\.\COM?" format
sprintf(acPortName, "\\\\.\\%s", pcPortName);
_strupr(acPortName);
// Try to open the serial port
sp->hPort = CreateFileA(acPortName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (sp->hPort == INVALID_HANDLE_VALUE) {
uart_close(sp);
return INVALID_SERIAL_PORT;
}
// Prepare the device control
memset(&sp->dcb, 0, sizeof(DCB));
sp->dcb.DCBlength = sizeof(DCB);
if (!BuildCommDCBA("baud=9600 data=8 parity=N stop=1", &sp->dcb)) {
uart_close(sp);
return INVALID_SERIAL_PORT;
}
// Update the active serial port
if (!SetCommState(sp->hPort, &sp->dcb)) {
uart_close(sp);
return INVALID_SERIAL_PORT;
}
sp->ct.ReadIntervalTimeout = 30;
sp->ct.ReadTotalTimeoutMultiplier = 0;
sp->ct.ReadTotalTimeoutConstant = 30;
sp->ct.WriteTotalTimeoutMultiplier = 30;
sp->ct.WriteTotalTimeoutConstant = 0;
if (!SetCommTimeouts(sp->hPort, &sp->ct)) {
uart_close(sp);
return INVALID_SERIAL_PORT;
}
PurgeComm(sp->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
return sp;
}
void
uart_close(const serial_port sp)
{
if (((struct serial_port_windows *) sp)->hPort != INVALID_HANDLE_VALUE) {
CloseHandle(((struct serial_port_windows *) sp)->hPort);
}
free(sp);
}
void
uart_flush_input(const serial_port sp, bool wait)
{
PurgeComm(((struct serial_port_windows *) sp)->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
}
void
uart_set_speed(serial_port sp, const uint32_t uiPortSpeed)
{
struct serial_port_windows *spw;
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Serial port speed requested to be set to %d baud.", uiPortSpeed);
// Set port speed (Input and Output)
switch (uiPortSpeed) {
case 9600:
case 19200:
case 38400:
case 57600:
case 115200:
case 230400:
case 460800:
break;
default:
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to set serial port speed to %d baud. Speed value must be one of these constants: 9600 (default), 19200, 38400, 57600, 115200, 230400 or 460800.", uiPortSpeed);
return;
};
spw = (struct serial_port_windows *) sp;
// Set baud rate
spw->dcb.BaudRate = uiPortSpeed;
if (!SetCommState(spw->hPort, &spw->dcb)) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Unable to apply new speed settings.");
return;
}
PurgeComm(spw->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
}
uint32_t
uart_get_speed(const serial_port sp)
{
const struct serial_port_windows *spw = (struct serial_port_windows *) sp;
if (!GetCommState(spw->hPort, (serial_port) & spw->dcb))
return spw->dcb.BaudRate;
return 0;
}
int
uart_receive(serial_port sp, uint8_t *pbtRx, const size_t szRx, void *abort_p, int timeout)
{
DWORD dwBytesToGet = (DWORD)szRx;
DWORD dwBytesReceived = 0;
DWORD dwTotalBytesReceived = 0;
BOOL res;
// XXX Put this part into uart_win32_timeouts () ?
DWORD timeout_ms = timeout;
COMMTIMEOUTS timeouts;
timeouts.ReadIntervalTimeout = 0;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.ReadTotalTimeoutConstant = timeout_ms;
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = timeout_ms;
if (!SetCommTimeouts(((struct serial_port_windows *) sp)->hPort, &timeouts)) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to apply new timeout settings.");
return NFC_EIO;
}
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Timeouts are set to %lu ms", timeout_ms);
// TODO Enhance the reception method
// - According to MSDN, it could be better to implement nfc_abort_command() mechanism using Cancello()
volatile bool *abort_flag_p = (volatile bool *)abort_p;
do {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "ReadFile");
res = ReadFile(((struct serial_port_windows *) sp)->hPort, pbtRx + dwTotalBytesReceived,
dwBytesToGet,
&dwBytesReceived, NULL);
dwTotalBytesReceived += dwBytesReceived;
if (!res) {
DWORD err = GetLastError();
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "ReadFile error: %lu", err);
return NFC_EIO;
} else if (dwBytesReceived == 0) {
return NFC_ETIMEOUT;
}
if (((DWORD)szRx) > dwTotalBytesReceived) {
dwBytesToGet -= dwBytesReceived;
}
if (abort_flag_p != NULL && (*abort_flag_p) && dwTotalBytesReceived == 0) {
return NFC_EOPABORTED;
}
} while (((DWORD)szRx) > dwTotalBytesReceived);
LOG_HEX(LOG_GROUP, "RX", pbtRx, szRx);
return (dwTotalBytesReceived == (DWORD) szRx) ? 0 : NFC_EIO;
}
int
uart_send(serial_port sp, const uint8_t *pbtTx, const size_t szTx, int timeout)
{
DWORD dwTxLen = 0;
COMMTIMEOUTS timeouts;
timeouts.ReadIntervalTimeout = 0;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.ReadTotalTimeoutConstant = timeout;
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = timeout;
if (!SetCommTimeouts(((struct serial_port_windows *) sp)->hPort, &timeouts)) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to apply new timeout settings.");
return NFC_EIO;
}
LOG_HEX(LOG_GROUP, "TX", pbtTx, szTx);
if (!WriteFile(((struct serial_port_windows *) sp)->hPort, pbtTx, szTx, &dwTxLen, NULL)) {
return NFC_EIO;
}
if (!dwTxLen)
return NFC_EIO;
return 0;
}
BOOL is_port_available(int nPort)
{
TCHAR szPort[15];
COMMCONFIG cc;
DWORD dwCCSize;
sprintf(szPort, "COM%d", nPort);
// Check if this port is available
dwCCSize = sizeof(cc);
return GetDefaultCommConfig(szPort, &cc, &dwCCSize);
}
// Path to the serial port is OS-dependant.
// Try to guess what we should use.
#define MAX_SERIAL_PORT_WIN 255
char **
uart_list_ports(void)
{
char **availablePorts = malloc((1 + MAX_SERIAL_PORT_WIN) * sizeof(char *));
if (!availablePorts) {
perror("malloc");
return availablePorts;
}
int curIndex = 0;
int i;
for (i = 1; i <= MAX_SERIAL_PORT_WIN; i++) {
if (is_port_available(i)) {
availablePorts[curIndex] = (char *)malloc(10);
if (!availablePorts[curIndex]) {
perror("malloc");
break;
}
sprintf(availablePorts[curIndex], "COM%d", i);
// printf("found candidate port: %s\n", availablePorts[curIndex]);
curIndex++;
}
}
availablePorts[curIndex] = NULL;
return availablePorts;
}

View File

@ -0,0 +1,61 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
* Copyright (C) 2013 Alex Lian
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include "log-internal.h"
#include <stdio.h>
#include <stdarg.h>
#include <strsafe.h>
static void
log_output_debug(const char *format, va_list args)
{
char buffer[1024];
HRESULT hr = StringCbVPrintf(buffer, sizeof(buffer), format, args);
// Spew what we got, even if the buffer is not sized large enough
if ((STRSAFE_E_INSUFFICIENT_BUFFER == hr) || (S_OK == hr))
OutputDebugString(buffer);
}
void
log_vput_internal(const char *format, va_list args)
{
vfprintf(stderr, format, args);
// Additional windows output to the debug window for debugging purposes
log_output_debug(format, args);
}
void
log_put_internal(const char *format, ...)
{
va_list va;
va_start(va, format);
vfprintf(stderr, format, va);
// Additional windows output to the debug window for debugging purposes
log_output_debug(format, va);
va_end(va);
}

57
contrib/win32/nfc.def Normal file
View File

@ -0,0 +1,57 @@
LIBRARY libnfc
VERSION 1.7
EXPORTS
nfc_init
nfc_exit
nfc_register_driver
nfc_open
nfc_close
nfc_abort_command
nfc_list_devices
nfc_idle
nfc_initiator_init
nfc_initiator_init_secure_element
nfc_initiator_select_passive_target
nfc_initiator_list_passive_targets
nfc_initiator_poll_target
nfc_initiator_select_dep_target
nfc_initiator_poll_dep_target
nfc_initiator_deselect_target
nfc_initiator_transceive_bytes
nfc_initiator_transceive_bits
nfc_initiator_transceive_bytes_timed
nfc_initiator_transceive_bits_timed
nfc_initiator_target_is_present
nfc_target_init
nfc_target_send_bytes
nfc_target_receive_bytes
nfc_target_send_bits
nfc_target_receive_bits
nfc_strerror
nfc_strerror_r
nfc_perror
nfc_device_get_last_error
nfc_device_get_name
nfc_device_get_connstring
nfc_device_get_supported_modulation
nfc_device_get_supported_baud_rate
nfc_device_get_supported_baud_rate_target_mode
nfc_device_set_property_int
nfc_device_set_property_bool
nfc_emulate_target
iso14443a_crc
iso14443a_crc_append
iso14443b_crc
iso14443b_crc_append
iso14443a_locate_historical_bytes
nfc_free
nfc_version
nfc_device_get_information_about
str_nfc_modulation_type
str_nfc_baud_rate
str_nfc_target
pn53x_transceive
pn532_SAMConfiguration
pn53x_read_register
pn53x_write_register

View File

@ -0,0 +1,57 @@
LIBRARY nfc
VERSION 1.7
EXPORTS
nfc_init
nfc_exit
nfc_register_driver
nfc_open
nfc_close
nfc_abort_command
nfc_list_devices
nfc_idle
nfc_initiator_init
nfc_initiator_init_secure_element
nfc_initiator_select_passive_target
nfc_initiator_list_passive_targets
nfc_initiator_poll_target
nfc_initiator_select_dep_target
nfc_initiator_poll_dep_target
nfc_initiator_deselect_target
nfc_initiator_transceive_bytes
nfc_initiator_transceive_bits
nfc_initiator_transceive_bytes_timed
nfc_initiator_transceive_bits_timed
nfc_initiator_target_is_present
nfc_target_init
nfc_target_send_bytes
nfc_target_receive_bytes
nfc_target_send_bits
nfc_target_receive_bits
nfc_strerror
nfc_strerror_r
nfc_perror
nfc_device_get_last_error
nfc_device_get_name
nfc_device_get_connstring
nfc_device_get_supported_modulation
nfc_device_get_supported_baud_rate
nfc_device_get_supported_baud_rate_target_mode
nfc_device_set_property_int
nfc_device_set_property_bool
nfc_emulate_target
iso14443a_crc
iso14443a_crc_append
iso14443b_crc
iso14443b_crc_append
iso14443a_locate_historical_bytes
nfc_free
nfc_version
nfc_device_get_information_about
str_nfc_modulation_type
str_nfc_baud_rate
str_nfc_target
pn53x_transceive
pn532_SAMConfiguration
pn53x_read_register
pn53x_write_register

57
contrib/win32/stdlib.c Normal file
View File

@ -0,0 +1,57 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
* Copyright (C) 2013 Alex Lian
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
/**
* @file stdlib.c
* @brief Windows System compatibility
*/
// Handle platform specific includes
#include "contrib/windows.h"
//There is no setenv()and unsetenv() in windows,but we can use putenv() instead.
int setenv(const char *name, const char *value, int overwrite)
{
char *env = getenv(name);
if ((env && overwrite) || (!env)) {
char *str[32];
strcpy(str, name);
strcat(str, "=");
strcat(str, value);
return putenv(str);
}
return -1;
}
void unsetenv(const char *name)
{
char *str[32];
strcpy(str, name);
strcat(str, "=");
putenv(str);
}

View File

@ -0,0 +1,2 @@
EXTRA_DIST = \
select.h

View File

@ -1,13 +1,18 @@
/**
* Public platform independent Near Field Communication (NFC) library
*
* Copyright (C) 2009, Roel Verdult
*
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
@ -15,11 +20,10 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file buses.h
* @brief
*/
#include <nfc/nfc-types.h>
/**
* @file select.h
* @brief Dummy file to make the code compile under Windows
*/

48
contrib/win32/unistd.h Normal file
View File

@ -0,0 +1,48 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file unistd.h
* @brief This file intended to serve as a drop-in replacement for unistd.h on Windows
*/
#ifndef _UNISTD_H_
#define _UNISTD_H_
#include "contrib/windows.h"
// Needed by Sleep() under Windows
# include <winbase.h>
# define sleep(X) Sleep( X * 1000)
// With MinGW, getopt(3) is provided as separate header
#if defined(WIN32) && defined(__GNUC__) /* mingw compiler */
#include <getopt.h>
#endif
#endif /* _UNISTD_H_ */

View File

@ -0,0 +1,29 @@
1 VERSIONINFO
FILEVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0
PRODUCTVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x00040004L
FILETYPE @RC_FILE_TYPE@
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "Comments", "@RC_COMMENT@\0"
VALUE "CompanyName", "libnfc.org\0"
VALUE "FileDescription", "\0"
VALUE "FileVersion", "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.0\0"
VALUE "InternalName", "@RC_INTERNAL_NAME@ @WIN32_MODE@\0"
VALUE "LegalCopyright", "Copyright (C) @CURRENT_YEAR@\0"
VALUE "OriginalFilename", "@RC_ORIGINAL_NAME@\0"
VALUE "ProductName", "@PACKAGE_NAME@ @WIN32_MODE@\0"
VALUE "ProductVersion", "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.0\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1252
END
END

64
contrib/windows.h Normal file
View File

@ -0,0 +1,64 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
* Copyright (C) 2011 Glenn Ergeerts
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file windows.h
* @brief Provide some windows related hacks due to lack of POSIX compat
*/
#ifndef __WINDOWS_H__
#define __WINDOWS_H__
# include <windows.h>
# include <winerror.h>
# include "win32/err.h"
# if defined (__MINGW32__)
/*
* Cheating here on the snprintf to incorporate the format argument
* into the VA_ARGS. Else we get MinGW errors regarding number of arguments
* if doing a fixed string with no arguments.
*/
# define snprintf(S, n, ...) sprintf(S, __VA_ARGS__)
# define pipe(fds) _pipe(fds, 5000, _O_BINARY)
# define ETIMEDOUT WSAETIMEDOUT
# define ENOTSUP WSAEOPNOTSUPP
# define ECONNABORTED WSAECONNABORTED
# else
#ifndef _MSC_VER
# define snprintf sprintf_s
#endif
# define strdup _strdup
# endif
/*
* setenv and unsetenv are not Windows compliant nor implemented in MinGW.
* These declarations get rid of the "implicit declaration warning."
*/
int setenv(const char *name, const char *value, int overwrite);
void unsetenv(const char *name);
#endif

67
debian/changelog vendored
View File

@ -1,67 +0,0 @@
libnfc (1.3.3-0) unstable; urgency=low
* New upstream release.
-- Romuald Conty <rconty@il4p.fr> Thu, 17 Feb 2010 15:42:42 +0100
libnfc (1.3.2-0) unstable; urgency=low
* New upstream release.
-- Romuald Conty <rconty@il4p.fr> Fri, 29 Jan 2010 15:42:42 +0100
libnfc (1.3.1-0) unstable; urgency=low
* New upstream release.
-- Romuald Conty <rconty@il4p.fr> Mon, 25 Jan 2010 11:42:42 +0100
libnfc (1.3.0-0) unstable; urgency=low
* New upstream release.
-- Romuald Conty <rconty@il4p.fr> Thu, 14 Jan 2010 16:42:42 +0100
libnfc (1.2.1-4) unstable; urgency=low
* Add udev rules for USB PN53x.
-- Romuald Conty <rconty@il4p.fr> Fri, 20 Nov 2009 16:42:42 +0100
libnfc (1.2.1-3) unstable; urgency=low
* Don't use CDBS anymore, should now cross compile.
-- Romuald Conty <rconty@il4p.fr> Thu, 29 Sep 2009 9:42:42 +0100
libnfc (1.2.1-2) unstable; urgency=low
* Add missing dependencies for ACR122 devices (pcscd).
-- Romuald Conty <rconty@il4p.fr> Fri, 23 Sep 2009 16:42:42 +0100
libnfc (1.2.1-1) unstable; urgency=low
* Description have been updated.
* Provided binairies should not be consider as tools but as examples.
-- Romuald Conty <rconty@il4p.fr> Fri, 03 Sep 2009 18:42:42 +0100
libnfc (1.2.1-0) unstable; urgency=low
* New upstream version.
-- Romuald Conty <rconty@il4p.fr> Fri, 24 Jul 2009 16:42:42 +0100
libnfc (1.2.0-0) unstable; urgency=low
* New upstream version.
-- Romuald Conty <rconty@il4p.fr> Thu, 23 Jul 2009 15:42:42 +0100
libnfc (1.1.0-0) unstable; urgency=low
* Initial debian package.
-- Romuald Conty <rconty@il4p.fr> Wed, 22 Apr 2009 10:42:42 +0100

1
debian/compat vendored
View File

@ -1 +0,0 @@
7

29
debian/control vendored
View File

@ -1,29 +0,0 @@
Source: libnfc
Section: devel
Priority: optional
Maintainer: Romuald Conty <rconty@il4p.fr>
Build-Depends: debhelper (>= 5.0.37.2), automake, libtool, pkg-config, libusb-dev, libpcsclite-dev
Standards-Version: 3.7.3
Homepage: http://www.libnfc.org/
Package: libnfc0
Architecture: any
Depends: ${shlibs:Depends}, libusb-0.1-4, libpcsclite1 (>= 1.5), libccid (>= 1.3.10), pcscd (>= 1.5)
Description: Near Field Communication (NFC) library
libnfc is a Free Software library for Near Field Communication. Supported NFC hardware
devices are, theorically, all hardware based on the NXP PN531, PN532 or PN533 NFC
controller chip.
Package: libnfc-dev
Architecture: any
Depends: libnfc0, libusb-dev, libpcsclite-dev
Description: Near Field Communication library (development files)
libnfc is a Free Software library for Near Field Communication. Supported NFC hardware
devices are, theorically, all hardware based on the NXP PN531, PN532 or PN533 NFC
controller chip.
Package: libnfc-examples
Architecture: any
Depends: libnfc0
Description: Near Field Communication examples
Some examples are provided with libnfc to show basics functions (nfc-list, nfc-anticol, etc.).

27
debian/copyright vendored
View File

@ -1,27 +0,0 @@
This package was debianized by Romuald Conty <romuald.conty@free.fr> on
Wed, 22 Apr 2009 10:42:42 +0100.
It was downloaded from: http://www.libnfc.org/
Copyright (C) 2009 by Roel Verdult <roel@libnfc.org>
License: GNU Lesser General Public License version 3
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
as published by the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
On Debian GNU/Linux systems, the complete text of the GNU General Public
License, version 3, can be found in `/usr/share/common-licenses/LGPL-3'.
The Debian packaging is (C) 2009, Romuald Conty <romuald.conty@free.fr> and
is licensed under the GPL, see `/usr/share/common-licenses/GPL'.

View File

@ -1,3 +0,0 @@
debian/tmp/usr/include/nfc
debian/tmp/usr/lib/libnfc.{a,la,so}
debian/tmp/usr/lib/pkgconfig/libnfc.pc

View File

@ -1,2 +0,0 @@
debian/tmp/usr/bin/nfc-*
debian/tmp/usr/share/man/man1/nfc-*

View File

@ -1,2 +0,0 @@
debian/tmp/usr/lib/libnfc.so.*
pn53x.rules etc/udev/rules.d/

117
debian/rules vendored
View File

@ -1,117 +0,0 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
CROSS_CFLAGS=-I/usr/$(DEB_HOST_GNU_TYPE)/include -I/usr/$(DEB_HOST_GNU_TYPE)/usr/include
LDFLAGS=-L/usr/$(DEB_HOST_GNU_TYPE)/lib -L/usr/$(DEB_HOST_GNU_TYPE)/usr/lib
MAKE_LDFLAGS=-inst-prefix-dir /usr/$(DEB_HOST_GNU_TYPE) -Wl,-rpath-link /usr/$(DEB_HOST_GNU_TYPE)/lib -Wl,-rpath-link /usr/$(DEB_HOST_GNU_TYPE)/usr/lib
DH_STRIP=
DH_SHLIBDEPS=
else
CROSS= --build $(DEB_BUILD_GNU_TYPE)
DH_STRIP=dh_strip
DH_SHLIBDEPS=dh_shlibdeps
endif
# shared library versions, option 1
version=2.0.5
major=2
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
#version=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
#major=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
config.status: configure
dh_testdir
# Add here commands to configure the package.
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
cp -f /usr/share/misc/config.guess config.guess
endif
./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS) $(CROSS_CFLAGS)" LDFLAGS="-Wl,-z,defs $(LDFLAGS)"
build: build-stamp
build-stamp: config.status
dh_testdir
# Add here commands to compile the package.
$(MAKE) LDFLAGS="$(MAKE_LDFLAGS) $(LDFLAGS)"
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
[ ! -f Makefile ] || $(MAKE) distclean
rm -f config.sub config.guess
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/tmp
$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs ChangeLog
dh_installdocs
dh_installexamples
dh_install
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
$(DH_STRIP)
dh_compress
dh_fixperms
# dh_perl
# dh_python
dh_makeshlibs
dh_installdeb
$(DH_SHLIBDEPS)
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

55
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,55 @@
SET(EXAMPLES-SOURCES
nfc-anticol
nfc-dep-initiator
nfc-dep-target
nfc-emulate-forum-tag2
nfc-emulate-tag
nfc-emulate-uid
nfc-mfsetuid
nfc-poll
nfc-relay
nfc-st25tb
pn53x-diagnose
pn53x-sam
pn53x-tamashell
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libnfc)
# Examples
FOREACH(source ${EXAMPLES-SOURCES})
SET (TARGETS ${source}.c)
IF(WIN32)
SET(RC_COMMENT "${PACKAGE_NAME} example")
SET(RC_INTERNAL_NAME ${source})
SET(RC_ORIGINAL_NAME ${source}.exe)
# RC_FILE_TYPE: VFT_APP
SET(RC_FILE_TYPE 0x00000001L)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc @ONLY)
LIST(APPEND TARGETS ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc)
IF(${source} MATCHES "nfc-st25tb")
LIST(APPEND TARGETS ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/getopt.c)
ENDIF()
ENDIF(WIN32)
ADD_EXECUTABLE(${source} ${TARGETS})
TARGET_LINK_LIBRARIES(${source} nfc)
TARGET_LINK_LIBRARIES(${source} nfcutils)
INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT examples)
ENDFOREACH(source)
#install required libraries
IF(WIN32)
INCLUDE(InstallRequiredSystemLibraries)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/FixBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake @ONLY)
INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake)
ENDIF(WIN32)
IF(NOT WIN32)
# Manuals for the examples
FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1")
INSTALL(FILES ${manuals} DESTINATION ${SHARE_INSTALL_PREFIX}/man/man1 COMPONENT manuals)
ENDIF(NOT WIN32)

107
examples/Makefile.am Normal file
View File

@ -0,0 +1,107 @@
SUBDIRS = pn53x-tamashell-scripts
bin_PROGRAMS = \
nfc-anticol \
nfc-dep-initiator \
nfc-dep-target \
nfc-emulate-forum-tag2 \
nfc-emulate-tag \
nfc-emulate-uid \
nfc-mfsetuid \
nfc-poll \
nfc-relay \
nfc-st25tb \
pn53x-diagnose \
pn53x-sam
if POSIX_ONLY_EXAMPLES_ENABLED
bin_PROGRAMS += \
pn53x-tamashell
endif
check_PROGRAMS = \
quick_start_example1 \
quick_start_example2
# set the include path found by configure
AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS)
AM_CFLAGS = -I$(top_srcdir)/libnfc -I$(top_srcdir)
nfc_poll_SOURCES = nfc-poll.c
nfc_poll_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
nfc_anticol_SOURCES = nfc-anticol.c
nfc_anticol_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
nfc_relay_SOURCES = nfc-relay.c
nfc_relay_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
nfc_emulate_forum_tag2_SOURCES = nfc-emulate-forum-tag2.c
nfc_emulate_forum_tag2_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
nfc_emulate_tag_SOURCES = nfc-emulate-tag.c
nfc_emulate_tag_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
nfc_emulate_uid_SOURCES = nfc-emulate-uid.c
nfc_emulate_uid_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
nfc_dep_target_SOURCES = nfc-dep-target.c
nfc_dep_target_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
nfc_dep_initiator_SOURCES = nfc-dep-initiator.c
nfc_dep_initiator_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
nfc_mfsetuid_SOURCES = nfc-mfsetuid.c
nfc_mfsetuid_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
nfc_st25tb_SOURCES = nfc-st25tb.c
nfc_st25tb_LDADD = $(top_builddir)/libnfc/libnfc.la
pn53x_diagnose_SOURCES = pn53x-diagnose.c
pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
pn53x_sam_SOURCES = pn53x-sam.c
pn53x_sam_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
pn53x_tamashell_SOURCES = pn53x-tamashell.c
pn53x_tamashell_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
pn53x_tamashell_CFLAGS = @READLINE_INCLUDES@ -I$(top_srcdir)
pn53x_tamashell_LDFLAGS = @READLINE_LIBS@
quick_start_example1_SOURCES = doc/quick_start_example1.c
quick_start_example1_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
quick_start_example2_SOURCES = doc/quick_start_example2.c
quick_start_example2_LDADD = $(top_builddir)/libnfc/libnfc.la \
$(top_builddir)/utils/libnfcutils.la
dist_man_MANS = \
nfc-anticol.1 \
nfc-dep-initiator.1 \
nfc-dep-target.1 \
nfc-emulate-tag.1 \
nfc-emulate-uid.1 \
nfc-poll.1 \
nfc-relay.1 \
nfc-mfsetuid.1 \
pn53x-diagnose.1 \
pn53x-sam.1 \
pn53x-tamashell.1 \
nfc-emulate-forum-tag2.1
EXTRA_DIST = CMakeLists.txt

View File

@ -0,0 +1,86 @@
/**
* @file quick_start_example1.c
* @brief Quick start example that presents how to use libnfc
*/
// To compile this simple example:
// $ gcc -o quick_start_example1 quick_start_example1.c -lnfc
#include <stdlib.h>
#include <nfc/nfc.h>
static void
print_hex(const uint8_t *pbtData, const size_t szBytes)
{
size_t szPos;
for (szPos = 0; szPos < szBytes; szPos++) {
printf("%02x ", pbtData[szPos]);
}
printf("\n");
}
int
main(int argc, const char *argv[])
{
nfc_device *pnd;
nfc_target nt;
// Allocate only a pointer to nfc_context
nfc_context *context;
// Initialize libnfc and set the nfc_context
nfc_init(&context);
if (context == NULL) {
printf("Unable to init libnfc (malloc)\n");
exit(EXIT_FAILURE);
}
// Display libnfc version
const char *acLibnfcVersion = nfc_version();
(void)argc;
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
// Open, using the first available NFC device which can be in order of selection:
// - default device specified using environment variable or
// - first specified device in libnfc.conf (/etc/nfc) or
// - first specified device in device-configuration directory (/etc/nfc/devices.d) or
// - first auto-detected (if feature is not disabled in libnfc.conf) device
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
printf("ERROR: %s\n", "Unable to open NFC device.");
exit(EXIT_FAILURE);
}
// Set opened NFC device to initiator mode
if (nfc_initiator_init(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init");
exit(EXIT_FAILURE);
}
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
// Poll for a ISO14443A (MIFARE) tag
const nfc_modulation nmMifare = {
.nmt = NMT_ISO14443A,
.nbr = NBR_106,
};
if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) > 0) {
printf("The following (NFC) ISO14443A tag was found:\n");
printf(" ATQA (SENS_RES): ");
print_hex(nt.nti.nai.abtAtqa, 2);
printf(" UID (NFCID%c): ", (nt.nti.nai.abtUid[0] == 0x08 ? '3' : '1'));
print_hex(nt.nti.nai.abtUid, nt.nti.nai.szUidLen);
printf(" SAK (SEL_RES): ");
print_hex(&nt.nti.nai.btSak, 1);
if (nt.nti.nai.szAtsLen) {
printf(" ATS (ATR): ");
print_hex(nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
}
}
// Close NFC device
nfc_close(pnd);
// Release the context
nfc_exit(context);
exit(EXIT_SUCCESS);
}

View File

@ -0,0 +1,83 @@
/**
* @file quick_start_example2.c
* @brief Quick start example that presents how to use libnfc
*/
// This is same example as quick_start_example1.c but using
// some helper functions existing in libnfc.
// Those functions are not available yet in a library
// so binary object must be linked statically:
// $ gcc -o quick_start_example2 -lnfc -I../.. quick_start_example2.c ../../utils/nfc-utils.o
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <stdlib.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
int
main(int argc, const char *argv[])
{
nfc_device *pnd;
nfc_target nt;
// Allocate only a pointer to nfc_context
nfc_context *context;
// Initialize libnfc and set the nfc_context
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
// Display libnfc version
const char *acLibnfcVersion = nfc_version();
(void)argc;
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
// Open, using the first available NFC device which can be in order of selection:
// - default device specified using environment variable or
// - first specified device in libnfc.conf (/etc/nfc) or
// - first specified device in device-configuration directory (/etc/nfc/devices.d) or
// - first auto-detected (if feature is not disabled in libnfc.conf) device
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
ERR("%s", "Unable to open NFC device.");
exit(EXIT_FAILURE);
}
// Set opened NFC device to initiator mode
if (nfc_initiator_init(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init");
exit(EXIT_FAILURE);
}
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
// Poll for a ISO14443A (MIFARE) tag
const nfc_modulation nmMifare = {
.nmt = NMT_ISO14443A,
.nbr = NBR_106,
};
if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) > 0) {
printf("The following (NFC) ISO14443A tag was found:\n");
printf(" ATQA (SENS_RES): ");
print_hex(nt.nti.nai.abtAtqa, 2);
printf(" UID (NFCID%c): ", (nt.nti.nai.abtUid[0] == 0x08 ? '3' : '1'));
print_hex(nt.nti.nai.abtUid, nt.nti.nai.szUidLen);
printf(" SAK (SEL_RES): ");
print_hex(&nt.nti.nai.btSak, 1);
if (nt.nti.nai.szAtsLen) {
printf(" ATS (ATR): ");
print_hex(nt.nti.nai.abtAts, nt.nti.nai.szAtsLen);
}
}
// Close NFC device
nfc_close(pnd);
// Release the context
nfc_exit(context);
exit(EXIT_SUCCESS);
}

39
examples/nfc-anticol.1 Normal file
View File

@ -0,0 +1,39 @@
.TH nfc-anticol 1 "June 26, 2009" "libnfc" "libnfc's examples"
.SH NAME
nfc-anticol \- Demonstration of NFC anti-collision command line tool based on libnfc
.SH SYNOPSIS
.B nfc-anticol
.SH DESCRIPTION
.B nfc-anticol
is an anti-collision demonstration tool for ISO/IEC 14443-A tags, performed by
custom constructed frames. The first frame must be a short frame which is only
7 bits long. Commercial SDK's often don't support a feature to send frames that
are not a multiple of 8 bits (1 byte) long. This makes it impossible to do the
anti-collision yourself. The developer has to rely on closed proprietary
software and should hope it does not contain vulnerabilities during the
anti-collision phase. Performing the anti-collision using custom frames could
protect against a malicious tag that, for example, violates the standard by
sending frames with unsupported lengths.
Note that this is only a demonstration tool, which can not handle multiple tags
as real life anti-collisions with multiple tags generate "messy" bits which
are neither 0 nor 1.
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Roel Verdult <roel@libnfc.org>
.PP
This manual page was written by Romuald Conty <romuald@libnfc.org>.
It is licensed under the terms of the GNU GPL (version 2 or later).

364
examples/nfc-anticol.c Normal file
View File

@ -0,0 +1,364 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-anticol.c
* @brief Generates one ISO14443-A anti-collision process "by-hand"
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
#define SAK_FLAG_ATS_SUPPORTED 0x20
#define MAX_FRAME_LEN 264
static uint8_t abtRx[MAX_FRAME_LEN];
static int szRxBits;
static size_t szRx = sizeof(abtRx);
static uint8_t abtRawUid[12];
static uint8_t abtAtqa[2];
static uint8_t abtSak;
static uint8_t abtAts[MAX_FRAME_LEN];
static uint8_t szAts = 0;
static size_t szCL = 1;//Always start with Cascade Level 1 (CL1)
static nfc_device *pnd;
bool quiet_output = false;
bool force_rats = false;
bool timed = false;
bool iso_ats_supported = false;
// ISO14443A Anti-Collision Commands
uint8_t abtReqa[1] = { 0x26 };
uint8_t abtSelectAll[2] = { 0x93, 0x20 };
uint8_t abtSelectTag[9] = { 0x93, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
uint8_t abtRats[4] = { 0xe0, 0x50, 0x00, 0x00 };
uint8_t abtHalt[4] = { 0x50, 0x00, 0x00, 0x00 };
#define CASCADE_BIT 0x04
static bool
transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
{
uint32_t cycles = 0;
// Show transmitted command
if (!quiet_output) {
printf("Sent bits: ");
print_hex_bits(pbtTx, szTxBits);
}
// Transmit the bit frame command, we don't use the arbitrary parity feature
if (timed) {
if ((szRxBits = nfc_initiator_transceive_bits_timed(pnd, pbtTx, szTxBits, NULL, abtRx, sizeof(abtRx), NULL, &cycles)) < 0)
return false;
if ((!quiet_output) && (szRxBits > 0)) {
printf("Response after %u cycles\n", cycles);
}
} else {
if ((szRxBits = nfc_initiator_transceive_bits(pnd, pbtTx, szTxBits, NULL, abtRx, sizeof(abtRx), NULL)) < 0)
return false;
}
// Show received answer
if (!quiet_output) {
printf("Received bits: ");
print_hex_bits(abtRx, szRxBits);
}
// Succesful transfer
return true;
}
static bool
transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
{
uint32_t cycles = 0;
// Show transmitted command
if (!quiet_output) {
printf("Sent bits: ");
print_hex(pbtTx, szTx);
}
int res;
// Transmit the command bytes
if (timed) {
if ((res = nfc_initiator_transceive_bytes_timed(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), &cycles)) < 0)
return false;
if ((!quiet_output) && (res > 0)) {
printf("Response after %u cycles\n", cycles);
}
} else {
if ((res = nfc_initiator_transceive_bytes(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
return false;
}
szRx = res;
// Show received answer
if (!quiet_output) {
printf("Received bits: ");
print_hex(abtRx, szRx);
}
// Succesful transfer
return true;
}
static void
print_usage(char *argv[])
{
printf("Usage: %s [OPTIONS]\n", argv[0]);
printf("Options:\n");
printf("\t-h\tHelp. Print this message.\n");
printf("\t-q\tQuiet mode. Suppress output of READER and EMULATOR data (improves timing).\n");
printf("\t-f\tForce RATS.\n");
printf("\t-t\tMeasure response time (in cycles).\n");
}
int
main(int argc, char *argv[])
{
int arg;
// Get commandline options
for (arg = 1; arg < argc; arg++) {
if (0 == strcmp(argv[arg], "-h")) {
print_usage(argv);
exit(EXIT_SUCCESS);
} else if (0 == strcmp(argv[arg], "-q")) {
quiet_output = true;
} else if (0 == strcmp(argv[arg], "-f")) {
force_rats = true;
} else if (0 == strcmp(argv[arg], "-t")) {
timed = true;
} else {
ERR("%s is not supported option.", argv[arg]);
print_usage(argv);
exit(EXIT_FAILURE);
}
}
nfc_context *context;
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
// Try to open the NFC reader
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
ERR("Error opening NFC reader");
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Initialise NFC device as "initiator"
if (nfc_initiator_init(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Configure the CRC
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Use raw send/receive methods
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Disable 14443-4 autoswitching
if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC reader: %s opened\n\n", nfc_device_get_name(pnd));
// Send the 7 bits request command specified in ISO 14443A (0x26)
if (!transmit_bits(abtReqa, 7)) {
printf("Error: No tag available\n");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
memcpy(abtAtqa, abtRx, 2);
// Anti-collision
transmit_bytes(abtSelectAll, 2);
// Check answer
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
printf("WARNING: BCC check failed!\n");
}
// Save the UID CL1
memcpy(abtRawUid, abtRx, 4);
//Prepare and send CL1 Select-Command
memcpy(abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append(abtSelectTag, 7);
transmit_bytes(abtSelectTag, 9);
abtSak = abtRx[0];
// Test if we are dealing with a CL2
if (abtSak & CASCADE_BIT) {
szCL = 2;//or more
// Check answer
if (abtRawUid[0] != 0x88) {
printf("WARNING: Cascade bit set but CT != 0x88!\n");
}
}
if (szCL == 2) {
// We have to do the anti-collision for cascade level 2
// Prepare CL2 commands
abtSelectAll[0] = 0x95;
// Anti-collision
transmit_bytes(abtSelectAll, 2);
// Check answer
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
printf("WARNING: BCC check failed!\n");
}
// Save UID CL2
memcpy(abtRawUid + 4, abtRx, 4);
// Selection
abtSelectTag[0] = 0x95;
memcpy(abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append(abtSelectTag, 7);
transmit_bytes(abtSelectTag, 9);
abtSak = abtRx[0];
// Test if we are dealing with a CL3
if (abtSak & CASCADE_BIT) {
szCL = 3;
// Check answer
if (abtRawUid[0] != 0x88) {
printf("WARNING: Cascade bit set but CT != 0x88!\n");
}
}
if (szCL == 3) {
// We have to do the anti-collision for cascade level 3
// Prepare and send CL3 AC-Command
abtSelectAll[0] = 0x97;
transmit_bytes(abtSelectAll, 2);
// Check answer
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
printf("WARNING: BCC check failed!\n");
}
// Save UID CL3
memcpy(abtRawUid + 8, abtRx, 4);
// Prepare and send final Select-Command
abtSelectTag[0] = 0x97;
memcpy(abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append(abtSelectTag, 7);
transmit_bytes(abtSelectTag, 9);
abtSak = abtRx[0];
}
}
// Request ATS, this only applies to tags that support ISO 14443A-4
if (abtRx[0] & SAK_FLAG_ATS_SUPPORTED) {
iso_ats_supported = true;
}
if ((abtRx[0] & SAK_FLAG_ATS_SUPPORTED) || force_rats) {
iso14443a_crc_append(abtRats, 2);
if (transmit_bytes(abtRats, 4)) {
memcpy(abtAts, abtRx, szRx);
szAts = szRx;
}
}
// Done, halt the tag now
iso14443a_crc_append(abtHalt, 2);
transmit_bytes(abtHalt, 4);
printf("\nFound tag with\n UID: ");
switch (szCL) {
case 1:
printf("%02x%02x%02x%02x", abtRawUid[0], abtRawUid[1], abtRawUid[2], abtRawUid[3]);
break;
case 2:
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
printf("%02x%02x%02x%02x", abtRawUid[4], abtRawUid[5], abtRawUid[6], abtRawUid[7]);
break;
case 3:
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
printf("%02x%02x%02x", abtRawUid[5], abtRawUid[6], abtRawUid[7]);
printf("%02x%02x%02x%02x", abtRawUid[8], abtRawUid[9], abtRawUid[10], abtRawUid[11]);
break;
}
printf("\n");
printf("ATQA: %02x%02x\n SAK: %02x\n", abtAtqa[1], abtAtqa[0], abtSak);
if (szAts > 1) { // if = 1, it's not actual ATS but error code
if (force_rats && ! iso_ats_supported) {
printf(" RATS forced\n");
}
printf(" ATS: ");
print_hex(abtAts, szAts);
}
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

View File

@ -0,0 +1,36 @@
.TH nfc-dep-initiator 1 "October 8, 2010" "libnfc" "libnfc's examples"
.SH NAME
nfc-dep-initiator \- Demonstration tool to send/received data as D.E.P. initiator
.SH SYNOPSIS
.B nfc-dep-initiator
.SH DESCRIPTION
.B nfc-dep-initiator
is a demonstration tool for putting NFC device in D.E.P. initiator mode.
This example will attempt to select a passive D.E.P. target and exchange a
simple "Hello" data with target.
Note: this example is designed to work with a D.E.P. target driven by
\fBnfc-dep-target\fP
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Roel Verdult <roel@libnfc.org>,
.br
Romuald Conty <romuald@libnfc.org>.
.PP
This manual page was written by Romuald Conty <romuald@libnfc.org>.
It is licensed under the terms of the GNU GPL (version 2 or later).

View File

@ -0,0 +1,136 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-dep-initiator.c
* @brief Turns the NFC device into a D.E.P. initiator (see NFCIP-1)
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
#define MAX_FRAME_LEN 264
static nfc_device *pnd;
static nfc_context *context;
static void stop_dep_communication(int sig)
{
(void) sig;
if (pnd != NULL) {
nfc_abort_command(pnd);
} else {
nfc_exit(context);
exit(EXIT_FAILURE);
}
}
int
main(int argc, const char *argv[])
{
nfc_target nt;
uint8_t abtRx[MAX_FRAME_LEN];
uint8_t abtTx[] = "Hello World!";
if (argc > 1) {
printf("Usage: %s\n", argv[0]);
exit(EXIT_FAILURE);
}
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
ERR("Unable to open NFC device.");
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC device: %s\n opened", nfc_device_get_name(pnd));
signal(SIGINT, stop_dep_communication);
if (nfc_initiator_init(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
if (nfc_initiator_select_dep_target(pnd, NDM_PASSIVE, NBR_212, NULL, &nt, 1000) < 0) {
nfc_perror(pnd, "nfc_initiator_select_dep_target");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
print_nfc_target(&nt, false);
printf("Sending: %s\n", abtTx);
int res;
if ((res = nfc_initiator_transceive_bytes(pnd, abtTx, sizeof(abtTx), abtRx, sizeof(abtRx), 0)) < 0) {
nfc_perror(pnd, "nfc_initiator_transceive_bytes");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
abtRx[res] = 0;
printf("Received: %s\n", abtRx);
if (nfc_initiator_deselect_target(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_deselect_target");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

36
examples/nfc-dep-target.1 Normal file
View File

@ -0,0 +1,36 @@
.TH nfc-dep-target 1 "October 8, 2010" "libnfc" "libnfc's examples"
.SH NAME
nfc-dep-target \- Demonstration tool to send/received data as D.E.P. target
.SH SYNOPSIS
.B nfc-dep-target
.SH DESCRIPTION
.B nfc-dep-target
is a demonstration tool for putting NFC device in D.E.P. target mode.
This example will listen for a D.E.P. initiator and exchange a simple "Hello"
data with initiator.
Note: this example is designed to work with a D.E.P. initiator driven by
\fBnfc-dep-initiator\fP.
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Roel Verdult <roel@libnfc.org>,
.br
Romuald Conty <romuald@libnfc.org>.
.PP
This manual page was written by Romuald Conty <romuald@libnfc.org>.
It is licensed under the terms of the GNU GPL (version 2 or later).

167
examples/nfc-dep-target.c Normal file
View File

@ -0,0 +1,167 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-dep-target.c
* @brief Turns the NFC device into a D.E.P. target (see NFCIP-1)
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
#define MAX_FRAME_LEN 264
static nfc_device *pnd;
static nfc_context *context;
static void stop_dep_communication(int sig)
{
(void) sig;
if (pnd != NULL) {
nfc_abort_command(pnd);
} else {
nfc_exit(context);
exit(EXIT_FAILURE);
}
}
int
main(int argc, const char *argv[])
{
uint8_t abtRx[MAX_FRAME_LEN];
int szRx;
uint8_t abtTx[] = "Hello Mars!";
if (argc > 1) {
printf("Usage: %s\n", argv[0]);
exit(EXIT_FAILURE);
}
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
#define MAX_DEVICE_COUNT 2
nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t szDeviceFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
// Little hack to allow using nfc-dep-initiator & nfc-dep-target from
// the same machine: if there is more than one readers opened
// nfc-dep-target will open the second reader
// (we hope they're always detected in the same order)
if (szDeviceFound == 1) {
pnd = nfc_open(context, connstrings[0]);
} else if (szDeviceFound > 1) {
pnd = nfc_open(context, connstrings[1]);
} else {
printf("No device found.\n");
nfc_exit(context);
exit(EXIT_FAILURE);
}
nfc_target nt = {
.nm = {
.nmt = NMT_DEP,
.nbr = NBR_UNDEFINED
},
.nti = {
.ndi = {
.abtNFCID3 = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xff, 0x00, 0x00 },
.szGB = 4,
.abtGB = { 0x12, 0x34, 0x56, 0x78 },
.ndm = NDM_UNDEFINED,
/* These bytes are not used by nfc_target_init: the chip will provide them automatically to the initiator */
.btDID = 0x00,
.btBS = 0x00,
.btBR = 0x00,
.btTO = 0x00,
.btPP = 0x01,
},
},
};
if (pnd == NULL) {
printf("Unable to open NFC device.\n");
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
signal(SIGINT, stop_dep_communication);
printf("NFC device will now act as: ");
print_nfc_target(&nt, false);
printf("Waiting for initiator request...\n");
if ((szRx = nfc_target_init(pnd, &nt, abtRx, sizeof(abtRx), 0)) < 0) {
nfc_perror(pnd, "nfc_target_init");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("Initiator request received. Waiting for data...\n");
if ((szRx = nfc_target_receive_bytes(pnd, abtRx, sizeof(abtRx), 0)) < 0) {
nfc_perror(pnd, "nfc_target_receive_bytes");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
abtRx[(size_t) szRx] = '\0';
printf("Received: %s\n", abtRx);
printf("Sending: %s\n", abtTx);
if (nfc_target_send_bytes(pnd, abtTx, sizeof(abtTx), 0) < 0) {
nfc_perror(pnd, "nfc_target_send_bytes");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("Data sent.\n");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

View File

@ -0,0 +1,52 @@
.Dd September 19, 2012
.Dt NFC-EMULATE-FORUM-TAG2 1 URM
.Sh NAME
.Nm nfc-emulate-forum-tag2
.Nd NFC Forum tag type 2 emulation command line demonstration tool
.Sh SYNOPSIS
.Nm
.Sh DESCRIPTION
.Nm
is a demonstration tool that emulates a NFC-Forum Tag Type 2 with NDEF content.
.Pp
Some devices compliant with NFC-Forum Tag Type 2 can be used with this example,
in read mode only.
.Sh IMPORTANT
This example has been developed using PN533 USB hardware as target and Google
Nexus S phone as initiator.
.Pp
This is know to NOT work with Nokia 6212 Classic and could fail with several
NFC Forum compliant devices due to the following reasons:
.Pp
- The emulated target has only a 4-byte UID while most devices assume a
Tag Type 2 has always a 7-byte UID (as a real Mifare Ultralight tag);
.Pp
- The chip is emulating an ISO/IEC 14443-3 tag, without any hardware helper.
If the initiator have too strict timeouts for software-based emulation
(which is usually the case), this example will fail.
This is not a bug and we can't do anything using this hardware (PN531/PN533).
.Pp
ACR122 devices (like touchatag, etc.) can be used by this example, but if
something goes wrong, you will have to unplug/replug your device.
This is not a
.Em libnfc's
bug, this problem is due to ACR122's internal MCU in front of NFC chip (PN532).
.Sh BUGS
Please report any bugs on the
.Em libnfc
issue tracker at:
.Em https://github.com/nfc-tools/libnfc/issues
.Sh LICENCE
.Em libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.Em libnfc-utils
and
.Em libnfc-examples
are covered by the BSD 2-Clause license.
.Sh AUTHORS
.An Roel Verdult Aq roel@libnfc.org
.An Romain Tartière Aq romain@libnfc.org
.An Romuald Conty Aq romuald@libnfc.org
.Pp
This manual page was written by Romuald Conty.
It is licensed under the terms of the GNU GPL (version 2 or later).

View File

@ -0,0 +1,223 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-emulate-forum-tag2.c
* @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 has 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 fail with
* several NFC Forum compliant devices due to the following reasons:
* - The emulated target has only a 4-byte UID while most devices assume a Tag
* Type 2 has always a 7-byte UID (as a real Mifare Ultralight tag);
* - The chip is emulating an ISO/IEC 14443-3 tag, without any hardware helper.
* If the initiator has too strict timeouts for software-based emulation
* (which is usually the case), this example will fail. This is not a bug
* and we can't do anything using this hardware (PN531/PN533).
*/
/*
* This implementation was written based on information provided by the
* following documents:
*
* NFC Forum Type 2 Tag Operation
* Technical Specification
* NFCForum-TS-Type-2-Tag_1.0 - 2007-07-09
*
* ISO/IEC 14443-3
* First edition - 2001-02-01
* Identification cards Contactless integrated circuit(s) cards Proximity cards
* Part 3: Initialization and anticollision
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <nfc/nfc.h>
#include <nfc/nfc-emulation.h>
#include "utils/nfc-utils.h"
static nfc_device *pnd;
static nfc_context *context;
static void
stop_emulation(int sig)
{
(void)sig;
if (pnd != NULL) {
nfc_abort_command(pnd);
} else {
nfc_exit(context);
exit(EXIT_FAILURE);
}
}
static uint8_t __nfcforum_tag2_memory_area[] = {
0x00, 0x00, 0x00, 0x00, // Block 0
0x00, 0x00, 0x00, 0x00,
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)
0x03, 33, 0xd1, 0x02, // Block 4 (NDEF)
0x1c, 0x53, 0x70, 0x91,
0x01, 0x09, 0x54, 0x02,
0x65, 0x6e, 0x4c, 0x69,
0x62, 0x6e, 0x66, 0x63,
0x51, 0x01, 0x0b, 0x55,
0x03, 0x6c, 0x69, 0x62,
0x6e, 0x66, 0x63, 0x2e,
0x6f, 0x72, 0x67, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
#define READ 0x30
#define WRITE 0xA2
#define SECTOR_SELECT 0xC2
#define HALT 0x50
static int
nfcforum_tag2_io(struct nfc_emulator *emulator, const uint8_t *data_in, const size_t data_in_len, uint8_t *data_out, const size_t data_out_len)
{
int res = 0;
uint8_t *nfcforum_tag2_memory_area = (uint8_t *)(emulator->user_data);
printf(" In: ");
print_hex(data_in, data_in_len);
switch (data_in[0]) {
case READ:
if (data_out_len >= 16) {
memcpy(data_out, nfcforum_tag2_memory_area + (data_in[1] * 4), 16);
res = 16;
} else {
res = -ENOSPC;
}
break;
case HALT:
printf("HALT sent\n");
res = -ECONNABORTED;
break;
default:
printf("Unknown command: 0x%02x\n", data_in[0]);
res = -ENOTSUP;
}
if (res < 0) {
ERR("%s (%d)", strerror(-res), -res);
} else {
printf(" Out: ");
print_hex(data_out, res);
}
return res;
}
int
main(int argc, char *argv[])
{
(void)argc;
(void)argv;
nfc_target nt = {
.nm = {
.nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED, // Will be updated by nfc_target_init()
},
.nti = {
.nai = {
.abtAtqa = { 0x00, 0x04 },
.abtUid = { 0x08, 0x00, 0xb0, 0x0b },
.szUidLen = 4,
.btSak = 0x00,
.szAtsLen = 0,
},
}
};
struct nfc_emulation_state_machine state_machine = {
.io = nfcforum_tag2_io
};
struct nfc_emulator emulator = {
.target = &nt,
.state_machine = &state_machine,
.user_data = __nfcforum_tag2_memory_area,
};
signal(SIGINT, stop_emulation);
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
ERR("Unable to open NFC device");
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
printf("Emulating NDEF tag now, please touch it with a second NFC device\n");
if (nfc_emulate_target(pnd, &emulator, 0) < 0) {
nfc_perror(pnd, argv[0]);
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

View File

@ -0,0 +1,55 @@
.TH nfc-emulate-tag 1 "October 8, 2010" "libnfc" "libnfc's examples"
.SH NAME
nfc-emulate-tag \- Simple tag emulation command line demonstration tool
.SH SYNOPSIS
.B nfc-emulate-tag
.SH DESCRIPTION
.B nfc-emulate-tag
is a simple tag emulation tool that demonstrates how emulation can be done
using libnfc.
Currently, this tool partially emulates a Mifare Mini: it is detected as
Mifare Mini but internal MIFARE proprietary commands are not yet implemented.
To be able to emulate a target, there are two main parts:
- communication: handle modulation, anticollision, etc.
- computation: process commands (input) and produce results (output).
This demonstration tool proposes a logical structure to handle communication and
a simple function to deal with computation.
To improve the target capabilities, we can now implement more allowed commands
in a single function: target_io()
Please note that, due to timing issues, it is very difficult to implement an
ISO14443-4 tag this way: RATS request expects a quick ATS answer. By the way,
even if you implement another kind of tag, timing issues are often the source of
problems like CRC or parity errors.
The OmniKey CardMan 5321 is known to be very large on timings and is a good
choice if you want to experiment with this emulator with a tolerant reader.
.SH IMPORTANT
ACR122 devices (like touchatag, etc.) can be used by this example (with
probably timing issue), but if something goes wrong, you will have to
unplug/replug your device. This is not a
.B libnfc's
bug, this problem is due to ACR122's internal MCU in front of NFC chip (PN532).
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Romuald Conty <romuald@libnfc.org>
.PP
This manual page was written by Romuald Conty <romuald@libnfc.org>.
It is licensed under the terms of the GNU GPL (version 2 or later).

302
examples/nfc-emulate-tag.c Normal file
View File

@ -0,0 +1,302 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-emulate-tag.c
* @brief Emulates a simple tag
*/
// Note that depending on the device (initiator) you'll use against, this
// emulator it might work or not. Some readers are very strict on responses
// timings, e.g. a Nokia NFC and will drop communication too soon for us.
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <signal.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
#define MAX_FRAME_LEN (264)
#define SAK_ISO14443_4_COMPLIANT 0x20
static uint8_t abtRx[MAX_FRAME_LEN];
static int szRx;
static nfc_context *context;
static nfc_device *pnd;
static bool quiet_output = false;
static bool init_mfc_auth = false;
static void
intr_hdlr(int sig)
{
(void) sig;
printf("\nQuitting...\n");
if (pnd != NULL) {
nfc_abort_command(pnd);
}
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
static bool
target_io(nfc_target *pnt, const uint8_t *pbtInput, const size_t szInput, uint8_t *pbtOutput, size_t *pszOutput)
{
bool loop = true;
*pszOutput = 0;
// Show transmitted command
if (!quiet_output) {
printf(" In: ");
print_hex(pbtInput, szInput);
}
if (szInput) {
switch (pbtInput[0]) {
case 0x30: // Mifare read
// block address is in pbtInput[1]
*pszOutput = 15;
strcpy((char *)pbtOutput, "You read block ");
pbtOutput[15] = pbtInput[1];
break;
case 0x50: // HLTA (ISO14443-3)
if (!quiet_output) {
printf("Initiator HLTA me. Bye!\n");
}
loop = false;
break;
case 0x60: // Mifare authA
case 0x61: // Mifare authB
// Let's give back a very random nonce...
*pszOutput = 2;
pbtOutput[0] = 0x12;
pbtOutput[1] = 0x34;
// Next commands will be without CRC
init_mfc_auth = true;
break;
case 0xe0: // RATS (ISO14443-4)
// Send ATS
*pszOutput = pnt->nti.nai.szAtsLen + 1;
pbtOutput[0] = pnt->nti.nai.szAtsLen + 1; // ISO14443-4 says that ATS contains ATS_Length as first byte
if (pnt->nti.nai.szAtsLen) {
memcpy(pbtOutput + 1, pnt->nti.nai.abtAts, pnt->nti.nai.szAtsLen);
}
break;
case 0xc2: // S-block DESELECT
if (!quiet_output) {
printf("Initiator DESELECT me. Bye!\n");
}
loop = false;
break;
default: // Unknown
if (!quiet_output) {
printf("Unknown frame, emulated target abort.\n");
}
loop = false;
}
}
// Show transmitted command
if ((!quiet_output) && *pszOutput) {
printf(" Out: ");
print_hex(pbtOutput, *pszOutput);
}
return loop;
}
static bool
nfc_target_emulate_tag(nfc_device *dev, nfc_target *pnt)
{
size_t szTx;
uint8_t abtTx[MAX_FRAME_LEN];
bool loop = true;
if ((szRx = nfc_target_init(dev, pnt, abtRx, sizeof(abtRx), 0)) < 0) {
nfc_perror(dev, "nfc_target_init");
return false;
}
while (loop) {
loop = target_io(pnt, abtRx, (size_t) szRx, abtTx, &szTx);
if (szTx) {
if (nfc_target_send_bytes(dev, abtTx, szTx, 0) < 0) {
nfc_perror(dev, "nfc_target_send_bytes");
return false;
}
}
if (loop) {
if (init_mfc_auth) {
if (nfc_device_set_property_bool(dev, NP_HANDLE_CRC, false) < 0) {
nfc_perror(pnd, "nfc_target_emulate_tag");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
init_mfc_auth = false;
}
if ((szRx = nfc_target_receive_bytes(dev, abtRx, sizeof(abtRx), 0)) < 0) {
nfc_perror(dev, "nfc_target_receive_bytes");
return false;
}
}
}
return true;
}
int
main(int argc, char *argv[])
{
(void) argc;
const char *acLibnfcVersion;
#ifdef WIN32
signal(SIGINT, (void (__cdecl *)(int)) intr_hdlr);
#else
signal(SIGINT, intr_hdlr);
#endif
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
// Display libnfc version
acLibnfcVersion = nfc_version();
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
// Try to open the NFC reader
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
ERR("Unable to open NFC device");
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
// Notes for ISO14443-A emulated tags:
// * Only short UIDs are supported
// If your UID is longer it will be truncated
// Therefore e.g. an UltraLight can only have short UID, which is
// typically badly handled by readers who still try to send their "0x95"
// * First byte of UID will be masked by 0x08 by the PN53x firmware
// as security countermeasure against real UID emulation
// Example of a Mifare Classic Mini
// Note that crypto1 is not implemented in this example
nfc_target nt = {
.nm = {
.nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED,
},
.nti = {
.nai = {
.abtAtqa = { 0x00, 0x04 },
.abtUid = { 0x08, 0xab, 0xcd, 0xef },
.btSak = 0x09,
.szUidLen = 4,
.szAtsLen = 0,
},
},
};
/*
// Example of a FeliCa
nfc_target nt = {
.nm = {
.nmt = NMT_FELICA,
.nbr = NBR_UNDEFINED,
},
.nti = {
.nfi = {
.abtId = { 0x01, 0xFE, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF },
.abtPad = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF },
.abtSysCode = { 0xFF, 0xFF },
},
},
};
*/
/*
// Example of a ISO14443-4 (DESfire)
nfc_target nt = {
.nm = {
.nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED,
},
.nti = {
.nai = {
.abtAtqa = { 0x03, 0x44 },
.abtUid = { 0x08, 0xab, 0xcd, 0xef },
.btSak = 0x20,
.szUidLen = 4,
.abtAts = { 0x75, 0x77, 0x81, 0x02, 0x80 },
.szAtsLen = 5,
},
},
};
*/
printf("%s will emulate this ISO14443-A tag:\n", argv[0]);
print_nfc_target(&nt, true);
// Switch off NP_EASY_FRAMING if target is not ISO14443-4
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, (nt.nti.nai.btSak & SAK_ISO14443_4_COMPLIANT)) < 0) {
nfc_perror(pnd, "nfc_target_emulate_tag");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC device (configured as target) is now emulating the tag, please touch it with a second NFC device (initiator)\n");
if (!nfc_target_emulate_tag(pnd, &nt)) {
nfc_perror(pnd, "nfc_target_emulate_tag");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

View File

@ -0,0 +1,70 @@
.TH nfc-emulate-uid 1 "June 26, 2009" "libnfc" "libnfc's examples"
.SH NAME
nfc-emulate-uid \- NFC target emulation command line tool based on libnfc
.SH SYNOPSIS
.B nfc-emulate-uid
.RI [ OPTIONS ]
.RI [ UID ]
.SH DESCRIPTION
.B nfc-emulate-uid
is a tag emulation tool that allows one to choose any tag UID. Tag emulation is one
of the main added features in NFC. But to avoid abuse of existing systems,
manufacturers of the NFC controller intentionally did not support emulation of
fully customized UID but only of "random" UIDs, which always start with 0x08.
The nfc-emulate-uid tool demonstrates that this can still be done using
transmission of raw frames, and the desired UID can be optionally specified.
This makes it a serious threat for security systems that rely only on the
uniqueness of the UID.
Unfortunately, this example can't directly start in fully customisable
target mode. Just after launching this example, you will have to go through
the hardcoded initial anti-collision with the 0x08-prefixed UID.
To achieve it, you can e.g. send a RATS (Request for Answer To Select) command
by using a second NFC device (placed in target's field) and launching nfc-list
or nfc-anticol. After this first step, you now have a NFC device (configured
as target) that really emulates a custom UID.
You could view it using the second NFC device with nfc-list.
Timing control is very important for a successful anti-collision sequence:
- The emulator must be very fast to react:
Using the ACR122 device gives many timing issues, "PN53x only" USB
devices also give some timing issues but an embedded microprocessor
would probably improve greatly the situation.
- The reader should not be too strict on timing (the standard is very
strict). The OmniKey CardMan 5321 is known to be very large on
timings and is a good choice if you want to experiment with this
emulator with a tolerant reader.
Nokia NFC 6212 and Pegoda readers are much too strict and won't be fooled.
.SH OPTIONS
.IR UID
8 hex digits format that represents desired UID (default is DEADBEEF).
.SH IMPORTANT
ACR122 devices (like touchatag, etc.) can be used by this example (with timing
issues), but if something goes wrong, you will have to unplug/replug your
device. This is not a
.B libnfc's
bug, this problem is due to ACR122's internal MCU in front of NFC chip (PN532).
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Roel Verdult <roel@libnfc.org>
.PP
This manual page was written by Romuald Conty <romuald@libnfc.org>.
It is licensed under the terms of the GNU GPL (version 2 or later).

243
examples/nfc-emulate-uid.c Normal file
View File

@ -0,0 +1,243 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-emulate-uid.c
* @brief Emulates a tag which which have a "really" custom UID
*
* 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
* byte of emulated UID is hard-wired to 0x08 which is the standard way to say
* this is a random UID. This example shows how to emulate a fully customized
* UID by "manually" replying to anti-collision process sent by the initiator.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <signal.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
#define MAX_FRAME_LEN 264
static uint8_t abtRecv[MAX_FRAME_LEN];
static int szRecvBits;
static nfc_device *pnd;
static nfc_context *context;
// ISO14443A Anti-Collision response
uint8_t abtAtqa[2] = { 0x04, 0x00 };
uint8_t abtUidBcc[5] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x22 };
uint8_t abtSak[9] = { 0x08, 0xb6, 0xdd };
static void
intr_hdlr(int sig)
{
(void) sig;
if (pnd != NULL) {
printf("\nAborting current command...\n");
nfc_abort_command(pnd);
nfc_close(pnd);
}
nfc_exit(context);
exit(EXIT_SUCCESS);
}
static void
print_usage(char *argv[])
{
printf("Usage: %s [OPTIONS] [UID]\n", argv[0]);
printf("Options:\n");
printf("\t-h\tHelp. Print this message.\n");
printf("\t-q\tQuiet mode. Silent output: received and sent frames will not be shown (improves timing).\n");
printf("\n");
printf("\t[UID]\tUID to emulate, specified as 8 HEX digits (default is DEADBEEF).\n");
}
int
main(int argc, char *argv[])
{
uint8_t *pbtTx = NULL;
size_t szTxBits;
bool quiet_output = false;
int arg,
i;
// Get commandline options
for (arg = 1; arg < argc; arg++) {
if (0 == strcmp(argv[arg], "-h")) {
print_usage(argv);
exit(EXIT_SUCCESS);
} else if (0 == strcmp(argv[arg], "-q")) {
printf("Quiet mode.\n");
quiet_output = true;
} else if ((arg == argc - 1) && (strlen(argv[arg]) == 8)) { // See if UID was specified as HEX string
uint8_t abtTmp[3] = { 0x00, 0x00, 0x00 };
printf("[+] Using UID: %s\n", argv[arg]);
abtUidBcc[4] = 0x00;
for (i = 0; i < 4; ++i) {
memcpy(abtTmp, argv[arg] + i * 2, 2);
abtUidBcc[i] = (uint8_t) strtol((char *) abtTmp, NULL, 16);
abtUidBcc[4] ^= abtUidBcc[i];
}
} else {
ERR("%s is not supported option.", argv[arg]);
print_usage(argv);
exit(EXIT_FAILURE);
}
}
#ifdef WIN32
signal(SIGINT, (void (__cdecl *)(int)) intr_hdlr);
#else
signal(SIGINT, intr_hdlr);
#endif
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
// Try to open the NFC device
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
ERR("Unable to open NFC device");
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("\n");
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
printf("[+] Try to break out the auto-emulation, this requires a second NFC device!\n");
printf("[+] To do this, please send any command after the anti-collision\n");
printf("[+] For example, send a RATS command or use the \"nfc-anticol\" or \"nfc-list\" tool.\n");
// Note: We have to build a "fake" nfc_target in order to do exactly the same that was done before the new nfc_target_init() was introduced.
nfc_target nt = {
.nm = {
.nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED,
},
.nti = {
.nai = {
.abtAtqa = { 0x04, 0x00 },
.abtUid = { 0x08, 0xad, 0xbe, 0xef },
.btSak = 0x20,
.szUidLen = 4,
.szAtsLen = 0,
},
},
};
if ((szRecvBits = nfc_target_init(pnd, &nt, abtRecv, sizeof(abtRecv), 0)) < 0) {
nfc_perror(pnd, "nfc_target_init");
ERR("Could not come out of auto-emulation, no command was received");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("[+] Received initiator command: ");
print_hex_bits(abtRecv, (size_t) szRecvBits);
printf("[+] Configuring communication\n");
if ((nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) || (nfc_device_set_property_bool(pnd, NP_HANDLE_PARITY, true) < 0)) {
nfc_perror(pnd, "nfc_device_set_property_bool");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("[+] Done, the emulated tag is initialized with UID: %02X%02X%02X%02X\n\n", abtUidBcc[0], abtUidBcc[1],
abtUidBcc[2], abtUidBcc[3]);
while (true) {
// Test if we received a frame
if ((szRecvBits = nfc_target_receive_bits(pnd, abtRecv, sizeof(abtRecv), 0)) > 0) {
// Prepare the command to send back for the anti-collision request
switch (szRecvBits) {
case 7: // Request or Wakeup
pbtTx = abtAtqa;
szTxBits = 16;
// New anti-collsion session started
if (!quiet_output)
printf("\n");
break;
case 16: // Select All
pbtTx = abtUidBcc;
szTxBits = 40;
break;
case 72: // Select Tag
pbtTx = abtSak;
szTxBits = 24;
break;
default: // unknown length?
szTxBits = 0;
break;
}
if (!quiet_output) {
printf("R: ");
print_hex_bits(abtRecv, (size_t) szRecvBits);
}
// Test if we know how to respond
if (szTxBits) {
// Send and print the command to the screen
if (nfc_target_send_bits(pnd, pbtTx, szTxBits, NULL) < 0) {
nfc_perror(pnd, "nfc_target_send_bits");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
if (!quiet_output) {
printf("T: ");
print_hex_bits(pbtTx, szTxBits);
}
}
}
}
}

40
examples/nfc-mfsetuid.1 Normal file
View File

@ -0,0 +1,40 @@
.TH nfc-mfsetuid 1 "Sep 05, 2011" "libnfc" "NFC Utilities"
.SH NAME
nfc-mfsetuid \- MIFARE 1K special card UID setting and recovery tool
.SH SYNOPSIS
.B nfc-mfsetuid
[
.I UID
]
.SH DESCRIPTION
.B nfc-mfsetuid
is a MIFARE tool that allows setting of UID on special versions (Chinese clones) of Mifare 1K cards. It will also recover
damaged cards that have had invalid data written to block 0 (e.g. wrong BCC). Currently only 4 Byte UID is supported.
Specify an eight hex character UID or leave blank for the default '01234567'.
.SH OPTIONS
.B -f
Format. Wipe all data (set to 0xFF) and reset ACLs to defaults.
.B -q
Quiet. Suppress output of commands and responses.
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Adam Laurie <adam@algroup.co.uk>
.PP
This manual page was written by Adam Laurie <adam@algroup.co.uk>.
It is licensed under the terms of the GNU GPL (version 2 or later).

399
examples/nfc-mfsetuid.c Normal file
View File

@ -0,0 +1,399 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
* Copyright (C) 2011 Adam Laurie
* Copyright (C) 2014 Dario Carluccio
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-mfsetuid.c
* @brief Set UID of special Mifare cards
*/
/**
* based on nfc-anticol.c
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
#define SAK_FLAG_ATS_SUPPORTED 0x20
#define MAX_FRAME_LEN 264
static uint8_t abtRx[MAX_FRAME_LEN];
static int szRxBits;
static uint8_t abtRawUid[12];
static uint8_t abtAtqa[2];
static uint8_t abtSak;
static uint8_t abtAts[MAX_FRAME_LEN];
static uint8_t szAts = 0;
static size_t szCL = 1;//Always start with Cascade Level 1 (CL1)
static nfc_device *pnd;
bool quiet_output = false;
bool iso_ats_supported = false;
// ISO14443A Anti-Collision Commands
uint8_t abtReqa[1] = { 0x26 };
uint8_t abtSelectAll[2] = { 0x93, 0x20 };
uint8_t abtSelectTag[9] = { 0x93, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
uint8_t abtRats[4] = { 0xe0, 0x50, 0x00, 0x00 };
uint8_t abtHalt[4] = { 0x50, 0x00, 0x00, 0x00 };
#define CASCADE_BIT 0x04
// special unlock command
uint8_t abtUnlock1[1] = { 0x40 };
uint8_t abtUnlock2[1] = { 0x43 };
uint8_t abtWipe[1] = { 0x41 };
uint8_t abtWrite[4] = { 0xa0, 0x00, 0x5f, 0xb1 };
uint8_t abtData[18] = { 0x01, 0x23, 0x45, 0x67, 0x00, 0x08, 0x04, 0x00, 0x46, 0x59, 0x25, 0x58, 0x49, 0x10, 0x23, 0x02, 0x23, 0xeb };
uint8_t abtBlank[18] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x69, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x36, 0xCC };
static bool
transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
{
// Show transmitted command
if (!quiet_output) {
printf("Sent bits: ");
print_hex_bits(pbtTx, szTxBits);
}
// Transmit the bit frame command, we don't use the arbitrary parity feature
if ((szRxBits = nfc_initiator_transceive_bits(pnd, pbtTx, szTxBits, NULL, abtRx, sizeof(abtRx), NULL)) < 0)
return false;
// Show received answer
if (!quiet_output) {
printf("Received bits: ");
print_hex_bits(abtRx, szRxBits);
}
// Succesful transfer
return true;
}
static bool
transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
{
// Show transmitted command
if (!quiet_output) {
printf("Sent bits: ");
print_hex(pbtTx, szTx);
}
int res;
// Transmit the command bytes
if ((res = nfc_initiator_transceive_bytes(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
return false;
// Show received answer
if (!quiet_output) {
printf("Received bits: ");
print_hex(abtRx, res);
}
// Succesful transfer
return true;
}
static void
print_usage(char *argv[])
{
printf("Usage: %s [OPTIONS] [UID|BLOCK0]\n", argv[0]);
printf("Options:\n");
printf("\t-h\tHelp. Print this message.\n");
printf("\t-f\tFormat. Delete all data (set to 0xFF) and reset ACLs to default.\n");
printf("\t-q\tQuiet mode. Suppress output of READER and CARD data (improves timing).\n");
printf("\n\tSpecify UID (4 HEX bytes) to set UID, or leave blank for default '01234567'.\n");
printf("\n\tSpecify BLOCK0 (16 HEX bytes) to set content of Block0. CRC (Byte 4) is recalculated an overwritten'.\n");
printf("\tThis utility can be used to recover cards that have been damaged by writing bad\n");
printf("\tdata (e.g. wrong BCC), thus making them non-selectable by most tools/readers.\n");
printf("\n\t*** Note: this utility only works with special Mifare 1K cards (Chinese clones).\n\n");
}
int
main(int argc, char *argv[])
{
int arg, i;
bool format = false;
unsigned int c;
char tmp[3] = { 0x00, 0x00, 0x00 };
// Get commandline options
for (arg = 1; arg < argc; arg++) {
if (0 == strcmp(argv[arg], "-h")) {
print_usage(argv);
exit(EXIT_SUCCESS);
} else if (0 == strcmp(argv[arg], "-f")) {
format = true;
} else if (0 == strcmp(argv[arg], "-q")) {
quiet_output = true;
} else if (strlen(argv[arg]) == 8) {
for (i = 0 ; i < 4 ; ++i) {
memcpy(tmp, argv[arg] + i * 2, 2);
sscanf(tmp, "%02x", &c);
abtData[i] = (char) c;
}
abtData[4] = abtData[0] ^ abtData[1] ^ abtData[2] ^ abtData[3];
iso14443a_crc_append(abtData, 16);
} else if (strlen(argv[arg]) == 32) {
for (i = 0 ; i < 16 ; ++i) {
memcpy(tmp, argv[arg] + i * 2, 2);
sscanf(tmp, "%02x", &c);
abtData[i] = (char) c;
}
abtData[4] = abtData[0] ^ abtData[1] ^ abtData[2] ^ abtData[3];
iso14443a_crc_append(abtData, 16);
} else {
ERR("%s is not supported option.", argv[arg]);
print_usage(argv);
exit(EXIT_FAILURE);
}
}
nfc_context *context;
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
// Try to open the NFC reader
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
ERR("Error opening NFC reader");
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Initialise NFC device as "initiator"
if (nfc_initiator_init(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Configure the CRC
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Use raw send/receive methods
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Disable 14443-4 autoswitching
if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
// Send the 7 bits request command specified in ISO 14443A (0x26)
if (!transmit_bits(abtReqa, 7)) {
printf("Error: No tag available\n");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
memcpy(abtAtqa, abtRx, 2);
// Anti-collision
transmit_bytes(abtSelectAll, 2);
// Check answer
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
printf("WARNING: BCC check failed!\n");
}
// Save the UID CL1
memcpy(abtRawUid, abtRx, 4);
//Prepare and send CL1 Select-Command
memcpy(abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append(abtSelectTag, 7);
transmit_bytes(abtSelectTag, 9);
abtSak = abtRx[0];
// Test if we are dealing with a CL2
if (abtSak & CASCADE_BIT) {
szCL = 2;//or more
// Check answer
if (abtRawUid[0] != 0x88) {
printf("WARNING: Cascade bit set but CT != 0x88!\n");
}
}
if (szCL == 2) {
// We have to do the anti-collision for cascade level 2
// Prepare CL2 commands
abtSelectAll[0] = 0x95;
// Anti-collision
transmit_bytes(abtSelectAll, 2);
// Check answer
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
printf("WARNING: BCC check failed!\n");
}
// Save UID CL2
memcpy(abtRawUid + 4, abtRx, 4);
// Selection
abtSelectTag[0] = 0x95;
memcpy(abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append(abtSelectTag, 7);
transmit_bytes(abtSelectTag, 9);
abtSak = abtRx[0];
// Test if we are dealing with a CL3
if (abtSak & CASCADE_BIT) {
szCL = 3;
// Check answer
if (abtRawUid[0] != 0x88) {
printf("WARNING: Cascade bit set but CT != 0x88!\n");
}
}
if (szCL == 3) {
// We have to do the anti-collision for cascade level 3
// Prepare and send CL3 AC-Command
abtSelectAll[0] = 0x97;
transmit_bytes(abtSelectAll, 2);
// Check answer
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
printf("WARNING: BCC check failed!\n");
}
// Save UID CL3
memcpy(abtRawUid + 8, abtRx, 4);
// Prepare and send final Select-Command
abtSelectTag[0] = 0x97;
memcpy(abtSelectTag + 2, abtRx, 5);
iso14443a_crc_append(abtSelectTag, 7);
transmit_bytes(abtSelectTag, 9);
abtSak = abtRx[0];
}
}
// Request ATS, this only applies to tags that support ISO 14443A-4
if (abtRx[0] & SAK_FLAG_ATS_SUPPORTED) {
iso_ats_supported = true;
}
printf("\nFound tag with\n UID: ");
switch (szCL) {
case 1:
printf("%02x%02x%02x%02x", abtRawUid[0], abtRawUid[1], abtRawUid[2], abtRawUid[3]);
break;
case 2:
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
printf("%02x%02x%02x%02x", abtRawUid[4], abtRawUid[5], abtRawUid[6], abtRawUid[7]);
break;
case 3:
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
printf("%02x%02x%02x", abtRawUid[5], abtRawUid[6], abtRawUid[7]);
printf("%02x%02x%02x%02x", abtRawUid[8], abtRawUid[9], abtRawUid[10], abtRawUid[11]);
break;
}
printf("\n");
printf("ATQA: %02x%02x\n SAK: %02x\n", abtAtqa[1], abtAtqa[0], abtSak);
if (szAts > 1) { // if = 1, it's not actual ATS but error code
printf(" ATS: ");
print_hex(abtAts, szAts);
}
printf("\n");
// now reset UID
iso14443a_crc_append(abtHalt, 2);
transmit_bytes(abtHalt, 4);
if (!transmit_bits(abtUnlock1, 7)) {
printf("Warning: Unlock command [1/2]: failed / not acknowledged.\n");
} else {
if (format) {
transmit_bytes(abtWipe, 1);
transmit_bytes(abtHalt, 4);
transmit_bits(abtUnlock1, 7);
}
if (transmit_bytes(abtUnlock2, 1)) {
printf("Card unlocked\n");
} else {
printf("Warning: Unlock command [2/2]: failed / not acknowledged.\n");
}
}
transmit_bytes(abtWrite, 4);
transmit_bytes(abtData, 18);
if (format) {
for (i = 3 ; i < 64 ; i += 4) {
abtWrite[1] = (char) i;
iso14443a_crc_append(abtWrite, 2);
transmit_bytes(abtWrite, 4);
transmit_bytes(abtBlank, 18);
}
}
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

58
examples/nfc-poll.1 Normal file
View File

@ -0,0 +1,58 @@
.TH nfc-poll 1 "June 26, 2009" "libnfc" "libnfc's examples"
.SH NAME
nfc-poll \- poll first available NFC target
.SH SYNOPSIS
.B nfc-poll
.SH DESCRIPTION
.B nfc-poll
is a utility for polling any available target (tags but also NFCIP targets)
using ISO14443-A, FeliCa, Jewel and ISO14443-B modulations.
This tool uses hardware polling feature if available (ie. PN532) or switch back
to software polling, it will display available information retrieved from the
tag.
.SH OPTIONS
.TP
.B \-v
Tells
.I
nfc-poll
to be verbose and display detailed information about the targets shown.
This includes SAK decoding and fingerprinting is available.
.SH IMPORTANT
There are some well-know limits with this example:
- Even with NDO_AUTO_14443_4A enabled (default),
.B nfc-poll
can miss ATS. That due to the way the PN532 use to poll for ISO14443 type A, it
will attempt to find ISO14443-4-only targets, then ISO14443-3. If your
ISO14443-4 target is present when PN532 looks for ISO14443-4-only, ATS will be
retrieved. But if your target enter the field during ISO14443-3, RATS will not
be sent and ATS not retrieved.
-
.B nfc-poll
can show up only one card while two are in field. That's due, again, to the way
the PN532 poll for targets. It will stop polling when one modulation got a
result, so if you have, for example, one ISO14443-3 (eg. Mifare Ultralight) and
one ISO14443-4 (eg. Mifare DESFire), it will probably return only the
ISO14443-4.
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Romuald Conty <romuald@libnfc.org>
.PP
This manual page was written by Romuald Conty <romuald@libnfc.org>.
It is licensed under the terms of the GNU GPL (version 2 or later).

162
examples/nfc-poll.c Normal file
View File

@ -0,0 +1,162 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
* Copyright (C) 2020 Adam Laurie
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-poll.c
* @brief Polling example
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <err.h>
#include <inttypes.h>
#include <signal.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <nfc/nfc.h>
#include <nfc/nfc-types.h>
#include "utils/nfc-utils.h"
#define MAX_DEVICE_COUNT 16
static nfc_device *pnd = NULL;
static nfc_context *context;
static void stop_polling(int sig)
{
(void) sig;
if (pnd != NULL)
nfc_abort_command(pnd);
else {
nfc_exit(context);
exit(EXIT_FAILURE);
}
}
static void
print_usage(const char *progname)
{
printf("usage: %s [-v]\n", progname);
printf(" -v\t verbose display\n");
}
int
main(int argc, const char *argv[])
{
bool verbose = false;
signal(SIGINT, stop_polling);
// Display libnfc version
const char *acLibnfcVersion = nfc_version();
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
if (argc != 1) {
if ((argc == 2) && (0 == strcmp("-v", argv[1]))) {
verbose = true;
} else {
print_usage(argv[0]);
exit(EXIT_FAILURE);
}
}
const uint8_t uiPollNr = 20;
const uint8_t uiPeriod = 2;
const nfc_modulation nmModulations[6] = {
{ .nmt = NMT_ISO14443A, .nbr = NBR_106 },
{ .nmt = NMT_ISO14443B, .nbr = NBR_106 },
{ .nmt = NMT_FELICA, .nbr = NBR_212 },
{ .nmt = NMT_FELICA, .nbr = NBR_424 },
{ .nmt = NMT_JEWEL, .nbr = NBR_106 },
{ .nmt = NMT_ISO14443BICLASS, .nbr = NBR_106 },
};
const size_t szModulations = 6;
nfc_target nt;
int res = 0;
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
ERR("%s", "Unable to open NFC device.");
nfc_exit(context);
exit(EXIT_FAILURE);
}
if (nfc_initiator_init(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
printf("NFC device will poll during %ld ms (%u pollings of %lu ms for %" PRIdPTR " modulations)\n", (unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (unsigned long) uiPeriod * 150, szModulations);
if ((res = nfc_initiator_poll_target(pnd, nmModulations, szModulations, uiPollNr, uiPeriod, &nt)) < 0) {
nfc_perror(pnd, "nfc_initiator_poll_target");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
if (res > 0) {
print_nfc_target(&nt, verbose);
printf("Waiting for card removing...");
fflush(stdout);
while (0 == nfc_initiator_target_is_present(pnd, NULL)) {}
nfc_perror(pnd, "nfc_initiator_target_is_present");
printf("done.\n");
} else {
printf("No target found.\n");
}
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

38
examples/nfc-relay.1 Normal file
View File

@ -0,0 +1,38 @@
.TH nfc-relay 1 "June 26, 2009" "libnfc" "libnfc'examples"
.SH NAME
nfc-relay \- Relay attack command line tool based on libnfc
.SH SYNOPSIS
.B nfc-relay
.SH DESCRIPTION
.B nfc-relay
is a utility that demonstrates a relay attack.
This tool requires two NFC devices. One device (configured as target) will
emulate an ISO/IEC 14443 type A tag, while the second device (configured as
initiator) will act as a reader. The genuine tag can be placed on the second
device (initiator) and the tag emulator (target) can be placed close to the
original reader. All communication is now relayed and shown in the screen on
real-time.
This tool has the same issues regarding timing as \fBnfc-emulate-uid\fP has,
therefore we advise you to try it against e.g. an OmniKey CardMan 5321 reader.
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Roel Verdult <roel@libnfc.org>
.PP
This manual page was written by Romuald Conty <romuald@libnfc.org>.
It is licensed under the terms of the GNU GPL (version 2 or later).

263
examples/nfc-relay.c Normal file
View File

@ -0,0 +1,263 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-relay.c
* @brief Relay example using two devices.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <signal.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
#define MAX_FRAME_LEN 264
#define MAX_DEVICE_COUNT 2
static uint8_t abtReaderRx[MAX_FRAME_LEN];
static uint8_t abtReaderRxPar[MAX_FRAME_LEN];
static int szReaderRxBits;
static uint8_t abtTagRx[MAX_FRAME_LEN];
static uint8_t abtTagRxPar[MAX_FRAME_LEN];
static int szTagRxBits;
static nfc_device *pndReader;
static nfc_device *pndTag;
static bool quitting = false;
static void
intr_hdlr(int sig)
{
(void) sig;
printf("\nQuitting...\n");
quitting = true;
return;
}
static void
print_usage(char *argv[])
{
printf("Usage: %s [OPTIONS]\n", argv[0]);
printf("Options:\n");
printf("\t-h\tHelp. Print this message.\n");
printf("\t-q\tQuiet mode. Suppress output of READER and EMULATOR data (improves timing).\n");
}
int
main(int argc, char *argv[])
{
int arg;
bool quiet_output = false;
const char *acLibnfcVersion = nfc_version();
// Get commandline options
for (arg = 1; arg < argc; arg++) {
if (0 == strcmp(argv[arg], "-h")) {
print_usage(argv);
exit(EXIT_SUCCESS);
} else if (0 == strcmp(argv[arg], "-q")) {
quiet_output = true;
} else {
ERR("%s is not supported option.", argv[arg]);
print_usage(argv);
exit(EXIT_FAILURE);
}
}
// Display libnfc version
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
#ifdef WIN32
signal(SIGINT, (void (__cdecl *)(int)) intr_hdlr);
#else
signal(SIGINT, intr_hdlr);
#endif
nfc_context *context;
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
nfc_connstring connstrings[MAX_DEVICE_COUNT];
// List available devices
size_t szFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
if (szFound < 2) {
ERR("%" PRIdPTR " device found but two opened devices are needed to relay NFC.", szFound);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Try to open the NFC emulator device
pndTag = nfc_open(context, connstrings[0]);
if (pndTag == NULL) {
ERR("Error opening NFC emulator device");
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("Hint: tag <---> initiator (relay) <---> target (relay) <---> original reader\n\n");
printf("NFC emulator device: %s opened\n", nfc_device_get_name(pndTag));
printf("[+] Try to break out the auto-emulation, this requires a second reader!\n");
printf("[+] To do this, please send any command after the anti-collision\n");
printf("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n");
nfc_target nt = {
.nm = {
.nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED,
},
.nti = {
.nai = {
.abtAtqa = { 0x04, 0x00 },
.abtUid = { 0x08, 0xad, 0xbe, 0xef },
.btSak = 0x20,
.szUidLen = 4,
.szAtsLen = 0,
},
},
};
if ((szReaderRxBits = nfc_target_init(pndTag, &nt, abtReaderRx, sizeof(abtReaderRx), 0)) < 0) {
ERR("%s", "Initialization of NFC emulator failed");
nfc_close(pndTag);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("%s", "Configuring emulator settings...");
if ((nfc_device_set_property_bool(pndTag, NP_HANDLE_CRC, false) < 0) ||
(nfc_device_set_property_bool(pndTag, NP_HANDLE_PARITY, false) < 0) || (nfc_device_set_property_bool(pndTag, NP_ACCEPT_INVALID_FRAMES, true)) < 0) {
nfc_perror(pndTag, "nfc_device_set_property_bool");
nfc_close(pndTag);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("%s", "Done, emulated tag is initialized");
// Try to open the NFC reader
pndReader = nfc_open(context, connstrings[1]);
if (pndReader == NULL) {
printf("Error opening NFC reader device\n");
nfc_close(pndTag);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC reader device: %s opened", nfc_device_get_name(pndReader));
printf("%s", "Configuring NFC reader settings...");
if (nfc_initiator_init(pndReader) < 0) {
nfc_perror(pndReader, "nfc_initiator_init");
nfc_close(pndTag);
nfc_close(pndReader);
nfc_exit(context);
exit(EXIT_FAILURE);
}
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_ACCEPT_INVALID_FRAMES, true)) < 0) {
nfc_perror(pndReader, "nfc_device_set_property_bool");
nfc_close(pndTag);
nfc_close(pndReader);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("%s", "Done, relaying frames now!");
while (!quitting) {
// Test if we received a frame from the reader
if ((szReaderRxBits = nfc_target_receive_bits(pndTag, abtReaderRx, sizeof(abtReaderRx), abtReaderRxPar)) > 0) {
// Drop down the field before sending a REQA command and start a new session
if (szReaderRxBits == 7 && abtReaderRx[0] == 0x26) {
// Drop down field for a very short time (original tag will reboot)
if (nfc_device_set_property_bool(pndReader, NP_ACTIVATE_FIELD, false) < 0) {
nfc_perror(pndReader, "nfc_device_set_property_bool");
nfc_close(pndTag);
nfc_close(pndReader);
nfc_exit(context);
exit(EXIT_FAILURE);
}
if (!quiet_output)
printf("\n");
if (nfc_device_set_property_bool(pndReader, NP_ACTIVATE_FIELD, true) < 0) {
nfc_perror(pndReader, "nfc_device_set_property_bool");
nfc_close(pndTag);
nfc_close(pndReader);
nfc_exit(context);
exit(EXIT_FAILURE);
}
}
// Print the reader frame to the screen
if (!quiet_output) {
printf("R: ");
print_hex_par(abtReaderRx, (size_t) szReaderRxBits, abtReaderRxPar);
}
// Forward the frame to the original tag
if ((szTagRxBits = nfc_initiator_transceive_bits
(pndReader, abtReaderRx, (size_t) szReaderRxBits, abtReaderRxPar, abtTagRx, sizeof(abtTagRx), abtTagRxPar)) > 0) {
// Redirect the answer back to the reader
if (nfc_target_send_bits(pndTag, abtTagRx, szTagRxBits, abtTagRxPar) < 0) {
nfc_perror(pndTag, "nfc_target_send_bits");
nfc_close(pndTag);
nfc_close(pndReader);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Print the tag frame to the screen
if (!quiet_output) {
printf("T: ");
print_hex_par(abtTagRx, szTagRxBits, abtTagRxPar);
}
}
}
}
nfc_close(pndTag);
nfc_close(pndReader);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

600
examples/nfc-st25tb.c Normal file
View File

@ -0,0 +1,600 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file nfc-st25tb.c
* @brief Tool to operate on ISO-14443-B ST25TB* and legacy SR* cards
*/
/* Benjamin DELPY `gentilkiwi`
* https://blog.gentilkiwi.com
* benjamin@gentilkiwi.com
* Licence : https://creativecommons.org/licenses/by/4.0/
* Rely on : libnfc - https://github.com/nfc-tools/libnfc
*
* $ gcc -Wall -lnfc -o nfc-st25tb nfc-st25tb.c
* $ ./nfc-st25tb -h
*
* Tested with
* - ST25TB512-AC - (BE/Brussels/STIB ; AliExpress ones)
* - ST25TB512-AT - (FR/Lille/Ilevia ; FR/Reims/Citura ; FR/Dijon/Divia ; FR/Strasbourg/CTS)
* - SRT512 - legacy - (FR/Bordeaux/TBM)
* - SRI512 - legacy - (anonymous vending machine)
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <nfc/nfc.h>
#if defined(WIN32) /* mingw compiler */
#include <getopt.h>
#endif
#define ST25TB_SR_BLOCK_MAX_SIZE ((uint8_t) 4) // for static arrays
typedef void(*get_info_specific) (uint8_t * systemArea);
typedef struct _st_data {
uint8_t chipId;
bool bIsLegacy;
const char *szName;
const char *szDatasheetUrl;
uint8_t blockSize;
uint8_t nbNormalBlock;
uint8_t bnSystem;
get_info_specific pfnGetInfo;
} st_data;
bool get_block_at(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt);
bool set_block_at(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt);
bool set_block_at_confirmed(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt);
const st_data * get_info(const nfc_target *pnt, bool bPrintIt);
void display_system_info(nfc_device *pnd, const st_data * stdata);
void print_hex(const uint8_t *pbtData, const size_t szBytes);
int main(int argc, char *argv[])
{
nfc_context *context = NULL;
nfc_device *pnd = NULL;
nfc_target nt = {0};
nfc_modulation nm = {NMT_ISO14443B2SR, NBR_106};
const st_data * stcurrent;
int opt, res;
bool bIsBlock = false, bIsRead = false, bIsWrite = false, bIsBadCli = false;
uint8_t i, blockNumber = 0, data[ST25TB_SR_BLOCK_MAX_SIZE] = {0xff, 0xff, 0xff, 0xff}; // just in case...
size_t cbData = 0;
while(!bIsBadCli && ((opt = getopt(argc, argv, ":hib:rw:")) != -1))
{
switch(opt)
{
case 'i':
break;
case 'b':
if(optarg)
{
bIsBlock = true;
blockNumber = strtoul(optarg, NULL, 0);
}
else bIsBadCli = true;
break;
case 'r':
bIsRead = true;
break;
case 'w':
if(optarg)
{
cbData = strlen(optarg);
if((cbData == (2*2)) || ((cbData == (4*2))))
{
cbData >>= 1;
if(cbData == 2) // sr176
{
res = sscanf(optarg, "%02hhx%02hhx", data, data + 1);
}
else // all others
{
res = sscanf(optarg, "%02hhx%02hhx%02hhx%02hhx", data, data + 1, data + 2, data + 3);
}
if(res == (int) cbData)
{
bIsWrite = true;
}
}
if(!bIsWrite)
{
bIsBadCli = true;
}
}
break;
default: // includes -h
bIsBadCli = true;
}
}
if(!bIsBadCli)
{
if(bIsBlock && (bIsRead || bIsWrite))
{
if(bIsRead && bIsWrite)
{
printf("|mode : read then write\n");
}
else if(bIsRead)
{
printf("|mode : read\n");
}
else if(bIsWrite)
{
printf("|mode : write\n");
}
printf("|blk num: 0x%02hhx\n", blockNumber);
if(bIsWrite)
{
printf("|data : ");
print_hex(data, cbData);
printf("\n");
}
}
else if(!bIsRead && !bIsWrite && !bIsBlock)
{
printf("|mode : info\n");
}
else bIsBadCli = true;
}
if(!bIsBadCli)
{
nfc_init(&context);
if(context)
{
pnd = nfc_open(context, NULL);
if(pnd)
{
res = nfc_initiator_init(pnd);
if(res == NFC_SUCCESS)
{
printf("Reader : %s - via %s\n ...wait for card...\n", nfc_device_get_name(pnd), nfc_device_get_connstring(pnd));
if (nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt) > 0)
{
stcurrent = get_info(&nt, true);
if(stcurrent)
{
printf("\n");
if(bIsBlock && (bIsRead || bIsWrite))
{
if(bIsRead)
{
get_block_at(pnd, blockNumber, NULL, 0, true);
}
if(bIsWrite)
{
set_block_at_confirmed(pnd, blockNumber, data, cbData, true);
}
}
else if(!bIsRead && !bIsWrite && !bIsBlock)
{
for(i = 0; i < stcurrent->nbNormalBlock; i++)
{
get_block_at(pnd, i, NULL, 0, true);
}
display_system_info(pnd, stcurrent);
}
}
}
}
else printf("ERROR - nfc_initiator_init: %i\n", res);
nfc_close(pnd);
}
else printf("ERROR - nfc_open\n");
nfc_exit(context);
}
else printf("ERROR - nfc_init\n");
}
else
{
printf(
"Usage:\n"
" %s [-i]\n"
" %s -b N -r\n"
" %s -b N [-r] -w ABCD[EF01]\n %s -h\n"
"Options:\n"
" -i (default) information mode - will try to dump the tag content and display informations\n"
" -b N specify block number to operate on (tag dependent), needed for read (-r) and write (-w) modes\n"
" -r read mode - will try to read block (specified with -b N parameter)\n"
" -w ABCD[EF01] write mode - will try to write specicied data (2 or 4 bytes depending on tag) to block (specified with -b N parameter)\n"
" -h this help\n"
"Examples:\n"
" %s -i\n"
" Display all tag informations\n"
" %s -b 0x0e -r\n"
" Read block 0x0e (14) of the tag\n"
" %s -b 0x0d -w 0123abcd\n"
" Write block 0x0d (13) of the tag with hexadecimal value '01 23 ab cd'\n"
" %s -b 0x0c -r -w 0123abcd\n"
" Read, then write block 0x0c (12) of the tag with hexadecimal value '01 23 ab cd'\n"
"Warnings:\n"
" Be careful with: system area, counters & otp, bytes order.\n"
, argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0]);
}
return 0;
}
bool get_block_at(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt)
{
bool bRet = false;
uint8_t tx[2] = {0x08, block}, rx[ST25TB_SR_BLOCK_MAX_SIZE]; // 4 is the maximum, SR176 (only 2) will fit
int res;
res = nfc_initiator_transceive_bytes(pnd, tx, sizeof(tx), rx, sizeof(rx), 0);
if((res == 2) || (res == 4))
{
if(data)
{
if(cbData == res)
{
memcpy(data, rx, res);
bRet = true;
}
else printf("ERROR - We got %i bytes for a %hhu buffer size?\n", res, cbData);
}
else bRet = true;
if(bPrintIt)
{
printf("[0x%02hhx] ", block);
print_hex(rx, res);
printf("\n");
}
}
else if(res > 0)
{
printf("ERROR - We got %i bytes?\n", res);
}
else printf("ERROR - nfc_initiator_transceive_bytes(get): %i\n", res);
return bRet;
}
bool set_block_at(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt)
{
bool bRet = false;
uint8_t tx[2 + ST25TB_SR_BLOCK_MAX_SIZE] = {0x09, block}; // 4 is the maximum, SR176 (only 2) will fit
int res;
if(cbData <= ST25TB_SR_BLOCK_MAX_SIZE)
{
memcpy(tx + 2, data, cbData);
if(bPrintIt)
{
printf(">0x%02hhx> ", block);
print_hex(data, cbData);
printf("\n");
}
res = nfc_initiator_transceive_bytes(pnd, tx, 2 + cbData, NULL, 0, 0);
if(res == NFC_ERFTRANS) // ? :')
{
bRet = true;
}
else printf("ERROR - nfc_initiator_transceive_bytes(set): %i\n", res);
}
else printf("ERROR - Wanted to write %hhu bytes, but maximum is %hhu\n", cbData, ST25TB_SR_BLOCK_MAX_SIZE);
return bRet;
}
bool set_block_at_confirmed(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt)
{
bool bRet = false;
uint8_t buffer[ST25TB_SR_BLOCK_MAX_SIZE]; // maximum size will be checked in set_block_at
if(set_block_at(pnd, block, data, cbData, bPrintIt))
{
if(get_block_at(pnd, block, buffer, cbData, bPrintIt))
{
if(memcmp(data, buffer, cbData) == 0)
{
bRet = true;
}
else if(bPrintIt)
{
printf("WARNING - not same value readed after write\n");
}
}
}
return bRet;
}
void get_info_st25tb512(uint8_t * systemArea)
{
uint8_t b, i;
b = ((*(uint32_t *) systemArea) >> 15) & 1;
printf(" | ST reserved : ");
for(i = 0; i < 15; i++)
{
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
}
printf("\n | b15 : %hhu - %sOTP (?)\n | OTP_Lock_Reg : ", b, b ? "not " : "");
for(i = 16; i < 32; i++)
{
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
}
printf("\n");
for(i = 16; i < 32; i++)
{
if(!(((*(uint32_t *) systemArea) >> i) & 1))
{
printf(" block 0x%02hhx is write protected\n", ((uint8_t) (i - 16)));
}
}
}
void get_info_st25tb2k_4k(uint8_t * systemArea)
{
uint8_t b, i;
b = ((*(uint32_t *) systemArea) >> 15) & 1;
printf(" | ST reserved : ");
for(i = 0; i < 15; i++)
{
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
}
printf("\n | b15 : %hhu - %sOTP (?)\n | OTP_Lock_RegU: ", b, b ? "not " : "");
for(i = 16; i < 24; i++)
{
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
}
printf("\n | OTP_Lock_Reg : ");
for(i = 24; i < 32; i++)
{
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
}
printf("\n");
if(!(((*(uint32_t *) systemArea) >> 24) & 1))
{
printf(" blocks 0x07 and 0x08 are write protected\n");
}
for(i = 25; i < 32; i++)
{
if(!(((*(uint32_t *) systemArea) >> i) & 1))
{
printf(" block 0x%02hhx is write protected\n", ((uint8_t) (i - 16)));
}
}
}
void get_info_sr176_legacy(uint8_t * systemArea)
{
uint8_t i;
printf(" | Fixed Chip_ID: 0x%1x\n | ST reserved : ", systemArea[0] & 0x0f);
for(i = 4; i < 8; i++)
{
printf("%hhu", (uint8_t) (((*(uint16_t *) systemArea) >> i) & 1));
}
printf("\n | OTP_Lock_Reg : ");
for(i = 8; i < 16; i++)
{
printf("%hhu", (uint8_t) (((*(uint16_t *) systemArea) >> i) & 1));
}
printf("\n");
for(i = 8; i < 16; i++)
{
if(((*(uint16_t *) systemArea) >> i) & 1)
{
printf(" blocks 0x%02hhx and 0x%02hhx are write protected\n", (uint8_t) ((i - 8) * 2), (uint8_t) (((i - 8) * 2) + 1));
}
}
}
void get_info_sri_srt_512_legacy(uint8_t * systemArea)
{
uint8_t b, i;
b = ((*(uint32_t *) systemArea) >> 15) & 1;
printf(" | Fixed Chip_ID: 0x%02hhx\n | ST reserved : ", systemArea[0]);
for(i = 8; i < 15; i++)
{
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
}
printf("\n | b15 : %hhu - %sOTP (?)\n | OTP_Lock_Reg : ", b, b ? "not " : "");
for(i = 16; i < 32; i++)
{
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
}
printf("\n");
for(i = 16; i < 32; i++)
{
if(!(((*(uint32_t *) systemArea) >> i) & 1))
{
printf(" block 0x%02hhx is write protected\n", (uint8_t) (i - 16));
}
}
}
void get_info_sri2k_4k_srix4k_srix512_legacy(uint8_t * systemArea)
{
uint8_t i;
printf(" | Fixed Chip_ID: 0x%02hhx\n | ST reserved : ", systemArea[0]);
for(i = 8; i < 24; i++)
{
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
}
printf("\n | OTP_Lock_Reg : ");
for(i = 24; i < 32; i++)
{
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
}
printf("\n");
if(!(((*(uint32_t *) systemArea) >> 24) & 1))
{
printf(" blocks 0x07 and 0x08 are write protected\n");
}
for(i = 25; i < 32; i++)
{
if(!(((*(uint32_t *) systemArea) >> i) & 1))
{
printf(" block 0x%02hhx is write protected\n", (uint8_t) (i - 16));
}
}
}
const st_data STRefs[] = {
{0x1b, false, "ST25TB512-AC", "https://www.st.com/resource/en/datasheet/st25tb512-ac.pdf", 4, 16, 255, get_info_st25tb512},
{0x33, false, "ST25TB512-AT", "https://www.st.com/resource/en/datasheet/st25tb512-at.pdf", 4, 16, 255, get_info_st25tb512},
{0x3f, false, "ST25TB02K", "https://www.st.com/resource/en/datasheet/st25tb02k.pdf", 4, 64, 255, get_info_st25tb2k_4k},
{0x1f, false, "ST25TB04K", "https://www.st.com/resource/en/datasheet/st25tb04k.pdf", 4, 128, 255, get_info_st25tb2k_4k},
};
const st_data STRefs_legacy[] = {
{ 0, true, "SRI4K(s)", NULL, 4, 128, 255, NULL},
{ 2, true, "SR176", "https://www.st.com/resource/en/datasheet/sr176.pdf", 2, 15, 15, get_info_sr176_legacy},
{ 3, true, "SRIX4K", NULL, 4, 128, 255, get_info_sri2k_4k_srix4k_srix512_legacy},
{ 4, true, "SRIX512", "https://www.st.com/resource/en/datasheet/srix512.pdf", 4, 16, 255, get_info_sri2k_4k_srix4k_srix512_legacy},
{ 6, true, "SRI512", "https://www.st.com/resource/en/datasheet/sri512.pdf", 4, 16, 255, get_info_sri_srt_512_legacy},
{ 7, true, "SRI4K", "https://www.st.com/resource/en/datasheet/sri4k.pdf", 4, 128, 255, get_info_sri2k_4k_srix4k_srix512_legacy},
{12, true, "SRT512", "https://www.st.com/resource/en/datasheet/srt512.pdf", 4, 16, 255, get_info_sri_srt_512_legacy},
{15, true, "SRI2K", "https://www.st.com/resource/en/datasheet/sri2k.pdf", 4, 64, 255, get_info_sri2k_4k_srix4k_srix512_legacy},
};
const st_data * get_info(const nfc_target *pnt, bool bPrintIt)
{
const st_data *currentData = NULL;
const uint8_t *p;
uint8_t chipId, i;
if(pnt->nm.nmt == NMT_ISO14443B2SR)
{
printf("Target : %s (%s)\nUID : ", str_nfc_modulation_type(pnt->nm.nmt), str_nfc_baud_rate(pnt->nm.nbr));
print_hex(pnt->nti.nsi.abtUID, sizeof(pnt->nti.nsi.abtUID));
printf("\n");
p = pnt->nti.nsi.abtUID;
if(p[7] == 0xd0) // ST25TB* / SR*
{
chipId = p[5];
printf("Manuf : 0x%02hhx - %s\n", p[6], (p[6] == 0x02) ? "STMicroelectronics" : "other");
for(i = 0; i < (sizeof(STRefs) / sizeof(STRefs[0])); i++)
{
if(chipId == STRefs[i].chipId)
{
currentData = &STRefs[i];
break;
}
}
if(!currentData)
{
chipId >>= 2;
for(i = 0; i < (sizeof(STRefs_legacy) / sizeof(STRefs_legacy[0])); i++)
{
if(chipId == STRefs_legacy[i].chipId)
{
currentData = &STRefs_legacy[i];
break;
}
}
}
if(bPrintIt && currentData)
{
printf("ChipId : 0x%02hhx - %s%s\nSerial : 0x", currentData->chipId, currentData->szName, currentData->bIsLegacy ? " (legacy)" : "");
if(currentData->bIsLegacy)
{
printf("%1hhx", (uint8_t) (p[5] & 0x03));
}
printf("%02hhx%02hhx%02hhx%02hhx%02hhx\n|blk sz : %hhu bits\n|nb blks: %hhu\n|sys idx: %hhu\n", p[4], p[3], p[2], p[1], p[0], (uint8_t) (currentData->blockSize * 8), currentData->nbNormalBlock, currentData->bnSystem);
}
}
else printf("WARNI - Last byte of UID isn\'t 0xd0, but 0x%02hhx (not ST25TB / SR series?)\n", p[7]);
}
else printf("ERROR - not a NMT_ISO14443B2SR ?\n");
return currentData;
}
void display_system_info(nfc_device *pnd, const st_data * stdata)
{
uint8_t systemArea[ST25TB_SR_BLOCK_MAX_SIZE];
if(get_block_at(pnd, stdata->bnSystem, systemArea, stdata->blockSize, true))
{
if(stdata->pfnGetInfo)
{
stdata->pfnGetInfo(systemArea);
}
}
}
void print_hex(const uint8_t *pbtData, const size_t szBytes)
{
size_t szPos;
for (szPos = 0; szPos < szBytes; szPos++)
{
printf("%02hhx ", pbtData[szPos]);
}
}

29
examples/pn53x-diagnose.1 Normal file
View File

@ -0,0 +1,29 @@
.TH pn53x-diagnose 1 "June 15, 2010" "libnfc" "libnfc's examples"
.SH NAME
pn53x-diagnose \- PN53x diagnose tool
.SH SYNOPSIS
.B pn53x-diagnose
.SH DESCRIPTION
.B pn53x-diagnose
is a utility to diagnose PN531, PN532 and PN533 chips.
It runs communication, RAM and ROM tests.
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Romuald Conty <romuald@libnfc.org>
.PP
This manual page was written by Romuald Conty <romuald@libnfc.org>.
It is licensed under the terms of the GNU GPL (version 2 or later).

138
examples/pn53x-diagnose.c Normal file
View File

@ -0,0 +1,138 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file pn53x-diagnose.c
* @brief Small application to diagnose PN53x using dedicated commands
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <err.h>
#include <stdlib.h>
#include <string.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
#include "libnfc/chips/pn53x.h"
#define MAX_DEVICE_COUNT 16
int
main(int argc, const char *argv[])
{
size_t i;
nfc_device *pnd = NULL;
const char *acLibnfcVersion;
bool result;
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof(abtRx);
const uint8_t pncmd_diagnose_communication_line_test[] = { Diagnose, 0x00, 0x06, 'l', 'i', 'b', 'n', 'f', 'c' };
const uint8_t pncmd_diagnose_rom_test[] = { Diagnose, 0x01 };
const uint8_t pncmd_diagnose_ram_test[] = { Diagnose, 0x02 };
if (argc > 1) {
printf("Usage: %s", argv[0]);
exit(EXIT_FAILURE);
}
nfc_context *context;
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
// Display libnfc version
acLibnfcVersion = nfc_version();
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t szFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
if (szFound == 0) {
printf("No NFC device found.\n");
}
for (i = 0; i < szFound; i++) {
int res = 0;
pnd = nfc_open(context, connstrings[i]);
if (pnd == NULL) {
ERR("%s", "Unable to open NFC device.");
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC device [%s] opened.\n", nfc_device_get_name(pnd));
res = pn53x_transceive(pnd, pncmd_diagnose_communication_line_test, sizeof(pncmd_diagnose_communication_line_test), abtRx, szRx, 0);
if (res > 0) {
szRx = (size_t) res;
// Result of Diagnose ping for RC-S360 doesn't contain status byte so we've to handle both cases
result = (memcmp(pncmd_diagnose_communication_line_test + 1, abtRx, sizeof(pncmd_diagnose_communication_line_test) - 1) == 0) ||
(memcmp(pncmd_diagnose_communication_line_test + 2, abtRx, sizeof(pncmd_diagnose_communication_line_test) - 2) == 0);
printf(" Communication line test: %s\n", result ? "OK" : "Failed");
} else {
nfc_perror(pnd, "pn53x_transceive: cannot diagnose communication line");
}
res = pn53x_transceive(pnd, pncmd_diagnose_rom_test, sizeof(pncmd_diagnose_rom_test), abtRx, szRx, 0);
if (res > 0) {
szRx = (size_t) res;
result = ((szRx == 1) && (abtRx[0] == 0x00));
printf(" ROM test: %s\n", result ? "OK" : "Failed");
} else {
nfc_perror(pnd, "pn53x_transceive: cannot diagnose ROM");
}
res = pn53x_transceive(pnd, pncmd_diagnose_ram_test, sizeof(pncmd_diagnose_ram_test), abtRx, szRx, 0);
if (res > 0) {
szRx = (size_t) res;
result = ((szRx == 1) && (abtRx[0] == 0x00));
printf(" RAM test: %s\n", result ? "OK" : "Failed");
} else {
nfc_perror(pnd, "pn53x_transceive: cannot diagnose RAM");
}
}
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

35
examples/pn53x-sam.1 Normal file
View File

@ -0,0 +1,35 @@
.TH pn53x-sam 1 "June 15, 2010" "libnfc" "libnfc's examples"
.SH NAME
pn53x-sam \- PN53x SAM communication demonstration tool
.SH SYNOPSIS
.B pn53x-sam
.SH DESCRIPTION
.B pn53x-sam
is a utility attempt to test a simple connection with a SAM (Secure Access
Module) in several modes.
To run this utility you must have a SAM (like the NXP's P5CN072 chip)
successfully connected to your PN53x chip.
Warning: the SAM inside a Touchatag/ACR122U is \fInot\fP hooked to the PN532
but to the intermediate controller so \fBpn53x-sam\fP won't work with a Touchatag/ACR122U.
.SH BUGS
Please report any bugs on the
.B libnfc
issue tracker at:
.br
.BR https://github.com/nfc-tools/libnfc/issues
.SH LICENCE
.B libnfc
is licensed under the GNU Lesser General Public License (LGPL), version 3.
.br
.B libnfc-utils
and
.B libnfc-examples
are covered by the the BSD 2-Clause license.
.SH AUTHORS
Emanuele Bertoldi <emanuele.bertoldi@gmail.com>
.PP
This manual page was written by Emanuele Bertoldi <emanuele.bertoldi@gmail.com>.
It is licensed under the terms of the GNU GPL (version 2 or later).

244
examples/pn53x-sam.c Normal file
View File

@ -0,0 +1,244 @@
/*-
* Free/Libre Near Field Communication (NFC) library
*
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
* Copyright (C) 2009-2013 Romuald Conty
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* See AUTHORS file for a more comprehensive list of contributors.
* Additional contributors of this file:
* Copyright (C) 2010 Emanuele Bertoldi
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 )Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
* Note that this license only applies on the examples, NFC library itself is under LGPL
*
*/
/**
* @file pn53x-sam.c
* @brief Configures the NFC device to communicate with a SAM (Secure Access Module).
* @note This example requiers a PN532 with SAM connected using S2C interface
* @see PN532 User manual
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif // HAVE_CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <nfc/nfc.h>
#include "utils/nfc-utils.h"
#include "libnfc/chips/pn53x.h"
#define MAX_FRAME_LEN 264
#define TIMEOUT 60 // secs.
static void
wait_one_minute(void)
{
int secs = 0;
printf("|");
fflush(stdout);
while (secs < TIMEOUT) {
sleep(1);
secs++;
printf(".");
fflush(stdout);
}
printf("|\n");
}
int
main(int argc, const char *argv[])
{
(void) argc;
(void) argv;
nfc_context *context;
nfc_init(&context);
if (context == NULL) {
ERR("Unable to init libnfc (malloc)");
exit(EXIT_FAILURE);
}
// Display libnfc version
const char *acLibnfcVersion = nfc_version();
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
// Open using the first available NFC device
nfc_device *pnd;
pnd = nfc_open(context, NULL);
if (pnd == NULL) {
ERR("%s", "Unable to open NFC device.");
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
// Print the example's menu
printf("\nSelect the communication mode:\n");
printf("[1] Virtual card mode.\n");
printf("[2] Wired card mode.\n");
printf("[3] Dual card mode.\n");
printf(">> ");
// Take user's choice
int input = getchar();
printf("\n");
if ((input < '1') || (input > '3')) {
ERR("%s", "Invalid selection.");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
/*
* '1' -> "Virtual mode" (0x02)
* '2' -> "Wired card" (0x03)
* '3' -> "Dual card" (0x04)
*/
int iMode = input - '0' + 0x01;
pn532_sam_mode mode = iMode;
// Connect with the SAM
switch (mode) {
case PSM_VIRTUAL_CARD: {
// FIXME Its a private pn53x function
if (pn532_SAMConfiguration(pnd, mode, 0) < 0) {
nfc_perror(pnd, "pn53x_SAMConfiguration");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
printf("Now the SAM is readable for 1 minute from an external reader.\n");
wait_one_minute();
}
break;
case PSM_WIRED_CARD: {
// Set opened NFC device to initiator mode
if (nfc_initiator_init_secure_element(pnd) < 0) {
nfc_perror(pnd, "nfc_initiator_init_secure_element");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Let the reader only try once to find a tag
if (nfc_device_set_property_bool(pnd, NP_INFINITE_SELECT, false) < 0) {
nfc_perror(pnd, "nfc_device_set_property_bool");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// Read the SAM's info
const nfc_modulation nmSAM = {
.nmt = NMT_ISO14443A,
.nbr = NBR_106,
};
nfc_target nt;
int res;
if ((res = nfc_initiator_select_passive_target(pnd, nmSAM, NULL, 0, &nt)) < 0) {
nfc_perror(pnd, "nfc_initiator_select_passive_target");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
} else if (res == 0) {
ERR("No SAM found.");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
} else if (res == 1) {
printf("The following ISO14443A tag (SAM) was found:\n");
print_nfc_target(&nt, true);
} else {
ERR("%s", "More than one ISO14442 tag found as SAM.");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
}
break;
case PSM_DUAL_CARD: {
// FIXME Its a private pn53x function
if (pn532_SAMConfiguration(pnd, mode, 0) < 0) {
nfc_perror(pnd, "pn53x_SAMConfiguration");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
uint8_t abtRx[MAX_FRAME_LEN];
nfc_target nt = {
.nm = {
.nmt = NMT_ISO14443A,
.nbr = NBR_UNDEFINED,
},
.nti = {
.nai = {
.abtAtqa = { 0x04, 0x00 },
.abtUid = { 0x08, 0xad, 0xbe, 0xef },
.btSak = 0x20,
.szUidLen = 4,
.szAtsLen = 0,
},
},
};
printf("Now both, NFC device (configured as target) and SAM are readables from an external NFC initiator.\n");
printf("Please note that NFC device (configured as target) stay in target mode until it receive RATS, ATR_REQ or proprietary command.\n");
if (nfc_target_init(pnd, &nt, abtRx, sizeof(abtRx), 0) < 0) {
nfc_perror(pnd, "nfc_target_init");
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_FAILURE);
}
// wait_one_minute ();
}
break;
case PSM_NORMAL:
// This should not happend... nothing to do.
break;
}
// Disconnect from the SAM
pn532_SAMConfiguration(pnd, PSM_NORMAL, -1);
// Close NFC device
nfc_close(pnd);
nfc_exit(context);
exit(EXIT_SUCCESS);
}

View File

@ -0,0 +1,58 @@
# To be used only on ASK LoGO readers!!!
# As we don't know how GPIO can be wired, it may hurt your hardware!!!
# P32=0 LED1
# P34=0 progressive field off
# SFR_P3: 0x..101011
08 ff b0 2b
p 100
# P32=0 LED1
# P31=0 LED2
# SFR_P3: 0x..101001
08 ff b0 29
p 100
# P32=0 LED1
# P31=0 LED2
# P30=0 P33=0 LED3
# SFR_P3: 0x..100000
08 ff b0 20
p 100
# P32=0 LED1
# P31=0 LED2
# P30=0 P33=0 LED3
# P35=0 LED4
# SFR_P3: 0x..000000
08 ff b0 00
p 100
# P32=0 LED1
# P31=0 LED2
# P30=0 P33=0 LED3
# SFR_P3: 0x..100000
08 ff b0 20
p 100
# P32=0 LED1
# P31=0 LED2
# SFR_P3: 0x..101001
08 ff b0 29
p 100
# P32=0 LED1
# SFR_P3: 0x..101011
08 ff b0 2b
p 100
# P32=0 LED1
# SFR_P3: 0x..101011
08 ff b0 2b

Some files were not shown because too many files have changed in this diff Show More