Timeout error???

Asked by Juan Trujillo on 2015-12-13

I have been using the following piece of source code for a while and have seen below messages from time to time and I would like to confirm if they a real problem or just a warning:

Source code:
timeOut = lambda: time.time() - started > (10 * 60)
started = time.time()
myNfcTag = clf.connect(rdwr={'on-connect': connected}, terminate=timeOut)

Error messages:
WARNING:nfc.dev:Driver.set_communication_mode() should be implemented.
ERROR:nfc.tag.tt2:while reading ndef: TimeoutError('9.9.1.3')

Any feedback is really appreciated.

-Juan

Question information

Language:
English Edit question
Status:
Answered
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Last query:
2015-12-13
Last reply:
2015-12-18

The WARNING is just a warning and can be safely ignored.

The TimeoutError '9.9.1.3' says that the Type 2 Tag failed to respond in time. This can be expected for example if the tag is moved out of range or close to end of communication range.

You're using an old version of nfcpy, just to note that.

How do I know the version of nfcpy that I'm running? And what is the latest version?

BTW, what's the right approach to catch this warning condition and retry to find a "good" NFC tag?

This is what I'm currently doing:

timeOut = lambda: time.time() - started > (5 * 60)
started = time.time()
myNfcTag = clf.connect(rdwr={'on-connect': connected}, terminate=timeOut)
if myNfcTag is None:
  #do nothing, just print a message
else:
  if myNfcTag.ndef.message:
    #do something with the tag
else:
    #ignore this tag

Unfortunately my code is printing the "warning" message AND passes the "if myNfcTag.ndef.message" check and then it crashes (most likely because myNfcTag is invalid).

This is the crash error message:

if myNfcTag.ndef.message:
AttributeError: 'NoneType' object has no attribute 'message'

The version is in in nfc.__version__ (file nfc/__init__.py). It should be like 0.9.x or 0.10.x, latest release is 0.10.2.

Check myNfcTag.ndef against None, if it has ndef then message is always present (it's an empty Message in case there is no or corrupted NDEF data).

Thanks for all the feedback!!!

I checked my version and it is 0.9.2. Som how do I smoothly upgrade my nfcpy?

Just grab the latest version and extract into some directory, then copy your code there and check if it works.

Can you help with this problem?

Provide an answer of your own, or ask Juan Trujillo for more information if necessary.

To post a message you must log in.