Skip to content

Instantly share code, notes, and snippets.

@gucchan22
Last active October 1, 2016 12:01
Show Gist options
  • Save gucchan22/66d51e0568c317c4c3a2b44c7664396e to your computer and use it in GitHub Desktop.
Save gucchan22/66d51e0568c317c4c3a2b44c7664396e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import nfc
import time
import random
import pprint
#import requests
import binascii
servcode = 0x110B
suica = 0x090f
previd = 0
def connected(tag):
import __main__
service_code = [nfc.tag.tt3.ServiceCode(servcode >> 6, servcode & 0x3f)]
students_id = [nfc.tag.tt3.BlockCode(i) for i in range(1, 2)]
result_id = tag.read_without_encryption(service_code, students_id)
res_id = int(result_id[0:8])
if res_id != __main__.previd:
print "学籍番号 : "+str(res_id)
__main__.previd = res_id
else:
print "すでに出席登録しています"
clf.connect(rdwr={'on-connect': connected})
clf = nfc.ContactlessFrontend('usb:054c:06c3')
clf.connect(rdwr={'on-connect': connected})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment