]> sigrok.org Git - libsigrok.git/commitdiff
scpi: Don't process received data of zero length
authorGerhard Sittig <redacted>
Fri, 30 Dec 2016 12:16:04 +0000 (13:16 +0100)
committerUwe Hermann <redacted>
Sat, 7 Jan 2017 14:51:47 +0000 (15:51 +0100)
When nothing was received in a read attempt, we need not adjust the
buffered data's read position nor the glib string object's size. Skip
any processing for empty input, just keep checking for timeouts.

src/scpi/scpi.c

index 222201ce279b5ca8fb3950cb6c7060d66154134a..efa839de748972052898156ecd1d4f087be3d3b6 100644 (file)
@@ -448,9 +448,9 @@ SR_PRIV int sr_scpi_get_data(struct sr_scpi_dev_inst *scpi,
                        return SR_ERR;
                } else if (len > 0) {
                        laststart = g_get_monotonic_time();
+                       offset += len;
+                       g_string_set_size(response, offset);
                }
-               offset += len;
-               g_string_set_size(response, offset);
                elapsed_ms = (g_get_monotonic_time() - laststart) / 1000;
                if (elapsed_ms >= scpi->read_timeout_ms) {
                        sr_err("Timed out waiting for SCPI response.");