User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:126.96.36.199) Gecko/20100423 Thunderbird/3.0.4
While reviewing Fernando's code suggestion I realized that I had
implemented this solution already. So nothing new was being presented.
However, I took this chance to review the code and refactor it to make
it more versatile as Fernando's suggestion is, in terms of concurrent
read submission (with the for loop for submission and the refcon passing).
While doing this refactor I realized that I had 2 things terribly wrong
in my code:
- I was reading 4096 bytes to a 64 length FRAME_PACKET struture which is
64 length. But I was omly processing 16 of this units........ That
explains the missing data. This is because in libusb there are two
parameters passed to transfers. Buffer size and transfer length. Here is
- The variable that counts the usefull bytes from my packets (for a
frame constitution) was declared as non static, so it was becoming 0
every transfer callback call. No frames were actually being processed at
Basicly I had already the code well since the first time I wrote to the
list with sync readings in what regards to USB communication.
Now I just have to thank you for the time you spent helping me. It was
not a waste of time because this problem was also usefull to learn how
to make async calls to USB bus in OSX.
This API is very simple to use. Great work!
Once again thx for the support.
With my best regards,
On 05/20/2010 09:05 PM, Fernando Urbina wrote:
You can do something like this -- note, this is not complete, but it does show you how to queue up the multiple reads:
// Called when our asynchronous read completes
MyAsyncCallBackFunction(void *refCon, IOReturn result, void *arg0)
IOReturn kr = kIOReturnSuccess;
MyRefconData * myData = ( MyRefconData *) refCon;
// At this point, we would do something with this data, like looking for a SOF
// Process the Data received
// Will issue multiple reads to the given pipe
// First, we need to create an async event source and add it to our runloop
kr = (*gInterface)->CreateInterfaceAsyncEventSource(gInterface,&gCFSource);
require_string(kr == kIOReturnSuccess, Exit, USBErrorToString(kr));
CFRunLoopAddSource(CFRunLoopGetCurrent(), gCFSource, kCFRunLoopDefaultMode);
for ( UInt32 i = 0; i< kNumberOfConcurrentTransfers; i++)
// Fill out our refcon
gTheData[i].buffer = XXXXX;
gTheData[i].size = YYYY;
// Queue up the first read
kr = (**gInterface).ReadPipeAsync( gInterface, //
gPipeRef, // pipeRef
gTheData[i].buffer, // * buf
gTheData[i].size, // size,
MyAsyncCallBackFunction, // Callback
(void *)&gTheData[i]); // Refcon
if ( kr != kIOReturnSuccess )
printf("ReadIsochPipeAsync returns 0x%x\n",kr);
Do not post admin requests to the list. They will be ignored.
Usb mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden