I think I have finally figured it out. Thanks for the suggestion, I ran the
executable (compiled C code) and it worked, and it returned 0x8B.
Previously I saw this value and thought was bunkum. I thought it was incorrect
because of the way ctypes encodes a string buffer: ('value', '\x8b|').
Except that now I'm trying to read PORTD which is also returning the same value
(0x8B) but I'm expecting a different value. So either it's just a coincidence
that I read 0x8B, or I have my data aligned wrong and it's getting a '0' in the
field where it's expecting a 7 for PORTD.
Eureka! After the function returned I did a print on getmembers(buffer)
and I found the data (except for the pipe character).
If the function had returned all port values I would expect it to return:
OEA, IOA, OEB, IOB, OEC, IOC, OED, IOD, OEE, IOE
which I expected to look like:
0x8B, 0x09,
Mystery solved. The value on the port had changed from 0x09 to 0x76 from the
time I used the c-based program to the time I came along and red it in Python.
Went back and used the c-based program and found the port was indeed 0x76.
I used your array example:
x = array.array('B')
Hi. I'm a bit of a novice with ctypes and this is my first post here so please
forgive any detected newbiness. After trying and searching I hereby give up
and appeal to the pros out there who may be more intimately familiar with
DeviceIoControl usage.
I'm trying use Python to access a USB