From: Frank Stettner Date: Tue, 9 Apr 2019 15:41:29 +0000 (+0200) Subject: scpi-pps: Add configurable sr_mqflags. X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=f2bbcc330a6bcb65500b298bec8c40974ed246d4 scpi-pps: Add configurable sr_mqflags. --- diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index 8fff5748..104a020d 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -152,6 +152,13 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi, for (l = sdi->channels; l; l = l->next) { ch = l->data; pch = ch->priv; + /* Add mqflags from channel_group_spec only to voltage + * and current channels + */ + if (pch->mq == SR_MQ_VOLTAGE || pch->mq == SR_MQ_CURRENT) + pch->mqflags = cgs->mqflags; + else + pch->mqflags = 0; if (pch->hw_output_idx == j) cg->channels = g_slist_append(cg->channels, ch); } diff --git a/src/hardware/scpi-pps/profiles.c b/src/hardware/scpi-pps/profiles.c index ef1a12ad..a83e0396 100644 --- a/src/hardware/scpi-pps/profiles.c +++ b/src/hardware/scpi-pps/profiles.c @@ -48,7 +48,7 @@ static const uint32_t agilent_n5700a_devopts_cg[] = { }; static const struct channel_group_spec agilent_n5700a_cg[] = { - { "1", CH_IDX(0), PPS_OVP | PPS_OCP }, + { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC }, }; static const struct channel_spec agilent_n5767a_ch[] = { @@ -109,9 +109,9 @@ static const struct channel_spec bk_9130_ch[] = { }; static const struct channel_group_spec bk_9130_cg[] = { - { "1", CH_IDX(0), PPS_OVP }, - { "2", CH_IDX(1), PPS_OVP }, - { "3", CH_IDX(2), PPS_OVP }, + { "1", CH_IDX(0), PPS_OVP, SR_MQFLAG_DC }, + { "2", CH_IDX(1), PPS_OVP, SR_MQFLAG_DC }, + { "3", CH_IDX(2), PPS_OVP, SR_MQFLAG_DC }, }; static const struct scpi_command bk_9130_cmd[] = { @@ -156,7 +156,7 @@ static const struct channel_spec chroma_61604_ch[] = { }; static const struct channel_group_spec chroma_61604_cg[] = { - { "1", CH_IDX(0), PPS_OVP | PPS_OCP }, + { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_AC }, }; static const struct scpi_command chroma_61604_cmd[] = { @@ -199,7 +199,7 @@ static const uint32_t chroma_62000_devopts_cg[] = { }; static const struct channel_group_spec chroma_62000_cg[] = { - { "1", CH_IDX(0), PPS_OVP | PPS_OCP }, + { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC }, }; static const struct scpi_command chroma_62000_cmd[] = { @@ -305,7 +305,7 @@ static const struct channel_spec rigol_dp712_ch[] = { }; static const struct channel_group_spec rigol_dp700_cg[] = { - { "1", CH_IDX(0), PPS_OVP | PPS_OCP }, + { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC }, }; /* Same as the DP800 series, except for the missing :SYST:OTP* commands. */ @@ -383,14 +383,14 @@ static const struct channel_spec rigol_dp832_ch[] = { }; static const struct channel_group_spec rigol_dp820_cg[] = { - { "1", CH_IDX(0), PPS_OVP | PPS_OCP }, - { "2", CH_IDX(1), PPS_OVP | PPS_OCP }, + { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC }, + { "2", CH_IDX(1), PPS_OVP | PPS_OCP, SR_MQFLAG_DC }, }; static const struct channel_group_spec rigol_dp830_cg[] = { - { "1", CH_IDX(0), PPS_OVP | PPS_OCP }, - { "2", CH_IDX(1), PPS_OVP | PPS_OCP }, - { "3", CH_IDX(2), PPS_OVP | PPS_OCP }, + { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC }, + { "2", CH_IDX(1), PPS_OVP | PPS_OCP, SR_MQFLAG_DC }, + { "3", CH_IDX(2), PPS_OVP | PPS_OCP, SR_MQFLAG_DC }, }; static const struct scpi_command rigol_dp800_cmd[] = { @@ -491,7 +491,7 @@ static const struct channel_spec hp_6634b_ch[] = { }; static const struct channel_group_spec hp_663xx_cg[] = { - { "1", CH_IDX(0), 0 }, + { "1", CH_IDX(0), 0, SR_MQFLAG_DC }, }; static const struct scpi_command hp_6630a_cmd[] = { @@ -826,6 +826,7 @@ static int philips_pm2800_probe_channels(struct sr_dev_inst *sdi, (*channel_groups)[i].name = (char *)philips_pm2800_names[i]; (*channel_groups)[i].channel_index_mask = 1 << i; (*channel_groups)[i].features = PPS_OTP | PPS_OVP | PPS_OCP; + (*channel_groups)[i].mqflags = SR_MQFLAG_DC; } *num_channels = *num_channel_groups = num_modules; @@ -878,9 +879,9 @@ static const struct channel_spec rs_hmc8043_ch[] = { }; static const struct channel_group_spec rs_hmc8043_cg[] = { - { "1", CH_IDX(0), PPS_OVP }, - { "2", CH_IDX(1), PPS_OVP }, - { "3", CH_IDX(2), PPS_OVP }, + { "1", CH_IDX(0), PPS_OVP, SR_MQFLAG_DC }, + { "2", CH_IDX(1), PPS_OVP, SR_MQFLAG_DC }, + { "3", CH_IDX(2), PPS_OVP, SR_MQFLAG_DC }, }; static const struct scpi_command rs_hmc8043_cmd[] = { diff --git a/src/hardware/scpi-pps/protocol.c b/src/hardware/scpi-pps/protocol.c index 762fcae1..b6e60b96 100644 --- a/src/hardware/scpi-pps/protocol.c +++ b/src/hardware/scpi-pps/protocol.c @@ -105,6 +105,7 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data) analog.meaning->channels = g_slist_append(NULL, devc->cur_acquisition_channel); analog.num_samples = 1; analog.meaning->mq = pch->mq; + analog.meaning->mqflags = pch->mqflags; if (pch->mq == SR_MQ_VOLTAGE) { analog.meaning->unit = SR_UNIT_VOLT; analog.encoding->digits = ch_spec->voltage[4]; @@ -118,7 +119,6 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data) analog.encoding->digits = ch_spec->power[4]; analog.spec->spec_digits = ch_spec->power[3]; } - analog.meaning->mqflags = SR_MQFLAG_DC; f = (float)g_variant_get_double(gvdata); g_variant_unref(gvdata); analog.data = &f; diff --git a/src/hardware/scpi-pps/protocol.h b/src/hardware/scpi-pps/protocol.h index e9da0d6d..04f3a0b0 100644 --- a/src/hardware/scpi-pps/protocol.h +++ b/src/hardware/scpi-pps/protocol.h @@ -126,10 +126,13 @@ struct channel_group_spec { const char *name; uint64_t channel_index_mask; uint64_t features; + /* The mqflags will only be applied to voltage and current channels! */ + enum sr_mqflag mqflags; }; struct pps_channel { enum sr_mq mq; + enum sr_mqflag mqflags; unsigned int hw_output_idx; const char *hwname; int digits;