“线程:测试”中讨论的其它部件
您好,
我的客户报告使用 LwIP 1.4.1时出现问题。
两块 RM57L 主板与以太网连接,并重复发送/接收256字节的数据。
几分钟后,它将停止工作,并且不会调用发送回叫。
以下是客户代码:
a) recv_callback()接收回调,并接收256字节数据。
b) sended_callback()是发送回调。 tcpSend256()发送256字节后,将设置 sndWl_complete 标志('1')。
c) tcpSend256()是传输子例程。用8msec 间隔检查 sndWl_complete=1并调用它。
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) LwIP 1.4.1中是否存在相关的已知问题?
问题2)您对客户的测试代码有任何疑问吗?
如果您需要客户提供更多信息,请告诉我。
谢谢,此致,
柯一朗·塔希罗