This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我正在尝试将一个 UDP 封包从 Tiva 板发送回 PC。 我使用的是 UDP 回波示例、我可以这么做。 但我希望能够从主函数而非 UDP 接收函数发送数据包。 但是、当我这么做时、UDP_sendto 函数会崩溃。 下面是代码。 addr 和端口变量是我从接收函数中保存的值。 有人知道问题是什么? 谢谢
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->to_len = 16; p->payload = buf; 如果(p) { WR_ERR = UDP_sendto (new_UDP_PCB、p、UDP_addr、UDP_port); pbuf_free (p); } }
您好!
请参阅以下帖子、特别注意 David Wilson 的评论。 如果不从中断上下文调用 udp_sendto、系统可能会受到挤压。 虽然原始海报最初能够让它使用与您类似的代码(在再次调用 udp_sendto 或轮询 TXFE 标志之前增加了延迟)、但有时它也会被清除。 我还建议您联系 LwIP 论坛、征求他们的专家意见。
谢谢 Charles。 我没有意识到必须从中断中调用它。
Jon