Mailing Lists: Apple Mailing Lists

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

Re: reading from an interrupt Endpoint with USB fxs



I did manage to look at a block of data looking bytes by
adding a printf of gbuffer after CFRunLoopRun();

now what I need to know is,  how do I read several blocks??

In the synchronous case, I did a for loop around readpipe.
In the asynchronous case, how do I need to modify the code
to get several blocks of data, instead of just one?

thanks

Anne


On Thu, 11 Aug 2005, Anne G wrote:

> I have been able to read data with ReadPipe, but I am not
> sure I am getting all the data, and in any case, I am told
> I need to learn asynchronous reading for my application.
>
> I think I did the same as some folks on this list: I took
> the USBSimpleExample and tried to adapt it for an
> asynchronous read.
>
> I am imitating without any understanding. In my program
> the last argument of ReadPipeAsync is inpipe, in another
> err. What should it be in my case?
>
> I get no error, and one printout from mycallBackFunction,
> but whatever it is being printed out, it does not look like
> data: I guess my data should be in gbuffer.
>
> Where and when do I access my data?
>
> thanks
>
> anne
> ----------------------------------------------------
>
> MyCallBackFunction(void *dummy, IOReturn result, void *arg0)
> {
>     printf("MyCallbackfunction: %d, %d, %d\n", (int)dummy,
> (int)result, (int)arg0);
>     CFRunLoopStop(CFRunLoopGetCurrent());
> }
>
> void transferData(IOUSBInterfaceInterface **intf, UInt8
> inPipeRef)
> {
>     IOReturn			err;
>     CFRunLoopSourceRef		cfSource;
>     int				i;
>
> 	char                gBuffer[8];
> 	UInt32		    numBytesRead;
>
> 	numBytesRead = sizeof(gBuffer);
>
>     err = (*intf)->CreateInterfaceAsyncEventSource(intf,
> &cfSource);
>     if (err)
>     {
> 	printf("transferData: unable to create event source,
> err = %08x\n", err);
> 	return;
>     }
>     CFRunLoopAddSource(CFRunLoopGetCurrent(), cfSource,
> kCFRunLoopDefaultMode);
> 	printf("Asynchronous event source added to run
> loop\n");
>
> 	err = (*intf)->ReadPipeAsync(intf, inPipeRef,
> gBuffer, numBytesRead, (IOAsyncCallback1)MyCallBackFunction,
> (void*)(UInt32)inPipeRef);
> 	if (err != kIOReturnSuccess)
> 	   {
> 	    printf("Unable to perform asynchronous bulk read
> (%08x)\n", err);
> 		CFRunLoopRemoveSource(CFRunLoopGetCurrent(),
> cfSource, kCFRunLoopDefaultMode);
> 		return;
> 		}
>
>     printf("transferData: calling CFRunLoopRun\n");
>     CFRunLoopRun();
>     printf("transferData: returned from  CFRunLoopRun\n");
>     CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource,
> kCFRunLoopDefaultMode);
>
> }
>
>
>
>
>
>

 _______________________________________________
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

References: 
 >Re: reading from an interrupt Endpoint with USB fxs (From: Anne G <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.