LoginSignup
0
1

More than 5 years have passed since last update.

nfc raspberrypi read tag

Last updated at Posted at 2017-04-18

ref:
[1] http://tfukui2012.blog.fc2.com/blog-entry-22.html
[2] http://nfcpy.readthedocs.io/en/latest/modules/clf.html

nfc tagを読む
16進法らしいのでそのencodeだけ気をつける.

read_tag.py
import nfc
import time

def connected (tag):
    print(tag)
    print(tag.type)
    print( tag.idm )
    print( str(tag.idm) )
    print( str(tag.idm).encode("hex") )
    print( tag.pmm )
    print( str(tag.pmm) )
    print( str(tag.pmm).encode("hex") )
    print( tag.sys )
    print( str(tag.sys) )
    print( str(tag.sys).encode("hex") )
    time.sleep(1)

clf = nfc.ContactlessFrontend('usb')

while True:
    print('waiting...')
    result = clf.connect(rdwr={'on-connect':connected})
    print('----------------------')
    print(result)
    print( str(result.idm).encode("hex"))
    print( str(result.pmm).encode("hex"))
    print( str(result.sys).encode("hex"))
    print('scaned')

とやると,
仮に,
ID =01010501b00ac30b
PMM=03014b024f4993ff
SYS=1234
の場合(ref[2]の情報を利用)

waiting...
Type3Tag ID=01010501b00ac30b PMM=03014b024f4993ff SYS=1234
Type3Tag
|?
|?
01010501b00ac30b
1CEF???
1CEF???
03014b024f4993ff
3
3
33
----------------------
Type3Tag ID=01010501b00ac30b PMM=03014b024f4993ff SYS=1234
01010501b00ac30b
03014b024f4993ff
33
scaned
waiting...

のような感じで出る.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1