nfc raspberrypi read tag on-release, on-connect

on-release

import nfc
import time

def released (tag):
    print(tag)
    print('released!!')
    time.sleep(1)

clf = nfc.ContactlessFrontend('usb')

while True:
    print('waiting...')
    result = clf.connect(rdwr={'on-release':released})
    print('----------------------')
    print(result)
    print('scaned')

をやると,
felicaを離した時に,

waiting...
Type3Tag ID=01010501b00ac30b PMM=03014b024f4993ff SYS=1234
released!!

とでる.

“scaned”が出ないけど, felicaをつけて離してつけて離して…を繰り返すと

waiting...
Type3Tag ID=01010501b00ac30b PMM=03014b024f4993ff SYS=1234
released!!
waiting...
Type3Tag ID=01010501b00ac30b PMM=03014b024f4993ff SYS=1234
released!!
waiting...
Type3Tag ID=01010501b00ac30b PMM=03014b024f4993ff SYS=1234
released!!
waiting...
Type3Tag ID=01010501b00ac30b PMM=03014b024f4993ff SYS=1234
released!!

となるので, while trueは効いてる模様.
ふむ…

on-connect, on-release

import nfc
import time

def connected (tag):
    print('connected!!')
    time.sleep(1)

def released (tag):
    print('released!!')
    time.sleep(1)

clf = nfc.ContactlessFrontend('usb')

rdwr_options={
    'on-connect':connected,
    'on-release':released,
}

while True:
    print('waiting...')
    #clf.connect(rdwr={'on-connect':connected, 'on-release':released})
    clf.connect(rdwr=rdwr_options)
    print('scaned')

のようにon-connectとon-releaseを両方使用してみたが,
つけて離してつけて離して…を繰り返しても

waiting...
connected!!
scaned
waiting...
connected!!
scaned
waiting...
connected!!

となるだけで, on-releaseが効かず….

rdwr_optionsを使用せずに,

import nfc
import time

def connected (tag):
    print('connected!!')
    time.sleep(1)

def released (tag):
    print('released!!')
    time.sleep(1)

clf = nfc.ContactlessFrontend('usb')

while True:
    print('waiting...')
    clf.connect(rdwr={'on-connect':connected, 'on-release':released})
    print('scaned')

とやっても結果は同じ.
ふむ….