Mailing Lists: Apple Mailing Lists

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

Reading less than the available bytes



This is a question for a vendor-specific, user-space USB implementation
for MacOS X.

The device I'm dealing with used the SerialShim lib for its USB driver
under MacOS 9.  The device also operates with a traditional serial cable.
It's a bulk device, 1 in pipe, 1 out pipe.

The issue is that the device can be very slow and connections have a
pretty high potential for intermittence, so the existing code
we have for it reads 1 byte at a time with a rather large timeout for
each byte.  This is at the recommendation of the manufacturer.

The problem is that, at least with synchronous calls, IOKit does not seem
to like the fact that I ask for only 1 byte from the read pipe when there
may be more available (even if I'm in a loop and will immediately be
asking for another byte). I get an IOReturnOverrun error. It also appears
that if there are, say, 4 bytes ready to read in the in pipe, reading
only 1 and getting this error effectively kills the other 3 - subsequent
calls to read 1 byte don't work. Is there any way to read from a bulk pipe
in this sort of 1-byte-at-a-time fashion, or does one always have to read
all that's available or lose it? Or is this behavior specific to the device?


If there's no other way I can set up an intermediate in buffer and an
async read state or thread, but if there's any way to avoid that I'd
rather keep things simple.

I'm using the ReadPipeTO() method of IOUSBInterfaceInterface (182).

Thanks for any help,
Chris Corbell
_______________________________________________
usb mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/usb
Do not post admin requests to the list. They will be ignored.



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.