2021-08-16
NFC, Python, Raspberrypi, Sensor
nfc raspberrypi read tag
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だけ気をつける.
ximport 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]の情報を利用)
xxxxxxxxxx
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...
のような感じで出る.