From 9b2022f216e903a916a69e7bc4e5545d890b6f3b Mon Sep 17 00:00:00 2001
From: Jan Breuer <jan.breuer@jaybee.cz>
Date: 周一, 22 2月 2021 18:02:31 +0800
Subject: [PATCH] Add example code assertions and note to documentation

---
 examples/test-LwIP-netconn/scpi_server.c |   24 ++++++++++++++++++++----
 README.md                                |   10 +++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index fe36682..bcc0c7e 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,16 @@
 SCPI parser library v2
 ===========
 
-[Documentation](http://j123b567.github.io/scpi-parser)
+Documentation
 --------
+Documentation is available at [http://j123b567.github.io/scpi-parser](http://j123b567.github.io/scpi-parser).
+
+Examples
+--------
+Library contains several [examples](https://github.com/j123b567/scpi-parser/tree/master/examples) of usage but please note, that this code is just for educational purpose and not production ready.
+Examples are from several contributors and they are not tested and it is also not known, if they really work or can compile at all.
+
+The core library itself is well tested and has more then 93% of the code covered by unit tests and integration tests and tries to be SCPI-99 compliant as much as possible.
 
 About
 --------
diff --git a/examples/test-LwIP-netconn/scpi_server.c b/examples/test-LwIP-netconn/scpi_server.c
index 5145167..309dd38 100644
--- a/examples/test-LwIP-netconn/scpi_server.c
+++ b/examples/test-LwIP-netconn/scpi_server.c
@@ -165,6 +165,7 @@
 }
 
 void SCPI_RequestControl(void) {
+    BaseType_t xReturned;
     queue_event_t msg;
     msg.cmd = SCPI_MSG_SET_ESE_REQ;
 
@@ -174,18 +175,24 @@
     }
      */
 
-    xQueueSend(user_data.evtQueue, &msg, 1000);
+    xReturned = xQueueSend(user_data.evtQueue, &msg, 1000);
+    /* @fixme: replace by real error handling code */
+    LWIP_ASSERT("SCPI_RequestControl failed", xReturned == pdPASS);
 }
 
 void SCPI_AddError(int16_t err) {
+    BaseType_t xReturned;
     queue_event_t msg;
     msg.cmd = SCPI_MSG_SET_ERROR;
     msg.param2 = err;
 
-    xQueueSend(user_data.evtQueue, &msg, 1000);
+    xReturned = xQueueSend(user_data.evtQueue, &msg, 1000);
+    /* @fixme: replace by real error handling code */
+    LWIP_ASSERT("SCPI_AddError failed", xReturned == pdPASS);
 }
 
 void scpi_netconn_callback(struct netconn * conn, enum netconn_evt evt, u16_t len) {
+    BaseType_t xReturned;
     queue_event_t msg;
     (void) len;
 
@@ -201,7 +208,9 @@
         } else if (conn == user_data.control_io_listen) {
             msg.cmd = SCPI_MSG_CONTROL_IO_LISTEN;
         }
-        xQueueSend(user_data.evtQueue, &msg, 1000);
+        xReturned = xQueueSend(user_data.evtQueue, &msg, 1000);
+        /* @fixme: replace by real error handling code */
+        LWIP_ASSERT("scpi_netconn_callback failed", xReturned == pdPASS);
     }
 }
 
@@ -357,6 +366,7 @@
     (void) arg;
 
     user_data.evtQueue = xQueueCreate(10, sizeof (queue_event_t));
+    LWIP_ASSERT("user_data.evtQueue != NULL", user_data.evtQueue != NULL);
 
     /* user_context will be pointer to socket */
     SCPI_Init(&scpi_context,
@@ -370,7 +380,10 @@
     scpi_context.user_context = &user_data;
 
     user_data.io_listen = createServer(DEVICE_PORT);
+    LWIP_ASSERT("user_data.io_listen != NULL", user_data.io_listen != NULL);
+
     user_data.control_io_listen = createServer(CONTROL_PORT);
+    LWIP_ASSERT("user_data.control_io_listen != NULL", user_data.control_io_listen != NULL);
 
     while (1) {
         waitServer(&user_data, &evt);
@@ -409,5 +422,8 @@
 }
 
 void scpi_server_init(void) {
-    sys_thread_new("SCPI", scpi_server_thread, NULL, 2 * DEFAULT_THREAD_STACKSIZE, SCPI_THREAD_PRIO);
+    TaskHandle_t xHandle = NULL;
+    BaseType_t xReturned;
+    xReturned = xTaskCreate(scpi_server_thread, "SCPI", DEFAULT_THREAD_STACKSIZE, NULL, SCPI_THREAD_PRIO, &xHandle);
+    LWIP_ASSERT("scpi_server_init failed", xReturned == pdPASS);
 }

--
Gitblit v1.9.1