[PYTHON] Mac edition that reads IC card with PaSoRi RC-S380 / P

What is PaSoRi RC-S380 / P?

This thing https://www.sony.co.jp/Products/felica/consumer/products/RC-S380.html

Try reading various IC cards using this.

What to try this time

Test environment

Unfortunately nfcpy doesn't support python 3 yet. (As of September 30, 2016)

Library preparation

Use nfcpy.

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

Run the sample

$ 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

I got an error. Since there is an error around OpenSSL, I thought that it would be cured if I re-installed OpenSSL, but as expected, OpenSSL was not the latest, so 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

After confirming that OpenSSL is new, execute it again.

$ 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

The first card is Suica, the second card is Nanaco, and the third card e-pass cannot be read because the card is broken (maybe because I accidentally washed it ...)

Read more about Felica here http://www.sony.co.jp/Products/felica/business/tech-support/data/code_descriptions_1.2.pdf

Referenced articles

what's Next There is a Raspberry Pi that seems to be free, so I will try to make attendance management etc. using it

Recommended Posts

Mac edition that reads IC card with PaSoRi RC-S380 / P
Visualize point P that works with Python
Read FeliCa using Pasori (RC-380S) on Mac