 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Thu Jan 15, 2009 4:31 am Post subject: ps2ip_init() hangs?...again |
|
|
Hi!
I'm back to my project, and some parts are almost done, I've sucessfully finished the PC version of my network program, but... there's a little problem on the PS2.
When I make a call to ps2ip_init(), the application hangs!
I loaded all the modules, look to the function:
| Code: |
void loadmodules(){
//pad and cdvd modules
SifExecModuleBuffer(ps2dev9, size_ps2dev9, 0, NULL, &ret);
if(ret<0){
scr_printf("Error loading ps2dev9 modules\n");
SleepThread();
}
//load up, in this order: ps2ip and ps2ips, and finally:
char *ip = "192.168.2.12", *gw = 192.168.2.1, *nm = "255.255.255.0";
char* args = malloc(strlen(ip)+strlen(nm)+strlen(gw)+3);
int a;
strcpy(&args[a], ip); a+=strlen(ip)+1;
strcpy(&args[a], nm); a+=strlen(nm)+1;
strcpy(&args[a], gw); a+=strlen(gw)+1;
SifExecModuleBuffer(ps2smap, size_ps2smap, a, args, &ret);
if(ret<0)
printf("Error loading ps2smap\n");
SleepThread();
}
|
Ok, this functions works, and I can also see the "192.168.2.12" IP on my router's traf monitor;
But, the first thing that I do in main function is:
| Code: |
int main(){
resetIop(); //Ok, this is my IOP reset function, ever worker for me
SifInitRpc(0);
if(ps2ip_init() < 0){
scr_printf("Error initializing ps2ip rpc!\n");
SleepThread();
}
//grapf init stuff
//server functions (no joypad functions)
return 0;
}
|
I tried to load the program using the launchelf's network, and via USB, but nothing worked...
Any idea?
Maybe it's the order of the modules loading? (ps2dev9, ps2ip, ps2ips and then ps2smap)?
Thanks for any help!
methos |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Fri Jan 16, 2009 11:21 pm Post subject: |
|
|
Maybe I'm missing something?
I found here on the forums that the ps2dev9.irx doesn't relies anymore on the iomanx.irx, and so I'm not loading it.
I'm using the latest ps2sdk revision, from the svn.
All the modules load OK, as I said, but there is any other module that I need to load to get this program running?
[edit]:
I spend an entire day trying to get the ps2link source to see what it loads to use ps2ips, and didn't find, looked at uLE but it doen't use a propietary ftp driver, but I founf the ps2ftp source at the SVN and foun this:
| Code: |
if (!underPS2Link) {
SifExitRpc();
SifIopReset("rom0:UDNL rom0:EELOADCNF", 0);
while(!SifIopSync());
}
SifInitRpc(0);
//load dev9 and smap here
printf("Loading Network Adapter drivers...\n");
if (!underPS2Link) {
setupIP();
SifExecModuleBuffer(&iomanx_irx, size_iomanx_irx, 0, NULL, &ret);
printf("\tLoaded IOMANX: %d\n", ret);
SifExecModuleBuffer(&ps2dev9_irx, size_ps2dev9_irx, 0, NULL, &ret);
printf("\tLoaded PS2DEV9: %d\n", ret);
SifExecModuleBuffer(&ps2ip_irx, size_ps2ip_irx, 0, NULL, &ret);
printf("\tLoaded PS2IP: %d\n", ret);
SifExecModuleBuffer(&ps2ips_irx, size_ps2ips_irx, 0, NULL, &ret);
printf("\tLoaded PS2IPS: %d\n", ret);
SifExecModuleBuffer(&ps2smap_irx, size_ps2smap_irx, if_conf_len, &if_conf[0], &ret);
printf("\tLoaded PS2SMAP: %d\n", ret);
}
printf("Initialising IP stack...\n");
ps2ip_init();
|
The only thing different from mine is that it loads the iomanx.irx, even the order of the module loading is the same that I used:
ps2dev9, ps2ip, ps2ips, ps2smap with args.
I also used bin2c, and not bin2s, but don't believe it coul be a prolem, since I can load/init the freesio2/freepad modules and use controlers, the old version of the usb mas device driver with the rpc server works (only for testing purposes I added the old usb_mass.irx and its rpc stuff, in place of the usbhdfsd.irx).
I don't have time to test on my ps2 today, I'm not at home right now.
Someone can explain me what the iomanx.irx does and if it's really necessary to use the ps2ips? |
|
| Back to top |
|
 |
