<?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 Re: LWIP can't Read Unsigned Byte ?  in MCUXpresso General</title>
    <link>https://community.nxp.com/t5/MCUXpresso-General/LWIP-can-t-Read-Unsigned-Byte/m-p/976079#M2713</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please be aware that the parameter 'len' of the pbuf_copy_partial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 class="" style="color: #000000; background-color: #e2e8f2; border-top: 1px solid #a8b8d9; border-left: 1px solid #a8b8d9; border-right: 1px solid #a8b8d9; font-weight: 300; margin-bottom: -1px; margin-right: 15px; padding: 8px;"&gt;pbuf_copy_partial()&lt;/H2&gt;&lt;DIV class="" style="color: #000000; background-color: #ffffff; margin-bottom: 10px; margin-right: 5px;"&gt;&lt;DIV class="" style="color: #253555; background-color: #dfe5f1; border-top: 1px solid #a8b8d9; border-left: 1px solid #a8b8d9; border-right: 1px solid #a8b8d9; padding: 6px 0px;"&gt;&lt;TABLE style="margin-left: 6px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="" style="margin-left: 6px;"&gt;u16_t pbuf_copy_partial&lt;/TD&gt;&lt;TD&gt;(&lt;/TD&gt;&lt;TD class=""&gt;const struct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://www.nongnu.org/lwip/2_1_x/structpbuf.html" style="color: #4665a2; font-weight: bold; text-decoration: none;"&gt;pbuf&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;*&amp;nbsp;&lt;/TD&gt;&lt;TD class="" style="color: #602020;"&gt;&lt;EM&gt;buf&lt;/EM&gt;,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=""&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD class=""&gt;void *&amp;nbsp;&lt;/TD&gt;&lt;TD class="" style="color: #602020;"&gt;&lt;EM&gt;dataptr&lt;/EM&gt;,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=""&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD class=""&gt;u16_t&amp;nbsp;&lt;/TD&gt;&lt;TD class="" style="color: #602020;"&gt;&lt;EM&gt;len&lt;/EM&gt;,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=""&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD class=""&gt;u16_t&amp;nbsp;&lt;/TD&gt;&lt;TD class="" style="color: #602020;"&gt;&lt;EM&gt;offset&lt;/EM&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;)&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV class="" style="background-color: #ffffff; border-width: 0px 1px 1px; border-bottom-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-color: #a8b8d9; border-left-color: #a8b8d9; padding: 6px 10px 2px;"&gt;&lt;P&gt;Copy (part of) the contents of a packet buffer to an application supplied buffer.&lt;/P&gt;&lt;DL class=""&gt;&lt;DT style="font-weight: bold;"&gt;Parameters&lt;/DT&gt;&lt;DD&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="" style="color: #602020; font-weight: bold;"&gt;buf&lt;/TD&gt;&lt;TD&gt;the pbuf from which to copy data&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="" style="color: #602020; font-weight: bold;"&gt;dataptr&lt;/TD&gt;&lt;TD&gt;the application supplied buffer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="" style="color: #602020; font-weight: bold;"&gt;len&lt;/TD&gt;&lt;TD&gt;length of data to copy (dataptr must be big enough). &lt;STRONG&gt;No more than buf-&amp;gt;tot_len will be copied, irrespective of len&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="" style="color: #602020; font-weight: bold;"&gt;offset&lt;/TD&gt;&lt;TD&gt;offset into the packet buffer from where to begin copying len bytes&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DD&gt;&lt;/DL&gt;&lt;/DIV&gt;&lt;/DIV&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>Tue, 02 Jun 2020 03:16:18 GMT</pubDate>
    <dc:creator>danielchen</dc:creator>
    <dc:date>2020-06-02T03:16:18Z</dc:date>
    <item>
      <title>LWIP can't Read Unsigned Byte ?</title>
      <link>https://community.nxp.com/t5/MCUXpresso-General/LWIP-can-t-Read-Unsigned-Byte/m-p/976078#M2712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. My application is Lwip tcp/ip client app. LPC1769 conntect to my server and server send unsigned byte array. Lwip can't read data that bigger than 128.&lt;/P&gt;&lt;P&gt;How can ı solve this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not: I modify&amp;nbsp;&lt;SPAN style="background-color: #f6f6f6;"&gt;pbuf_copy_partial function with char to int but dont affected.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;MEMCPY(&amp;amp;((char*)dataptr)[left], &amp;amp;((char*)p-&amp;gt;payload)[offset], buf_copy_len);&amp;nbsp; // original&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;MEMCPY(&amp;amp;((uint8_t*)dataptr)[left], &amp;amp;((uint8_t*)p-&amp;gt;payload)[offset], buf_copy_len); // changed&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is my tcp_recv callback function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;uint8_t rcvbuff[1024];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;err_t&lt;BR /&gt;echo_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;enet_recv_flag=1;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; struct echo_state *es;&lt;BR /&gt; err_t ret_err;&lt;/P&gt;&lt;P&gt;LWIP_ASSERT("arg != NULL",arg != NULL);&lt;BR /&gt; es = (struct echo_state *)arg;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; if (p == NULL)&lt;BR /&gt; {&lt;BR /&gt; /* remote host closed connection */&lt;BR /&gt; es-&amp;gt;state = ES_CLOSING;&lt;BR /&gt; if(es-&amp;gt;p == NULL)&lt;BR /&gt; {&lt;BR /&gt; /* we're done sending, close it */&lt;BR /&gt; echo_close(tpcb, es);&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; /* we're not done yet */&lt;BR /&gt; tcp_sent(tpcb, echo_sent);&lt;BR /&gt; echo_send(tpcb, es);&lt;BR /&gt; }&lt;BR /&gt; ret_err = ERR_OK;&lt;BR /&gt; }&lt;BR /&gt; else if(err != ERR_OK)&lt;BR /&gt; {&lt;BR /&gt; /* cleanup, for unkown reason */&lt;BR /&gt; if (p != NULL)&lt;BR /&gt; {&lt;BR /&gt; es-&amp;gt;p = NULL;&lt;BR /&gt; pbuf_free(p);&lt;BR /&gt; }&lt;BR /&gt; ret_err = err;&lt;BR /&gt; }&lt;BR /&gt; else if(es-&amp;gt;state == ES_ACCEPTED)&lt;BR /&gt; {&lt;BR /&gt; /* first data chunk in p-&amp;gt;payload */&lt;BR /&gt; es-&amp;gt;state = ES_RECEIVED;&lt;BR /&gt; /* store reference to incoming pbuf (chain) */&lt;BR /&gt; es-&amp;gt;p = p;&lt;BR /&gt; /* install send completion notifier */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;memset(rcvbuff, 0, 1024);&lt;BR /&gt; pbuf_copy_partial(p, rcvbuff, 1024, 0);&lt;BR /&gt; DEBUGOUT("Receiveda Data is : %s\r\n", rcvbuff);&lt;BR /&gt; tcp_sent(tpcb, echo_sent);&lt;BR /&gt; echo_send(tpcb, es);&lt;BR /&gt; ret_err = ERR_OK;&lt;BR /&gt; }&lt;BR /&gt; else if (es-&amp;gt;state == ES_RECEIVED)&lt;BR /&gt; {&lt;BR /&gt; /* read some more data */&lt;BR /&gt; if(es-&amp;gt;p == NULL)&lt;BR /&gt; {&lt;BR /&gt; memset(rcvbuff, 0, 1024);&lt;BR /&gt; pbuf_copy_partial(p, rcvbuff, 1024, 0);&lt;/P&gt;&lt;P&gt;DEBUGOUT("Received Data is : %s\r\n", rcvbuff);&lt;BR /&gt; es-&amp;gt;p = p;&lt;BR /&gt; tcp_sent(tpcb, echo_sent);&lt;BR /&gt; echo_send(tpcb, es);&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; struct pbuf *ptr;&lt;/P&gt;&lt;P&gt;/* chain pbufs to the end of what we recv'ed previously */&lt;BR /&gt; ptr = es-&amp;gt;p;&lt;BR /&gt; pbuf_chain(ptr,p);&lt;BR /&gt; }&lt;BR /&gt; ret_err = ERR_OK;&lt;BR /&gt; }&lt;BR /&gt; else if(es-&amp;gt;state == ES_CLOSING)&lt;BR /&gt; {&lt;BR /&gt; /* odd case, remote side closing twice, trash data */&lt;BR /&gt; tcp_recved(tpcb, p-&amp;gt;tot_len);&lt;BR /&gt; es-&amp;gt;p = NULL;&lt;BR /&gt; pbuf_free(p);&lt;BR /&gt; ret_err = ERR_OK;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; /* unkown es-&amp;gt;state, trash data */&lt;BR /&gt; tcp_recved(tpcb, p-&amp;gt;tot_len);&lt;BR /&gt; es-&amp;gt;p = NULL;&lt;BR /&gt; pbuf_free(p);&lt;BR /&gt; ret_err = ERR_OK;&lt;BR /&gt; }&lt;BR /&gt; return ret_err;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void&lt;BR /&gt;echo_error(void *arg, err_t err)&lt;BR /&gt;{&lt;BR /&gt; struct echo_state *es;&lt;/P&gt;&lt;P&gt;LWIP_UNUSED_ARG(err);&lt;/P&gt;&lt;P&gt;es = (struct echo_state *)arg;&lt;BR /&gt; if (es != NULL)&lt;BR /&gt; {&lt;BR /&gt; mem_free(es);&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u16_t&lt;BR /&gt;pbuf_copy_partial(struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)&lt;BR /&gt;{&lt;BR /&gt; struct pbuf *p;&lt;BR /&gt; u16_t left;&lt;BR /&gt; u16_t buf_copy_len;&lt;BR /&gt; u16_t copied_total = 0;&lt;/P&gt;&lt;P&gt;LWIP_ERROR("pbuf_copy_partial: invalid buf", (buf != NULL), return 0;);&lt;BR /&gt; LWIP_ERROR("pbuf_copy_partial: invalid dataptr", (dataptr != NULL), return 0;);&lt;/P&gt;&lt;P&gt;left = 0;&lt;/P&gt;&lt;P&gt;if((buf == NULL) || (dataptr == NULL)) {&lt;BR /&gt; return 0;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */&lt;BR /&gt; for(p = buf; len != 0 &amp;amp;&amp;amp; p != NULL; p = p-&amp;gt;next) {&lt;BR /&gt; if ((offset != 0) &amp;amp;&amp;amp; (offset &amp;gt;= p-&amp;gt;len)) {&lt;BR /&gt; /* don't copy from this buffer -&amp;gt; on to the next */&lt;BR /&gt; offset -= p-&amp;gt;len;&lt;BR /&gt; } else {&lt;BR /&gt; /* copy from this buffer. maybe only partially. */&lt;BR /&gt; buf_copy_len = p-&amp;gt;len - offset;&lt;BR /&gt; if (buf_copy_len &amp;gt; len)&lt;BR /&gt; buf_copy_len = len;&lt;BR /&gt; /* copy the necessary parts of the buffer */&lt;BR /&gt; MEMCPY(&amp;amp;((uint8_t*)dataptr)[left], &amp;amp;((uint8_t*)p-&amp;gt;payload)[offset], buf_copy_len);&lt;BR /&gt; copied_total += buf_copy_len;&lt;BR /&gt; left += buf_copy_len;&lt;BR /&gt; len -= buf_copy_len;&lt;BR /&gt; offset = 0;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; return copied_total;&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2020 08:59:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-General/LWIP-can-t-Read-Unsigned-Byte/m-p/976078#M2712</guid>
      <dc:creator>ramazan_kurban3</dc:creator>
      <dc:date>2020-03-03T08:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: LWIP can't Read Unsigned Byte ?</title>
      <link>https://community.nxp.com/t5/MCUXpresso-General/LWIP-can-t-Read-Unsigned-Byte/m-p/976079#M2713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please be aware that the parameter 'len' of the pbuf_copy_partial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 class="" style="color: #000000; background-color: #e2e8f2; border-top: 1px solid #a8b8d9; border-left: 1px solid #a8b8d9; border-right: 1px solid #a8b8d9; font-weight: 300; margin-bottom: -1px; margin-right: 15px; padding: 8px;"&gt;pbuf_copy_partial()&lt;/H2&gt;&lt;DIV class="" style="color: #000000; background-color: #ffffff; margin-bottom: 10px; margin-right: 5px;"&gt;&lt;DIV class="" style="color: #253555; background-color: #dfe5f1; border-top: 1px solid #a8b8d9; border-left: 1px solid #a8b8d9; border-right: 1px solid #a8b8d9; padding: 6px 0px;"&gt;&lt;TABLE style="margin-left: 6px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="" style="margin-left: 6px;"&gt;u16_t pbuf_copy_partial&lt;/TD&gt;&lt;TD&gt;(&lt;/TD&gt;&lt;TD class=""&gt;const struct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://www.nongnu.org/lwip/2_1_x/structpbuf.html" style="color: #4665a2; font-weight: bold; text-decoration: none;"&gt;pbuf&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;*&amp;nbsp;&lt;/TD&gt;&lt;TD class="" style="color: #602020;"&gt;&lt;EM&gt;buf&lt;/EM&gt;,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=""&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD class=""&gt;void *&amp;nbsp;&lt;/TD&gt;&lt;TD class="" style="color: #602020;"&gt;&lt;EM&gt;dataptr&lt;/EM&gt;,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=""&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD class=""&gt;u16_t&amp;nbsp;&lt;/TD&gt;&lt;TD class="" style="color: #602020;"&gt;&lt;EM&gt;len&lt;/EM&gt;,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class=""&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD class=""&gt;u16_t&amp;nbsp;&lt;/TD&gt;&lt;TD class="" style="color: #602020;"&gt;&lt;EM&gt;offset&lt;/EM&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;)&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV class="" style="background-color: #ffffff; border-width: 0px 1px 1px; border-bottom-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-color: #a8b8d9; border-left-color: #a8b8d9; padding: 6px 10px 2px;"&gt;&lt;P&gt;Copy (part of) the contents of a packet buffer to an application supplied buffer.&lt;/P&gt;&lt;DL class=""&gt;&lt;DT style="font-weight: bold;"&gt;Parameters&lt;/DT&gt;&lt;DD&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="" style="color: #602020; font-weight: bold;"&gt;buf&lt;/TD&gt;&lt;TD&gt;the pbuf from which to copy data&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="" style="color: #602020; font-weight: bold;"&gt;dataptr&lt;/TD&gt;&lt;TD&gt;the application supplied buffer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="" style="color: #602020; font-weight: bold;"&gt;len&lt;/TD&gt;&lt;TD&gt;length of data to copy (dataptr must be big enough). &lt;STRONG&gt;No more than buf-&amp;gt;tot_len will be copied, irrespective of len&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="" style="color: #602020; font-weight: bold;"&gt;offset&lt;/TD&gt;&lt;TD&gt;offset into the packet buffer from where to begin copying len bytes&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DD&gt;&lt;/DL&gt;&lt;/DIV&gt;&lt;/DIV&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>Tue, 02 Jun 2020 03:16:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-General/LWIP-can-t-Read-Unsigned-Byte/m-p/976079#M2713</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2020-06-02T03:16:18Z</dc:date>
    </item>
  </channel>
</rss>

