LwIP轻量级IP - pbuf_alloc返回null。 PBUF_POOL_IS_EMPTY

时间:2016-06-21 10:48:09

标签: c tcp lwip

我目前在飞思卡尔K60项目中使用lwIP来帮助我们的以太网TCP实现,并在lwipopts.h中设置以下选项。

#define MEM_SIZE                (12*1024)

/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
   sends a lot of data out of ROM (or other static memory), this
   should be set high. */
#define MEMP_NUM_PBUF           10
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
   per active UDP "connection". */
#define MEMP_NUM_UDP_PCB        6
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
   connections. */
#define MEMP_NUM_TCP_PCB        10
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
   connections. */
#define MEMP_NUM_TCP_PCB_LISTEN 6
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
   segments. */
#define MEMP_NUM_TCP_SEG        12
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. */
#define MEMP_NUM_SYS_TIMEOUT    10

/* ---------- Pbuf options ---------- */
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#define PBUF_POOL_SIZE          10

/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
#define PBUF_POOL_BUFSIZE       1518

我遇到过一个问题,即从PC客户端到设备的前9条消息已成功读取并传递到应用程序级别,但在第10次尝试时失败,我们不再通过以太网接收任何消息连接。

在追逐这个之后我发现在pbuf.c中,由于

的调用,我收到了PBUF_POOL_IS_EMPTY()
(struct pbuf *)memp_malloc(MEMP_PBUF_POOL); returning NULL.

进一步检查显示memp_tab的值在发布后如下

-memp_tab[0] 0x1FFF4160 </br>
-memp_tab[1] 0x1FFF421C </br>
-memp_tab[2] 0x1FFF423C </br>
-memp_tab[3] 0x1FFF4364 </br>
-memp_tab[4] 0x1FFF4478 </br>
-memp_tab[5] 0x1FFF450C </br>
-memp_tab[6] 0x1FFF467C </br>
-memp_tab[7] 0x1FFF46D4 </br>
-memp_tab[8] 0x1FFF4744 </br> 
-memp_tab[9] 0x00000000 </br>

memp_tab[9]的价值令人担忧。

在我看来,尽管我们包含了memp_malloc调用,但是在使用后我们的内存没有被重新分配。有没有什么办法可以在使用后重新分配这个内存,在调用中允许我们使用该函数超过声明的用途。

0 个答案:

没有答案
相关问题