PythonからPaSoRiを使って交通系ICカードのIDmを読む
環境 Ubuntu 18.04 (VirtualBox on Windows 10) Python 2.7.15rc1(nfcpyはPython3非対応のため) Sony PaSoRi RC-S380 Suica (2019/12/19 追記)未検証ですがnfcpyがv1.0.0でPython3対応したみたいです。https://github.com/nfcpy/nfcpy/issues/47#issuecomment-499693493 セットアップ まずPaSoRiを接続する。PaSoRiをUSBポートに挿して、VirtualBox仮想マシンの設定からUSB、USB デバイスフィルターにSONY RC-S380/Pを追加。 $ lsusb Bus 001 Device 004: ID 054c:06c3 Sony Corp. ... これでOK。 次にnfcpyのインストール(※Python2に導入すること、virtualenvを使うといいのでは)。 pip install nfcpy いくらか準備が必要なので、python -m nfcを実行する。 $ python -m nfc No handlers could be found for logger "nfc.llcp.sec" This is the 0.13.5 version of nfcpy run in Python 2.7.15rc1 on Linux-4.15.0-33-generic-x86_64-with-Ubuntu-18.04-bionic I'm now searching your system for contactless devices ** found usb:054c:06c3 at usb:001:004 but access is denied -- the device is owned by 'root' but you are 'USERNAME' -- also members of the 'root' group would be permitted -- you could use 'sudo' but this is not recommended -- better assign the device to the 'plugdev' group sudo sh -c 'echo SUBSYSTEM==\"usb\", ACTION==\"add\", ATTRS{idVendor}==\"054c\", ATTRS{idProduct}==\"06c3\", GROUP=\"plugdev\" >> /etc/udev/rules.d/nfcdev.rules' sudo udevadm control -R # then re-attach device I'm not trying serial devices because you haven't told me -- add the option '--search-tty' to have me looking -- but beware that this may break other serial devs Sorry, but I couldn't find any contactless device 一般ユーザーの場合こんなメッセージが出るので、指示通りデバイスをplugdevグループに割り当てる。 ...