Commit graph

2201 commits

Author SHA1 Message Date
Benjamin Delpy
3f0101bd3f Fix nfc_initiator_select_passive_target target count on PN53x when not using InListPassiveTarget
When using `pn53x` chip with target not compatible with `InListPassiveTarget` (like `NMT_ISO14443BICLASS`, `NMT_ISO14443B2CT` & `NMT_ISO14443B2SR` by eg.), the logic behind `nfc_initiator_select_passive_target` to return target count seems to be buggy

`nfc_initiator_select_passive_target`:
> Returns:
> Returns selected passive target count on success, otherwise returns libnfc's error code (negative value)

In `pn53x_initiator_select_passive_target_ext`, the return value in success is always `abtTargetsData[0]`. This is correct when using `InListPassiveTarget` as the first byte is `NbTg`, but it can be problematic for other cases.

- Example with a Mifare:
```
gentilkiwi@pi5:~/libnfc-dev $ ./utils/nfc-list -t 1
NFC device: Elechouse NFC Module V3 (SPI) opened

## End of function 'pn53x_initiator_select_passive_target_ext'...
##  abtTargetsData content is : 01 01 00 04 08 04 1a da 74 44
##  return will be:           0x01 (?)

1 ISO14443A passive target(s) found:
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04
       UID (NFCID1): 1a  da  74  44
      SAK (SEL_RES): 08
```

- Example with 2x ST25TB:
```
gentilkiwi@pi5:~/libnfc-dev $ ./utils/nfc-list -t 32
NFC device: Elechouse NFC Module V3 (SPI) opened

## End of function 'pn53x_initiator_select_passive_target_ext'...
##  abtTargetsData content is : 35 a5 f2 a4 68 1f 02 d0
##  return will be:           0x35 (?)

1 ISO14443B-2 ST SRx passive target(s) found:
ISO/IEC 14443-2B ST SRx (106 kbps) target:
                UID: 35  a5  f2  a4  68  1f  02  d0
```
```
gentilkiwi@pi5:~/libnfc-dev $ ./utils/nfc-list -t 32
NFC device: Elechouse NFC Module V3 (SPI) opened

## End of function 'pn53x_initiator_select_passive_target_ext'...
##  abtTargetsData content is : 00 92 f0 a4 68 1f 02 d0
##  return will be:           0x00 (?)

0 ISO14443B-2 ST SRx passive target(s) found.
```

The proposed PR will fix the target count to 1 when not using `InListPassiveTarget`, since current versions of target initialisation do not support for more.

- Results:

```
gentilkiwi@pi5:~/libnfc-dev $ ./utils/nfc-list -t 32
NFC device: Elechouse NFC Module V3 (SPI) opened
1 ISO14443B-2 ST SRx passive target(s) found:
ISO/IEC 14443-2B ST SRx (106 kbps) target:
                UID: 00  92  f0  a4  68  1f  02  d0

gentilkiwi@pi5:~/libnfc-dev $ ./examples/nfc-st25tb
|mode   : info
Reader  : Elechouse NFC Module V3 (SPI) - via pn532_spi:/dev/spidev0.0:500000
  ...wait for card...
Target  : ISO/IEC 14443-2B ST SRx (106 kbps)
UID     : 00 92 f0 a4 68 1f 02 d0
Manuf   : 0x02 - STMicroelectronics
ChipId  : 0x1f - ST25TB04K
Serial  : 0x68a4f09200
|blk sz : 32 bits
|nb blks: 128
|sys idx: 255
```

(also checked for non-regression with `InListPassiveTarget`, including multiples `A` targets)
2024-07-28 12:36:49 +02:00
Ludovic Rousseau
df0a3beca9 Fix cmake warning
CMake Warning (dev) at utils/CMakeLists.txt:50 (ADD_EXECUTABLE):
  Policy CMP0115 is not set: Source file extensions must be explicit.  Run
  "cmake --help-policy CMP0115" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  File:

    /home/rousseau/Documents/github/libnfc/utils/jewel.c
This warning is for project developers.  Use -Wno-dev to suppress it.
2024-02-16 14:52:20 +01:00
Ludovic Rousseau
c6657c7c00 Fix cmake warning
CMake Warning (dev) at libnfc/CMakeLists.txt:77 (ADD_LIBRARY):
  Policy CMP0115 is not set: Source file extensions must be explicit.  Run
  "cmake --help-policy CMP0115" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  File:

    /home/rousseau/Documents/github/libnfc/libnfc/nfc.c
This warning is for project developers.  Use -Wno-dev to suppress it.
2024-02-16 14:49:38 +01:00
Davide Prade
92cc3b1ed1
Fixed the CMake file because under MSYS2 it always forced 32bit compilation even on 64bit machine. (#661)
Co-authored-by: Davide Prade <dprade@olari.it>
2024-02-16 14:35:48 +01:00
thewetzel
9dc65e4075
Refactor HAL macro using gcc statement expressions to avoid returning from a macro. (#705)
Fix memory leak in nfc_initiator_select_passive_target().
2024-02-16 14:34:29 +01:00
Yang Kun
d40cbef104
Fixed getting the current time wrong in the script file (#712)
Co-authored-by: Yang Kun <13147081-ikspress@users.noreply.gitlab.com>
2024-02-16 14:30:38 +01:00
Didier A
1f77bcec17 Document environment variables in README.md 2023-10-21 17:41:00 +02:00
Samuel Prevost
72262133f1 Fixes error libnfc.driver.acr122_usb Invalid RDR_to_PC_DataBlock frame 2023-10-21 17:40:26 +02: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