21
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PaSoRi RC-S380/P でICカードを読み込む Mac編

Last updated at Posted at 2016-09-29

PaSoRi RC-S380/Pとは?

これの事
https://www.sony.co.jp/Products/felica/consumer/products/RC-S380.html

これを使って様々なICカードを読み込んでみる。

今回試すもの

  • Nanaco (7&11)
  • Suica (JR東日本)
  • e-amusement pass(KONAMI)

試験環境

  • Mac OS X El Captain
  • Python 2.7.10(システム標準のPython)

残念ながらまだnfcpyはpython 3 に対応していない。(2016年9月30日時点)

ライブラリの準備

nfcpyを使用する。

$ brew install libusb
$ brew install libusb-compat
$ brew install bzr
$ sudo pip install pyusb libusb1 pyserial
$ bzr branch lp:nfcpy trunk

サンプルの実行

$ python examples/tagtool.py show
Traceback (most recent call last):
  File "examples/tagtool.py", line 37, in <module>
    from cli import CommandLineInterface
  File "/Users/ryo/programming/python/trunk/examples/cli.py", line 35, in <module>
    import nfc
  File "/Users/ryo/programming/python/trunk/nfc/__init__.py", line 28, in <module>
    from clf import ContactlessFrontend
  File "/Users/ryo/programming/python/trunk/nfc/clf/__init__.py", line 34, in <module>
    import nfc.llcp
  File "/Users/ryo/programming/python/trunk/nfc/llcp/__init__.py", line 31, in <module>
    from llc import LOGICAL_DATA_LINK, DATA_LINK_CONNECTION
  File "/Users/ryo/programming/python/trunk/nfc/llcp/llc.py", line 41, in <module>
    from . import sec
  File "/Users/ryo/programming/python/trunk/nfc/llcp/sec.py", line 490, in <module>
    OpenSSL = OpenSSLWrapper(libcrypto)
  File "/Users/ryo/programming/python/trunk/nfc/llcp/sec.py", line 183, in __init__
    self.crypto.EC_KEY_set_public_key_affine_coordinates.restype = c_int
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
    func = self.__getitem__(name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7fecdb411890, EC_KEY_set_public_key_affine_coordinates): symbol not found

エラーが出た。OpenSSL周りでエラーが出てるからきっとOpenSSL入れ直したら治るんだろうなと思ったら案の定OpenSSLが最新じゃなかったので、brew installする。

$ brew install openssl
ln -s /usr/local/opt/openssl/bin/openssl /usr/local/bin/openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/libcrypto.dylib
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/libssl.dylib

OpenSSLが新しくなったことを確認したら再度実行。

$ python examples/tagtool.py show
[nfc.clf] searching for reader on path usb
[nfc.clf] using SONY RC-S380/P NFC Port-100 v1.11 at usb:020:005
** waiting for a tag **
Type3Tag 'FeliCa Standard (RC-S???)' ID=xxxxxxxxxxxxxxxx PMM=xxxxxxxxxxxxxxxx SYS=0003
$ python examples/tagtool.py show
[nfc.clf] searching for reader on path usb
[nfc.clf] using SONY RC-S380/P NFC Port-100 v1.11 at usb:020:005
** waiting for a tag **
Type3Tag 'FeliCa Standard (RC-SA00/1)' ID=xxxxxxxxxxxxxxxx PMM=xxxxxxxxxxxxxxxx SYS=04C7

1枚目がSuica、2枚目がNanaco、3枚目e-passは、カードが壊れてるのか読み込めず(誤って洗濯してしまったせいかも……)

  • ID : カードを特定するための一意な値
  • PMM : よくわからない
  • SYS : システムを特定する為の値

Felicaに関する詳細はここを読むのがよさそう
http://www.sony.co.jp/Products/felica/business/tech-support/data/code_descriptions_1.2.pdf

参考にした記事

what's Next

そこに暇そうなラズベリーパイがあるので、それを使って出勤管理などを作ってみる

21
20
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?