Sony FeliCa Lite-S format issues

Asked by ian@iwjohnston.com on 2016-02-17

Stephen,

I am trying to use the Sony FeliCa Lite-S as a Tag3 with nfcpy. They were supplied as "NDEF formatted". However tagtool.py complains when I try to "show" the Tag. See below:

pi@pi3:~/nfcpy/trunk/examples $ python 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:001:007
** waiting for a tag **
Type3Tag 'FeliCa Lite-S (RC-S966)' ID=012E34E829CE1E71 PMM=00F1000000014300 SYS=88B4
Traceback (most recent call last):
  File "tagtool.py", line 569, in <module>
    TagTool().run()
  File "/home/pi/nfcpy/trunk/examples/cli.py", line 415, in run
    while self.run_once() and self.options.loop:
  File "/home/pi/nfcpy/trunk/examples/cli.py", line 410, in run_once
    return clf.connect(**kwargs)
  File "/home/pi/nfcpy/trunk/nfc/clf/__init__.py", line 546, in connect
    result = self._rdwr_connect(rdwr_options, terminate)
  File "/home/pi/nfcpy/trunk/nfc/clf/__init__.py", line 572, in _rdwr_connect
    if options['on-connect'](tag):
  File "tagtool.py", line 303, in on_rdwr_connect
    self.rdwr_commands[self.options.command](tag)
  File "tagtool.py", line 324, in show_tag
    if tag.ndef:
  File "/home/pi/nfcpy/trunk/nfc/tag/__init__.py", line 221, in ndef
    if ndef.has_changed:
  File "/home/pi/nfcpy/trunk/nfc/tag/__init__.py", line 135, in has_changed
    old_data, self._data = self._data, self._read_ndef_data()
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3.py", line 190, in _read_ndef_data
    attributes = self._read_attribute_data()
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3_sony.py", line 760, in _read_attribute_data
    attributes = super(FelicaLiteS.NDEF, self)._read_attribute_data()
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3_sony.py", line 397, in _read_attribute_data
    attributes = super(FelicaLite.NDEF, self)._read_attribute_data()
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3.py", line 153, in _read_attribute_data
    try: data = self._tag.read_from_ndef_service(0)
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3_sony.py", line 688, in read_without_mac
    return self.read_without_encryption(service_list, block_list)
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3.py", line 511, in read_without_encryption
    data = self.send_cmd_recv_rsp(0x06, data, timeout)
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3.py", line 657, in send_cmd_recv_rsp
    if rsp[0] != len(rsp):
IndexError: bytearray index out of range

It companies even more when I try the tag tool,py format tt3 command

pi@pi3:~/nfcpy/trunk/examples $ python tagtool.py format tt3
[nfc.clf] searching for reader on path usb
[nfc.clf] using SONY RC-S380/P NFC Port-100 v1.11 at usb:001:005
** waiting for a tag **
Traceback (most recent call last):
  File "tagtool.py", line 569, in <module>
    TagTool().run()
  File "/home/pi/nfcpy/trunk/examples/cli.py", line 415, in run
    while self.run_once() and self.options.loop:
  File "/home/pi/nfcpy/trunk/examples/cli.py", line 410, in run_once
    return clf.connect(**kwargs)
  File "/home/pi/nfcpy/trunk/nfc/clf/__init__.py", line 546, in connect
    result = self._rdwr_connect(rdwr_options, terminate)
  File "/home/pi/nfcpy/trunk/nfc/clf/__init__.py", line 572, in _rdwr_connect
    if options['on-connect'](tag):
  File "tagtool.py", line 303, in on_rdwr_connect
    self.rdwr_commands[self.options.command](tag)
  File "tagtool.py", line 392, in format_tag
    formatted = tag.format(version=version, wipe=self.options.wipe)
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3_sony.py", line 625, in format
    return super(FelicaLite, self).format(version, wipe)
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3.py", line 339, in format
    return super(Type3Tag, self).format(version, wipe)
  File "/home/pi/nfcpy/trunk/nfc/tag/__init__.py", line 281, in format
    status = self._format(version, wipe)
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3_sony.py", line 637, in _format
    mc = self.read_without_mac(0x88)
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3_sony.py", line 688, in read_without_mac
    return self.read_without_encryption(service_list, block_list)
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3.py", line 511, in read_without_encryption
    data = self.send_cmd_recv_rsp(0x06, data, timeout)
  File "/home/pi/nfcpy/trunk/nfc/tag/tt3.py", line 657, in send_cmd_recv_rsp
    if rsp[0] != len(rsp):
IndexError: bytearray index out of range

Am I doing something basically wrong here? I'm sure it is due to my very basic knowledge of python

Thx Ian

Question information

Language:
English Edit question
Status:
Solved
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Solved by:
ian@iwjohnston.com
Solved:
2016-02-19
Last query:
2016-02-19
Last reply:
2016-02-18

I remember that very recently I saw a similar output and it turned out to be a corner case of tag response time out below one millisecond versus millisecond granularity in the corresponding RC-S380 command, effectively resulting in a zero wait for the tag's answer. This issue is corrected in trunk revision #270 (which is just the tip of trunk at this moment). It's not yet part of any release version, so please try with latest trunk.

ian@iwjohnston.com (ian-5) said : #2

Hello Stephen,

I removed the old trunk and reinstalled it with revision #270. It now works well.

See below:

pi@pi3:~/nfcpy/trunk/examples $ python 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:001:007
** waiting for a tag **
Type3Tag 'FeliCa Lite-S (RC-S966)' ID=012E34E829CE2867 PMM=00F1000000014300 SYS=88B4
[nfc.tag.tt3] got ndef attributes {'ver': 16, 'ln': 0, 'nbr': 4, 'nmaxb': 13, 'nbw': 1, 'rwflag': 1, 'writef': 0}
[nfc.tag.tt3] got 0 byte ndef data
NDEF Capabilities:
  readable = yes
  writeable = yes
  capacity = 208 byte
  message = 0 byte

Regards,
Ian