<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic lpc4330 lwip tcpecho_client in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/lpc4330-lwip-tcpecho-client/m-p/828144#M7893</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I follow the some suggestion and modify tcpecho example to tcpecho_client.&lt;/P&gt;&lt;P&gt;Though it works. But system will crash every 30 mins if it has connected with tcp server like below.&lt;/P&gt;&lt;P&gt;I think the problem is pbuf allocation is run out and reset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that any way to fix this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GATEWAY_IP : 192.168.1.2&lt;BR /&gt;Ping_IP Sent : 192.168.1.25&lt;BR /&gt;lwip_sendto(0, data=0x100016e0, short_size=40, flags=0x0 to=192.168.1.25 port=16&lt;BR /&gt;ping: send PingSend192.168.1.25&lt;BR /&gt;_Done&lt;BR /&gt; recv_start lwip_recvfrom(0, 0x10006294, 64z, 0x0, ..)&lt;BR /&gt;lwip_recvfrom: top while sock-&amp;gt;lastdata=0x0&lt;BR /&gt;lwip_recvfrom: netconn_recv err=0, netbuf=0x100017a8&lt;BR /&gt;lwip_recvfrom: buflen=60 len=64z off=0 sock-&amp;gt;lastoffset=0&lt;BR /&gt;lwip_recvfrom(0): addr=192.168.1.25 port=1 len=60&lt;BR /&gt;lwip_recvfrom: deleting netbuf=0x100017a8&lt;BR /&gt;ping: recv 0.0.0.97 63 ms&lt;BR /&gt;PingReturn OK &lt;BR /&gt;pbuf_free: sane type:637 in file ../lwip/core/pbuf.c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static void&lt;BR /&gt;tcpecho_thread(void *arg)&lt;BR /&gt;{&lt;BR /&gt; struct netconn *conn, *newconn;&lt;BR /&gt; err_t err;&lt;BR /&gt; int i,j=0;&lt;BR /&gt; LWIP_UNUSED_ARG(arg);&lt;BR /&gt; uint32_t len;&lt;/P&gt;&lt;P&gt;char rx_array[20];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Create a new connection identifier. */&lt;BR /&gt; conn = netconn_new(NETCONN_TCP);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#ifdef Server&lt;BR /&gt; /* Bind connection to well known port number 7. */&lt;BR /&gt; netconn_bind(conn, NULL, 234);&lt;BR /&gt;#else&lt;BR /&gt; netconn_bind(conn, IP_ADDR_ANY, 234);&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;/* Tell connection to go into listening mode. */&lt;/P&gt;&lt;P&gt;#ifdef SERVER&lt;BR /&gt; netconn_listen(conn);&lt;BR /&gt;#else&lt;BR /&gt; ip_addr_t IpAdd;&lt;BR /&gt; IP4_ADDR(&amp;amp;IpAdd, 192, 168, 0, 237);&lt;BR /&gt; //IP4_ADDR(&amp;amp;IpAdd, 18, 235, 222, 172);&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;while (1)&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;struct netbuf *buf;&lt;BR /&gt; void *data;&lt;BR /&gt; u16_t len;&lt;BR /&gt; int message_flag=0;&lt;/P&gt;&lt;P&gt;/* Grab new connection. */&lt;/P&gt;&lt;P&gt;#ifdef SERVER&lt;BR /&gt; err = netconn_accept(conn, &amp;amp;newconn);&lt;BR /&gt;#else&lt;BR /&gt; if(err!=ERR_OK)&lt;BR /&gt; {&lt;BR /&gt; err=netconn_connect(conn, &amp;amp;IpAdd, 8080);&lt;BR /&gt; printf("Connect to TCP Server with %d\r\n",err);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;for(i=0;i&amp;lt;20;i++)&lt;BR /&gt; {&lt;BR /&gt; message[i]=0x0;&lt;BR /&gt; }&lt;BR /&gt; strcpy(message,"Test Code\r\n");&lt;BR /&gt; message_flag=1;&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;if (err == ERR_OK)&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;#ifdef SERVER&lt;/P&gt;&lt;P&gt;while ((err = netconn_recv(newconn, &amp;amp;buf)) == ERR_OK)&lt;BR /&gt; {&lt;BR /&gt; /*printf("Recved\n");*/&lt;BR /&gt; do {&lt;BR /&gt; netbuf_data(buf, &amp;amp;data, &amp;amp;len);&lt;BR /&gt; err = netconn_write(newconn, data, len, NETCONN_COPY);&lt;BR /&gt; } while (netbuf_next(buf) &amp;gt;= 0);&lt;BR /&gt; netbuf_delete(buf);&lt;BR /&gt; }&lt;BR /&gt; /* Close connection and discard connection identifier. */&lt;BR /&gt; netconn_close(newconn);&lt;BR /&gt; netconn_delete(newconn);&lt;/P&gt;&lt;P&gt;#else&lt;/P&gt;&lt;P&gt;if(message_flag==1)&lt;BR /&gt; {&lt;BR /&gt; //err=netconn_write(conn, message, sizeof(message), NETCONN_NOFLAG);&lt;BR /&gt; for(i=0;i&amp;lt;20;i++)&lt;BR /&gt; {&lt;BR /&gt; message[i]=0x0;&lt;BR /&gt; }&lt;BR /&gt; //sprintf(message,"Head%d",j);&lt;BR /&gt; //printf("%s \r\n",message);&lt;BR /&gt; sprintf(message,"Head%d",j);&lt;BR /&gt; printf("%s \r\n",message);&lt;BR /&gt; //printf("%s\r\n",http_string);&lt;BR /&gt; err=netconn_write(conn,message,strlen(message), NETCONN_NOFLAG);&lt;/P&gt;&lt;P&gt;if((err = netconn_recv(conn, &amp;amp;buf)) == ERR_OK)&lt;BR /&gt; {&lt;BR /&gt; do&lt;BR /&gt; {&lt;BR /&gt; netbuf_data(buf, &amp;amp;data, &amp;amp;len);&lt;BR /&gt; //err = netconn_write(newconn, data, len, NETCONN_COPY);&lt;/P&gt;&lt;P&gt;} while (netbuf_next(buf) &amp;gt;= 0);&lt;/P&gt;&lt;P&gt;strncpy(rx_array,(char *)data,len);&lt;BR /&gt; rx_array[len]='\0';&lt;BR /&gt; printf("%s\r\n",rx_array);&lt;BR /&gt; netbuf_delete(buf);&lt;BR /&gt; for(i=0;i&amp;lt;20;i++)&lt;BR /&gt; {&lt;BR /&gt; message[i]=0x0;&lt;BR /&gt; }&lt;BR /&gt; sprintf(message,"Tail%d",j);&lt;BR /&gt; printf("%s \r\n",message);&lt;BR /&gt; err=netconn_write(conn, message, sizeof(message), NETCONN_NOFLAG);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;//netbuf_delete(buf);&lt;BR /&gt; message_flag=0;&lt;BR /&gt; //netconn_close(conn);&lt;BR /&gt; //netconn_delete(conn);&lt;BR /&gt; }&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; if(fr_cnt%10000==0)&lt;BR /&gt; {&lt;BR /&gt; for(i=0;i&amp;lt;20;i++)&lt;BR /&gt; {&lt;BR /&gt; message[i]=0x0;&lt;BR /&gt; }&lt;BR /&gt; strcpy(message,"Test Code\r\n");&lt;BR /&gt; message_flag=1;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; if(fr_cnt&amp;lt;4000000)&lt;BR /&gt; fr_cnt++;&lt;BR /&gt; else&lt;BR /&gt; fr_cnt=0;&lt;BR /&gt; j++;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;}&lt;BR /&gt;/*-----------------------------------------------------------------------------------*/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Dec 2018 04:19:39 GMT</pubDate>
    <dc:creator>li-chinwang</dc:creator>
    <dc:date>2018-12-25T04:19:39Z</dc:date>
    <item>
      <title>lpc4330 lwip tcpecho_client</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/lpc4330-lwip-tcpecho-client/m-p/828144#M7893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I follow the some suggestion and modify tcpecho example to tcpecho_client.&lt;/P&gt;&lt;P&gt;Though it works. But system will crash every 30 mins if it has connected with tcp server like below.&lt;/P&gt;&lt;P&gt;I think the problem is pbuf allocation is run out and reset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that any way to fix this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GATEWAY_IP : 192.168.1.2&lt;BR /&gt;Ping_IP Sent : 192.168.1.25&lt;BR /&gt;lwip_sendto(0, data=0x100016e0, short_size=40, flags=0x0 to=192.168.1.25 port=16&lt;BR /&gt;ping: send PingSend192.168.1.25&lt;BR /&gt;_Done&lt;BR /&gt; recv_start lwip_recvfrom(0, 0x10006294, 64z, 0x0, ..)&lt;BR /&gt;lwip_recvfrom: top while sock-&amp;gt;lastdata=0x0&lt;BR /&gt;lwip_recvfrom: netconn_recv err=0, netbuf=0x100017a8&lt;BR /&gt;lwip_recvfrom: buflen=60 len=64z off=0 sock-&amp;gt;lastoffset=0&lt;BR /&gt;lwip_recvfrom(0): addr=192.168.1.25 port=1 len=60&lt;BR /&gt;lwip_recvfrom: deleting netbuf=0x100017a8&lt;BR /&gt;ping: recv 0.0.0.97 63 ms&lt;BR /&gt;PingReturn OK &lt;BR /&gt;pbuf_free: sane type:637 in file ../lwip/core/pbuf.c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static void&lt;BR /&gt;tcpecho_thread(void *arg)&lt;BR /&gt;{&lt;BR /&gt; struct netconn *conn, *newconn;&lt;BR /&gt; err_t err;&lt;BR /&gt; int i,j=0;&lt;BR /&gt; LWIP_UNUSED_ARG(arg);&lt;BR /&gt; uint32_t len;&lt;/P&gt;&lt;P&gt;char rx_array[20];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Create a new connection identifier. */&lt;BR /&gt; conn = netconn_new(NETCONN_TCP);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#ifdef Server&lt;BR /&gt; /* Bind connection to well known port number 7. */&lt;BR /&gt; netconn_bind(conn, NULL, 234);&lt;BR /&gt;#else&lt;BR /&gt; netconn_bind(conn, IP_ADDR_ANY, 234);&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;/* Tell connection to go into listening mode. */&lt;/P&gt;&lt;P&gt;#ifdef SERVER&lt;BR /&gt; netconn_listen(conn);&lt;BR /&gt;#else&lt;BR /&gt; ip_addr_t IpAdd;&lt;BR /&gt; IP4_ADDR(&amp;amp;IpAdd, 192, 168, 0, 237);&lt;BR /&gt; //IP4_ADDR(&amp;amp;IpAdd, 18, 235, 222, 172);&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;while (1)&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;struct netbuf *buf;&lt;BR /&gt; void *data;&lt;BR /&gt; u16_t len;&lt;BR /&gt; int message_flag=0;&lt;/P&gt;&lt;P&gt;/* Grab new connection. */&lt;/P&gt;&lt;P&gt;#ifdef SERVER&lt;BR /&gt; err = netconn_accept(conn, &amp;amp;newconn);&lt;BR /&gt;#else&lt;BR /&gt; if(err!=ERR_OK)&lt;BR /&gt; {&lt;BR /&gt; err=netconn_connect(conn, &amp;amp;IpAdd, 8080);&lt;BR /&gt; printf("Connect to TCP Server with %d\r\n",err);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;for(i=0;i&amp;lt;20;i++)&lt;BR /&gt; {&lt;BR /&gt; message[i]=0x0;&lt;BR /&gt; }&lt;BR /&gt; strcpy(message,"Test Code\r\n");&lt;BR /&gt; message_flag=1;&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;if (err == ERR_OK)&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;#ifdef SERVER&lt;/P&gt;&lt;P&gt;while ((err = netconn_recv(newconn, &amp;amp;buf)) == ERR_OK)&lt;BR /&gt; {&lt;BR /&gt; /*printf("Recved\n");*/&lt;BR /&gt; do {&lt;BR /&gt; netbuf_data(buf, &amp;amp;data, &amp;amp;len);&lt;BR /&gt; err = netconn_write(newconn, data, len, NETCONN_COPY);&lt;BR /&gt; } while (netbuf_next(buf) &amp;gt;= 0);&lt;BR /&gt; netbuf_delete(buf);&lt;BR /&gt; }&lt;BR /&gt; /* Close connection and discard connection identifier. */&lt;BR /&gt; netconn_close(newconn);&lt;BR /&gt; netconn_delete(newconn);&lt;/P&gt;&lt;P&gt;#else&lt;/P&gt;&lt;P&gt;if(message_flag==1)&lt;BR /&gt; {&lt;BR /&gt; //err=netconn_write(conn, message, sizeof(message), NETCONN_NOFLAG);&lt;BR /&gt; for(i=0;i&amp;lt;20;i++)&lt;BR /&gt; {&lt;BR /&gt; message[i]=0x0;&lt;BR /&gt; }&lt;BR /&gt; //sprintf(message,"Head%d",j);&lt;BR /&gt; //printf("%s \r\n",message);&lt;BR /&gt; sprintf(message,"Head%d",j);&lt;BR /&gt; printf("%s \r\n",message);&lt;BR /&gt; //printf("%s\r\n",http_string);&lt;BR /&gt; err=netconn_write(conn,message,strlen(message), NETCONN_NOFLAG);&lt;/P&gt;&lt;P&gt;if((err = netconn_recv(conn, &amp;amp;buf)) == ERR_OK)&lt;BR /&gt; {&lt;BR /&gt; do&lt;BR /&gt; {&lt;BR /&gt; netbuf_data(buf, &amp;amp;data, &amp;amp;len);&lt;BR /&gt; //err = netconn_write(newconn, data, len, NETCONN_COPY);&lt;/P&gt;&lt;P&gt;} while (netbuf_next(buf) &amp;gt;= 0);&lt;/P&gt;&lt;P&gt;strncpy(rx_array,(char *)data,len);&lt;BR /&gt; rx_array[len]='\0';&lt;BR /&gt; printf("%s\r\n",rx_array);&lt;BR /&gt; netbuf_delete(buf);&lt;BR /&gt; for(i=0;i&amp;lt;20;i++)&lt;BR /&gt; {&lt;BR /&gt; message[i]=0x0;&lt;BR /&gt; }&lt;BR /&gt; sprintf(message,"Tail%d",j);&lt;BR /&gt; printf("%s \r\n",message);&lt;BR /&gt; err=netconn_write(conn, message, sizeof(message), NETCONN_NOFLAG);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;//netbuf_delete(buf);&lt;BR /&gt; message_flag=0;&lt;BR /&gt; //netconn_close(conn);&lt;BR /&gt; //netconn_delete(conn);&lt;BR /&gt; }&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; if(fr_cnt%10000==0)&lt;BR /&gt; {&lt;BR /&gt; for(i=0;i&amp;lt;20;i++)&lt;BR /&gt; {&lt;BR /&gt; message[i]=0x0;&lt;BR /&gt; }&lt;BR /&gt; strcpy(message,"Test Code\r\n");&lt;BR /&gt; message_flag=1;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; if(fr_cnt&amp;lt;4000000)&lt;BR /&gt; fr_cnt++;&lt;BR /&gt; else&lt;BR /&gt; fr_cnt=0;&lt;BR /&gt; j++;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;}&lt;BR /&gt;/*-----------------------------------------------------------------------------------*/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Dec 2018 04:19:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/lpc4330-lwip-tcpecho-client/m-p/828144#M7893</guid>
      <dc:creator>li-chinwang</dc:creator>
      <dc:date>2018-12-25T04:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: lpc4330 lwip tcpecho_client</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/lpc4330-lwip-tcpecho-client/m-p/828145#M7894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Li-chin:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is one similar issue, I would suggest you refer to below link&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/message/1081486"&gt;https://community.nxp.com/message/1081486&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2019 07:34:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/lpc4330-lwip-tcpecho-client/m-p/828145#M7894</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2019-03-01T07:34:10Z</dc:date>
    </item>
  </channel>
</rss>

