sceNetTerm hangs with adhoc on fw 3.60

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
uberjack
Posts: 34
Joined: Tue Jul 17, 2007 9:09 am
Location: California, USA
Contact:

sceNetTerm hangs with adhoc on fw 3.60

Post by uberjack »

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: Select all

  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 &#40;_pdp_id <= 0&#41; &#123; return _pdp_id; &#125;

  _net_adhoc_pdp_create = 1;



  err = sceNetAdhocMatchingInit&#40;0x20000&#41;;

if &#40;err != 0&#41; &#123; return err; &#125;

  _net_adhoc_matching_init = 1;



  _matching_id = sceNetAdhocMatchingCreate&#40; 3,

                                          0xa,

                                          0x22b,

                                          0x800,

                                          0x2dc6c0,

                                          0x5b8d80,

                                          3,

                                          0x7a120,

                                          matchingCallback&#41;;

if &#40;_matching_id < 0&#41; &#123; return _matching_id; &#125;

  _net_adhoc_matching_create = 1;



  err = sceNetAdhocMatchingStart&#40;_matching_id,  // 1 in lumines &#40;presuming what is returned from create&#41;

                                 0x10,    // 0x10

                                 0x2000,    // 0x2000

                                 0x10,    // 0x10

                                 0x2000,    // 0x2000

                                 0,

                                 NULL&#41;;

if &#40;err != 0&#41; &#123;return err; &#125;

  _net_adhoc_matching_start = 1;


  return 0;

Shutdown code:

Code: Select all

  unsigned int err;


  if &#40;_net_adhoc_ctl_connect&#41;

  &#123;

    err = sceNetAdhocctlDisconnect&#40;&#41;;

    _net_adhoc_ctl_connect = 0;

  &#125;



  if &#40;_net_adhoc_pdp_create&#41;

  &#123;

    err = sceNetAdhocPdpDelete&#40;_pdp_id, 0&#41;;

    _net_adhoc_pdp_create = 0;

  &#125;



  if &#40;_net_adhoc_matching_start&#41;

  &#123;

    err = sceNetAdhocMatchingStop&#40;_matching_id&#41;;

    _net_adhoc_matching_start = 0;

  &#125;



  if &#40;_net_adhoc_matching_create&#41;

  &#123;

    err = sceNetAdhocMatchingDelete&#40;_matching_id&#41;;

    _net_adhoc_matching_create = 0;

  &#125;

  

  if &#40;_net_adhoc_matching_init&#41;

  &#123;

    err = sceNetAdhocMatchingTerm&#40;&#41;;

    _net_adhoc_matching_init = 0;

  &#125;

  

  if &#40;_net_adhoc_ctl_init&#41;

  &#123;

    err = sceNetAdhocctlTerm&#40;&#41;;

    _net_adhoc_ctl_init = 0;

  &#125;



  if &#40;_net_adhoc_init&#41;

  &#123;

    err = sceNetAdhocTerm&#40;&#41;;

    _net_adhoc_init = 0;

  &#125;



  if &#40;_net_init&#41;

  &#123;

    err = sceNetTerm&#40;&#41;; // hangs here

    _net_init = 0;

  &#125;


  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
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

I've had a similar error previously myself.

Try changing your call to sceNetInet to:

Code: Select all

sceNetInit&#40;128*1024, 42, 4*1024, 42, 4*1024&#41;;
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.
User avatar
uberjack
Posts: 34
Joined: Tue Jul 17, 2007 9:09 am
Location: California, USA
Contact:

Post by uberjack »

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: Select all

sceNetInit&#40;128*1024, 42, 4*1024, 42, 4*1024&#41;;
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.
Post Reply