Skip to content

Instantly share code, notes, and snippets.

@shotarok
Created July 23, 2016 05:23
Show Gist options
  • Save shotarok/fed595781b55330e3137b5b5b072cf91 to your computer and use it in GitHub Desktop.
Save shotarok/fed595781b55330e3137b5b5b072cf91 to your computer and use it in GitHub Desktop.
A test code to extract ID from SUICA/PASMO through nfcpy
#!/usr/bin/env python
# coding:utf-8
from __future__ import print_function
from binascii import hexlify
import sys
import nfc
def connected(tag):
if isinstance(tag, nfc.tag.tt3.Type3Tag):
try:
print("Your IDm is {}".format(hexlify(tag.idm).upper()))
except Exception as e:
print("error: {}".format(e))
else:
print("error: tag isn't Type3Tag")
if __name__ == "__main__":
print("Please put your card on the nfc reader. Waiting...")
sys.stdout.flush()
clf = nfc.ContactlessFrontend('usb')
clf.connect(rdwr={'on-connect': connected})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment