- 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
libnfc/buses/Makefile.am:16: warning: EXTRA_DIST multiply defined in
condition TRUE ...
libnfc/buses/Makefile.am:9: ... 'EXTRA_DIST' previously defined here
* 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
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().
* master:
CMake: enable same set of default drivers as for autotools
pn532_uart: Unify copyright notices & update authors lists (somehow this file was forgotten)
* 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
* 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
...
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.
- 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
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.
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
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
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...
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);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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++) {
^ ~~
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)
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)
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)
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.
- 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.
- 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
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.
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).
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 ;-)
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.
- 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
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
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()
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