[python-win32] USB access using win32file.deviceIOcontrol
basti at benkers-rock.de
Wed Dec 12 21:41:15 CET 2007
Tim Roberts wrote:
TR> That's fundamentally correct. How are you creating the
TR> SCSI_PASS_THROUGH structure in "byte_list"? Are you sure it is 42
TR> bytes? Are you setting all the fields correctly? How are you setting
TR> the DataBuffer pointer? Have you set the Length field correctly?
That's exactly my problem.
I know there are some pointers in the C++ structure pointing to the
data inside the structure. But I don't have an idea at all, how to
port it to Python.
Could you give me an example of a very basic SCSI command, like the
Tim Roberts wrote:
TR> I would have guessed it would be easier to use the struct module to
TR> build the buffer, rather than array.
I didn't know if it would work, so I
started with a very strait forward approach.
I extracted the content of the SCSI_PASS_THROUGH in my C++ example
into a array of bytes.
I included the byte stream I found into my byte_list.
byte_list = SCSI_TEST_UNIT_READY
If the basic functionality is proven, I planned to go for a more
object oriented approach like:
def __init__(self, cdbLength = 16, transfer_length, transfer_direction):
self.Length = 0 # USHORT Length;
self.ScsiStatus = 0 # UCHAR ScsiStatus;
self.PathId = 0 # UCHAR PathId;
self.TargetId = 1 # UCHAR TargetId;
self.Lun = 0 # UCHAR Lun;
self.CdbLength = cdbLength # UCHAR CdbLength;
self.SenseInfoLength = 24 # UCHAR SenseInfoLength;
self.DataIn = transfer_direction # UCHAR DataIn;
self.DataTransferLength = transfer_length # ULONG DataTransferLength;
self.TimeOutValue = 2 # ULONG TimeOutValue;
self.DataBuffer = 0 # PVOID DataBuffer;
self.SenseInfoOffset = 0 # ULONG SenseInfoOffset;
self.Cdb =  # UCHAR Cdb;
But again, I don't know how to handle the buffer pointers inside the
More information about the python-win32