USB - Sending command to a USB Device

Hi All,

Can any body send me some sample code for sending a command to a USB
Device connected to a USB Port that has an interrupt out endpoint ?

And if the device has to send some response,how to receive the same
?

Thanks & Regards,
Sai Prasad

**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

Sai,

There’s not much advantage to using an interrupt OUT over using a bulk OUT
endpoint. If you’re choosing interrupt for responsiveness, you’re likely
to notice very little difference between the interrupt and the bulk in a
loaded system anyway. I’d first recommend making the endpoint bulk OUT
instead of an interrupt OUT.

A more likely way to increase responsiveness (among other benefits) would
be to make sure your driver is written in such a fashion that the
user-mode code that calls it can make use of overlapped I/O. The basic
issue here is to use asynchronous requests to USBD, rather than waiting in
the driver for each IRP to complete. Depending on your device, this may
require serialization in your driver (an IRP queue).

Finally, the Bulk Out code in the DDK sample bulkusb will probably work
with either your bulk OR interrupt OUT endpoint. From the client driver’s
perspective, there’s very little difference between an interrupt or a bulk
transfer - primarily just the descriptor. The URB’s essentially the same.
See BulkUsb_DispatchReadWrite in bulkrwr.c.

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com

Hi Johns,
There is one file in DDK by name ocrwbulk.c.Is it this one,tht you had
mentioned ?.Actually the device vendor is somebody else.I am writing the
driver for it.

Can u pls send me the piece of code to do that.I have tried it but I suspect
the way I am building the URB is giving me a problem.When I send the request
down USB stack returns me STATUS_DEVICE_DATA_ERROR.What exactly is this
?.Actally the problem is I am sending a buffer which contains the command I
want to send to the device in URB structure but I expect a response from the
device also.How do i receive it ?.I framed a new Read IRP,but I don’t see
the control coming to the completion routine of read request that I have
built.

Any suggestion would be extremely helpful.

Thanks.
Best Regards,
Sai Prasad


From: xxxxx@driverdev.com[SMTP:xxxxx@driverdev.com]
Reply To: NT Developers Interest List
Sent: Tuesday, March 26, 2002 11:45 PM
To: NT Developers Interest List
Subject: [ntdev] Re: USB - Sending command to a USB Device

Sai,

There’s not much advantage to using an interrupt OUT over using a bulk OUT
endpoint. If you’re choosing interrupt for responsiveness, you’re likely
to notice very little difference between the interrupt and the bulk in a
loaded system anyway. I’d first recommend making the endpoint bulk OUT
instead of an interrupt OUT.

A more likely way to increase responsiveness (among other benefits) would
be to make sure your driver is written in such a fashion that the
user-mode code that calls it can make use of overlapped I/O. The basic
issue here is to use asynchronous requests to USBD, rather than waiting in
the driver for each IRP to complete. Depending on your device, this may
require serialization in your driver (an IRP queue).

Finally, the Bulk Out code in the DDK sample bulkusb will probably work
with either your bulk OR interrupt OUT endpoint. From the client driver’s
perspective, there’s very little difference between an interrupt or a bulk
transfer - primarily just the descriptor. The URB’s essentially the same.
See BulkUsb_DispatchReadWrite in bulkrwr.c.

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com


You are currently subscribed to ntdev as: xxxxx@satyam.com
To unsubscribe send a blank email to %%email.unsub%%

**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

Did you read ANY of my previous emails? Interrupt transfers are ONE WAY
ONLY!!! You cannot expect to send data down an interrupt IN pipe. I
suggested that, if you don’t have any other pipes, you use vendor requests
to send commands, remembed?

For examples look into your DDK in the src\wdm\usb directory. You may want
to seriously consider getting yourself some training or, bare minimum,
reading a book (the USB spec would be helpful along with Walter Oney’s WDM
book).

  • Dennis

Dennis Merrill
Embedded Systems Engineer
Thermo Electron Corporation
Spectroscopy Division

-----Original Message-----
From: Sai_Prasad [mailto:xxxxx@Satyam.com]
Sent: Wednesday, March 27, 2002 1:26 AM
To: NT Developers Interest List
Subject: [ntdev] Re: USB - Sending command to a USB Device

Hi Johns,
There is one file in DDK by name ocrwbulk.c.Is it this one,tht you had
mentioned ?.Actually the device vendor is somebody else.I am writing the
driver for it.

Can u pls send me the piece of code to do that.I have tried it but I suspect
the way I am building the URB is giving me a problem.When I send the request
down USB stack returns me STATUS_DEVICE_DATA_ERROR.What exactly is this
?.Actally the problem is I am sending a buffer which contains the command I
want to send to the device in URB structure but I expect a response from the
device also.How do i receive it ?.I framed a new Read IRP,but I don’t see
the control coming to the completion routine of read request that I have
built.

Any suggestion would be extremely helpful.

Thanks.
Best Regards,
Sai Prasad


From: xxxxx@driverdev.com[SMTP:xxxxx@driverdev.com]
Reply To: NT Developers Interest List
Sent: Tuesday, March 26, 2002 11:45 PM
To: NT Developers Interest List
Subject: [ntdev] Re: USB - Sending command to a USB Device

Sai,

There’s not much advantage to using an interrupt OUT over using a bulk OUT
endpoint. If you’re choosing interrupt for responsiveness, you’re likely
to notice very little difference between the interrupt and the bulk in a
loaded system anyway. I’d first recommend making the endpoint bulk OUT
instead of an interrupt OUT.

A more likely way to increase responsiveness (among other benefits) would
be to make sure your driver is written in such a fashion that the
user-mode code that calls it can make use of overlapped I/O. The basic
issue here is to use asynchronous requests to USBD, rather than waiting in
the driver for each IRP to complete. Depending on your device, this may
require serialization in your driver (an IRP queue).

Finally, the Bulk Out code in the DDK sample bulkusb will probably work
with either your bulk OR interrupt OUT endpoint. From the client driver’s
perspective, there’s very little difference between an interrupt or a bulk
transfer - primarily just the descriptor. The URB’s essentially the same.
See BulkUsb_DispatchReadWrite in bulkrwr.c.

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com


You are currently subscribed to ntdev as: xxxxx@satyam.com
To unsubscribe send a blank email to %%email.unsub%%

**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************


You are currently subscribed to ntdev as: xxxxx@thermonicolet.com
To unsubscribe send a blank email to %%email.unsub%%