lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] lwip lock


From: Tazzari Davide
Subject: Re: [lwip-users] lwip lock
Date: Tue, 19 Apr 2011 08:29:14 +0200

Hi Martin,

I am very happy to hear that I lived for long time with a bug!!!!

 

By the way, what you are saying explains me also why if I run my code in FLASH there is still the problem but I have to wait for long time before it happens and if I run my code in SDRAM in a few reloads I crashed everything.

The reason is that the code in SDRAM run slower than in FLASH. The MACB is involved at the same speed no matter where the code runs. So, in percentage, from SDRAM code point of view, MACB runs more time that before. If there is a bug there, it may happen in percentage more often than it happens for FLASH code.

 

I’ll take a look at the messages you wrote.

If you could send my your correct solution I would be very very pleased.

 

About the Ethernet cable reconnection. I have had the same problem. If I unplugged and plugged the cable the web server didn’t recognize the requests any more.

My solution is in my previous post…

WebServer task
...
    for (;;)
    {
        iRestartBinding = 0;
        pxHTTPListener = netconn_new( NETCONN_TCP );
        netconn_bind(pxHTTPListener, NULL, webHTTP_PORT );
        netconn_listen( pxHTTPListener );
        int iTimeout = 1000;

        for( ; (iRestartBinding < 10) && (gucRestartWebServer == FALSE); iRestartBinding++)
        {
            xLastFocusTime = xTaskGetTickCount();
            vTaskDelayUntil( &xLastFocusTime, xDelayLength );
            if (iGlobalWtdBomb == FALSE) // TRUE I am waiting for a WDT suicide
            {
                // Wait for a first connection.
                #if LWIP_SO_RCVTIMEO
                pxHTTPListener->recv_timeout = iTimeout;
                #endif

                pxNewConnection = netconn_accept(pxHTTPListener);
                if (xTaskCreate(WebServerAnswerTask,
                        ( signed portCHAR * ) "WebServerAnswer",
                        WEB_SERVER_STACK_SIZE,
                        pxNewConnection,
                        ethWEBSERVER_PRIORITY,
                        ( xTaskHandle * ) NULL ) != pdPASS)
                {
                   // Task not correctly created!!!
                   netconn_write( pxNewConnection, (char *) webHTTP_HTM_INTERNAL_ERROR, (u16_t) strlen( webHTTP_HTM_INTERNAL_ERROR ), NETCONN_COPY ); // error HTTP 500

                   netconn_close( pxNewConnection );
                   netconn_delete( pxNewConnection );
                }
                iRestartBinding = 0;
                iTimeout = 5000;           
            }
        }   // end acquisition loop
        gucRestartWebServer = FALSE;
        netconn_close(pxHTTPListener);
        while(netconn_delete(pxHTTPListener) != 0)
        {
            vTaskDelay(20);
        }
        pxHTTPListener = NULL;
    }
...

a double “for” cycle

The first “for” is the infinite cycle to manage the task

The second “for” lets recreate the connection and the binding/listening if nothing has touched the web server for a certain amount of time (in my solution 10 seconds)

The timeout is also important because this lets the netconn_accept function exits and processes the first “for” using the counter iRestartBinding. The flag gucRestartWebServer is only for testing purpose so forget it.

In this way I could plug and unplug how much time I want. Of course, this doesn’t react immediately but I need to wait at least 10 seconds. I didn’t think this is such a big problem!

 

Davide

 

 

From: address@hidden [mailto:address@hidden On Behalf Of Martin Persich
Sent: lunedì 18 aprile 2011 20:45
To: Mailing list for lwIP users
Subject: Re: [lwip-users] lwip lock

 

Hi Davide,

I see very important information in your message today: "AVR32" !

There is no problem in LwIP, but in Atmel's port file and Atmel's MACB driver, I think. (many thans to Kieran for stable version of LwIP ...)

I work with the AVR32 too and there was (is ?) many and many bugs in Atmel's MACB driver and Atmel's port files for LwIP !!

I haven't time to study your problem in this moment, but it is look like my problems one, two years ago.

You can look to my messages in :

...

I had problem with reconnection of Ethernet cable too ...  :-(

I can send you to private address my port files for LwIP 1.4.0 (I advise upgrade to 1.4.0) and my working version of MACB driver

 

Martin Persich

 

 

WebServer task
...
    for (;;)
    {
        iRestartBinding = 0;
        pxHTTPListener = netconn_new( NETCONN_TCP );
        netconn_bind(pxHTTPListener, NULL, webHTTP_PORT );
        netconn_listen( pxHTTPListener );
        int iTimeout = 1000;

        //for( ; (iRestartBinding < 10) && (gucRestartWebServer == FALSE); iRestartBinding++)
        for( ; ; ) // <<-- for this test purpose; In the real case the above line is present
        {
            REL_TGL; // <<-- for this test purpose
            xLastFocusTime = xTaskGetTickCount();
            vTaskDelayUntil( &xLastFocusTime, xDelayLength );
            if (iGlobalWtdBomb == FALSE) // TRUE I am waiting for a WDT suicide
            {
                // Wait for a first connection.
                #if LWIP_SO_RCVTIMEO
                pxHTTPListener->recv_timeout = iTimeout;
                #endif

                pxNewConnection = netconn_accept(pxHTTPListener);
                if (xTaskCreate(WebServerAnswerTask,
                        ( signed portCHAR * ) "WebServerAnswer",
                        WEB_SERVER_STACK_SIZE,
                        pxNewConnection,
                        ethWEBSERVER_PRIORITY,
                        ( xTaskHandle * ) NULL ) != pdPASS)
                {
                   // Task not correctly created!!!
                   netconn_write( pxNewConnection, (char *) webHTTP_HTM_INTERNAL_ERROR, (u16_t) strlen( webHTTP_HTM_INTERNAL_ERROR ), NETCONN_COPY ); // error HTTP 500

                   netconn_close( pxNewConnection );
                   netconn_delete( pxNewConnection );
                }
                iRestartBinding = 0;
                iTimeout = 5000;           
            }
        }   // end acquisition loop
        gucRestartWebServer = FALSE;
        netconn_close(pxHTTPListener);
        while(netconn_delete(pxHTTPListener) != 0)
        {
            vTaskDelay(20);
        }
        pxHTTPListener = NULL;
    }
...


reply via email to

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