From 523d303e2ab6a35845cd7ae07821d6aa0b14965c Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周一, 21 10月 2013 17:16:21 +0800 Subject: [PATCH] Add example to ParamChoice --- examples/common/scpi-def.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/examples/common/scpi-def.c b/examples/common/scpi-def.c index 485cd85..492ba8b 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) { + + size_t param; + + if (!SCPI_ParamChoice(context, trigger_source, ¶m, true)) { + return SCPI_RES_ERR; + } + + fprintf(stderr, "\tP1=%s (%u)\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,6 +163,8 @@ {.pattern = "SYSTem:COMMunication:TCPIP:CONTROL?", .callback = SCPI_SystemCommTcpipControlQ,}, + {.pattern = "TEST:CHOice?", .callback = TEST_ChoiceQ,}, + SCPI_CMD_LIST_END }; -- Gitblit v1.9.1