Hi,
My customer reported an issue using LwIP 1.4.1.
Two RM57L boards are connected with Ethernet and 256bytes of data are sent/received repeatedly.
After a few minutes, it stops working and send callback is never called.
Here are customer's code:
a) recv_callback() is receive callback and it receives 256bytes data.
b) sent_callback() is send callback. After 256bytes are sent by tcpSend256(), sndWl_complete flag is set('1').
c) tcpSend256() is transmit sub-routine. sndWl_complete=1 is checked with 8msec interval and call it.
struct tcp_pcb* conn_pcb=NULL; err_t recv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err) { struct pbuf *pre_p = p; LWIP_UNUSED_ARG(err); /* do not read the packet if we are not in ESTABLISHED state */ if (!p) { conn_pcb = NULL; tcp_recv(tpcb, NULL); tcp_sent(tpcb, NULL); tcp_err(tpcb, NULL); tcp_close(tpcb); return ERR_OK; } /* indicate that the packet has been received */ do{ // check if received data is under analysis if(rcvAnaFlg == 0){ // receive buffer memcpy(&crxWlDtwk[cwlrxw.RxCnt], p->payload, p->len); // update received data count cwlrxw.RxCnt = (cwlrxw.RxCnt + p->len) % WL_BUF_SZ; } else{ // skip if received data is under analysis testFlg++; } if(p->next==NULL) break; p=p->next; }while(p->len != 0); tcp_recved(tpcb, pre_p->tot_len); // all data received /* free the received pbuf */ pbuf_free(pre_p); return ERR_OK; } u8_t sndWl_complete=1; //tcpSend256 completion flag err_t sent_callback(void *arg, struct tcp_pcb *tpcb, u16_t len) { if(len>=256) { sndWl_complete = 1; } else{ // check if len<256 sndWl_complete = 0; // never comes here. len must be 256 or bigger. } return (ERR_OK); } err_t tcpSend256(const void *buf) { err_t t_err; u16_t send_bufs; if(conn_pcb == NULL) return ERR_CONN; while(1){ send_bufs = tcp_sndbuf(conn_pcb); if(send_bufs < 256){ continue; // wait until tcp transmit buffer gets 256byte } t_err = tcp_write(conn_pcb, buf, 256, TCP_WRITE_FLAG_COPY); if (t_err != ERR_OK) return t_err; t_err = tcp_output(conn_pcb); if (t_err != ERR_OK) return t_err; sndWl_complete = 0; break; } }
Q1) Is there a related known issue in LwIP 1.4.1?
Q2) Do you have any concerns in customer's test code?
Please let me know if you need further information from customer.
Thanks and regards,
Koichiro Tashiro