]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds: Rename and document some confusingly named variables.
authorMartin Ling <redacted>
Fri, 27 Dec 2013 14:59:25 +0000 (15:59 +0100)
committerBert Vermeulen <redacted>
Fri, 27 Dec 2013 21:47:42 +0000 (22:47 +0100)
hardware/rigol-ds/api.c
hardware/rigol-ds/protocol.c
hardware/rigol-ds/protocol.h

index 6b92fa8de091ec5a943402fc6a8bd25f0a754abe..d4ae829ad76d96628a36c0d42778457284782b3a 100644 (file)
@@ -842,17 +842,17 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
                /* Fetch the first frame. */
                if (devc->enabled_analog_probes) {
                        devc->analog_frame_size = DS1000_ANALOG_LIVE_WAVEFORM_SIZE;
-                       devc->channel_frame = devc->enabled_analog_probes->data;
+                       devc->channel = devc->enabled_analog_probes->data;
                        if (sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%d",
-                                       devc->channel_frame->index + 1) != SR_OK)
+                                       devc->channel->index + 1) != SR_OK)
                                return SR_ERR;
                } else {
-                       devc->channel_frame = devc->enabled_digital_probes->data;
+                       devc->channel = devc->enabled_digital_probes->data;
                        if (sr_scpi_send(sdi->conn, ":WAV:DATA? DIG") != SR_OK)
                                return SR_ERR;
                }
 
-               devc->num_frame_bytes = 0;
+               devc->num_frame_samples = 0;
        } else {
                if (devc->enabled_analog_probes) {
                        if (devc->data_source == DATA_SOURCE_MEMORY)
@@ -872,7 +872,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
                                        return SR_ERR;
                        } else
                                devc->analog_frame_size = DS2000_ANALOG_LIVE_WAVEFORM_SIZE;
-                       devc->channel_frame = devc->enabled_analog_probes->data;
+                       devc->channel = devc->enabled_analog_probes->data;
                        if (rigol_ds_capture_start(sdi) != SR_OK)
                                return SR_ERR;
                }
index af369e9cf5881234d316c15faa1237b9e9999b3b..0b60cbe0c27b44a403ccd817ca0718b8e4492a71 100644 (file)
@@ -217,7 +217,7 @@ static int rigol_ds_check_stop(const struct sr_dev_inst *sdi)
                return SR_ERR;
 
        if (sr_scpi_send(sdi->conn, ":WAV:SOUR CHAN%d",
-                         devc->channel_frame->index + 1) != SR_OK)
+                         devc->channel->index + 1) != SR_OK)
                return SR_ERR;
        /* Check that the number of samples will be accepted */
        if (sr_scpi_send(sdi->conn, ":WAV:POIN %d;*OPC", devc->analog_frame_size) != SR_OK)
@@ -325,10 +325,10 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
                return SR_ERR;
 
        sr_dbg("Starting reading data from channel %d",
-              devc->channel_frame->index + 1);
+              devc->channel->index + 1);
 
        if (sr_scpi_send(sdi->conn, ":WAV:SOUR CHAN%d",
-                         devc->channel_frame->index + 1) != SR_OK)
+                         devc->channel->index + 1) != SR_OK)
                return SR_ERR;
        if (devc->data_source != DATA_SOURCE_LIVE) {
                if (sr_scpi_send(sdi->conn, ":WAV:RES") != SR_OK)
@@ -339,7 +339,7 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
        } else
                rigol_ds_set_wait_event(devc, WAIT_NONE);
 
-       devc->num_frame_bytes = 0;
+       devc->num_frame_samples = 0;
        devc->num_block_bytes = 0;
 
        return SR_OK;
@@ -452,7 +452,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                 * appear eventually.
                                 */
                                if (devc->data_source == DATA_SOURCE_LIVE
-                                   && (unsigned)len < devc->num_frame_bytes) {
+                                   && (unsigned)len < devc->num_frame_samples) {
                                        sr_dbg("Discarding short data block");
                                        sr_scpi_read(scpi, (char *)devc->buffer, len + 1);
                                        return TRUE;
@@ -462,7 +462,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                        }
                }
 
-               probe = devc->channel_frame;
+               probe = devc->channel;
                if (devc->model->protocol == PROTOCOL_IEEE488_2) {
                        len = devc->num_block_bytes - devc->num_block_read;
                        len = sr_scpi_read(scpi, (char *)devc->buffer,
@@ -474,13 +474,13 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                                DS1000_ANALOG_LIVE_WAVEFORM_SIZE) :
                                        DIGITAL_WAVEFORM_SIZE;
                        len = sr_scpi_read(scpi, (char *)devc->buffer,
-                                       waveform_size - devc->num_frame_bytes);
+                                       waveform_size - devc->num_frame_samples);
                }
                sr_dbg("Received %d bytes.", len);
                if (len == -1)
                        return TRUE;
 
