Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

MCP2221 read error
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MCP2221 read error

by joncubs on Wed Jan 01, 2020 2:31 am

I tried different python versions, but keep getting this error with AnalogOut and I2C on Windows:

>>> dac=AnalogOut(board.G3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\analogio.py", line 40, in __init__
self._pin.init(mode=Pin.DAC)
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\pin.py", line 36, in init
mcp2221.gp_set_mode(self.id, mcp2221.GP_ALT1)
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\mcp2221.py", line 66, in gp_set_mode
current = self._hid_xfer(b'\x61')
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\mcp2221.py", line 56, in _hid_xfer
return self._hid.read(64)
File "hid.pyx", line 122, in hid.device.read
OSError: read error

joncubs
 
Posts: 9
Joined: Wed Jan 01, 2020 2:24 am

Re: MCP2221 read error

by joncubs on Wed Jan 01, 2020 2:55 pm

Additional info. Ran these commands first:

>>> import board
>>> from analogio import AnalogOut

Board seems to be ok:
>>> dir(board)
['G0', 'G1', 'G2', 'G3', 'I2C', 'SCL', 'SDA', 'SPI', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'ap_board', 'board_id', 'detector', 'pin', 'sys']

joncubs
 
Posts: 9
Joined: Wed Jan 01, 2020 2:24 am

Re: MCP2221 read error

by siddacious on Wed Jan 01, 2020 3:37 pm

Before we dig in, please make sure you've followed the setup instructions for windows here:
https://learn.adafruit.com/circuitpytho ... 21/windows

If that doesn't clear things up, please share some additional details about your setup, such as specific windows version, python version, and any other details that seem pertinent.

siddacious
 
Posts: 338
Joined: Fri Apr 21, 2017 3:09 pm

Re: MCP2221 read error

by joncubs on Wed Jan 01, 2020 7:10 pm

It works about 50% of the time now. I tried different USB ports and python 3.6, 3.7, 3.8 with no difference. Here are the package versions:

Package Version
----------------------- -------------
Adafruit-Blinka 3.3.4
Adafruit-PlatformDetect 1.3.8
Adafruit-PureIO 1.0.4
hidapi 0.7.99.post21
pip 19.3.1
pyftdi 0.42.2
pyserial 3.4
pyusb 1.0.2
setuptools 43.0.0

joncubs
 
Posts: 9
Joined: Wed Jan 01, 2020 2:24 am

Re: MCP2221 read error

by siddacious on Thu Jan 02, 2020 3:45 pm

What version of Windows are you using?

siddacious
 
Posts: 338
Joined: Fri Apr 21, 2017 3:09 pm

Re: MCP2221 read error

by joncubs on Fri Jan 03, 2020 12:29 am

Windows 10 Home, version 1903, HP 64-bit latptop

joncubs
 
Posts: 9
Joined: Wed Jan 01, 2020 2:24 am

Re: MCP2221 read error

by adafruit2 on Fri Jan 03, 2020 3:04 pm

hiya by chance are you hotplugging parts/wires? what if you do a try/except for retrying? MCP2221 is 'inexpensive' and 'not very well documented' so we did our best with trying to get it to fit with python - may need some tweaks :D

adafruit2
Site Admin
 
Posts: 19408
Joined: Fri Mar 11, 2005 7:36 pm

Re: MCP2221 read error

by adafruit_support_carter on Fri Jan 03, 2020 3:43 pm

Also maybe different USB cables?

Does it always fail at the same line of code? Does it also fail if you try other features, like DAC or digital IO?

adafruit_support_carter
 
Posts: 17282
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 read error

by joncubs on Sat Jan 04, 2020 12:37 am

Try/except didn't work, but when I run from a script it seems to always work. If I insert a time delay it becomes intermittent.

import time
import board
#time.sleep(5)
from analogio import AnalogOut
dac=AnalogOut(board.G3)
print(dac)

Thanks for your help.

joncubs
 
Posts: 9
Joined: Wed Jan 01, 2020 2:24 am

Re: MCP2221 read error

by adafruit2 on Sat Jan 04, 2020 12:28 pm

sorry, we're confused - we always run from a script - are you trying from a REPL?

adafruit2
Site Admin
 
Posts: 19408
Joined: Fri Mar 11, 2005 7:36 pm

Re: MCP2221 read error

by joncubs on Sat Jan 04, 2020 3:00 pm

Yes, REPL as indicated by '>>>'. I was following the approach here: https://learn.adafruit.com/circuitpytho ... all-checks

Yesterday, when I combined on one line it worked, but today I'm getting this error using one line or the file:

>>> import board; from analogio import AnalogOut
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\analogio.py", line 12, in <module>
if detector.board.microchip_mcp2221:
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\adafruit_platformdetect\board.py", line 508, in microchip_mcp2221
return self.id == MICROCHIP_MCP2221
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\adafruit_platformdetect\board.py", line 307, in id
chip_id = self.detector.chip.id
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\adafruit_platformdetect\chip.py", line 57, in id
'set, but no MCP2221 device found')
RuntimeError: BLINKA_MCP2221 environment variable set, but no MCP2221 device found

When I put a small delay in, I avoid that error, but get the one posted originally:

>>> import time; import board; time.sleep(0.5);from analogio import AnalogOut
>>> dac=AnalogOut(board.G3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\analogio.py", line 40, in __init__
self._pin.init(mode=Pin.DAC)
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\pin.py", line 36, in init
mcp2221.gp_set_mode(self.id, mcp2221.GP_ALT1)
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\mcp2221.py", line 66, in gp_set_mode
current = self._hid_xfer(b'\x61')
File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\lib\site-packages\adafruit_blinka\microcontroller\mcp2221\mcp2221.py", line 56, in _hid_xfer
return self._hid.read(64)
File "hid.pyx", line 122, in hid.device.read
OSError: read error

joncubs
 
Posts: 9
Joined: Wed Jan 01, 2020 2:24 am

Re: MCP2221 read error

by adafruit_support_carter on Sun Jan 05, 2020 9:16 am

You mention trying other USB ports, but what about USB cable? The issue seems to relate to the basic communication between the PC and the MCP2221.

Or, as another way to test, do you have another PC you can try?

Can you post photos of the MCP2221 so we can look for any obvious hardware issues.

adafruit_support_carter
 
Posts: 17282
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 read error

by pnw on Sun Jan 05, 2020 2:07 pm

I will just add my voice to say that I am experiencing exactly the same issue as reported in this thread. Win10, Python 3.7.2, Adafruit-Blinka 3.3.6, hidapi 0.7.99.post21, Brand new Anker USB3-A to USB-C cable, tried various USB ports, including behind a hub.

pnw
 
Posts: 4
Joined: Wed Apr 16, 2014 7:57 pm

Re: MCP2221 read error

by adafruit2 on Sun Jan 05, 2020 3:17 pm

pnw, does it work in a script and not repl?

adafruit2
Site Admin
 
Posts: 19408
Joined: Fri Mar 11, 2005 7:36 pm

Re: MCP2221 read error

by joncubs on Sun Jan 05, 2020 5:55 pm

Here are pictures. I tried two laptops and two cables, same result. It doesn't work at all now...
MCP2221_photo_back.jpg
MCP2221_photo_back.jpg (544.23 KiB) Viewed 166 times
Attachments
MCP2221_photo.jpg
MCP2221_photo.jpg (460.33 KiB) Viewed 166 times

joncubs
 
Posts: 9
Joined: Wed Jan 01, 2020 2:24 am

Please be positive and constructive with your questions and comments.