Help us understand the problem. What is going on with this article?

nfc raspberrypi return true? tag?

More than 1 year has passed since last update.

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

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away