I am trying to send a UDP packet from the TIVA board back to the pc. I am using the UDP echo example and I can do this OK. But I want to be able to send a packet from my main function rather than from the UDP receive function. But when I do this the udp_sendto function crashes. Below is the code. The addr and port vars are what I have saved from the receive function. Anyone know what the issue is? Thanks
void eth_udp_tx()
{
struct pbuf *p;
uint8_t buf[16];
err_t wr_err = ERR_OK;
p = pbuf_alloc(PBUF_TRANSPORT, 16, PBUF_POOL);
p->len = 16;
p->tot_len = 16;
p->payload = buf;
if (p)
{
wr_err = udp_sendto(new_udp_pcb, p, udp_addr, udp_port);
pbuf_free(p);
}
}