From 8c408948cc956c50527cf6e6fc0808e185a6b105 Mon Sep 17 00:00:00 2001 From: Andrey Nakin <andrey.nakin@gmail.com> Date: ćšć, 16 4æ 2015 22:27:12 +0800 Subject: [PATCH] Merge branch 'master' of https://github.com/j123b567/scpi-parser --- libscpi/src/ieee488.c | 14 +++++++++----- examples/test-parser/main.c | 5 +---- examples/test-tcp/main.c | 5 +---- examples/test-LwIP-netconn/scpi_server.c | 5 +---- examples/test-interactive/main.c | 5 +---- examples/test-tcp-srq/main.c | 5 +---- libscpi/test/test_lib.c | 18 ++++++++++-------- 7 files changed, 24 insertions(+), 33 deletions(-) diff --git a/examples/test-LwIP-netconn/scpi_server.c b/examples/test-LwIP-netconn/scpi_server.c index afbfd7a..bc3af9e 100644 --- a/examples/test-LwIP-netconn/scpi_server.c +++ b/examples/test-LwIP-netconn/scpi_server.c @@ -146,13 +146,10 @@ return SCPI_RES_OK; } -/** - * Return 0 as OK and other number as error - */ scpi_result_t SCPI_Test(scpi_t * context) { (void) context; iprintf("**Test\r\n"); - return 0; + return SCPI_RES_OK; } scpi_result_t SCPI_Reset(scpi_t * context) { diff --git a/examples/test-interactive/main.c b/examples/test-interactive/main.c index ac23a48..b149558 100644 --- a/examples/test-interactive/main.c +++ b/examples/test-interactive/main.c @@ -65,12 +65,9 @@ return SCPI_RES_OK; } -/** - * Return 0 as OK and other number as error - */ scpi_result_t SCPI_Test(scpi_t * context) { fprintf(stderr, "**Test\r\n"); - return 0; + return SCPI_RES_OK; } scpi_result_t SCPI_Reset(scpi_t * context) { diff --git a/examples/test-parser/main.c b/examples/test-parser/main.c index 69a7f20..0ab2b2a 100644 --- a/examples/test-parser/main.c +++ b/examples/test-parser/main.c @@ -65,12 +65,9 @@ return SCPI_RES_OK; } -/** - * Return 0 as OK and other number as error - */ scpi_result_t SCPI_Test(scpi_t * context) { fprintf(stderr, "**Test\r\n"); - return 0; + return SCPI_RES_OK; } 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 2e44ba1..0837e95 100644 --- a/examples/test-tcp-srq/main.c +++ b/examples/test-tcp-srq/main.c @@ -108,12 +108,9 @@ return SCPI_RES_OK; } -/** - * Return 0 as OK and other number as error - */ scpi_result_t SCPI_Test(scpi_t * context) { fprintf(stderr, "**Test\r\n"); - return 0; + return SCPI_RES_OK; } scpi_result_t SCPI_Reset(scpi_t * context) { diff --git a/examples/test-tcp/main.c b/examples/test-tcp/main.c index 6aa99aa..2336165 100644 --- a/examples/test-tcp/main.c +++ b/examples/test-tcp/main.c @@ -76,12 +76,9 @@ return SCPI_RES_OK; } -/** - * Return 0 as OK and other number as error - */ scpi_result_t SCPI_Test(scpi_t * context) { fprintf(stderr, "**Test\r\n"); - return 0; + return SCPI_RES_OK; } scpi_result_t SCPI_Reset(scpi_t * context) { diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index 73701ec..7ed8bc8 100644 --- a/libscpi/src/ieee488.c +++ b/libscpi/src/ieee488.c @@ -250,10 +250,14 @@ * @return */ scpi_result_t SCPI_CoreIdnQ(scpi_t * context) { - SCPI_ResultString(context, context->idn[0]); - SCPI_ResultString(context, context->idn[1]); - SCPI_ResultString(context, context->idn[2]); - SCPI_ResultString(context, context->idn[3]); + int i; + for (i = 0; i<4; i++) { + if (context->idn[i]) { + SCPI_ResultString(context, context->idn[i]); + } else { + SCPI_ResultString(context, "0"); + } + } return SCPI_RES_OK; } @@ -331,7 +335,7 @@ scpi_result_t SCPI_CoreTstQ(scpi_t * context) { int result = 0; if (context && context->interface && context->interface->test) { - result = context->interface->test(context); + result = context->interface->test(context) == SCPI_RES_OK ? 0 : 1; } SCPI_ResultInt(context, result); return SCPI_RES_OK; diff --git a/libscpi/test/test_lib.c b/libscpi/test/test_lib.c index c5be44f..3fc74b8 100644 --- a/libscpi/test/test_lib.c +++ b/libscpi/test/test_lib.c @@ -32,15 +32,15 @@ { .pattern = "*WAI", .callback = SCPI_CoreWai,}, /* Required SCPI commands (SCPI std V1999.0 4.2.1) */ - {.pattern = "SYSTem:ERRor[:NEXT]?", .callback = SCPI_SystemErrorNextQ,}, - {.pattern = "SYSTem:ERRor:COUNt?", .callback = SCPI_SystemErrorCountQ,}, - {.pattern = "SYSTem:VERSion?", .callback = SCPI_SystemVersionQ,}, + { .pattern = "SYSTem:ERRor[:NEXT]?", .callback = SCPI_SystemErrorNextQ,}, + { .pattern = "SYSTem:ERRor:COUNt?", .callback = SCPI_SystemErrorCountQ,}, + { .pattern = "SYSTem:VERSion?", .callback = SCPI_SystemVersionQ,}, - {.pattern = "STATus:QUEStionable[:EVENt]?", .callback = SCPI_StatusQuestionableEventQ,}, - {.pattern = "STATus:QUEStionable:ENABle", .callback = SCPI_StatusQuestionableEnable,}, - {.pattern = "STATus:QUEStionable:ENABle?", .callback = SCPI_StatusQuestionableEnableQ,}, + { .pattern = "STATus:QUEStionable[:EVENt]?", .callback = SCPI_StatusQuestionableEventQ,}, + { .pattern = "STATus:QUEStionable:ENABle", .callback = SCPI_StatusQuestionableEnable,}, + { .pattern = "STATus:QUEStionable:ENABle?", .callback = SCPI_StatusQuestionableEnableQ,}, - {.pattern = "STATus:PRESet", .callback = SCPI_StatusPreset,}, + { .pattern = "STATus:PRESet", .callback = SCPI_StatusPreset,}, SCPI_CMD_LIST_END }; @@ -163,6 +163,7 @@ CU_ASSERT_STRING_EQUAL(output, output_buffer); \ } output_buffer_clear(); + error_buffer_clear(); /* Test single command */ TEST_INPUT("*IDN?\r\n", "MA, IN, 0, VER\r\n"); @@ -252,7 +253,7 @@ CU_ASSERT_EQUAL(RST_executed, TRUE); TST_executed = FALSE; - TEST_IEEE4882("*TST?\r\n", "1\r\n"); + TEST_IEEE4882("*TST?\r\n", "0\r\n"); CU_ASSERT_EQUAL(TST_executed, TRUE); TEST_IEEE4882("*WAI\r\n", ""); @@ -312,3 +313,4 @@ CU_cleanup_registry(); return CU_get_error(); } + -- Gitblit v1.9.1