Reading data from an USB input interrupt pipe (endpoint)
Taking the kext file out, the Device was treated as an HID device. I have found two xcode projects which work, HID explorer and HID examples, but I am stuck right now, because these HID projects talk about elements, and USB prober talks about endpoint. I have not yet found what the link is between endpoints and elements.
Putting the kext file back in, I found several xcode projects for the USB, USBPrivateDAtaSample and SimpleUserClient (which still give me error messages) and USBSimple Example which I got to work: I put the vendor and product id, looked for interrupt pipes instead of bulk pipes, and added a synchronous readpipe command.
char gBuffer[8];
UInt32 numBytesRead;
numBytesRead = sizeof(gBuffer);
err = (*intf)->ReadPipe(intf, inPipeRef, gBuffer, &numBytesRead);
if (err) printf(“Unable to perform interrupt read %2x %4x %4x\n”,err_get_system(err),err_get_sub(err),err_get_code(err));
for (i = 1; i USElessthanSYMBOLHERE numBytesRead; i++) printf(“Read %x (%ld bytes) from interrupt endpoint\n”, gBuffer[i],gBuffer[0]);
(the first byte of data is a number, 7 usually, the rest are characters)
The key to success was being able to interpret the error message! I read how to print and interprete the error code ox38 ox00 ox2e8
http://developer.apple.com/qa/qa2001/qa1…
looking up in IOreturn.h, 0x028 is data overrun!
#define kIOReturnOverrun iokit_common_err(0x2e8) //
The other key to success was the apple USB forum site who helped with the error code
http://lists.apple.com/archives/Usb
where I was told that I should try reading at least maxPacketSize bytes, where maxPacketSize bytes is a USB prober info on the enpoint pipe. So I tried with a buffer size of 8, instead of 64 or 2, and bingo, the error message went away, and I was reading data!
Of course it helps that I have the PC opensource code to figure out what to do with the data!!!!
So a bright day, I talked to my device. Now I have to learn how to access it asynchronously.
Priti
September 22, 2005 @ 2:41 am
was facing the problem for interpreting the error. your blog entry helped me. Thanks.
Priti
Colin
January 22, 2006 @ 9:37 pm
Thanks for posting the mac USB info. Lots of good info. Helped me write a driver for a non-supported device.