Hello all,
I am trying to set up a very simple udp echo server and I am not sure what is going wrong with my setup. There is a lot of sample code available on this topic but for some reason I cannot get my code to function correctly. This is running on EK-TM4C1294XL connected Launchpad (cortex M4)
My procedure is as follows:
- Set up some pins
- Set interrupts for system tick and ethernet
- Initialize lwIP with a static IP (Connection directly from evaluation board to PC through Ethernet)
- Allocate memory for a udp pcb
- Bind the udp pcb to any IP address on the port number I want (7)
- Register the udp_recv callback as my own function
- Allocate memory for a pbuf
This is my code for my callback function:
void UDPRecvData(void *arg, struct udp_pcb *pcb, struct pbuf *p,
ip_addr_t *addr, u16_t port) {
LWIP_UNUSED_ARG(arg);
// Just echo for now
udp_sendto(pcb, p, addr,port);
pbuf_free(p);
}
After this, I let my evaluation board sit in an infinite loop while it waits for UDP packets to be sent to it. To be clear, I am able to send out UDP packets and receive them on my PC just fine, my problem is that my callback function is never called by lwIP. I am monitoring traffic on wireshark and I can see my computer sending packets to my evaluation board's IP address but I am seeing no activity from my evaluation board.
One last note on my setup:
I solved a problem I had with ARP by hardcoding my evaluation board's mac address via the command arp -s 'evaluation board IP' 'evaluation board mac' 'interface ip'. Before I did that no packets were sent by my PC, only ARP's for my evaluation board's mac address.
Thanks,
Bryan