[PYTHON] Read FeliCa IDm with raspberrypi3 (pasori RC-S380 version)

To read FeliCa IDm on pasori RC-S320 here

Basically, it is exactly as described in Nfcpy official, but there were various stumbling points, so I summarized it. I did.

environment

Hard: raspberrypi3 OS:raspbian Leader: pasori RC-S380

nfcpy installation

For version 0.10 of nfcpy, IDm could not be read properly when reading FeliCa of Osaifu-Keitai or driver's license, so 0.9 is installed below.

$ sudo apt-get install python-usb
$ sudo apt-get install bzr
$ mkdir nfcpy
$ cd nfcpy
$ bzr branch lp:nfcpy/0.9

Pass the path to nfc

Make "import nfc" available everywhere.

sudo ln -s /home/pi/nfcpy/0.9/nfc /usr/local/lib/python2.7/dist-packages/

Allow nfc to be used without sudo

Check the ID with lsusb.

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

If the confirmed ID is different from 054c: 06c3, change the idVendor and idProduct specifications of the following command and execute.

$ sudo sh -c 'echo SUBSYSTEM==\"usb\", ACTION==\"add\", ATTRS{idVendor}==\"054c\", ATTRS{idProduct}==\"06c3\", GROUP=\"plugdev\" >> /etc/udev/rules.d/nfcdev.rules'

Reboot to reflect the settings.

sudo reboot -h now

Sample code to read IDm

idm_reader.py


import nfc
import binascii

def connected(tag):
    idm = binascii.hexlify(tag.idm)
    print(idm)
    return idm

clf = nfc.ContactlessFrontend('usb')
clf.connect(rdwr={'on-connect': connected}) # now touch a tag
clf.close()

reference

Connect Pasori RC-S380 to Raspberry Pi 2 and read ID nfcpy

Recommended Posts

Read FeliCa IDm with raspberrypi (pasori RC-S320 version)
Read FeliCa IDm with raspberrypi3 (pasori RC-S380 version)