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 

sceNetTerm hangs with adhoc on fw 3.60

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



Joined: 17 Jul 2007
Posts: 34
Location: California, USA

PostPosted: Wed Feb 06, 2008 1:07 pm    Post subject: sceNetTerm hangs with adhoc on fw 3.60 Reply with quote

Hi,

I'm having difficulty getting adhoc code running on firmware 3.60. The entire process consists of initializing adhoc, setting up matching, then shutting down.
The code works on fw 1.50, but it hangs on 3.60 at the very end - when I call sceNetTerm.
Does anyone have any suggestions on what may be causing the issue? The drivers load fine; I'm running in user mode on 3.60.

Initialization code:

Code:

  struct productStruct product;



  strcpy(product.product, "ULUS99999");

  product.unknown = 0;



  int _matching_id = 0;

  unsigned int err;



  err = sceNetInit(0x20000, 0x20, 0x1000, 0x20, 0x1000);

if (err != 0) { return err; }

  _net_init = 1;



  err = sceNetAdhocInit();

if (err != 0) { return err; }

  _net_adhoc_init = 1;



  err = sceNetAdhocctlInit(0x2000, 0x20, &product);

if (err != 0) { return err; }

  _net_adhoc_ctl_init = 1;



  err = sceNetAdhocctlConnect((void*)"");

if (err != 0) { return err; }

  _net_adhoc_ctl_connect = 1;



  int state, last_state = -1;



  for (;;)

  {

    err = sceNetAdhocctlGetState(&state);



    if (state > last_state) last_state = state;

    if (state == 1) break; /* connected */



    /* wait a little before polling again */

    sceKernelDelayThread(50 * 1000); // 50ms

  }


  char mac[6];

  sceWlanGetEtherAddr((unsigned char*)mac);


  _pdp_id = sceNetAdhocPdpCreate((unsigned char*)mac,

                               0x309,   // 0x309 in lumines

                               0x400,   // 0x400 in lumines

                               0);    // 0 in lumines

if (_pdp_id <= 0) { return _pdp_id; }

  _net_adhoc_pdp_create = 1;



  err = sceNetAdhocMatchingInit(0x20000);

if (err != 0) { return err; }

  _net_adhoc_matching_init = 1;



  _matching_id = sceNetAdhocMatchingCreate( 3,

                                          0xa,

                                          0x22b,

                                          0x800,

                                          0x2dc6c0,

                                          0x5b8d80,

                                          3,

                                          0x7a120,

                                          matchingCallback);

if (_matching_id < 0) { return _matching_id; }

  _net_adhoc_matching_create = 1;



  err = sceNetAdhocMatchingStart(_matching_id,  // 1 in lumines (presuming what is returned from create)

                                 0x10,    // 0x10

                                 0x2000,    // 0x2000

                                 0x10,    // 0x10

                                 0x2000,    // 0x2000

                                 0,

                                 NULL);

if (err != 0) {return err; }

  _net_adhoc_matching_start = 1;


  return 0;



Shutdown code:

Code:

  unsigned int err;


  if (_net_adhoc_ctl_connect)

  {

    err = sceNetAdhocctlDisconnect();

    _net_adhoc_ctl_connect = 0;

  }



  if (_net_adhoc_pdp_create)

  {

    err = sceNetAdhocPdpDelete(_pdp_id, 0);

    _net_adhoc_pdp_create = 0;

  }



  if (_net_adhoc_matching_start)

  {

    err = sceNetAdhocMatchingStop(_matching_id);

    _net_adhoc_matching_start = 0;

  }



  if (_net_adhoc_matching_create)

  {

    err = sceNetAdhocMatchingDelete(_matching_id);

    _net_adhoc_matching_create = 0;

  }

 

  if (_net_adhoc_matching_init)

  {

    err = sceNetAdhocMatchingTerm();

    _net_adhoc_matching_init = 0;

  }

 

  if (_net_adhoc_ctl_init)

  {

    err = sceNetAdhocctlTerm();

    _net_adhoc_ctl_init = 0;

  }



  if (_net_adhoc_init)

  {

    err = sceNetAdhocTerm();

    _net_adhoc_init = 0;

  }



  if (_net_init)

  {

    err = sceNetTerm(); // hangs here

    _net_init = 0;

  }


  return 0;



My matching callback is an empty function that currently does nothing.

If it helps, here's output from a bunch of trace fprintf statements:

starting... sceNetInit... OK
sceNetAdhocInit... OK
sceNetAdhocctlInit... OK
sceNetAdhocctlConnect... OK
sceNetAdhocctlGetState... OK
sceWlanGetEtherAddr... done
sceNetAdhocPdpCreate... OK: 1
sceNetAdhocMatchingInit... OK
sceNetAdhocMatchingCreate... OK: 1
sceNetAdhocMatchingStart... OK
sceNetAdhocctlDisconnect... OK
sceNetAdhocPdpDelete... OK
sceNetAdhocMatchingStop... OK
sceNetAdhocMatchingDelete... OK
sceNetAdhocMatchingTerm... OK
sceNetAdhocctlTerm... OK
sceNetAdhocTerm... OK
sceNetTerm... (never finishes)

Thanks for any help
Back to top
View user's profile Send private message Visit poster's website
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Wed Feb 06, 2008 10:56 pm    Post subject: Reply with quote

I've had a similar error previously myself.

Try changing your call to sceNetInet to:

Code:
sceNetInit(128*1024, 42, 4*1024, 42, 4*1024);


If that still fails to work and you use psplink, sleep the thread before the call to sceNetTerm and use thinfo and sminfo to see if there are still threads or semaphores for net active.
Back to top
View user's profile Send private message
uberjack



Joined: 17 Jul 2007
Posts: 34
Location: California, USA

PostPosted: Thu Feb 07, 2008 3:16 pm    Post subject: Reply with quote

It didn't work, but thanks for the suggestion. I'll post an update if I find out anything else.

Insert_witty_name wrote:
I've had a similar error previously myself.

Try changing your call to sceNetInet to:

Code:
sceNetInit(128*1024, 42, 4*1024, 42, 4*1024);


If that still fails to work and you use psplink, sleep the thread before the call to sceNetTerm and use thinfo and sminfo to see if there are still threads or semaphores for net active.
Back to top
View user's profile Send private message Visit poster's website
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