Can a USB host get data periodically without specific host request (no poling)?

Hi all,

I’m new to USB programming and was wondering whether it is possible for a
host to get data from a device without poling?

For example, How does Windows (as an application) get the position of the
mouse? Is it done by poling? Is it done on a lower level - like the HID
driver? Anyway, how can my application get data from a USB device
periodically without poling?

Thanks,

Assaf

Assaf Tomaschoff wrote:

Hi all,

I?m new to USB programming and was wondering whether it is possible for
a host to get data from a device without poling?

Not possible. This is how the USB bus protocol works.

For example, How does Windows (as an application) get the position of
the mouse? Is it done by poling? Is it done on a lower level ? like the
HID driver?

Yes and yes. The host controller does the polling, your
application or driver don’t see it, until some data arrives
from the device.

Anyway, how can my application get data from a USB device
periodically without poling?

Again, you can’t do this without polling, but it is not
your problem. Send the “read” command to the host controller
and let it do it’s magic.
By the way, write to USB device goes in the same way.

Regards,
–PA

> For example, How does Windows (as an application) get the position of the

mouse? Is it done by poling?

Yes, the lowest level (hardware) of USB is a polled bus.

driver? Anyway, how can my application get data from a USB device
periodically without poling?

Is there any interrupt pipes on the device?


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

>Is there any interrupt pipes on the device?

No, but would it make a difference?

xxxxx@cnoga.com wrote:

> Is there any interrupt pipes on the device?

No, but would it make a difference?

It makes no difference. Even interrupt pipes use polling, the host
controller schedules them slightly differently, that’s all.

–PA

> It makes no difference. Even interrupt pipes use polling, the host

controller schedules them slightly differently, that’s all.

Interrupt pipes have guaranteed polling frequency.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

I too think an interrupt pipe may be what you want. You can program the endpoint descriptor to interrupt the host with data at fixed intervals, for example every 1 millisecond.

Despite the terminology, for which the USB org ought to be collectively
horse-whipped, an interrupt endpoint doesn’t interrupt the host adapter
with anything and does not initiate any IO operations. All USB
operations are initiated by the adapter, not the endpoints. Interrupt
endpoints have guaranteed latency - the adapter is required to poll them
on a deterministic basis.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Tuesday, August 12, 2008 10:47 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Can a USB host get data periodically without
specific host request (no poling)?

I too think an interrupt pipe may be what you want. You can program the
endpoint descriptor to interrupt the host with data at fixed intervals,
for example every 1 millisecond.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

For such a simple question, some responses seem quite pedantic. OP does not appear interested in how it all works under the USB covers. OP just wants to know how his app can get data periodically without polling. An interrupt pipe achieves this goal.

Like mark said, an interrupt endpoint just gets you a guaranteed slice of the bandwidth. It does not allow the device to spontaneously report data to the host. The host has to ask for the data. Since the host has to ask, either the driver or the app (via winusb) must make sure there is always a transfer pending on the host for the interrupt endpoint to get the data from the device. While this is not polling in sense of repeatedly asking for something, not getting and then repeating, it is polling in the sense that you are making sure that you always asking and waiting for a(n async) response.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, August 13, 2008 9:08 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Can a USB host get data periodically without specific host request (no poling)?

For such a simple question, some responses seem quite pedantic. OP does not appear interested in how it all works under the USB covers. OP just wants to know how his app can get data periodically without polling. An interrupt pipe achieves this goal.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

If the OP doesn’t understand how it works at his driver lower edge interface
to the usb adapter the OP will be wondering why his ‘interrupt’ endpoint
ain’t generating any data. Interrupt pipes only work if you keep them fed.

On Wed, Aug 13, 2008 at 12:07 PM, wrote:

> For such a simple question, some responses seem quite pedantic. OP does not
> appear interested in how it all works under the USB covers. OP just wants to
> know how his app can get data periodically without polling. An interrupt
> pipe achieves this goal.
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


Mark Roddy

No, it won’t. Or, if you insist, it would to the same extent that a bulk pipe would.

Exactly. It’s not like the HCD will buffer data from the interrupt pipe. The only thing “different” about interrupt pipes is that they have a bounded (max) latency, and they reserve bandwidth. Other than that, they work remarkably like bulk pipes. Application sends down buffer, data arrives and gets put in buffer.

“Polling”? I dunno. You tell me.

Peter
OSR

I am aware of a project where interrupt pipes were used very effectively for a similar purpose. Worked perfectly. It seems no one here has offered a better way to go.

xxxxx@gmail.com wrote:

I am aware of a project where interrupt pipes were used very effectively for a similar purpose. Worked perfectly. It seems no one here has offered a better way to go.

Using interrupt endpoints also may help saving power
both on host and device
(since the host controller knows the “interrupt” latency
it can avoid continuously polling the device - but still it’s polling )

–PA

Indeed, this is a little known and seldom appreciated capability.

USB High Speed devices can specify that an interrupt endpoint polling intervals from 125usec to 4 SECONDS. Of course, the HCD is allowed to pool the device MORE frequently than that… but a comprehensive and well-written HCD will attempt to honor the request within limits.

Since we’re playing USB Interrupt Endpoint Trivia, another thing that most people don’t realize is that interrupt endpoints can be used for transferring data TO a device (not just reading data FROM a device). Because of their misunderstanding of the endpoint type due to its unfortunate name, many folks mistakenly believe that Interrupt Endpoints can only be used to RECEIVE data.

Peter
OSR

> Since we’re playing USB Interrupt Endpoint Trivia, another thing that most
people

don’t realize is that interrupt endpoints can be used for transferring data TO
a
device (not just reading data FROM a device).

Yes, this is how the keyboard LEDs and joystick force feedback are implemented.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

xxxxx@osr.com wrote:

No, it won’t. Or, if you insist, it would to the same extent that a bulk pipe would.

Exactly. It’s not like the HCD will buffer data from the interrupt pipe. The only thing “different” about interrupt pipes is that they have a bounded (max) latency, and they reserve bandwidth. Other than that, they work remarkably like bulk pipes.

Exactly right. So much so, in fact, that on both Windows and Linux,
bulk and interrupt pipe requests use the exact same request.
URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.