From a3fdd3589c713678eafe20840a7334de6bed038b Mon Sep 17 00:00:00 2001 From: nancy.liao <huihui.liao@greentest.com.cn> Date: 周五, 18 4月 2025 10:10:38 +0800 Subject: [PATCH] 修改 --- examples/test-LwIP-netconn/scpi_server.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/test-LwIP-netconn/scpi_server.c b/examples/test-LwIP-netconn/scpi_server.c index c31aacd..6147235 100644 --- a/examples/test-LwIP-netconn/scpi_server.c +++ b/examples/test-LwIP-netconn/scpi_server.c @@ -90,7 +90,7 @@ if (context->user_context != NULL) { user_data_t * u = (user_data_t *) (context->user_context); if (u->io) { - return (netconn_write(u->io, data, len, NETCONN_NOCOPY) == ERR_OK) ? len : 0; + return (netconn_write(u->io, data, len, NETCONN_COPY) == ERR_OK) ? len : 0; } } return 0; @@ -132,7 +132,7 @@ user_data_t * u = (user_data_t *) (context->user_context); if (u->control_io) { snprintf(b, sizeof (b), "SRQ%d\r\n", val); - return netconn_write(u->control_io, b, strlen(b), NETCONN_NOCOPY) == ERR_OK ? SCPI_RES_OK : SCPI_RES_ERR; + return netconn_write(u->control_io, b, strlen(b), NETCONN_COPY) == ERR_OK ? SCPI_RES_OK : SCPI_RES_ERR; } } return SCPI_RES_OK; @@ -246,6 +246,10 @@ } else { /* connection established */ SCPI_Event_DeviceConnected(context, newconn); + ip_set_option(newconn->pcb.tcp, SOF_KEEPALIVE); + newconn->pcb.tcp->keep_idle = SCPI_KEEP_IDLE; // Override TCP_KEEPIDLE_DEFAULT for this connection. + newconn->pcb.tcp->keep_intvl = SCPI_KEEP_INTVL; // Override TCP_KEEPINTVL_DEFAULT for this connection. + newconn->pcb.tcp->keep_cnt = SCPI_KEEP_CNT; // Override TCP_KEEPCNT_DEFAULT for this connection. user_data->io = newconn; } } @@ -263,6 +267,10 @@ } else { /* control connection established */ SCPI_Event_ControlConnected(context, newconn); + ip_set_option(newconn->pcb.tcp, SOF_KEEPALIVE); + newconn->pcb.tcp->keep_idle = SCPI_KEEP_IDLE; // Override TCP_KEEPIDLE_DEFAULT for this connection. + newconn->pcb.tcp->keep_intvl = SCPI_KEEP_INTVL; // Override TCP_KEEPINTVL_DEFAULT for this connection. + newconn->pcb.tcp->keep_cnt = SCPI_KEEP_CNT; // Override TCP_KEEPCNT_DEFAULT for this connection. user_data->control_io = newconn; } } -- Gitblit v1.9.1