radad
Joined: 19 May 2004 Posts: 246 Location: Melbourne, Australia
|
Posted: Sat Jan 17, 2009 10:06 am Post subject: |
|
|
You should check the return from SifExecModuleBuffer (I am not talking about the last parameter). A value of -200 means there is a dependency error and the module wasnt loaded.
IOMANX is the iop side of the rpc functions for file access. On the ee side its the fileXio* functions defined in ee/rpc/filexio. It shouldnt be needed for ps2ips. |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Sat Jan 17, 2009 11:37 am Post subject: |
|
|
| radad wrote: | You should check the return from SifExecModuleBuffer (I am not talking about the last parameter). A value of -200 means there is a dependency error and the module wasnt loaded.
IOMANX is the iop side of the rpc functions for file access. On the ee side its the fileXio* functions defined in ee/rpc/filexio. It shouldnt be needed for ps2ips. |
Yes, the problem was a dependency error!!
I never would check the returnn value instear of the last arg if you didn't say me!
ps2dev9.irx is returning -200.
Why should it return -200? I don't have time to test right now, but... what kind of module should ps2dev9.irx need to load? poweroff.irx?
Thanks, man! |
|
| Back to top |
|
 |
radad
Joined: 19 May 2004 Posts: 246 Location: Melbourne, Australia
|
Posted: Sat Jan 17, 2009 11:56 am Post subject: |
|
|
If you have a look in iop/dev9/dev9/src/imports.lst you can find out its dependencies:
| Code: | dmacman
intrman
loadcore
poweroff
stdio
thbase
thsemap |
poweroff should be the only one you need to load, the rest are loaded as standard. |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Sat Jan 17, 2009 12:32 pm Post subject: |
|
|
| Quote: | | Code: | int a;
strcpy(&args[a], ip); a+=strlen(ip)+1; |
|
Where is 'a' initialized?
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
LionX
Joined: 27 Dec 2004 Posts: 61
|
Posted: Sat Jan 17, 2009 2:38 pm Post subject: |
|
|
| what version of ps2link are you using > |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Sun Jan 18, 2009 2:52 am Post subject: |
|
|
| radad wrote: | If you have a look in iop/dev9/dev9/src/imports.lst you can find out its dependencies:
| Code: | dmacman
intrman
loadcore
poweroff
stdio
thbase
thsemap |
poweroff should be the only one you need to load, the rest are loaded as standard. |
Worked! I looked onto imports.lst before, but I didn't see the poweroff part.
Now ps2ip_init is working (I tested on the emulator), but the smap loading returns -200... Could it be anything that the ps2 emulator doens't load? I'm not at home right now, so I can't test on my PS2. (for sure this time I'm not missing any required module to load ps2smap.irx, I loaded: poweroff, dev9, ps2ip, dns(for ps2ips), ps2ips, and smap, which returns -200)
| Jim wrote: | Where is 'a' initialized?
|
Since it's declared, its value is equal to zero ;-)
| LionX wrote: | what version of ps2link are you using >
|
I don't use ps2link, I use uLaunchelf instead.
So... this is it, as soon as I get home I will test the code on the PS2 to see if the smap loading doesn't return -200.
I will post the results here later,
Cya! |
|
| Back to top |
|
 |
