]> sigrok.org Git - libsigrok.git/commitdiff
scpi-pps: Data capture dynamically-probed channels
authorMartin Atkins <redacted>
Sun, 25 Oct 2020 20:16:37 +0000 (13:16 -0700)
committerGerhard Sittig <redacted>
Sat, 28 Aug 2021 15:01:41 +0000 (17:01 +0200)
For the few device profiles that probe the device dynamically to determine
channel settings, the results end up in the dynamically-allocated
devc->channels instead of in the statically-configured
devc->device->channels field.

Previously this would crash by dereferencing a null ch_spec for the
device types that do dynamic channel configuration.

[ gsi: address minor style nits ]

src/hardware/scpi-pps/protocol.c

index 9609936a23ae0604df899b9ddc23482c12111715..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. */