jeremyherbert / mcp2210-python

MCP22100 python driver
MIT License
6 stars 4 forks source link

Range checking, and communication on Windows #1

Closed jandyman closed 3 months ago

jandyman commented 4 years ago

First, some of the range checking for registers checks against 0x1ff, because some of the bits are unused, but legal values are from 0 to 0xffff, and in fact 0xffff is the factory default for those registers.

Second, I've got this wonderful library running great on Mac OSX, but on Windows the hid read calls are returning nonsense. Has this been tested on Windows? It's suspicious that in the Windows device manager the mpc2210 shows up as two different devices. Can you shed any light?

jeremyherbert commented 3 years ago

Unfortunately I don’t have any hardware for this anymore to test the changes, but if you can point out which ones are wrong I can try to fix them.

I am normally working on Linux and Mac but I am pretty sure I tested this on Windows 10 pro and it worked fine. Is that the version you are using?

jandyman commented 3 years ago

Sorry for the delayed reply. If you look on lines 119, 240, and 246 you'll range checks for these values, the 0x1ff should be changed to 0xffff.

We never did get this library working under Windows. I had to use the dll from Microchip and create a layer on top of both your library and theirs to get cross platform capability. But without this one I wouldn't have things working on the Mac.

One final question though. On the Mac, I can't access the device without root permission. I downloaded a package called Elevate - it works but is a bit of a hassle. Do you know a way to tell MacOS that it is OK for your library to get access to the device without having root permission?

jeremyherbert commented 3 years ago

I borrowed some hardware from a colleague today and just pushed a fix for the windows problem; there is a windows quirk where an optional report ID needs to be prepended to the HID transaction (I had to break out the hardware USB protocol analyser to work this one out, it would have been very difficult to find otherwise). It works fine for me on Windows 10 Pro now.

You can install the new version with pip install --upgrade mcp2210-python (assuming you installed it with pip originally)

As for mac, I am running 10.15.6 and it works fine without any elevation, though I can't guarantee that I didn't do some tinkering in the past and forgot about it. I don't have a second Mac to test it on unfortunately.

Also tested and working fine on Ubuntu 20.04.