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: USB software crashes system in high speed



Thanks for the reply.

Does anyone have a sample piece of code that works in 10.3.8? I designed the device itself, so I can modify packet size, and other parameters if needed, but I really need to get this working somehow. Any info on what situation does work would be appreciated.

I'm now pretty sure the problem is not malloc/free because i switched to a static memory (char buffer[256]) and it still crashed the system.

Thanks,
Juan

On Feb 28, 2005, at 11:14 PM, Rhoads Hollowell wrote:

We have fixed a number of bugs with High Speed Isochronous transactions, including memory crashers as you describe. This could very easily be the OS, and not your code.

Many of these fixes will be in a future 10.3 update as well as in Tiger.

Sorry that this doesn't help you with 10.3.8 and earlier.

Rhoads Hollowell
USB Software Team
Apple Computer, Inc.

On Feb 28, 2005, at 7:46 PM, Juan Pablo Pertierra wrote:

Hello,

I am really hoping someone will point out a dumb error(as usual) in my software and everything will suddenly work. :D

This software is based on the USBSimple example. I modified it to read from an isochronous IN endpoint, and it worked perfectly in full speed mode.

However, when I test my device running in high speed mode, the software crashes the entire computer. I either get a white-on-black system crash error text on my screen and have to turn off the computer, or i get the "reset your computer" message.

It seems like it has something to do with the memory allocation, but like I said the exact same code work in full speed, and I am only allocating 16 bytes with malloc, and handing the buffer to ReadIsochPipeAsync. I use free() at the end.

The weird thing is that the data is read and written to the file, which makes me feel the error happens in free(). I tried removing free but that results in the "reboot your computer error".

I am not sure if this is a problem with my code, or maybe ReadIsochPipeAsync is doing something strange with the buffer.

I have attached my transferData() function where all gets done after the device is open/configured, etc. Everything happens successfully until this point, and i am sure the device is connecting at high-speed according to USB prober. It is also reading all descriptors correctly.

Thanks in advance!

--------------------------------

#define MAX_READ_FRAME 1
#define REQ_COUNT 16
double  endTime = 0;

void
MyCallBackFunction(void *dummy, IOReturn result, void *arg0)
{
//  UInt8	inPipeRef = (UInt32)dummy;

endTime = CFAbsoluteTimeGetCurrent();
printf("MyCallbackfunction: %d, %d, %d\n", (int)dummy, (int)result, (int)arg0);
printf("transferData: END %lf\n", CFAbsoluteTimeGetCurrent());
CFRunLoopStop(CFRunLoopGetCurrent());
}


void transferData(IOUSBInterfaceInterface **intf, UInt8 inPipeRef, UInt8 outPipeRef)
{
IOReturn err;
CFRunLoopSourceRef cfSource;
int i;
UInt64 frame;
AbsoluteTime atTime;
IOUSBIsocFrame frameList[MAX_READ_FRAME];
int file;
double startTime, intervalTime;
UInt32 actCount = 0;
char *inBuf = 0;


inBuf = malloc(MAX_READ_FRAME*REQ_COUNT);
if(inBuf != NULL)
printf("transferData: %d bytes allocated\n", (MAX_READ_FRAME*REQ_COUNT));
else
{
printf("transferData: malloc() error!\n");
return;
}
file = open("USBdump.raw", O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG);
if(!file)
{
printf("transferData: open() failed!\n");
return;
}
else
printf("transferData: open() succeeded\n");

err = (*intf)->CreateInterfaceAsyncEventSource(intf, &cfSource);
if (err)
{
printf("transferData: unable to create event source, err = %08x\n", err);
return;
}
else
printf("transferData: created event source\n");
CFRunLoopAddSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
err = (*intf)->GetBusFrameNumber(intf, &frame, &atTime);
if(err)
{
printf("transferData: GetBusFrameNumber failed err = %08x\n", err);
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
return;
}
else
printf("transferData: got frame number\n");
frame = frame + 10;
for(i = 0; i < MAX_READ_FRAME; i++)
{
frameList[i].frStatus = 2;
frameList[i].frReqCount = REQ_COUNT; //Transfer per frame, optimal should be 5x256
}
startTime = CFAbsoluteTimeGetCurrent();
printf("transferData: BEGIN %lf\n", startTime);
err = (*intf)->ReadIsochPipeAsync(intf, inPipeRef, inBuf, frame, (UInt32) MAX_READ_FRAME, frameList, (IOAsyncCallback1)MyCallBackFunction, (void*)(UInt32)inPipeRef);
if (err)
{
printf("transferData: ReadPipeAsyncFailed, err = %08x\n", err);
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
return;
}
printf("transferData: calling CFRunLoopRun\n");
CFRunLoopRun();
printf("transferData: returned from CFRunLoopRun\n");
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
for(i = 0; i < MAX_READ_FRAME; i++)
actCount = actCount + frameList[i].frActCount;
write(file, inBuf, actCount);
intervalTime = endTime - startTime;
printf("transferData: %d bytes read in %lf sec = %lf bytes/sec\n", actCount, intervalTime, (double) (actCount/intervalTime));
printf("%d %d %d %d %d %d\n", inBuf[0], inBuf[1], inBuf[2], inBuf[3], inBuf[4], inBuf[5]);
free(inBuf);
}


_______________________________________________
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


_______________________________________________ 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: 
 >USB software crashes system in high speed (From: Juan Pablo Pertierra <email@hidden>)
 >Re: USB software crashes system in high speed (From: Rhoads Hollowell <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.