From 5e97faee89d79c2b7a7867944ee7c1105a1c10c1 Mon Sep 17 00:00:00 2001
From: sola.lu <sola.lu@greentest.com.cn>
Date: 周五, 11 4月 2025 17:30:50 +0800
Subject: [PATCH] 1. 注释动态库生成

---
 examples/test-LwIP-netconn/scpi_server.c |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/examples/test-LwIP-netconn/scpi_server.c b/examples/test-LwIP-netconn/scpi_server.c
index 1a12ba5..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;
         }
     }
@@ -262,7 +266,11 @@
             netconn_delete(newconn);
         } else {
             /* control connection established */
-			SCPI_Event_ControlConnected(context, newconn);
+            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;
         }
     }
@@ -272,7 +280,7 @@
 
 static void closeIo(scpi_t * context, user_data_t * user_data) {
     /* connection closed */
-	SCPI_Event_DeviceDisconnected(context, user_data->io);
+    SCPI_Event_DeviceDisconnected(context, user_data->io);
     netconn_close(user_data->io);
     netconn_delete(user_data->io);
     user_data->io = NULL;
@@ -280,7 +288,7 @@
 
 static void closeSrqIo(scpi_t * context, user_data_t * user_data) {
     /* control connection closed */
-	SCPI_Event_ControlDisconnected(context, user_data->io);
+    SCPI_Event_ControlDisconnected(context, user_data->io);
     netconn_close(user_data->control_io);
     netconn_delete(user_data->control_io);
     user_data->control_io = NULL;
@@ -423,34 +431,34 @@
 
 /* Called by processIoListen() for additional reporting. Override on demand. */
 void __attribute__((weak)) SCPI_Event_DeviceConnected(scpi_t * context, struct netconn * conn) {
-	iprintf("***Connection established %s\r\n", inet_ntoa(newconn->pcb.ip->remote_ip));
+    iprintf("***Connection established %s\r\n", inet_ntoa(newconn->pcb.ip->remote_ip));
     /* Remote or Eth LED ON */
 }
 
 /* Called by closeIO() for additional reporting. Override on demand. */
 void __attribute__((weak)) SCPI_Event_DeviceDisconnected(scpi_t * context, struct netconn * conn) {
-	iprintf("***Connection closed\r\n");
+    iprintf("***Connection closed\r\n");
     /* Remote or Eth LED OFF */
 }
 
 /* Called by processIoListen() for additional reporting. Override on demand. */
 void __attribute__((weak)) SCPI_Event_ControlConnected(scpi_t * context, struct netconn * conn) {
-	iprintf("***Control Connection established %s\r\n", inet_ntoa(newconn->pcb.ip->remote_ip));
+    iprintf("***Control Connection established %s\r\n", inet_ntoa(newconn->pcb.ip->remote_ip));
 }
 
 /* Called by closeIO() for additional reporting. Override on demand. */
 void __attribute__((weak)) SCPI_Event_ControlDisconnected(scpi_t * context, struct netconn * conn) {
-	iprintf("***Control Connection closed\r\n");
+    iprintf("***Control Connection closed\r\n");
 }
 
 /* Called by SCPI_Error() for reporting. Override on demand. */
 void __attribute__((weak)) SCPI_Event_ErrorIndicatorOn(scpi_t * context, int_fast16_t err) {
-	iprintf("**ERROR: %ld, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err));
+    iprintf("**ERROR: %ld, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err));
     /* New error : BEEP, Error LED ON */
 }
 
 /* Called by SCPI_Error() for reporting. Override on demand. */
 void __attribute__((weak)) SCPI_Event_ErrorIndicatorOff(scpi_t * context, int_fast16_t err) {
-	iprintf("**ERROR: %ld, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err));
+    iprintf("**ERROR: %ld, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err));
     /* No more errors in the queue : Error LED OFF */
 }

--
Gitblit v1.9.1