<?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: UDP Socket in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578687#M19871</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mrabbasi61 on Fri Aug 15 09:46:09 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you all for your kind help :D&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;finally I decided to follow one of examples that use udp, for example in LWIP_DHCP it uses udp in order to communicate with dhcp server. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to make a UDP connection to a remote IP and Port, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think that at first I need to create a UDP PCB, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so, in my code I have the following lines, almost in the same sequence as below: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1- struct udp_pcb *my_pcb;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2- struct pbuf *my_buffer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3- my_pcb=udp_new();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4- udp_bind(my_pcb, IP_ADDR, PORT);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5- udp_connect(my_pcb, IP_ADDR, PORT);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6- udp_sendto(my_pcb, my_buffer, IP_ADDR, PORT);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when I want to debug the code,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;as soon as the execution is reached to the line 3 from above, or 4 (when line 3 is commented) , &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am always taken to the following place:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;__attribute__ ((section(".after_vectors")))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void HardFault_Handler(void) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (1) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:17:54 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:17:54Z</dc:date>
    <item>
      <title>UDP Socket</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578686#M19870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mrabbasi61 on Tue Aug 12 05:46:31 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I couldn't find a sample project for UDP socket send and recieve data, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I saw that some people also asked for this before, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;any suggestions is appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578686#M19870</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: UDP Socket</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578687#M19871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mrabbasi61 on Fri Aug 15 09:46:09 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you all for your kind help :D&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;finally I decided to follow one of examples that use udp, for example in LWIP_DHCP it uses udp in order to communicate with dhcp server. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to make a UDP connection to a remote IP and Port, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think that at first I need to create a UDP PCB, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so, in my code I have the following lines, almost in the same sequence as below: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1- struct udp_pcb *my_pcb;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2- struct pbuf *my_buffer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3- my_pcb=udp_new();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4- udp_bind(my_pcb, IP_ADDR, PORT);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5- udp_connect(my_pcb, IP_ADDR, PORT);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6- udp_sendto(my_pcb, my_buffer, IP_ADDR, PORT);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when I want to debug the code,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;as soon as the execution is reached to the line 3 from above, or 4 (when line 3 is commented) , &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am always taken to the following place:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;__attribute__ ((section(".after_vectors")))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void HardFault_Handler(void) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (1) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578687#M19871</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: UDP Socket</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578688#M19872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Fri Aug 15 10:40:25 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;So, you'll need to debug it then:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fcontent%2Ffaq%2Flpcxpresso%2Fdebugging-hard-fault" rel="nofollow" target="_blank"&gt;http://www.lpcware.com/content/faq/lpcxpresso/debugging-hard-fault&lt;/A&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578688#M19872</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: UDP Socket</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578689#M19873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mrabbasi61 on Fri Aug 15 13:37:48 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your help. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;seems to me that one of the following could be my problem, specially the second one! &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but I couldn't find the exact reason yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from the page (&lt;/SPAN&gt;&lt;A href="http://http://www.lpcware.com/content/faq/lpcxpresso/debugging-hard-fault"&gt;http://www.lpcware.com/content/faq/lpcxpresso/debugging-hard-fault&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;I&gt;Possible reasons for a Hard Fault include:&lt;BR /&gt;[list=1]&lt;BR /&gt;&amp;nbsp; [*]Trying to read or write to an on-chip peripheral that is powered down or not being clocked&lt;BR /&gt;&amp;nbsp; [*]Stack corruption - for example, overwriting the stack with data&lt;BR /&gt;&amp;nbsp; [*]Calling a function pointer with an invalid address&lt;BR /&gt;[/list]&lt;/I&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578689#M19873</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: UDP Socket</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578690#M19874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mrabbasi61 on Wed Aug 20 04:24:42 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I have this code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;struct ip_addr&amp;nbsp; serverIp, localIp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;udp_recv_fn udp_echo_recv;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IP4_ADDR(&amp;amp;serverIp,192,168,1,188);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;u16_t port;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;port = 3620;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;struct udp_pcb *pcb;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pcb = udp_new();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; udp_bind(pcb, &amp;amp;lpc_netif.ip_addr, port);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; udp_recv(pcb, udp_echo_recv, NULL);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; struct pbuf *p;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char msg[]="Hello Message from LPC4357 \r\n";&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//Allocate packet buffer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;p = pbuf_alloc(PBUF_TRANSPORT,sizeof(msg),PBUF_RAM);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;memcpy (p-&amp;gt;payload, msg, sizeof(msg));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;udp_connect(pcb, &amp;amp;serverIp, port);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;udp_sendto(pcb, p, &amp;amp;serverIp, port);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pbuf_free(p); //De-allocate packet buffer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and it is OK, it sends "Hello Message from LPC4357 \r\n" to the server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but when put the following line at the end of this part, it doesn't work, seems to me that in this case the p is Null !!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; while(1){};&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:17:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UDP-Socket/m-p/578690#M19874</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:17:56Z</dc:date>
    </item>
  </channel>
</rss>

