Hey all,
would some one be able to give an example of the sceIoReadAsync() function from the sdk. I have been looking all over the forums and even in PPA source code. But i can't seem to get it to work.
Regards
Homemister
Async Functions in SDK HELP
First, a disclaimer, I haven't played with async io, just relaying what I found in the docs with the hope that it'll help.
If I understand the docs correctly, first you register a callback with sceIoSetAsyncCallback(), then you call sceIoReadAsync() which will return immediately, and when it has done its work will fire your callback.
OR
Call sceIoReadAsync() and at a later time you can call sceIoPollAsync() to see if it's done and/or call sceIoWaitAsync() to wait for it to complete.
If I understand the docs correctly, first you register a callback with sceIoSetAsyncCallback(), then you call sceIoReadAsync() which will return immediately, and when it has done its work will fire your callback.
OR
Call sceIoReadAsync() and at a later time you can call sceIoPollAsync() to see if it's done and/or call sceIoWaitAsync() to wait for it to complete.
-
- Posts: 25
- Joined: Mon Mar 24, 2008 12:16 pm
Thx,
Got it working now.
Got it working now.
Code: Select all
int main(void)
{
SetupCallbacks();
pspDebugScreenInit();
printf("ms0:/test.txt\n");
SceUID fd = sceIoOpen("ms0:/test.txt", PSP_O_RDONLY, 0777);
char data[256];
sceIoChangeAsyncPriority(fd, 0x10);
sceIoReadAsync(fd, data, 100);
SceInt64 res;
sceIoWaitAsync(fd, &res);
sceIoClose(fd);
printf(data);
printf("\nDONE");
return 0;
}
I know this is just an example, but I think its worth mentioning (for other readers of the thread) that if you're using it that directly in your actual code you gain no benefit from using the async calls. I'd use the non async equivalents, they're much more direct in usage:
Just sceIoRead(fd, data, 100); and you've got 100 bytes, right away.
Just sceIoRead(fd, data, 100); and you've got 100 bytes, right away.
-
- Posts: 25
- Joined: Mon Mar 24, 2008 12:16 pm