Content originally posted in LPCWare by mrabbasi61 on Wed Aug 20 04:24:42 MST 2014
I have this code:
struct ip_addr serverIp, localIp;
udp_recv_fn udp_echo_recv;
IP4_ADDR(&serverIp,192,168,1,188);
u16_t port;
port = 3620;
struct udp_pcb *pcb;
pcb = udp_new();
udp_bind(pcb, &lpc_netif.ip_addr, port);
udp_recv(pcb, udp_echo_recv, NULL);
struct pbuf *p;
char msg[]="Hello Message from LPC4357 \r\n";
//Allocate packet buffer
p = pbuf_alloc(PBUF_TRANSPORT,sizeof(msg),PBUF_RAM);
memcpy (p->payload, msg, sizeof(msg));
udp_connect(pcb, &serverIp, port);
udp_sendto(pcb, p, &serverIp, port);
pbuf_free(p); //De-allocate packet buffer
and it is OK, it sends "Hello Message from LPC4357 \r\n" to the server.
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 !!!
while(1){};