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 device based on Cypress FX2 (EZ-USB) type 
part.  The first operation I'm attempting is to access a command that is 
supposed to return the microcontroller's PORTA value.  Here's a minimal amount 
of code:
 
  retCode = k32.DeviceIoControl(
   dev.deviceHandle,
   IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST,
   byref(vrControl),
   sizeof(VENDOR_OR_CLASS_REQUEST_CONTROL),
   pBuffer,
   c_ushort(255), # READ_LENGTH,
   byref(retBytes),
   None)
 
Where the vrControl is a struct like this:
  vrControl = VENDOR_OR_CLASS_REQUEST_CONTROL()
  vrControl.direction = VENDOR_REQUEST_DIRECTION_DEVICE2HOST
  vrControl.requestType = VENDOR_REQUEST_REQUESTTYPE_VENDOR
  vrControl.recipient = VENDOR_REQUEST_RECIPIENT_ENDPOINT
  vrControl.reqTypeResdBits = 0
  vrControl.request = VR_PORTS
  vrControl.value = VR_PORTS_READ << 8 | value
  vrControl.index = port

 
kernal32.DeviceIoControl returns a 0, and kernal32.GetLastError() is returning 
a 995, which is, "ERROR_OPERATION_ABORTED.  The I/O operation has been aborted 
because of either a thread exit or an application request" according to:
http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx
 
The reason for the abort does not make sense to me.  Anyone know what would 
most commonly cause this?  What should be my next step?  
 
Thanks in advance,
Mark
 


      
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to