Advertisement
Guest User

Untitled

a guest
Dec 16th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. import logging
  2. logging.basicConfig()
  3.  
  4. import sys
  5. import time
  6. import errno
  7. import nfc
  8.  
  9. def connected(tag):
  10.     print(tag)
  11.     return True
  12.  
  13. def connect_reader(path):
  14.     while True:
  15.         try:
  16.             return nfc.ContactlessFrontend(path)
  17.         except IOError as error:
  18.             time.sleep(0.5)
  19.             continue
  20.    
  21. if __name__ == '__main__':
  22.     while True:
  23.         try:
  24.             clf = connect_reader("usb")
  25.         except KeyboardInterrupt:
  26.             sys.exit()
  27.  
  28.         try:
  29.             clf.connect(rdwr={'on-connect': connected})
  30.         finally:
  31.             clf.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement