From 90f9c5a84c9e4c281cd665bcb41dc6b2d2abb550 Mon Sep 17 00:00:00 2001
From: Jan Breuer <jan.breuer@jaybee.cz>
Date: 周日, 18 1月 2015 16:49:17 +0800
Subject: [PATCH] Correct type of *TST? callback function

---
 libscpi/inc/scpi/types.h                 |    3 ++-
 examples/test-parser/main.c              |   11 +++++++++--
 examples/test-tcp/main.c                 |    9 ++++++++-
 examples/test-LwIP-netconn/scpi_server.c |   11 +++++++++--
 examples/test-interactive/main.c         |   11 +++++++++--
 examples/test-tcp-srq/main.c             |   11 +++++++++--
 6 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/examples/test-LwIP-netconn/scpi_server.c b/examples/test-LwIP-netconn/scpi_server.c
index e6dee56..aecfbd1 100644
--- a/examples/test-LwIP-netconn/scpi_server.c
+++ b/examples/test-LwIP-netconn/scpi_server.c
@@ -145,10 +145,17 @@
     return SCPI_RES_OK;
 }
 
-scpi_result_t SCPI_Test(scpi_t * context) {
+/**
+ * Callback for *TST? command
+ * 
+ * It returns directly the result of the test
+ * @param context
+ * @return 0 means "test was OK", other values means, that some error bits are set
+ */
+int32_t SCPI_Test(scpi_t * context) {
     (void) context;
     iprintf("**Test\r\n");
-    return SCPI_RES_OK;
+    return 0;
 }
 
 scpi_result_t SCPI_Reset(scpi_t * context) {
diff --git a/examples/test-interactive/main.c b/examples/test-interactive/main.c
index b149558..ba284e7 100644
--- a/examples/test-interactive/main.c
+++ b/examples/test-interactive/main.c
@@ -65,9 +65,16 @@
     return SCPI_RES_OK;
 }
 
-scpi_result_t SCPI_Test(scpi_t * context) {
+/**
+ * Callback for *TST? command
+ * 
+ * It returns directly the result of the test
+ * @param context
+ * @return 0 means "test was OK", other values means, that some error bits are set
+ */
+int32_t SCPI_Test(scpi_t * context) {
     fprintf(stderr, "**Test\r\n");
-    return SCPI_RES_OK;
+    return 0;
 }
 
 scpi_result_t SCPI_Reset(scpi_t * context) {
diff --git a/examples/test-parser/main.c b/examples/test-parser/main.c
index fef4bdb..c4b3155 100644
--- a/examples/test-parser/main.c
+++ b/examples/test-parser/main.c
@@ -65,9 +65,16 @@
     return SCPI_RES_OK;
 }
 
-scpi_result_t SCPI_Test(scpi_t * context) {
+/**
+ * Callback for *TST? command
+ * 
+ * It returns directly the result of the test
+ * @param context
+ * @return 0 means "test was OK", other values means, that some error bits are set
+ */
+int32_t SCPI_Test(scpi_t * context) {
     fprintf(stderr, "**Test\r\n");
-    return SCPI_RES_OK;
+    return 0;
 }
 
 scpi_result_t SCPI_Reset(scpi_t * context) {
diff --git a/examples/test-tcp-srq/main.c b/examples/test-tcp-srq/main.c
index 0837e95..227628b 100644
--- a/examples/test-tcp-srq/main.c
+++ b/examples/test-tcp-srq/main.c
@@ -108,9 +108,16 @@
     return SCPI_RES_OK;
 }
 
-scpi_result_t SCPI_Test(scpi_t * context) {
+/**
+ * Callback for *TST? command
+ * 
+ * It returns directly the result of the test
+ * @param context
+ * @return 0 means "test was OK", other values means, that some error bits are set
+ */
+int32_t SCPI_Test(scpi_t * context) {
     fprintf(stderr, "**Test\r\n");
-    return SCPI_RES_OK;
+    return 0;
 }
 
 scpi_result_t SCPI_Reset(scpi_t * context) {
diff --git a/examples/test-tcp/main.c b/examples/test-tcp/main.c
index 2336165..596a4cf 100644
--- a/examples/test-tcp/main.c
+++ b/examples/test-tcp/main.c
@@ -76,7 +76,14 @@
     return SCPI_RES_OK;
 }
 
-scpi_result_t SCPI_Test(scpi_t * context) {
+/**
+ * Callback for *TST? command
+ * 
+ * It returns directly the result of the test
+ * @param context
+ * @return 0 means "test was OK", other values means, that some error bits are set
+ */
+int32_t SCPI_Test(scpi_t * context) {
     fprintf(stderr, "**Test\r\n");
     return SCPI_RES_OK;
 }
diff --git a/libscpi/inc/scpi/types.h b/libscpi/inc/scpi/types.h
index 52ee8f2..0ebe055 100644
--- a/libscpi/inc/scpi/types.h
+++ b/libscpi/inc/scpi/types.h
@@ -190,6 +190,7 @@
     typedef struct _scpi_parser_state_t scpi_parser_state_t;
 
     typedef scpi_result_t(*scpi_command_callback_t)(scpi_t *);
+    typedef int32_t(*scpi_test_command_callback_t)(scpi_t *);
 
     /* scpi error queue */
     typedef void * scpi_error_queue_t;
@@ -274,7 +275,7 @@
         scpi_write_control_t control;
         scpi_command_callback_t flush;
         scpi_command_callback_t reset;
-        scpi_command_callback_t test;
+        scpi_test_command_callback_t test;
     };
 
     struct _scpi_t {

--
Gitblit v1.9.1