Hi!
I am trying to write a custom driver to send Commands to a USB device.
The USB device supports 3.0 version.
My intention here is to issue a SetPortFeature Command.
the setup packet details is as follows.
bmrequesttype : 00100011 (CLASS request, OTHER recepient)
bmrequest : SET_FEATURE
wvalue : BH_PORT_RESET
windex = 17 (port number)
wlength = 0
The spec says This command is a Hub class request command.
I am trying to send the command using URB.
I have tried the below steps to send the URB packet.
-
Get the device object of our Driver (Functional Driver Object, FDO) using WdfDeviceWdmGetDeviceObject API.
-
Get the Physical device object of USB Hub (USB Hub PDO) using WdfDeviceWdmGetPhysicalDevice API.
-
Build IRP For the command using IoBuildDeviceIoControlRequest API. Internal IOCtl code is set to IOCTL_INTERNAL_USB_SUBMIT_URB.
-
Creating URB Handle using USBD_CreateHandle API. (Driver’s FDO from Step 1 and Hub PDO from step 2 are given as arguments to this API.)
-
Create a URB block using USBD_UrbAllocate API.
-
Create a URB Header structure and assign function value to URB_FUNCTION_CLASS_OTHER and length field to sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST);
//Create Header
struct _URB_HEADER urb_header;
urb_header.Function = URB_FUNCTION_CLASS_OTHER;
urb_header.Length = sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST); -
Assign the following values to urb block as given below.
//Assign header value.
urb->UrbControlVendorClassRequest.Hdr = urb_header;//Assign request code to SET_FEATURE.
urb->UrbControlVendorClassRequest.Request = 0x3;//Assign value to feature selector BH_PORT_RESET (0X28)
urb->UrbControlVendorClassRequest.Value = 0x28;//Assign index value to Port number (Port no is 17).
urb->UrbControlVendorClassRequest.Index = 0x11; -
Get next stack location of IRP and assign the urb block to that stack. Code snippet is given below.
IoStack = IoGetNextIrpStackLocation(Irp);
IoStack->Parameters.Others.Argument1 = urb; -
Send the IRP to the driver using IOCallDriver API. (Hubs PDO and IRP obtained in Step 3 are sent as Arguments to this API.)
I am doing the following steps above, but not getting the required status as SUCCESS in status field. The status code obtained is 0XC0000001 (STATUS_UNSUCCESSFUL)
I am not sure whether I am sending the command correctly… Can you please help me what could be the reason for this status? Am I missing anything here?
Regards,
Srihari.