Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Add support to handle numerical values in choice list #155

Open
u77345 opened this issue Nov 12, 2023 · 0 comments
Open

Comments

@u77345
Copy link

u77345 commented Nov 12, 2023

An example SCPI command:

CONFigure:VOLTage:DC {0.2|2|20|AUTO}

when implemented using the current interface it creates a complex code, getting a SCPI_Parameter first, then implementing two cases based on whether the parameter type is SCPI_TOKEN_PROGRAM_MNEMONIC for SCPI_ParamToChoice or SCPI_ParamToFloat. Additional validation code to match ranges also necessary.

However, a much simpler hack is possible:

const scpi_choice_def_t scpi_range[] = {
    {"0.2",       1}, 
    {"2",         2}, 
    {"20",        3}, 
    {"AUTO",      0}, 
    SCPI_CHOICE_LIST_END
};

    bool res = SCPI_Parameter(context, &param, true);
    if (res) {
        param.type = SCPI_TOKEN_PROGRAM_MNEMONIC;
        res = SCPI_ParamToChoice(context, &param, scpi_range, &range);
        if (!res) {
            return SCPI_RES_ERR;
        }        
    } else {
        return SCPI_RES_ERR;
    }

The ask is to be able to express choices as numerics without forcibly overwriting the parameter type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant