2021-08-16
NFC, Python, Raspberrypi, Sensor
nfc raspberrypi return true? tag?
true
import nfc
import time
def connected (tag):
print('connected!!')
time.sleep(1)
return 1
clf = nfc.ContactlessFrontend('usb')
while True:
print('waiting...')
result = clf.connect(rdwr={'on-connect':connected})
print(result)
print('scaned')
とやると, なぜか
waiting...
connected!!
True
scaned
waiting...
connected!!
True
scaned
waiting...
のようにtrueがでる.
tag
一方, returnに何も入れずに
import nfc
import time
def connected (tag):
print('connected!!')
time.sleep(1)
return
clf = nfc.ContactlessFrontend('usb')
while True:
print('waiting...')
result = clf.connect(rdwr={'on-connect':connected})
print(result)
print('scaned')
とすると,
waiting...
connected!!
Type3Tag ID=01010501b00ac30b PMM=03014b024f4993ff SYS=1234
scaned
waiting...
connected!!
Type3Tag ID=01010501b00ac30b PMM=03014b024f4993ff SYS=1234
scaned
waiting...
のようにtagがreturnされる. まぁこれは理解できる...か. でもreturn 1 でtrueになるのはやっぱ謎.