]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds: Send FRAME_BEGIN and FRAME_END per frame, not per channel.
authorMartin Ling <redacted>
Fri, 17 Jan 2014 15:07:15 +0000 (15:07 +0000)
committerMartin Ling <redacted>
Mon, 20 Jan 2014 00:24:57 +0000 (00:24 +0000)
hardware/rigol-ds/api.c
hardware/rigol-ds/protocol.c
hardware/rigol-ds/protocol.h

index 04196a46c4c33c728616bd9196e5df7efeef9b51..52a59a975d31e2f2b4eb2b6c5da4079fc0851823 100644 (file)
@@ -807,6 +807,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        struct sr_scpi_dev_inst *scpi;
        struct dev_context *devc;
        struct sr_probe *probe;
+       struct sr_datafeed_packet packet;
        GSList *l;
 
        if (sdi->status != SR_ST_ACTIVE)
@@ -908,6 +909,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
                }
        }
 
+       /* Start of first frame. */
+       packet.type = SR_DF_FRAME_BEGIN;
+       sr_session_send(cb_data, &packet);
+
        return SR_OK;
 }
 
index 4a3f80eb6b2d1adc594c72287f4e8d034af1a7ca..4f4ff412b015d7240b37c08ccb5fb30ffe346b02 100644 (file)
@@ -351,7 +351,7 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
                        rigol_ds_set_wait_event(devc, WAIT_NONE);
        }
 
-       devc->num_frame_samples = 0;
+       devc->num_channel_bytes = 0;
        devc->num_block_bytes = 0;
 
        return SR_OK;
@@ -448,7 +448,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
 
                expected_data_bytes = probe->type == SR_PROBE_ANALOG ?
                                devc->analog_frame_size : devc->digital_frame_size;
-               
+
                if (devc->num_block_bytes == 0 &&
                    devc->model->series >= RIGOL_DS1000Z) {
                                if (sr_scpi_send(sdi->conn, ":WAV:DATA?") != SR_OK)
@@ -494,12 +494,6 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
 
                devc->num_block_read += len;
 
-               if (devc->num_frame_samples == 0) {
-                       /* Start of a new frame. */
-                       packet.type = SR_DF_FRAME_BEGIN;
-                       sr_session_send(sdi, &packet);
-               }
-
                if (probe->type == SR_PROBE_ANALOG) {
                        vref = devc->vert_reference[probe->index];
                        vdiv = devc->vdiv[probe->index] / 25.6;
@@ -551,16 +545,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_samples += len;
+               devc->num_channel_bytes += len;
 
-               if (devc->num_frame_samples < expected_data_bytes)
-                       /* Don't have the whole frame yet. */
+               if (devc->num_channel_bytes < expected_data_bytes)
+                       /* Don't have the full data for this channel yet, re-run. */
                        return TRUE;
 
-               /* End of the frame. */
-               sr_dbg("Frame completed, %d samples", devc->num_frame_samples);
-               packet.type = SR_DF_FRAME_END;
-               sr_session_send(sdi, &packet);
+               /* End of data for this channel. */
                if (devc->model->series >= RIGOL_DS1000Z) {
                        /* Signal end of data download to scope */
                        if (devc->data_source != DATA_SOURCE_LIVE)
@@ -585,19 +576,30 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                /* Now we need to get the digital data. */
                                devc->channel_entry = devc->enabled_digital_probes;
                                rigol_ds_channel_start(sdi);
-                       } else if (++devc->num_frames == devc->limit_frames) {
-                               sdi->driver->dev_acquisition_stop(sdi, cb_data);
                        } else {
-                               /* Get the next frame, starting with the first analog channel. */
-                               if (devc->enabled_analog_probes)
-                                       devc->channel_entry = devc->enabled_analog_probes;
-                               else
-                                       devc->channel_entry = devc->enabled_digital_probes;
-
-                               if (devc->model->series < RIGOL_DS1000Z)
-                                       rigol_ds_channel_start(sdi);
-                               else
-                                       rigol_ds_capture_start(sdi);
+                               /* Done with this frame. */
+                               packet.type = SR_DF_FRAME_END;
+                               sr_session_send(cb_data, &packet);
+
+                               if (++devc->num_frames == devc->limit_frames) {
+                                       /* Last frame, stop capture. */
+                                       sdi->driver->dev_acquisition_stop(sdi, cb_data);
+                               } else {
+                                       /* Get the next frame, starting with the first analog channel. */
+                                       if (devc->enabled_analog_probes)
+                                               devc->channel_entry = devc->enabled_analog_probes;
+                                       else
+                                               devc->channel_entry = devc->enabled_digital_probes;
+
+                                       if (devc->model->series < RIGOL_DS1000Z)
+                                               rigol_ds_channel_start(sdi);
+                                       else
+                                               rigol_ds_capture_start(sdi);
+
+                                       /* Start of next frame. */
+                                       packet.type = SR_DF_FRAME_BEGIN;
+                                       sr_session_send(cb_data, &packet);
+                               }
                        }
                }
        }
index 4d502a5a8b0e25e8d78c23a4bbdd65edee30f3f6..121b3ea3f77dcd649e15390299962c74dabfe7c7 100644 (file)
@@ -132,8 +132,8 @@ struct dev_context {
        uint64_t num_frames;
        /* GSList entry for the current channel. */
        GSList *channel_entry;
-       /* Number of samples received in current frame. */
-       uint64_t num_frame_samples;
+       /* Number of bytes received for current channel. */
+       uint64_t num_channel_bytes;
        /* Number of bytes in current data block, if 0 block header expected */
        uint64_t num_block_bytes;
        /* Number of data block bytes already read */