[python-win32] kernal32.DeviceIoControl Operation Aborted

Red Rackham redrackem at yahoo.com
Fri Dec 19 21:11:23 CET 2008


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, 0x00, 0x00, 0xFF, 0x00, 0xFE, 0xB1, 0xFF, 0x00
what I got back was
"('raw', '\x8b|\x00\x00\xff\x00\xfe\xb1\xff\x00\x00\x00\x00..."

I find the suggestion below very relevant, since I would rather not pass a string buffer to get a byte array back.  So I will need to pass a different arg when I want to get back say, a string descriptor or something.


If you really want to handle the result as hex byte values, you can use
struct or array:

    import struct
    s = '\x8b|'
    t = struct.unpack('BB', s )
    print [hex(i) for i in t]

    import array
    x = array('B')
    x.fromstring( s )
    t = x.tolist()
    print [hex(i) for i in t]


 
 

 


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20081219/a0e85dd1/attachment.htm>


More information about the python-win32 mailing list