nfc-tools / libnfc

Platform independent Near Field Communication (NFC) library
http://nfc-tools.org
GNU Lesser General Public License v3.0
1.72k stars 442 forks source link

Is possible to have nfc_initiator_select_passive_target function with timeout? #527

Open crossmax opened 5 years ago

crossmax commented 5 years ago

Hi. I've a problem with nfc_initiator_select_passive_target function. I've verified that if the card is removed at the beginning of the reading, the function nfc_initiator_select_passive_target blocks the execution of the main thread and until the same card is not presented again in the reader, the flow does not continue. If you present another different card, it remains blocked. Is there any possibility to make the connection with a timeout?

crossmax commented 5 years ago

I'm still with this problem. Any suggestion?

ghost commented 5 years ago

Hi crossmax did you find any solution to your issue ? I have another problem with the same function after certain reads it remains blocked !!

crossmax commented 5 years ago

Hi @adriate No, this week I've taken up this issue because I really need fixed it. This function hang up my procesos but I'm really using libfreefare. I've detected tag, then I need select desfire (or mifare classic if tag isn't desfire), but if the tag is removed after detect it (before complete select tag action, the nfc_initiator_select_passive_target will stuck. Next week I'll try to fix it someway

ghost commented 5 years ago

Hi crossmax, Thank you, i will try as well to fix it this week by using timeout or another way. I will share with you my solution. thank you

crossmax commented 5 years ago

Hi @adriate Finally I found the solution to infinite loop on nfc_initiator_select_passive_target if you remove the card just before. You can set to false the follow property nfc_device_set_property_bool(tag->device, NP_INFINITE_SELECT, false) Default value is true and you can modified into nfc_initiator_init function within libnfc or with nfc_device_set_property_bool before calling mifare_classic_connect (mifare_defire_connect)

I hope it has been helpful

ghost commented 5 years ago

Hi @crossmax Amazing Thank you for sharing with me the solution. As I told you i am reading tags in high speed and some time the reader just stop to read(Blocked). yesterday i did some small tests and i have found it is blocked when it is vibrating or when the USB cable moves (not well installed mechanically) so i think is mechanical problem ! It seems strange to me. what you think about it ?