Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when no tag is on Explore NFC board #4

Closed
framboise314 opened this issue Dec 13, 2014 · 4 comments
Closed

Error when no tag is on Explore NFC board #4

framboise314 opened this issue Dec 13, 2014 · 4 comments

Comments

@framboise314
Copy link

Hello
I compiled nxppy successfully from source

I use a little loop test :

    import sys
    import nxppy
    uid = ""
    while True:
          mifare=nxppy.Mifare()
          uid=mifare.select()
          if uid is not None:
              print uid
              uid = ""
          else:
              print "No card"
              uid = ""

When I lounch the test with a NFC tag on the board I got :

pi@raspberrypi ~ $ sudo python test_de.py
8CA6450E
8CA6450E
......
8CA6450E

When removing the NFC tag, I would like to print "No Card" but the script stops and send an error as here under :

....
8CA6450E           ==> Here I remove the NFC TAG
Traceback (most recent call last):
  File "test_de.py", line 6, in <module>
    uid=mifare.select()
nxppy.SelectError: RequestA command failed: 201
pi@raspberrypi ~ $ 

When starting the script without a NFC tag I got directly

pi@raspberrypi ~ $ sudo python test_de.py
Traceback (most recent call last):
  File "test_de.py", line 6, in <module>
    uid=mifare.select()
nxppy.SelectError: RequestA command failed: 201
pi@raspberrypi ~ $

I made another try with this script read_nfc.py :

import nxppy
while True:
   mifare=nxppy.Mifare()
   if mifare is not None:
       print "Mifare is not null"
   uid=mifare.select()
   print "Read uid"
   if uid is not None:
       break

print uid

When launched with a NFC Tag it gives

pi@raspberrypi ~ $ sudo python read_nfc.py
Mifare is not null
Read uid
8CA6450E
pi@raspberrypi ~ $

But without NFC Tag on the board i have the same error...

pi@raspberrypi ~ $ sudo python read_nfc.py
Mifare is not null
Traceback (most recent call last):
  File "read_nfc.py", line 6, in <module>
    uid=mifare.select()
nxppy.SelectError: RequestA command failed: 201
pi@raspberrypi ~ $

I do not know why this append and if I make something wrong.
My goal is to write a post for the blog www.framboise314.fr. I would like to tell my readers how to use Explore NFC Board to open a door when a NFC Tag listed in a file is present.
But the script stops when no tag is near the board.

Hope you see where my mistake is
Best regards
François
www.framboise314.fr

@svvitale
Copy link
Owner

Hi Francois!

Thanks for reaching out! This is expected behavior. In the latest revision of nxppy (which uses a Mifare class instead of static methods), we throw an exception if the call to .select() fails. Here's how you would handle it (using one of your example scripts):

import nxppy
mifare=nxppy.Mifare()

while True:
    try:
        uid = mifare.select()
        print "Read uid", uid
    except nxppy.SelectError:
        pass   

I'll go and update my post on the NXP site, which I think still has the old example. Please let me know if you have any additional issues. I look forward to seeing your blog post when it's published!

Scott

@framboise314
Copy link
Author

Thank you Scott
I try it tomorrow
the post will follow rapidly if this test is Ok
I tell you when it's on the blog
best regards
François

@framboise314
Copy link
Author

Hello Scott
the post is online (2 parts)
http://www.framboise314.fr/jai-teste-pour-vous-la-carte-explore-nfc-delement-14-12/
http://www.framboise314.fr/jai-teste-pour-vous-la-carte-explore-nfc-delement-14-22/
thank you again
happy xmas and new year to you and familly
François

@svvitale
Copy link
Owner

Thanks Francois! I've just tweeted your post. Excited to see it! Joyeux
noël à vous et à votre famille aussi!

On Sun Dec 21 2014 at 10:08:26 AM Francois MOCQ notifications@github.com
wrote:

Hello Scott
the post is online (2 parts)

http://www.framboise314.fr/jai-teste-pour-vous-la-carte-explore-nfc-delement-14-12/

http://www.framboise314.fr/jai-teste-pour-vous-la-carte-explore-nfc-delement-14-22/
thank you again
happy xmas and new year to you and familly
François


Reply to this email directly or view it on GitHub
#4 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants