lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Transfer Mibs of data over TCP


From: Noam Weissman
Subject: Re: [lwip-users] Transfer Mibs of data over TCP
Date: Mon, 3 Apr 2017 13:43:44 +0000

Hi,

 

Why not use the RAW API server that is in the contribution ?

 

I am not using it because am using my own modified code that was created before the current version.

As far as I know it works nicely and many are using it J

 

I have no problems accepting a large file 1MB… never had to accept a larger file but I  do not think it makes

any difference.

 

I think that if netbuf_next() fails you need to add some delay and try again.

I mean add vTaskDelay(10) or similar and try again.

 

When you transfer large amount of data you may get into cases that the network has some lag.

In that case your netbuf_next() call nay fail.

 

Doing something like this:

 

#define READ_ERROR_DELAY          10

#define READ_ERROR_TIMEOUT    500

 

err_t MyRead( params )

{

   Int RetVal , TotalTimeOut  = 0;

 

   Do

   {

      RetVal = netbuf_next();

 

      If(RetVal == (-1))

      {

          vTaskDelay(READ_ERROR_DELAY / portTICK_RATE_MS);

          TotalTimeOut += READ_ERROR_DELAY;

      }

      else

      {

          break;

      }

 

   } while(TotalTimeOut < READ_ERROR_TIMEOUT);

 

}

 

 

The above function will try to read from the socket and if fails it will delay for about 10 ms… that way you give

the TCP and other system tasks time to run.

 

If the above is not an option due to system constrains you can adapt some kind of state machine, per connection

and use lwip own function sys_timeout to trigger for the above function or similar.

 

Hope that gives some ideas…

 

Good luck,

Noam.

 

From: lwip-users [mailto:lwip-users-bounces+address@hidden On Behalf Of Tóth Norbert
Sent: Monday, April 03, 2017 4:03 PM
To: address@hidden
Subject: [lwip-users] Transfer Mibs of data over TCP

 

Hi Folks,

I develop a system based on the followings:

  •     TM4C1294 TI Cortex M4 CPU
  •     FreeRTOS 7.x
  •     TinyFS for FAT file system handling on SD card
  •     LwIP 1.4.1 netconn API

I have to receive files (20-40MB) via HTTP POST request and store them into SD card (basically it is a simple HTTP file server).
Due to the other design decisions and the FreeRTOS, using "netconn" API seems to be the most suitable for me.
My problem is that it only works well with small files (20~100B) not with the desired sizes. I implemented the following logic looks like:

  • wait for an incoming connection
  • parse the HTTP header (excluding resource name and method)
  • write the rest of data from the current pbuf
  • repeat the following while data can be read from the connection:
    • acquire the next "part" of data by netbuf_next()
    • if it results -1
      • delete the current netbuf by netbuf_delete()
      • call netconn_recv() on the connection
    • store data (if all the above result success)


Can anybody help me, what should I fix?  What did I wrong?

Regards,
Nobert


reply via email to

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