Created
May 30, 2016 10:14
-
-
Save MtShadow/cf4afb3d7b2d3f4155158a892e4549e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import nfc | |
import sys | |
def connected(tag): | |
servc = 0x100B | |
service_code = [nfc.tag.tt3.ServiceCode( | |
servc >> 6, servc & 0x3f | |
)] | |
bc_id = [nfc.tag.tt3.BlockCode(i) for i in range(3)] | |
bc_name = [nfc.tag.tt3.BlockCode(3)] | |
try: | |
print(tag.read_without_encryption( | |
service_code, bc_id | |
).decode('ascii')[2:11] + ',' + | |
tag.read_without_encryption( | |
service_code, bc_name | |
).decode('shift-jis') | |
) | |
except Exception: | |
sys.exit("Read failed") | |
return False | |
if __name__ == "__main__": | |
clf = nfc.ContactlessFrontend('usb') | |
rdwr_options = { | |
'on-connect': connected | |
} | |
clf.connect(rdwr=rdwr_options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment