Problems with CyUSB IOCTL Interface

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

Im trying to change the drivers for our USB Devices (CY7C68013A) from EzUSB.sys to CyUSB.sys. I'm using Delphi 5, so I use the IOCTL Interface. Is there some more information about the IOCTL Interface than in CyUSB.pdf ?

   

Is it still possbile to use the IOCTL Ezusb Commands ?

   

How can I get a device Descriptor ?

   

I tried IOCTL_GET_DEVICE_DESCRIPTOR, but i always receive Error 87 (The parameter is incorrect.)  (with GetLastError() )

   

I also tried IOCTL_Ezusb_GET_DEVICE_DESCRIPTOR, with the same result.

   

Several simple IOCTL_ADAPT commands do work, so the handle seems to be correct and the driver installed properly.

   

Can someone give me a hint please ?

   

regards

0 Likes
1 Solution
Anonymous
Not applicable

Hi,

   

I try to get the device descriptor with the following code :

   

procedure GetDeviceDescriptor(handle:THandle; var devDescr:DEVICE_DESCRIPTOR);

   

var

   

dwBytes : DWORD;

   

ds : DEVICE_DESCRIPTOR;

   

begin

   

if not DeviceIoControl(handle, IOCTL_GET_DEVICE_DESCRIPTOR,

   
   

@ds, sizeof(DEVICE_DESCRIPTOR),

   

@ds, sizeof(DEVICE_DESCRIPTOR),

   

dwBytes, nil) then

   

raise ECyUSBException.Create('Error #14 : ' + inttostr(GetLastError()));

   

devDescr := ds;

   

end;

   

 

   

IOCTL_GET_DEVICE_DESCRIPTOR is defined as followed (from usbscan.h):

   

IOCTL_GET_DEVICE_DESCRIPTOR   := CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 6, METHOD_BUFFERED,FILE_ANY_ACCESS);

   

FILE_DEVICE_USB_SCAN =$8000;
IOCTL_INDEX = $0800;

   

declariation of  the type DEVICE_DESCRIPTOR (from usbscan.h)

   

type

   

_DEVICE_DESCRIPTOR = packed record
    usVendorId: USHORT;
    usProductId: USHORT;
    usBcdDevice: USHORT;
    usLanguageId: USHORT;
  end {_DEVICE_DESCRIPTOR};
  DEVICE_DESCRIPTOR = _DEVICE_DESCRIPTOR;
  PDEVICE_DESCRIPTOR = ^_DEVICE_DESCRIPTOR;

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

Please post the part of code you're using to invoke get descriptor I would like to take a look at it to see which parameter is wrong.

   

Regards,

   

Anand

0 Likes
Anonymous
Not applicable

Hi,

   

I try to get the device descriptor with the following code :

   

procedure GetDeviceDescriptor(handle:THandle; var devDescr:DEVICE_DESCRIPTOR);

   

var

   

dwBytes : DWORD;

   

ds : DEVICE_DESCRIPTOR;

   

begin

   

if not DeviceIoControl(handle, IOCTL_GET_DEVICE_DESCRIPTOR,

   
   

@ds, sizeof(DEVICE_DESCRIPTOR),

   

@ds, sizeof(DEVICE_DESCRIPTOR),

   

dwBytes, nil) then

   

raise ECyUSBException.Create('Error #14 : ' + inttostr(GetLastError()));

   

devDescr := ds;

   

end;

   

 

   

IOCTL_GET_DEVICE_DESCRIPTOR is defined as followed (from usbscan.h):

   

IOCTL_GET_DEVICE_DESCRIPTOR   := CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 6, METHOD_BUFFERED,FILE_ANY_ACCESS);

   

FILE_DEVICE_USB_SCAN =$8000;
IOCTL_INDEX = $0800;

   

declariation of  the type DEVICE_DESCRIPTOR (from usbscan.h)

   

type

   

_DEVICE_DESCRIPTOR = packed record
    usVendorId: USHORT;
    usProductId: USHORT;
    usBcdDevice: USHORT;
    usLanguageId: USHORT;
  end {_DEVICE_DESCRIPTOR};
  DEVICE_DESCRIPTOR = _DEVICE_DESCRIPTOR;
  PDEVICE_DESCRIPTOR = ^_DEVICE_DESCRIPTOR;

0 Likes