]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/scpi-pps/protocol.c
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / scpi-pps / protocol.c
index 762fcae1ec8ed434a3095ad4cb410f617bcecd04..825fdb945257a32b62eaadc36f8f7d57fee1534b 100644 (file)
@@ -97,7 +97,13 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data)
        if (ret != SR_OK)
                return ret;
 
-       ch_spec = &devc->device->channels[pch->hw_output_idx];
+       if (devc->channels) {
+               /* Dynamically-probed devices. */
+               ch_spec = &devc->channels[pch->hw_output_idx];
+       } else {
+               /* Statically-configured devices. */
+               ch_spec = &devc->device->channels[pch->hw_output_idx];
+       }
        packet.type = SR_DF_ANALOG;
        packet.payload = &analog;
        /* Note: digits/spec_digits will be overridden later. */
@@ -105,6 +111,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];
@@ -117,8 +124,11 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data)
                analog.meaning->unit = SR_UNIT_WATT;
                analog.encoding->digits = ch_spec->power[4];
                analog.spec->spec_digits = ch_spec->power[3];
+       } else if (pch->mq == SR_MQ_FREQUENCY) {
+               analog.meaning->unit = SR_UNIT_HERTZ;
+               analog.encoding->digits = ch_spec->frequency[4];
+               analog.spec->spec_digits = ch_spec->frequency[3];
        }
-       analog.meaning->mqflags = SR_MQFLAG_DC;
        f = (float)g_variant_get_double(gvdata);
        g_variant_unref(gvdata);
        analog.data = &f;