
我的板子为神州IV,,,调试UDP client时,调用udp_send(upcb, p)之后,server端也能接收到发送的内容,,但是程序指针跑到了void HardFault_Handler(void)死循环中,,,不知道什么引起的,求解???? void client_init(void) {& s$ {$ c/ B! v' Y( I struct udp_pcb *upcb; struct pbuf *p;# P4 q4 I# q) C# c( R/ e8 ^ err_t ret; uint8_t Sent[]="fanqh test udp client\r\n"; * _0 M* B) h0 E b /* Create a new UDP control block */ upcb = udp_new(); : {& d1 H3 w- u9 Z: Z! d /* Connect the upcb */ udp_connect(upcb, IP_ADDR_BROADCAST, UDP_SERVER_PORT); ! D R- o' `& [* y8 L/ a p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_RAM);: I7 N3 s9 m- O! z r1 W3 a+ P3 e' t p->payload = Sent; p->tot_len=p->len = sizeof(Sent);" v) \% S. `, Z$ s/ p /* Send out an UDP datagram to inform the server that we have strated a client application */' M4 M8 o6 }4 ?7 F& j1 b& } udp_send(upcb, p); /////////////////////////////////////////////////程序执行到这个函数后调到死循环HardFault_Handler{}中 0 H9 E% h3 |+ o4 c7 v /* Reset the upcb */ udp_disconnect(upcb);* O3 K5 a9 W; x% e7 B9 y! g /* Bind the upcb to any IP address and the UDP_PORT port*/' U+ ^% \$ c. h+ f! c5 m ret = udp_bind(upcb, IP_ADDR_ANY, UDP_CLIENT_PORT); w1 H. M$ w/ `) Q, g3 r L0 O) n) Z* [# p' P /* Set a receive callback for the upcb */ udp_recv(upcb, udp_client_callback, NULL); b" E6 e! ^: [$ Y% V4 F" d1 W: \ /* Free the p buffer */* Y" r' h" W$ @- O4 ]' g2 e pbuf_free(p); . e5 O. u) x/ E- Z; v } |
楼主要学会自己解决问题。
谢谢!!!