Notes on nfc.ContactlessFrontend () for nfcpy in python

Sample program

SimpleSample.py


# coding: utf-8

import sys
import os
sys.path.append(os.path.dirname(__file__) + '/nfcpy')
import nfc

#Function to execute when the card is touched
def hello(tag):
    print 'hello'

clf = nfc.ContactlessFrontend('usb')            #Specify only that it is a USB device
#clf = nfc.ContactlessFrontend('usb:054c:06c3')  #Specify vendor ID(Sony's PaSoRi Vendor ID)
#clf = nfc.ContactlessFrontend('usb:001')        #Specify the bus number. Choose the first one on this bus
#clf = nfc.ContactlessFrontend('usb:001:011')    #Specify bus number and device number

rdwr = {'on-connect':hello}

print 'start'
clf.connect(rdwr=rdwr)
print 'end'

clf = nfc.ContactlessFrontend ()

Connect to the card reader with clf = nfc.ContactlessFrontend (), but there are several types of arguments.

argument Example meaning
'usb' 'usb' Connect to the device found (first?)
'usb:Vendor ID' 'usb:054c:06c3' 指定のVendor IDのデバイスの中から(一番初めに?)見つかったものに接続
'usb:Bus number' 'usb:001' 指定のBus numberのデバイスの中から一番初めに見つかったものに接続
'usb:Bus number:Device number' 'usb:001:011' 指定のBus numberとDevice numberのデバイスに接続

You can find the vendor ID, bus number, and device number with the lsusb command.

$ lsusb
Bus 001 Device 010: ID 054c:06c3 Sony Corp.
Bus 001 Device 011: ID 054c:06c3 Sony Corp.

# Bus [Bus number] Device [Device number]: ID [Vendor ID] [Manufacturer's name]

Recommended Posts

Notes on nfc.ContactlessFrontend () for nfcpy in python
Notes for using OpenCV on Windows10 Python 3.8.3.
Notes for using python (pydev) in eclipse
Notes on using code formatter in Python
Notes on using dict in python [Competition Pro]
Notes for implementing simple collaborative filtering in Python
ABC125_C --GCD on Blackboard [Notes solved in Python]
Web scraping notes in python3
Search for strings in Python
Python Tkinter notes (for myself)
[Python] Notes on data analysis
Techniques for sorting in Python
Notes on installing Python on Mac
Get Evernote notes in Python
Notes on writing config files for Python Note: configparser
Notes on imshow () in OpenCV
Notes on installing Python on CentOS
About "for _ in range ():" in python
Notes on reading and writing float32 TIFF images in python
Check for memory leaks in Python
Notes on Python and dictionary types
Check for external commands in python
Minimum grammar notes for writing Python
Notes on using MeCab from Python
Personal notes for python image processing
Notes for me python csv graph
Notes on installing Python using PyEnv
Notes for Python file input / output
Notes on using rstrip with python.
Notes on accessing dashDB from python
Install confluent-kafka for Python on Ubuntu
Run unittests in Python (for beginners)
Create a Python environment for professionals in VS Code on Windows
Best practice for logging in JSON format on AWS Lambda / Python
Notes using cChardet and python3-chardet in Python 3.3.1.
WEB scraping with Python (for personal notes)
Notes on PyQ machine learning python grammar
Find files like find on linux in Python
Notes for installing Sublime Text on Ubuntu
Inject is recommended for DDD in Python
Documents on approaches for embedding in ARM
Tips for dealing with binaries in Python
Notes on creating static files in Django
Summary of various for statements in Python
Type annotations for Python2 in stub files!
Notes on doing Japanese OCR with Python
Run AzureKinect in Python on Christmas Eve.
Template for writing batch scripts in python
Notes on building Python and pyenv on Mac
Process multiple lists with for in Python
Notes for setting up pydicom on macOS
MongoDB for the first time in Python
Get a token for conoha in python
Sample for handling eml files in Python
AtCoder cheat sheet in python (for myself)
I searched for prime numbers in python
Tips for making small tools in python
Use pathlib in Maya (Python 2.7) for upcoming Python 3.7
Run Python in C ++ on Visual Studio 2017
Add words to MeCab's user dictionary on Ubuntu for use in Python
Notes on resolving references to packages in Python projects in IntelliJ IDEA (PyCharm)