<?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 Set up udp communication between board (echo server) and pc (client) based on lwip example in S32 Design Studio</title>
    <link>https://community.nxp.com/t5/S32-Design-Studio/Set-up-udp-communication-between-board-echo-server-and-pc-client/m-p/1059529#M6292</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I'm using lwip_example for mpc5748g in s32ds for power architecture. Based on that example, I wanna build an echo server on the board, so I add the following codes in main.c and call&amp;nbsp;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;udp_echo_init &lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff;"&gt;in the main function. I set up a client on pc and I checked by wireshark that it did send out the message to the ip address of mpc5748g. However, the echo server doesn't work. I think probably I miss setting up something in the main function (maybe ethernet setup and socket but I have no idea)&lt;SPAN style="color: #000000;"&gt;.&lt;/SPAN&gt;&amp;nbsp;Does anyone have experience on udp communication between such boards and pc before? Any experience would be appreciated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;By the way, is there any way that I can debug the lwip_example by printing out messages? I tried adding a uart component but it seems that it's not allowed in this particular example.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;#include "lwip/udp.h"&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;#include "lwip/debug.h"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;{&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; if (p != NULL) {&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* send received packet back to sender */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; udp_sendto(pcb, p, addr, port);&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* free the pbuf */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pbuf_free(p);&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;void udp_echo_init(void)&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;{&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; struct udp_pcb * pcb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; /* get new pcb */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; pcb = udp_new();&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; if (pcb == NULL) {&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n"));&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; /* bind to any IP address on port 7 */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; if (udp_bind(pcb, IP_ADDR_ANY, 7) != ERR_OK) {&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n"));&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; /* set udp_echo_recv() as callback function&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for received packets */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; udp_recv(pcb, udp_echo_recv, NULL);&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Jun 2020 15:33:51 GMT</pubDate>
    <dc:creator>mjx1126</dc:creator>
    <dc:date>2020-06-04T15:33:51Z</dc:date>
    <item>
      <title>Set up udp communication between board (echo server) and pc (client) based on lwip example</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/Set-up-udp-communication-between-board-echo-server-and-pc-client/m-p/1059529#M6292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I'm using lwip_example for mpc5748g in s32ds for power architecture. Based on that example, I wanna build an echo server on the board, so I add the following codes in main.c and call&amp;nbsp;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;udp_echo_init &lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff;"&gt;in the main function. I set up a client on pc and I checked by wireshark that it did send out the message to the ip address of mpc5748g. However, the echo server doesn't work. I think probably I miss setting up something in the main function (maybe ethernet setup and socket but I have no idea)&lt;SPAN style="color: #000000;"&gt;.&lt;/SPAN&gt;&amp;nbsp;Does anyone have experience on udp communication between such boards and pc before? Any experience would be appreciated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;By the way, is there any way that I can debug the lwip_example by printing out messages? I tried adding a uart component but it seems that it's not allowed in this particular example.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;#include "lwip/udp.h"&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;#include "lwip/debug.h"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;{&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; if (p != NULL) {&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* send received packet back to sender */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; udp_sendto(pcb, p, addr, port);&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* free the pbuf */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pbuf_free(p);&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;void udp_echo_init(void)&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;{&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; struct udp_pcb * pcb;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; /* get new pcb */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; pcb = udp_new();&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; if (pcb == NULL) {&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n"));&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; /* bind to any IP address on port 7 */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; if (udp_bind(pcb, IP_ADDR_ANY, 7) != ERR_OK) {&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n"));&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; /* set udp_echo_recv() as callback function&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for received packets */&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;&amp;nbsp; &amp;nbsp; udp_recv(pcb, udp_echo_recv, NULL);&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff; font-size: 13.44px;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-size: 13.44px;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jun 2020 15:33:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/Set-up-udp-communication-between-board-echo-server-and-pc-client/m-p/1059529#M6292</guid>
      <dc:creator>mjx1126</dc:creator>
      <dc:date>2020-06-04T15:33:51Z</dc:date>
    </item>
  </channel>
</rss>

