[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] RAW Api to receive large image data
From: |
nkumar |
Subject: |
[lwip-users] RAW Api to receive large image data |
Date: |
Thu, 3 Jul 2014 12:47:24 -0700 (PDT) |
Hello,
I am newbie to lwip stack. After looking at a typical echo server example, I
am trying to implement a raw-api based server on arm-based board. I expect
to receive large (~4Mb) image data to server. I notice it works fine with
smaller data (~4k) however, it gets stuck on large data. While receiving I
keep track of data-received-so-far and keep appending the new data using
memcpy on pbuf->payload with pbuf->len size. I have been experimenting with
memory settings in lwipopts.h but no luck. My data is in format:
+--------------------------+------------------+
| img size (4-byte field) | image data ... | <--- (image data = ~ 4Mb)
+--------------------------+------------------+
Here's my code:
const int MAX_BUFF_SIZE = 4096000;
typedef struct _data_info {
u8_t datat[MAX_BUFF_SIZE];
u32_t expectedBytes;
u32_t bytesRxd;
bool readyRead;
} DataInfo;
err_t rxd_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t
err)
{
DataInfo *info = (DataInfo *)arg;
if (!p) {
tcp_close(tpcb);
tcp_recv(tpcb, NULL);
return ERR_OK;
}
/* Begin of data */
if ( (info->expectedBytes == 0) && (p->len > 0))
{
info->bytesRxd = 0;
info->readyRead = false;
info->expectedBytes = *((u32_t*)p->payload) + 4; //reading img size
}
if (info->expectedBytes > 0)
{
memcpy(&info->data[info->bytesRxd], p->payload, p->len);
info->bytesRxd += p->len;
info->expectedBytes -= p->len;
if (info->expectedBytes == 0)
{
info->readyRead = true; // Ready to process data.
}
}
tcp_recved(tpcp, p->len);
pbuf_free(p);
return ERR_OK;
}
My PBUF_POOL_BUFSIZE to 1700 & PBUF_POOL_SIZE is 516 in lwipopts.h. My
hardware has 1G of RAM available. This client - server completely
synchronous, i.e. client will not send any data until server is done
processing current data.
Please help.
nkumar
--
View this message in context:
http://lwip.100.n7.nabble.com/RAW-Api-to-receive-large-image-data-tp22873.html
Sent from the lwip-users mailing list archive at Nabble.com.
- [lwip-users] RAW Api to receive large image data,
nkumar <=