Jan Breuer
2017-08-07 02c004a7747e7f7f4c135c370dd82bf383750450
Merge pull request #89 from j123b567/feature/expose-on-off

expose bool choice definition (ON, OFF)
2个文件已修改
18 ■■■■■ 已修改文件
libscpi/inc/scpi/parser.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/src/parser.c 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/inc/scpi/parser.h
@@ -114,6 +114,7 @@
    scpi_bool_t SCPI_ParamArbitraryBlock(scpi_t * context, const char ** value, size_t * len, scpi_bool_t mandatory);
    scpi_bool_t SCPI_ParamCopyText(scpi_t * context, char * buffer, size_t buffer_len, size_t * copy_len, scpi_bool_t mandatory);
    extern const scpi_choice_def_t scpi_bool_def[];
    scpi_bool_t SCPI_ParamBool(scpi_t * context, scpi_bool_t * value, scpi_bool_t mandatory);
    scpi_bool_t SCPI_ParamChoice(scpi_t * context, const scpi_choice_def_t * options, int32_t * value, scpi_bool_t mandatory);
libscpi/src/parser.c
@@ -1270,6 +1270,15 @@
    return FALSE;
}
/*
 * Definition of BOOL choice list
 */
const scpi_choice_def_t scpi_bool_def[] = {
    {"OFF", 0},
    {"ON", 1},
    SCPI_CHOICE_LIST_END /* termination of option list */
};
/**
 * Read BOOL parameter (0,1,ON,OFF)
 * @param context
@@ -1281,12 +1290,6 @@
    scpi_bool_t result;
    scpi_parameter_t param;
    int32_t intval;
    scpi_choice_def_t bool_options[] = {
        {"OFF", 0},
        {"ON", 1},
        SCPI_CHOICE_LIST_END /* termination of option list */
    };
    if (!value) {
        SCPI_ErrorPush(context, SCPI_ERROR_SYSTEM_ERROR);
@@ -1300,7 +1303,7 @@
            SCPI_ParamToInt32(context, &param, &intval);
            *value = intval ? TRUE : FALSE;
        } else {
            result = SCPI_ParamToChoice(context, &param, bool_options, &intval);
            result = SCPI_ParamToChoice(context, &param, scpi_bool_def, &intval);
            if (result) {
                *value = intval ? TRUE : FALSE;
            }