From 56f5bddb7e2a6267bdfeddf8de601a057aef802f Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周六, 05 12月 2015 23:13:34 +0800 Subject: [PATCH] Extend expression.c tests --- examples/common/scpi-def.cpp | 38 +++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 15 deletions(-) diff --git a/examples/common/scpi-def.cpp b/examples/common/scpi-def.cpp index c53fa4f..eb7db0b 100644 --- a/examples/common/scpi-def.cpp +++ b/examples/common/scpi-def.cpp @@ -55,19 +55,18 @@ // do something, if parameter not present } - + SCPI_NumberToStr(context, scpi_special_numbers_def, ¶m1, bf, 15); fprintf(stderr, "\tP1=%s\r\n", bf); - + SCPI_NumberToStr(context, scpi_special_numbers_def, ¶m2, bf, 15); fprintf(stderr, "\tP2=%s\r\n", bf); SCPI_ResultDouble(context, 0); - + return SCPI_RES_OK; } - scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) { scpi_number_t param1, param2; @@ -138,7 +137,6 @@ SCPI_CHOICE_LIST_END /* termination of option list */ }; - scpi_result_t TEST_ChoiceQ(scpi_t * context) { int32_t param; @@ -149,16 +147,16 @@ } SCPI_ChoiceToName(trigger_source, param, &name); - fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (long int)param); + fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (long int) param); - SCPI_ResultInt(context, param); + SCPI_ResultInt32(context, param); return SCPI_RES_OK; } scpi_result_t TEST_Numbers(scpi_t * context) { - fprintf(stderr, "RAW CMD %.*s\r\n", (int)context->param_list.cmd_raw.length, context->param_list.cmd_raw.data); + fprintf(stderr, "RAW CMD %.*s\r\n", (int) context->param_list.cmd_raw.length, context->param_list.cmd_raw.data); return SCPI_RES_OK; } @@ -167,8 +165,9 @@ char buffer[100]; size_t copy_len; - buffer[0] = 0; - SCPI_ParamCopyText(context, buffer, 100, ©_len, false); + if (!SCPI_ParamCopyText(context, buffer, sizeof (buffer), ©_len, false)) { + buffer[0] = '\0'; + } fprintf(stderr, "TEXT: ***%s***\r\n", buffer); @@ -196,7 +195,7 @@ */ scpi_result_t My_CoreTstQ(scpi_t * context) { - SCPI_ResultInt(context, 0); + SCPI_ResultInt32(context, 0); return SCPI_RES_OK; } @@ -276,8 +275,12 @@ scpi_t scpi_context = { /* cmdlist */ scpi_commands, - /* buffer */ { /* length */ SCPI_INPUT_BUFFER_LENGTH, /* position */ 0, /* data */ scpi_input_buffer}, - /* param_list */ { /* cmd */ NULL, /* lex_state */ {NULL, NULL, 0}, /* cmd_raw */ {0, 0, NULL}}, + /* buffer */ + { /* length */ SCPI_INPUT_BUFFER_LENGTH, /* position */ 0, /* data */ scpi_input_buffer}, + /* param_list */ + { /* cmd */ NULL, /* lex_state */ + {NULL, NULL, 0}, /* cmd_raw */ + {0, 0, NULL}}, /* interface */ &scpi_interface, /* output_count */ 0, /* input_count */ 0, @@ -286,7 +289,12 @@ /* registers */ scpi_regs, /* units */ scpi_units_def, /* user_context */ NULL, - /* parser_state */ { /* programHeader */ {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* programData */ {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* numberOfParameters */ 0, /* termination */ SCPI_MESSAGE_TERMINATION_NONE}, - /* idn */ {"MANUFACTURE", "INSTR2013", NULL, "01-02"}, + /* parser_state */ + { /* programHeader */ + {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* programData */ + {SCPI_TOKEN_UNKNOWN, NULL, 0}, /* numberOfParameters */ 0, /* termination */ SCPI_MESSAGE_TERMINATION_NONE + }, + /* idn */ + {"MANUFACTURE", "INSTR2013", NULL, "01-02"}, }; -- Gitblit v1.9.1