From: Gerhard Sittig Date: Sat, 17 Nov 2018 15:26:51 +0000 (+0100) Subject: scpi-dmm: add support for model specific device options X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1d2f9963abc10554ee0b36c6a1cf18649d4212c0;p=libsigrok.git scpi-dmm: add support for model specific device options Supported SCPI DMM devices will differ in the set of options and whether parameters can get queried or configured. Use a "generic" set of devopts during scan and for simpler models, prepare support for other sets of devopts for more complex models. --- diff --git a/src/hardware/scpi-dmm/api.c b/src/hardware/scpi-dmm/api.c index 011f57b5..f6820de3 100644 --- a/src/hardware/scpi-dmm/api.c +++ b/src/hardware/scpi-dmm/api.c @@ -31,7 +31,7 @@ static const uint32_t drvopts[] = { SR_CONF_MULTIMETER, }; -static const uint32_t devopts[] = { +static const uint32_t devopts_generic[] = { SR_CONF_CONTINUOUS, SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, @@ -68,6 +68,7 @@ SR_PRIV const struct scpi_dmm_model models[] = { "Agilent", "34405A", 1, 5, cmdset_agilent, ARRAY_AND_SIZE(mqopts_agilent_5digit), scpi_dmm_get_meas_agilent, + ARRAY_AND_SIZE(devopts_generic), }, }; @@ -246,7 +247,12 @@ static int config_list(uint32_t key, GVariant **data, switch (key) { case SR_CONF_SCAN_OPTIONS: case SR_CONF_DEVICE_OPTIONS: - return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); + if (!devc) + return STD_CONFIG_LIST(key, data, sdi, cg, + scanopts, drvopts, devopts_generic); + return std_opts_config_list(key, data, sdi, cg, + ARRAY_AND_SIZE(scanopts), ARRAY_AND_SIZE(drvopts), + devc->model->devopts, devc->model->devopts_size); case SR_CONF_MEASURED_QUANTITY: /* TODO Use std_gvar_measured_quantities() when available. */ if (!devc) diff --git a/src/hardware/scpi-dmm/protocol.h b/src/hardware/scpi-dmm/protocol.h index 0881074c..dbca1bcf 100644 --- a/src/hardware/scpi-dmm/protocol.h +++ b/src/hardware/scpi-dmm/protocol.h @@ -60,6 +60,8 @@ struct scpi_dmm_model { const struct mqopt_item *mqopts; size_t mqopt_size; int (*get_measurement)(const struct sr_dev_inst *sdi, size_t ch); + const uint32_t *devopts; + size_t devopts_size; }; struct dev_context {