Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

calling ReadPipeAsync() a thousand times (a bad idea?)



I'm reading from an 8 byte interrupt endpoint (HID device, but I'm using a codeless KEXT).

The device normally sends 8 byte packets with a reasonable delay between packets. However, in some instances it blasts the packets out back-to-back, I think using the minimum 10 ms polling interval for the endpoint. The problem is the device does not queue up these packets well on its end (or maybe at all), so if I don't have a read request queued (host controller sending IN request during the poll interval) when the device has data for me the device locks up. This isn't a stalled pipe, but rather the device just stops communicating altogether until I hard reset it. This doesn't seem like a good behavior on the device side, but I need to work around it.

Originally, I daisy-chained my ReadPipeAsync() calls so that I called ReadPipeAsync() with a count of 8 inside the read complete callback. This works fine until the device needs to send data quickly (around 10 ms delay between packets). I tried using a dedicated thread to handle the reading and am doing as little work as possible in my callback, but it still cannot keep up in some cases, resulting in the device locking up since there isn't an IN request when the device wants to send data.

There isn't a good way for me to know when the device needs to send data quickly, so I tried queuing up a bunch of 8 byte ReadPipeAsync() requests at once. This seems to work well. However, in order to handle cases where around 8K of data might be send, I need to queue up around 1000 ReadPipeAsync() calls. Maybe I don't really need that many since I'm still calling ReadPipeAsync() in my read complete proc, but I'm not sure how often/quickly my read complete callback is guaranteed to be called.

Is there much overhead in queuing up that many calls? Any reasons why doing this would be a bad idea?

Any suggestions on other techniques to get around this problem? I had hoped I could just do a sequential daisy chain technique (only a single outstanding 8 byte ReadPipeAsync() at a time), but it just isn't fast enough to keep up.

Thanks in advance,
Matt

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.