From fea06605af79832c6abe7a8e6a24c142987994d6 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周二, 22 10月 2013 17:59:45 +0800 Subject: [PATCH] Add more robust detection of case insensitive string compare --- examples/common/scpi-def.c | 33 ++++++++++++++++++++++++++++++--- 1 files changed, 30 insertions(+), 3 deletions(-) diff --git a/examples/common/scpi-def.c b/examples/common/scpi-def.c index c49eb44..ea8be8a 100644 --- a/examples/common/scpi-def.c +++ b/examples/common/scpi-def.c @@ -89,6 +89,30 @@ return SCPI_RES_OK; } + +const char * trigger_source[] = { + "BUS", + "IMMediate", + "EXTernal", + NULL /* termination of option list */ +}; + + +scpi_result_t TEST_ChoiceQ(scpi_t * context) { + + int32_t param; + + if (!SCPI_ParamChoice(context, trigger_source, ¶m, true)) { + return SCPI_RES_ERR; + } + + fprintf(stderr, "\tP1=%s (%d)\r\n", trigger_source[param], param); + + SCPI_ResultInt(context, param); + + 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,}, @@ -139,16 +163,18 @@ {.pattern = "SYSTem:COMMunication:TCPIP:CONTROL?", .callback = SCPI_SystemCommTcpipControlQ,}, + {.pattern = "TEST:CHOice?", .callback = TEST_ChoiceQ,}, + SCPI_CMD_LIST_END }; static scpi_interface_t scpi_interface = { - .write = SCPI_Write, .error = SCPI_Error, - .reset = SCPI_Reset, - .test = SCPI_Test, + .write = SCPI_Write, .control = SCPI_Control, .flush = SCPI_Flush, + .reset = SCPI_Reset, + .test = SCPI_Test, }; #define SCPI_INPUT_BUFFER_LENGTH 256 @@ -167,4 +193,5 @@ .registers = scpi_regs, .units = scpi_units_def, .special_numbers = scpi_special_numbers_def, + .idn = {"MANUFACTURE", "INSTR2013", NULL, "01-02"}, }; -- Gitblit v1.9.1