From d811ac6da4ab97088f7560b7999449ecd9b1d81f Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周二, 14 4月 2015 04:04:37 +0800 Subject: [PATCH] Remove problematic test callback --- examples/common/scpi-def.h | 1 libscpi/inc/scpi/types.h | 2 - libscpi/src/ieee488.c | 7 +-- examples/test-parser/main.c | 12 ------ examples/test-tcp/main.c | 12 ------ libscpi/test/test_parser.c | 8 ---- examples/common/scpi-def.cpp | 1 examples/test-LwIP-netconn/scpi_server.c | 13 ------ examples/test-interactive/main.c | 12 ------ examples/test-tcp-srq/main.c | 12 ------ examples/common/scpi-def.c | 18 ++++++++- README.md | 3 + 12 files changed, 20 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 75ed0d2..2a2e9c4 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ Reading strings is now more correct but it needs secondary copy buffer. You can use function `SCPI_ParamCopyText` to correctly handle strings like `"normal ""quoted"" normal"` will be converted to `normal "quoted" normal`. It is now possible to use `SCPI_ParamArbitraryBlock` and `SCPI_ResultArbitraryBlock` to work with binary data input and output. + +Test callback is removed from context. You should now reimplement whole `*TST?` command callback. Usage --------------- @@ -131,7 +133,6 @@ .write = myWrite, .error = NULL, .reset = NULL, - .test = NULL, .srq = NULL, }; ``` diff --git a/examples/common/scpi-def.c b/examples/common/scpi-def.c index 562b67b..359fdc4 100644 --- a/examples/common/scpi-def.c +++ b/examples/common/scpi-def.c @@ -186,6 +186,21 @@ return SCPI_RES_OK; } +/** + * Reimplement IEEE488.2 *TST? + * + * Result should be 0 if everything is ok + * Result should be 1 if something goes wrong + * + * Return SCPI_RES_OK + */ +scpi_result_t My_CoreTstQ(scpi_t * context) { + + SCPI_ResultInt(context, 0); + + return SCPI_RES_OK; +} + static const scpi_command_t scpi_commands[] = { /* IEEE Mandated Commands (SCPI std V1999.0 4.1.1) */ { .pattern = "*CLS", .callback = SCPI_CoreCls,}, @@ -199,7 +214,7 @@ { .pattern = "*SRE", .callback = SCPI_CoreSre,}, { .pattern = "*SRE?", .callback = SCPI_CoreSreQ,}, { .pattern = "*STB?", .callback = SCPI_CoreStbQ,}, - { .pattern = "*TST?", .callback = SCPI_CoreTstQ,}, + { .pattern = "*TST?", .callback = My_CoreTstQ,}, { .pattern = "*WAI", .callback = SCPI_CoreWai,}, /* Required SCPI commands (SCPI std V1999.0 4.2.1) */ @@ -249,7 +264,6 @@ .control = SCPI_Control, .flush = SCPI_Flush, .reset = SCPI_Reset, - .test = SCPI_Test, }; #define SCPI_INPUT_BUFFER_LENGTH 256 diff --git a/examples/common/scpi-def.cpp b/examples/common/scpi-def.cpp index d5fc7ca..46e33b1 100644 --- a/examples/common/scpi-def.cpp +++ b/examples/common/scpi-def.cpp @@ -150,7 +150,6 @@ /* control */ SCPI_Control, /* flush */ SCPI_Flush, /* reset */ SCPI_Reset, - /* test */ SCPI_Test, }; #define SCPI_INPUT_BUFFER_LENGTH 256 diff --git a/examples/common/scpi-def.h b/examples/common/scpi-def.h index 2386320..4bfc06c 100644 --- a/examples/common/scpi-def.h +++ b/examples/common/scpi-def.h @@ -9,7 +9,6 @@ int SCPI_Error(scpi_t * context, int_fast16_t err); scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val); scpi_result_t SCPI_Reset(scpi_t * context); -int32_t SCPI_Test(scpi_t * context); scpi_result_t SCPI_Flush(scpi_t * context); diff --git a/examples/test-LwIP-netconn/scpi_server.c b/examples/test-LwIP-netconn/scpi_server.c index aecfbd1..872d1f5 100644 --- a/examples/test-LwIP-netconn/scpi_server.c +++ b/examples/test-LwIP-netconn/scpi_server.c @@ -145,19 +145,6 @@ return SCPI_RES_OK; } -/** - * 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 0; -} - scpi_result_t SCPI_Reset(scpi_t * context) { (void) context; iprintf("**Reset\r\n"); diff --git a/examples/test-interactive/main.c b/examples/test-interactive/main.c index ba284e7..22ec0af 100644 --- a/examples/test-interactive/main.c +++ b/examples/test-interactive/main.c @@ -65,18 +65,6 @@ return SCPI_RES_OK; } -/** - * 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 0; -} - scpi_result_t SCPI_Reset(scpi_t * context) { fprintf(stderr, "**Reset\r\n"); return SCPI_RES_OK; diff --git a/examples/test-parser/main.c b/examples/test-parser/main.c index c4b3155..5fc8e29 100644 --- a/examples/test-parser/main.c +++ b/examples/test-parser/main.c @@ -65,18 +65,6 @@ return SCPI_RES_OK; } -/** - * 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 0; -} - scpi_result_t SCPI_Reset(scpi_t * context) { fprintf(stderr, "**Reset\r\n"); return SCPI_RES_OK; diff --git a/examples/test-tcp-srq/main.c b/examples/test-tcp-srq/main.c index 227628b..0a993d3 100644 --- a/examples/test-tcp-srq/main.c +++ b/examples/test-tcp-srq/main.c @@ -108,18 +108,6 @@ return SCPI_RES_OK; } -/** - * 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 0; -} - scpi_result_t SCPI_Reset(scpi_t * context) { fprintf(stderr, "**Reset\r\n"); return SCPI_RES_OK; diff --git a/examples/test-tcp/main.c b/examples/test-tcp/main.c index 596a4cf..3251286 100644 --- a/examples/test-tcp/main.c +++ b/examples/test-tcp/main.c @@ -76,18 +76,6 @@ return SCPI_RES_OK; } -/** - * 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; -} - scpi_result_t SCPI_Reset(scpi_t * context) { fprintf(stderr, "**Reset\r\n"); return SCPI_RES_OK; diff --git a/libscpi/inc/scpi/types.h b/libscpi/inc/scpi/types.h index 6f02ec0..4851d9e 100644 --- a/libscpi/inc/scpi/types.h +++ b/libscpi/inc/scpi/types.h @@ -190,7 +190,6 @@ 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; @@ -272,7 +271,6 @@ scpi_write_control_t control; scpi_command_callback_t flush; scpi_command_callback_t reset; - scpi_test_command_callback_t test; }; struct _scpi_t { diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index 7b9bd9c..ad2bc78 100644 --- a/libscpi/src/ieee488.c +++ b/libscpi/src/ieee488.c @@ -329,11 +329,8 @@ * @return */ scpi_result_t SCPI_CoreTstQ(scpi_t * context) { - int result = 0; - if (context && context->interface && context->interface->test) { - result = context->interface->test(context); - } - SCPI_ResultInt(context, result); + (void) context; + SCPI_ResultInt(context, 0); return SCPI_RES_OK; } diff --git a/libscpi/test/test_parser.c b/libscpi/test/test_parser.c index 7abb3ce..33e51f4 100644 --- a/libscpi/test/test_parser.c +++ b/libscpi/test/test_parser.c @@ -68,17 +68,10 @@ (void)context; } -int32_t SCPI_Test(scpi_t * context) -{ - (void)context; - return 0; -} - scpi_result_t SCPI_Flush(scpi_t * context) { (void)context; } - static scpi_interface_t scpi_interface = { .error = SCPI_Error, @@ -86,7 +79,6 @@ .control = SCPI_Control, .flush = SCPI_Flush, .reset = SCPI_Reset, - .test = SCPI_Test, }; #define SCPI_INPUT_BUFFER_LENGTH 256 -- Gitblit v1.9.1