请大家帮忙看一下这个程序,一直在pstNewConn = netconn_accept(pstConn);处停下啦,用modbus poll重联后也只能发一次数据,平台是路虎开发板LPC1768,用EASY WEB例程上修改的,想做一下MODBUS TCP服务器,用HTTP WEB 在IE界面修改参数,UCOS 多任务没问题,网页AD显示不死机数据正常,请问万能的坛如何退出UCOS LWIP netconn_accept(pstConn)阻塞状态,实现连续回应TCP数据流。
static void uctsk_ModbusTcp(void )
{
struct netconn *pstConn, *pstNewConn;
struct netbuf *TCPNetbuf;
pstConn = netconn_new(NETCONN_TCP); /*新建TCP连接*/
netconn_bind(pstConn, NULL,502); /*绑定502端口*/
netconn_listen(pstConn); /*服务器侦听连接*/
for(;;)
{
printf("Default ModbusTcp_test: Acceqt\r\n");
程序此处阻塞 pstNewConn = netconn_accept(pstConn);/*获得新连接,阻塞进程直至从远程主机发出的连接请求到达指定的连接*/
if(pstNewConn != NULL) /*新连接有效,则处理数据*/
{
TCPNetbuf = netconn_recv(pstNewConn); /*接收数据*/
if(TCPNetbuf != NULL) /*处理有效数据*/
{
netbuf_data (TCPNetbuf,&pbData, &LWIP_Len );/*获得数据起始地址和长度*/
// netbuf_data (TCPNetbuf,(void *)&pbData, &LWIP_Len );/*获得数据起始地址和长度*/
ModbusTcp_Slave();
netconn_write(pstNewConn,pbData,LWIP_Len,NETCONN_NOCOPY);
netbuf_delete(TCPNetbuf);/*删除缓存数据*/
netconn_close(pstNewConn); /* 关闭连接 */
while(netconn_delete(pstNewConn) != ERR_OK)
{
OSTimeDlyHMSM(0, 0, 0, 10);
}
}
}
}
}
MODBUS TCP POLL数据断开重联响应一次数据,不断开只响应一次,用IRIS看一下TCP数据包有ACK确认就是不响应数据包:
000000-Tx:00 25 00 00 00 06 08 03 00 03 00 01
000001-Rx:00 25 00 00 00 05 08 03 02 00 00
000002-Tx:00 26 00 00 00 06 08 03 00 03 00 01
000003-Rx:00 25 00 00 00 05 08 03 02 00 00
000004-Tx:00 27 00 00 00 06 08 03 00 03 00 01
000005-Tx:00 28 00 00 00 06 08 03 00 03 00 01
000006-Tx:00 29 00 00 00 06 08 03 00 03 00 01
000007-Tx:00 2A 00 00 00 06 08 03 00 03 00 01
000008-Tx:00 2B 00 00 00 06 08 03 00 03 00 01
000009-Rx:00 2B 00 00 00 05 08 03 02 00 00
000010-Tx:00 2C 00 00 00 06 08 03 00 03 00 01
000011-Rx:00 2B 00 00 00 05 08 03 02 00 00
000012-Tx:00 2D 00 00 00 06 08 03 00 03 00 01
000013-Tx:00 2E 00 00 00 06 08 03 00 03 00 01
|