trouble connecting to reader: UnicodeDecodeError

Asked by Bruce

Hello,

I just installed nfcpy, and I am trying to first connect to my contactless reader (RC-S380).

I am running on Windows 10 64bit. I have copied the libusb binaries to the system folders, and I have installed the libusb-win32 driver using Zadig.

I am running the following commands:

import nfc
nfc.ContactlessFrontend("usb")

And I am getting the following error:

Traceback (most recent call last):
  File "E:/XXX/XXX/XXX/testing_grounds.py", line 11, in <module>
    nfc.ContactlessFrontend("usb")
  File "build\bdist.win-amd64\egg\nfc\clf\__init__.py", line 72, in __init__
  File "build\bdist.win-amd64\egg\nfc\clf\__init__.py", line 146, in open
  File "build\bdist.win-amd64\egg\nfc\clf\device.py", line 84, in connect
  File "build\bdist.win-amd64\egg\nfc\clf\rcs380.py", line 877, in init
  File "build\bdist.win-amd64\egg\nfc\clf\transport.py", line 247, in manufacturer_name
  File "build\bdist.win-amd64\egg\nfc\clf\transport.py", line 265, in _PYUSB1_get_string
  File "C:\Anaconda2\lib\site-packages\usb\util.py", line 261, in get_string
    return buf[2:].tostring().decode('utf-16-le')
  File "C:\Anaconda2\lib\encodings\utf_16_le.py", line 16, in decode
    return codecs.utf_16_le_decode(input, errors, True)
UnicodeDecodeError: 'utf16' codec can't decode bytes in position 214-215: illegal UTF-16 surrogate

--

The string being decoded is the device descriptor.
printing the result of the "buf[2:].tostring()" gives me this string
S O N Y 6!   � � * ��  @   � 2@ �@ 1#{4D1E55B2 �� `wm �m &PID_C52B&MI_00#7&2DFD4F31&0&0000#{4D1E55B2-F16F-11CF-88CB-001111000030}

�� ��m P�m 11000030}

Any help in getting me connected to my reader is appreciated.

Thank you.

Question information

Language:
English Edit question
Status:
Expired
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Stephen Tiedemann (stephen-tiedemann) said :
#1

This looks like you're using a pretty old version. Current versions do no longer use pyusb but the libusb1 module. How did you install nfcpy? If for no other reason, you should use "pip install nfcpy".

Revision history for this message
Bruce (bcam) said :
#2

Hi,

I installed using pip,

>pip install nfcpy
Requirement already satisfied: nfcpy in c:\anaconda2\lib\site-packages
Requirement already satisfied: libusb1 in c:\anaconda2\lib\site-packages (from nfcpy)
Requirement already satisfied: pyserial in c:\anaconda2\lib\site-packages (from nfcpy)
Requirement already satisfied: pydes in c:\anaconda2\lib\site-packages (from nfcpy)
Requirement already satisfied: ndeflib in c:\anaconda2\lib\site-packages (from nfcpy)

>pip show nfcpy
Name: nfcpy
Version: 0.13.4
Summary: Python module for Near Field Communication.
Home-page: https://github.com/nfcpy/nfcpy
Author: Stephen Tiedemann
Author-email: <email address hidden>
License: EUPL
Location: c:\anaconda2\lib\site-packages
Requires: libusb1, pyserial, pydes, ndeflib

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) said :
#3

The line "File "build\bdist.win-amd64\egg\nfc\clf\transport.py", line 265, in _PYUSB1_get_string" indicates that this is an nfcpy version before 0.11.0. I think there is just this older version found earlier than the one you've installed with pip.

Revision history for this message
Launchpad Janitor (janitor) said :
#4

This question was expired because it remained in the 'Open' state without activity for the last 15 days.