Advertisement
Guest User

Untitled

a guest
May 30th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. from __future__ import print_function
  2. import nfc
  3. import sys
  4.  
  5.  
  6. def connected(tag):
  7. servc = 0x100B
  8. service_code = [nfc.tag.tt3.ServiceCode(
  9. servc >> 6, servc & 0x3f
  10. )]
  11. bc_id = [nfc.tag.tt3.BlockCode(i) for i in range(3)]
  12. bc_name = [nfc.tag.tt3.BlockCode(3)]
  13. try:
  14. print(tag.read_without_encryption(
  15. service_code, bc_id
  16. ).decode('ascii')[2:11] + ',' +
  17. tag.read_without_encryption(
  18. service_code, bc_name
  19. ).decode('shift-jis')
  20. )
  21. except Exception:
  22. sys.exit("Read failed")
  23. return False
  24.  
  25. if __name__ == "__main__":
  26. clf = nfc.ContactlessFrontend('usb')
  27. rdwr_options = {
  28. 'on-connect': connected
  29. }
  30. clf.connect(rdwr=rdwr_options)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement