| View previous topic :: View next topic |
| Author |
Message |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Sat Dec 10, 2005 3:13 am Post subject: ME question |
|
|
Hi, i've been trying to think of a way to solve a problem, and thought about using the ME. My problem is that I need to write a lot of data to the memory stick without freezing the PSP. I could do this by splitting up the file, but a far faster way would be to use the ME as a file manager CPU.
What I'd like to know is: can I get the ME to save a 2MB+ file to the memory stick whilst allowing the main CPU to get on with it's work unhindered?
Thanks. |
|
| Back to top |
|
 |
jonny
Joined: 22 Sep 2005 Posts: 351
|
Posted: Sat Dec 10, 2005 4:31 am Post subject: |
|
|
you can try with async writes (or normal writes in a different thread), this could be sufficient to have the operation at the cost of 0.
also writing 64k chunks (with data aligned to 64 bytes) should be the optimal way for psp (it's the optimal size for reading, so i assume it's the same for writing) |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sat Dec 10, 2005 4:39 am Post subject: |
|
|
| Why not use the *Async() versions of the sceIo calls? |
|
| Back to top |
|
 |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Sat Dec 10, 2005 6:20 am Post subject: |
|
|
I'm trying to get the Async to work now, but I've never tried them before, so it's proving tricky, it just boots into a black screen with this code:
In main() before main loop:
| Code: | testAsFile = sceIoOpenAsync("ms0:/textfile.txt", O_RDWR | O_CREAT, 0777);
if(testAsFile < 0){printf("ERROR!");}
int cbida;
cbida = sceKernelCreateCallback("Async Callback", async_callback, NULL);
sceKernelRegisterExitCallback(cbida);
sceKernelSleepThreadCB();
sceIoSetAsyncCallback(testAsFile, cbida, NULL);
char* dat;
dat = "blablabla";
int ret;
ret = sceIoWriteAsync(testAsFile, dat, 9);
if(ret < 0){printf("ERROR!");} |
The callback:
| Code: | int async_callback(int arg1, int arg2, void *common)
{
int vl;
vl = sceIoCloseAsync(testAsFile);
return 0;
} |
I know there's somthing wrong here, but I'm not sure what. It may be to do with the callback, I think. |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Sat Dec 10, 2005 6:49 am Post subject: |
|
|
| Did you really mean to put that sceKernelSleepThreadCB() there? |
|
| Back to top |
|
 |
jonny
Joined: 22 Sep 2005 Posts: 351
|
Posted: Sat Dec 10, 2005 6:53 am Post subject: |
|
|
is this sequence not suited for your needs (?):
sceIoOpen
sceIoWriteAsync
*some stuff here, write is running in the back*
sceIoWaitAsync
sceIoClose
(i don't think you need async open/close, is it right?) |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Sat Dec 10, 2005 8:16 am Post subject: |
|
|
| AnonymousTipster wrote: | I'm trying to get the Async to work now, but I've never tried them before, so it's proving tricky, it just boots into a black screen with this code:
In main() before main loop:
| Code: | testAsFile = sceIoOpenAsync("ms0:/textfile.txt", O_RDWR | O_CREAT, 0777);
if(testAsFile < 0){printf("ERROR!");}
int cbida;
cbida = sceKernelCreateCallback("Async Callback", async_callback, NULL);
sceKernelRegisterExitCallback(cbida);
sceKernelSleepThreadCB();
sceIoSetAsyncCallback(testAsFile, cbida, NULL);
char* dat;
dat = "blablabla";
int ret;
ret = sceIoWriteAsync(testAsFile, dat, 9);
if(ret < 0){printf("ERROR!");} |
The callback:
| Code: | int async_callback(int arg1, int arg2, void *common)
{
int vl;
vl = sceIoCloseAsync(testAsFile);
return 0;
} |
I know there's somthing wrong here, but I'm not sure what. It may be to do with the callback, I think. |
The callback is a mess too. You've created an async callback but registered it as an exit callback.
Stick with Jonny's code, it's simpler and should do everything you need. _________________ Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you! |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Sat Dec 10, 2005 9:29 am Post subject: |
|
|
To answer to your first question, I think the answer is no, because the ME has no kernel, it can just execute raw code and user routines (but no sce[Something] call). _________________ Sorry for my bad english
Oldschool library for PSP - PC version released |
|
| Back to top |
|
 |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Sat Dec 10, 2005 7:05 pm Post subject: |
|
|
I apologise for my ridiculous coding yesterday, I just grabbed the exit callback code without actually reading it.
Anyway, I've got the async file writer working correctly now. Thanks jonny. |
|
| Back to top |
|
 |
|