-               if (devc->num_frame_bytes == 0) {
+               if (devc->num_frame_samples == 0) {
                        /* Start of a new frame. */
                        packet.type = SR_DF_FRAME_BEGIN;
                        sr_session_send(sdi, &packet);
@@ -522,13 +522,13 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                        sr_dbg("%d of %d block bytes read", devc->num_block_read, devc->num_block_bytes);
                        }
 
-                       devc->num_frame_bytes += len;
+                       devc->num_frame_samples += len;
 
-                       if (devc->num_frame_bytes < devc->analog_frame_size)
+                       if (devc->num_frame_samples < devc->analog_frame_size)
                                /* Don't have the whole frame yet. */
                                return TRUE;
 
-                       sr_dbg("Frame completed, %d samples", devc->num_frame_bytes);
+                       sr_dbg("Frame completed, %d samples", devc->num_frame_samples);
                } else {
                        logic.length = len - 10;
                        logic.unitsize = 2;
@@ -546,7 +546,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                packet.type = SR_DF_FRAME_END;
                sr_session_send(sdi, &packet);
                if (devc->model->protocol == PROTOCOL_LEGACY)
-                       devc->num_frame_bytes = 0;
+                       devc->num_frame_samples = 0;
                else {
                        /* Signal end of data download to scope */
                        if (devc->data_source != DATA_SOURCE_LIVE)
@@ -559,23 +559,23 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                }
 
                if (devc->enabled_analog_probes
-                               && devc->channel_frame == devc->enabled_analog_probes->data
+                               && devc->channel == devc->enabled_analog_probes->data
                                && devc->enabled_analog_probes->next != NULL) {
                        /* We got the frame for the first analog channel, but
                         * there's a second analog channel. */
-                       devc->channel_frame = devc->enabled_analog_probes->next->data;
+                       devc->channel = devc->enabled_analog_probes->next->data;
                        if (devc->model->protocol == PROTOCOL_IEEE488_2) {
                                rigol_ds_channel_start(sdi);
                        } else {
                                sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%c",
-                                               devc->channel_frame->name[2]);
+                                               devc->channel->name[2]);
                        }
                } else {
                        /* Done with both analog channels in this frame. */
                        if (devc->enabled_digital_probes
-                                       && devc->channel_frame != devc->enabled_digital_probes->data) {
+                                       && devc->channel != devc->enabled_digital_probes->data) {
                                /* Now we need to get the digital data. */
-                               devc->channel_frame = devc->enabled_digital_probes->data;
+                               devc->channel = devc->enabled_digital_probes->data;
                                sr_scpi_send(sdi->conn, ":WAV:DATA? DIG");
                        } else if (++devc->num_frames == devc->limit_frames) {
                                /* End of last frame. */
@@ -586,16 +586,16 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                /* Get the next frame, starting with the first analog channel. */
                                if (devc->model->protocol == PROTOCOL_IEEE488_2) {
                                        if (devc->enabled_analog_probes) {
-                                               devc->channel_frame = devc->enabled_analog_probes->data;
+                                               devc->channel = devc->enabled_analog_probes->data;
                                                rigol_ds_capture_start(sdi);
                                        }
                                } else {
                                        if (devc->enabled_analog_probes) {
-                                               devc->channel_frame = devc->enabled_analog_probes->data;
+                                               devc->channel = devc->enabled_analog_probes->data;
                                                sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%c",
-                                                               devc->channel_frame->name[2]);
+                                                               devc->channel->name[2]);
                                        } else {
-                                               devc->channel_frame = devc->enabled_digital_probes->data;
+                                               devc->channel = devc->enabled_digital_probes->data;
                                                sr_scpi_send(sdi->conn, ":WAV:DATA? DIG");
                                        }
                                }
index d1c67fd8af2754e5edb7752c5f386de20abc54c1..65b3d7eb1c895050e3057353b0c3328456e4afc6 100644 (file)
@@ -114,10 +114,13 @@ struct dev_context {
        char *coupling[2];
 
        /* Operational state */
+
+       /* Number of frames received in total. */
        uint64_t num_frames;
-       /* FIXME: misnomer, actually this is number of frame samples? */
-       uint64_t num_frame_bytes;
-       struct sr_probe *channel_frame;
+       /* The channel we are currently receiving data for. */
+       struct sr_probe *channel;
+       /* Number of samples received in current frame. */
+       uint64_t num_frame_samples;
        /* Number of bytes in current data block, if 0 block header expected */
        uint64_t num_block_bytes;
        /* Number of data block bytes already read */