lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] problems using netif_is_up ...


From: Teratux
Subject: [lwip-users] problems using netif_is_up ...
Date: Fri, 22 Oct 2010 09:44:58 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7) Gecko/20100720 Lightning/1.0b2 Thunderbird/3.1.1

Hi ... I've been trying out the netif_is_up() command to verify if an existing connection is up but haven't been able to properly use it ...

My app crashes when my connection goes down.  Here's the snippet ...

for(;;)
    {
        in = NULL;
        vTaskDelay( (portTickType)50/portTICK_RATE_MS);


        while ( !RC_IS_STATUS_FLAG_ASSERTED( getStatus(), RC_STATUS_CLOSE|RC_STATUS_ERROR) )
        {
            if( xSemaphoreTake( ethConnectionSemaphore, (portTickType)10 ) == pdTRUE )
            {
                if ( pNewConnection != NULL )
                {
                    in = netconn_recv(pNewConnection);

                    if ( in != NULL )
                    {
                        netbuf_data(in, (void*)&pBuff, &len);

                        i = 0;
                        while( i < len )
                        {
                            if( xQueueSend( handleUpr, &pBuff[i++], 200 ) == pdPASS )
                            {
                                // vParTestToggleLED(0);
                            }
                        }
                        netbuf_delete(in);
                    }
                    else
                    {
                        if ( netif_is_up ( &s_EMAC_if ) )
                        {
                            vParTestToggleLED(1);
                        }
                        else
                        {
                            if( xSemaphoreTake( statusSemaphore, (portTickType)10 ) == pdTRUE )
                            {
                                RC_SET_STATUS_FLAG(cStatus, RC_STATUS_ERROR);
                                vParTestToggleLED(2);
                                xSemaphoreGive( statusSemaphore );
                            }
                        }
                    }
                }

                xSemaphoreGive( ethConnectionSemaphore );
            }

            vParTestToggleLED(0);

        }
    }


The while() statement above ensures that when a connection has finished this thread does no additional proccesing.  And it should stop when netif_is_up ( &s_EMAC_if ) is false and the cStatus variable is set.  This code works well when the connection is up.  However, when I close the link from the client app it crashes, I even lose the ping to the microcontroller board.   I've tried many alternatives in the section when I query the netif_is_up() function and it seems that the problem is here.  The other thread running in my app doesn't use any shared resource used in this thread.

I'm guessing that the s_EMAC_if variable gets somehow corrupted when the connection dies, or maybe I'm just using it wrong.

These are the datatypes:

static struct netif s_EMAC_if;
static struct netconn *pNewConnection;
struct netbuf *in;
char *pBuff;
unsigned char cStatus;

Can anyone help ?
Thanks in advance ...

reply via email to

[Prev in Thread] Current Thread [Next in Thread]