Mailing Lists: Apple Mailing Lists

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

system restart during async read



hi!! i encountered a poblem when using ReadPipeAsync
to read the continuous live streaming data from my
camera. whenever it goes to the ReadPipeAsync part, a
message will pop up asking me to restart my computer
by pressing the power button. why is this so? am i
using the correct method to read the streamming data?
can i use a loop to do this if i want to capture data
for 10 seconds???
pls help me out!! thks!

my code*************

void fASync(IOUSBInterfaceInterface **interface)
{
	IOReturn			theResult;
    CFRunLoopSourceRef	runLoopSource;
	kern_return_t kernResult;
	UInt32 numBytesRead = 512;
	
	  if ((picFile = fopen("pic.mov","wb+"))==NULL)
	  {
		printf("File could not be opened \n");
	  }
	
	
	kernResult =
(*interface)->CreateInterfaceAsyncEventSource(interface,
&runLoopSource);
    if (kIOReturnSuccess != kernResult)
    {
        printf("unable to create async event source
(%08x)\n", kernResult);
        (void)
(*interface)->USBInterfaceClose(interface);
        (void) (*interface)->Release(interface);
        
    }
	
    CFRunLoopAddSource(CFRunLoopGetCurrent(),
runLoopSource, kCFRunLoopDefaultMode);
   int wTime = time(NULL)+10;
	 while(time(NULL)<=wTime)

		theResult = (*interface)->ReadPipeAsync( interface,
2, fReceiveBuffer,numBytesRead, readCallback, (void
*)interface );

    if (kIOReturnSuccess != theResult)
    {
        printf( "Could not accomplish a bulk read
(%08x)\n", theResult );
        (void)
(*interface)->USBInterfaceClose(interface);
		(void) (*interface)->Release(interface);
        return;
    }
	
	
}




void readCallback(void *refcon, IOReturn result, void
*arg0)
{
	IOUSBInterfaceInterface **interface =
(IOUSBInterfaceInterface **)refcon;
    UInt32 numBytesRead = (UInt32) arg0;
    
	int line=0;
	int bb = 0;

for(bb =0; bb < numBytesRead;bb++) // loop to print
data in buffer
		{
		   printf("%0x ", fReceiveBuffer[bb]);
		  
fwrite(&fReceiveBuffer[bb],sizeof(UInt8),1,picFile);
		   if((bb+1)%16 == 0)
		      {
		 	   printf("\n");
			   
			   line++;
			   if(line%256 == 0)
			 	  printf("\n%d\n", line);
			  }
		
		}


}



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
 _______________________________________________
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.