radad
Joined: 19 May 2004 Posts: 246 Location: Melbourne, Australia
|
Posted: Sun Jan 18, 2009 8:57 am Post subject: |
|
|
smap should only need dev9 and ps2ip. Emulators cant be fully trusted, best wait till you can test on real hardware.
| Quote: | | Since it's declared, its value is equal to zero ;-) |
Thats not true. C doesnt initialise variables implicitly. You have to be explicit. |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Sun Jan 18, 2009 9:57 am Post subject: |
|
|
| radad wrote: | smap should only need dev9 and ps2ip. Emulators cant be fully trusted, best wait till you can test on real hardware.
| Quote: | | Since it's declared, its value is equal to zero ;-) |
Thats not true. C doesnt initialise variables implicitly. You have to be explicit. |
Serious?
I didn't know about this.
Yes, on the real hardware it worked, I needed the following:
*ps2dev9(needed ps2poweroff)
*ps2ip
*ps2ips(needed dns.irx)
*ps2smap with args
*get home to test everything
I made a simple program to transfer a file, I ported it from my PC version.
Then, I tested with a 220kb file, and it (veeeeeery slowly) transfered 180KB (or more, I don't remember) to the ps2
but, when the ps2 screen shows that 180KB was received, the pc side application says that the whole file was sent and closes the socket, should I leave the pc-side socket open? I'm going to test this tomorrow.
Looks like it's some buffering issue, because with any file that I try to transfer to the PS2, in the PC says that the file transfer was completed, and on the ps2 says that there are some KBs to be received.
ps.:Thanks for all the help that you gave me! |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Sun Jan 18, 2009 10:19 am Post subject: |
|
|
It's only guaranteed to be 0 if you declare it at global scope or you declare it as 'static' (and your C runtime is clearing it out at startup) . Otherwise automatic variables at function scope are undefined.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Mon Jan 19, 2009 1:39 am Post subject: |
|
|
| Jim wrote: | It's only guaranteed to be 0 if you declare it at global scope or you declare it as 'static' (and your C runtime is clearing it out at startup) . Otherwise automatic variables at function scope are undefined.
Jim |
Yes, first posted, I corrected the startup code, see the new one:
| Code: |
void loadmodules(int free)
{
scr_printf("Carregando modulos");
s32 ret;
int rv;
char* IP = "192.168.2.12";
char* NM = "255.255.255.0";
char* GW = "192.168.2.1";
char *args = malloc(strlen(IP) + strlen(NM) + strlen(GW));
int a = 0;
rv=SifExecModuleBuffer(freesio2, size_freesio2, 0, NULL, &ret);
scr_printf("Carregando freesio2: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(freepad, size_freepad, 0, NULL, &ret);
scr_printf("Carregando freepad: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(usbd, size_usbd, 0, NULL, &ret);
scr_printf("Carregando usbd: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(usb_mass, size_usb_mass, 0, NULL, &ret);
scr_printf("Carregando usb_mass: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(poweroff, size_poweroff, 0, NULL, &ret);
scr_printf("Carregando poweroff: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(ps2dev9, size_ps2dev9, 0, NULL, &ret);
scr_printf("Carregando dev9: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(ps2ip, size_ps2ip, 0, NULL, &ret);
scr_printf("Carregando ps2ip: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(dns, size_dns, 0, NULL, &ret);
scr_printf("Carregando dns: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(ps2ips, size_ps2ips, 0, NULL, &ret);
scr_printf("Carregando ps2ips: %d\n", rv);
if(rv<0) SleepThread();
/* load up smap with static settings */
strcpy(&args[a], IP); a += strlen(IP) + 1;
strcpy(&args[a], NM); a += strlen(NM) + 1;
strcpy(&args[a], GW); a += strlen(GW) + 1;
rv=SifExecModuleBuffer(ps2smap, size_ps2smap, a, args, &ret);
scr_printf("Carregando freesio2: %d", rv);
//if(rv<0) SleepThread();
}
|
Now I could receive a 70KB zipped file and save it to the memory card, whihout (much) problems.
And... why didn't I see THIS:
| Code: |
poweroff_IMPORTS_start
I_AddPowerOffHandler
poweroff_IMPORTS_end
|
on the imports.lst file!? Maybe it's my eyes :S
And I didn't know that SifExecModuleBuffer returns an int like SifLoadModule.
Now my little program is fully functional(I just need to don't close the socket on the client, that sends the file, because of the buffered data), I need only to remove the scr_printf's and make my GUI for the program,
Cya!
ps.: If you are interested on my program (veeeery simple), post here or send me a message, It have a server/client for PC and a server for the PS2 (i'm still developing the client). The PC side was built using Visual Studio 2005 (C++.NET), but can be easily ported to C for Windows, Linux, etc. |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Mon Jan 19, 2009 7:16 am Post subject: |
|
|
| Quote: |
| Code: |
char* IP = "192.168.2.12";
char* NM = "255.255.255.0";
char* GW = "192.168.2.1";
char *args = malloc(strlen(IP) + strlen(NM) + strlen(GW));
int a = 0;
...
strcpy(&args[a], IP); a += strlen(IP) + 1;
strcpy(&args[a], NM); a += strlen(NM) + 1;
strcpy(&args[a], GW); a += strlen(GW) + 1;
|
|
Now you are almost certainly corrupting the heap by writing 3 too many bytes. You had that right before with the +3 in the malloc..
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Mon Jan 19, 2009 8:27 am Post subject: |
|
|
Mmm...
Are you saying that the three empty bytes that I'll pass within the argument don't need to be allocated, because they are \0?
Can you explain me better why the '\0' bytes don't need any space allocated on the memory?
I'll correct this later. |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
|
| Back to top |
|
 |
dlanor
Joined: 28 Oct 2004 Posts: 269 Location: Stockholm, Sweden
|
Posted: Mon Jan 19, 2009 10:53 pm Post subject: |
|
|
| methos3 wrote: | Mmm...
Are you saying that the three empty bytes that I'll pass within the argument don't need to be allocated, because they are \0?
| No.
What he is saying is that you neglected to add 3 to the size specified in the malloc call. That size only includes the content characters of the three strings, with no extra space for the three string terminators. So your final string will have its terminator, and two preceding characters, stored beyond the end of the allocated block. And depending on the implementation this may or may not cause an error exception (it really should), and it is a definite error in either case.
@Jim:
Sorry, we seem to have posted close in time.
Didn't mean to 'step on your toes' here. :)
Best regards: dlanor |
|
| Back to top |
|
 |
methos3
Joined: 01 Feb 2008 Posts: 89
|
Posted: Mon Jan 19, 2009 11:40 pm Post subject: |
|
|
LOL!
I re-wrote the last code, because I was whihout my Motorola w388, that contains the code, and forgot the +3...
I was lucky when I tested, then, because it worked.
In no time I will put the +3 in the malloc funtcion.
Jim, sorry for don't paying attention on what you said, I've become confused thinking "why should I don't allocate space for the '\0's?".
Thanks! This way my program won't break so easily, haha
Cya! |
|
| Back to top |
|
 |
|
|
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
|