Hello,
I almost have UDP working on my board. I have an LM3S9B92 and using the enet_lwip software example. I'm using the UDP Test Tool to test my messaging. I'm able to send a message byte from my PC to the board. I'm able to test this by plaing a breakpoint in my_udp_rx() just after udp_connect().
my_udp_rx() is setup to ping back a 100 byte array of 0xAA, but I do not see it on my PC. I made sure my PC is on the same port. I'm not sure if my PC address is being setup correctly just before my_udp_tx().
Any help will be appreciated. Thanks!
Code below:
/* UDP transmit ............................................................*/ void my_udp_tx(u8_t *data, u16_t len) { if(g_upcb->remote_port != (unsigned short)0) { struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT,len, PBUF_RAM); memcpy(p->payload, data, len); udp_send(g_upcb, p); pbuf_free(p); } } /* UDP receive .............................................................*/ void my_udp_rx(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port) { u8_t buf[100]; int i; for(i = 0;i<100;i++) { buf[i] = 0xAA; } /* process the payload in p->payload */ udp_connect(upcb, addr, port); /* connect to the remote host */ my_udp_tx(buf,100); pbuf_free(p); /* don't leak the pbuf!*/ } /* UDP initialization ......................................................*/ void my_udp_init(void) { //struct ip_addr ipaddr1; //IP4_ADDR(&ipaddr1,192,168,4,114); g_upcb = udp_new(); udp_bind(g_upcb, IP_ADDR_ANY, 23); //udp_connect(g_upcb, &ipaddr1, 23); /* connect to the remote host */ udp_recv(g_upcb, &my_udp_rx, (void *)0); }
Can anyone give me a hint. Thanks!