gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > WIFI-LIB:stops receiveing messages after about 10 mins HELP!

#75739 - qw3rty - Wed Mar 15, 2006 5:18 pm

After I got my initial problems with the wifi-lib under control, it works quite well, but after about 10 minutes I can't receive any incoming messages anymore (outgoing still works like a charm).

I tried the original wifi-lib0.2 and the lib with the changes from stonebone, NO DIFFERENCE !

Anybody experienced similar problems ?
I read in the changelog of the original lib(0.2) :
"* Probably fixed issue with transmit locking up. Transmit is far more stable
now."

Is this my problem ?!

P.S. : I just found out, that the problems must be somewhere in my transfer-funtions.
UDPTest() still works after aprox. 20 mins.
At least I have a trace to follow :)

#75821 - qw3rty - Thu Mar 16, 2006 6:51 am

I replaced my receiveand send routines with simple calls to "sendto" and "receivefrom" - and it was working the whole night !

Here are my receive & send functions :
Code:


s16 sen_and_ack_COMM(COMMUNICATION* send_com, u32 destip, u32 portnum)//returns -1 if no (complete) packet was sent or acknowledged
{                                   //else returns num of bytes sent      
   int sain_size = sizeof(sa_incoming);
   u16 counter = 0;
   s16 num_bytes_rcvd = 0;
   s16 num_bytes_sent = 0;
   u16 i;
   COMMUNICATION in_com[1];
   
   
   sa_outgoing.sin_family=AF_INET;
   sa_outgoing.sin_port=htons(portnum);
   sa_outgoing.sin_addr.s_addr=destip;
   send_com[0].PAK_NUM++;//increment the PAK-NUM
   //send packet
   num_bytes_sent = sendto(sock,((u8*)&send_com[0]),sizeof(COMMUNICATION),0,(struct sockaddr *)&sa_outgoing,sizeof(sa_outgoing));
   printf("senandack %i\n",num_bytes_sent);
   
   if (num_bytes_sent != sizeof(COMMUNICATION))
   {
      printf("sent not enough\n");
      return -1;
   }
   while (counter <= TIMEOUT)
   {//wait for acknowledge packet
      //swiWaitForVBlank();
      
      
      
      //printf("rcvd %i\n",num_bytes_rcvd);
      num_bytes_rcvd = recvfrom(sock,((u8*)&in_com[0]),PACKET_HEADER_LEN,0,(struct sockaddr *)&sa_incoming,&sain_size);
      printf("rcvd %i\n",num_bytes_rcvd);
      if (num_bytes_rcvd == -1) //nothing received
      {
         counter++;
      }
      else if (num_bytes_rcvd >= PACKET_HEADER_LEN)
      {//paket received, at least the demanded length check for HEADER
         for (i = 0; i < PACKET_HEADER_LEN; i++)
         {
            if ( *(((u8*)&(in_com[0]))+i) != *(((u8*)&(in_com[0]))+i) ) return -1; //no legal header sent back
         }
         return num_bytes_sent;
      }
      
   }
   printf("TIMEOUT\n");
   return -1;
}


exchanging the code above with :
s16 sen_and_ack(...)
{
return sendto(......);
}
removing the wait for the answer results in working code (for more than 10 minutes).

#76006 - qw3rty - Fri Mar 17, 2006 5:38 pm

Ok, I found the bug - it was a silly mistake by me.
The problem was, that BOTH machines were in the sen_and_ack-routine, hence no one got the acknowledge packet.

They got out of sync, when the PC thought it sent an acknowledge packet back, but it actually sent only an ARP-request (who is [IP of NDS]).

I have to think a little more about my acknowledge routine.... hmmm... any tips ? ;)

EDIT : setting an static ARP entry for the NDS (on PC : arp -s [IP-Adress] [MAC]) eliminated my problem in the LAN (the ARPs are automatically updated every 10 minutes !), but my routine still gets out of sync if a packet is lost.