forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ME question

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Sat Dec 10, 2005 3:13 am    Post subject: ME question Reply with quote

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
View user's profile Send private message
jonny



Joined: 22 Sep 2005
Posts: 351

PostPosted: Sat Dec 10, 2005 4:31 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sat Dec 10, 2005 4:39 am    Post subject: Reply with quote

Why not use the *Async() versions of the sceIo calls?
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Sat Dec 10, 2005 6:20 am    Post subject: Reply with quote

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
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Sat Dec 10, 2005 6:49 am    Post subject: Reply with quote

Did you really mean to put that sceKernelSleepThreadCB() there?
Back to top
View user's profile Send private message
jonny



Joined: 22 Sep 2005
Posts: 351

PostPosted: Sat Dec 10, 2005 6:53 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Sat Dec 10, 2005 8:16 am    Post subject: Reply with quote

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
View user's profile Send private message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sat Dec 10, 2005 9:29 am    Post subject: Reply with quote

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
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Sat Dec 10, 2005 7:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group