tag.is_present always returns FALSE

Asked by Matija Urh

Hi,

IHi,

I have a small script (for now) which reads NFC tags and outputs what it gets

```
import nfc

def connected(tag):
    print "> def connected"
    print tag.is_present # Always False
    print tag # Type4Tag ATQ=0400 SAK=60 UID=08a52a0d ATS=0575807002
    # tag.read_binary(tag, 8, 16)

clf = nfc.ContactlessFrontend('usb')
print(clf)

while True:
    clf.connect(rdwr={'on-connect': connected})

```

At the end I would like to read 'read_binary' but first I stopped at 'tag.is_present' which is always false.
Am I doing something wrong here?

# Specs
* Raspberry Pi
* ACR122 reader

Question information

Language:
English Edit question
Status:
Answered
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Stephen Tiedemann (stephen-tiedemann) said :
#1

I'd guess the tag is not NDEF formatted. The T4T presence check in nfcpy is implemented as a periodic reading of the first two byte from the NDEF data file. You could use "examples/tagtool.py -d nfc.tag" to observe the debug log (or enable debug logs in your script).

It could generally be seen as a bug (or missing feature) that tag presence check relies on the NDEF structure be present. But unfortunately I did not yet have the time to figure out what a better mechanism would be. Reading ISO7816-4 just isn't fun.

Revision history for this message
fengzhiquan (fengzhiquan) said :
#2

I also encountered such a problem.

And I have two immature solutions here:

First, we can also periodically read a fixed file from ISO7816 structured t4t to check the presence.

Second, when t4t is out of field, we can get the deactive notification and change the presence status.

@Stephen, I'm not sure the second one can work.

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) said :
#3

I've meanwhile found that a good solution for Type 4 (ISO) Tags is to send R(NAK) commands. This is currently implemented in branch /dev-tags and will be in nfcpy v0.10 (and /trunk of course).

Can you help with this problem?

Provide an answer of your own, or ask Matija Urh for more information if necessary.

To post a message you must log in.