LoginSignup
1
0

More than 5 years have passed since last update.

nfc raspberrypi return true? tag?

Last updated at Posted at 2017-04-18

true

why_true.py
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に何も入れずに

why_tag.py
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になるのはやっぱ謎.

1
0
4

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
1
0