]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds: Use rigol_ds_channel_start() function for legacy protocol too.
authorMartin Ling <redacted>
Fri, 27 Dec 2013 16:03:13 +0000 (17:03 +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 d4ae829ad76d96628a36c0d42778457284782b3a..5a78b67ce38ddb690307c8ed9eb1f2c9a073c4e5 100644 (file)
@@ -839,20 +839,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        std_session_send_df_header(cb_data, LOG_PREFIX);
 
        if (devc->model->protocol == PROTOCOL_LEGACY) {
+               devc->analog_frame_size = DS1000_ANALOG_LIVE_WAVEFORM_SIZE;
                /* Fetch the first frame. */
-               if (devc->enabled_analog_probes) {
-                       devc->analog_frame_size = DS1000_ANALOG_LIVE_WAVEFORM_SIZE;
+               if (devc->enabled_analog_probes)
                        devc->channel = devc->enabled_analog_probes->data;
-                       if (sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%d",
-                                       devc->channel->index + 1) != SR_OK)
-                               return SR_ERR;
-               } else {
+               else
                        devc->channel = devc->enabled_digital_probes->data;
-                       if (sr_scpi_send(sdi->conn, ":WAV:DATA? DIG") != SR_OK)
-                               return SR_ERR;
-               }
-
-               devc->num_frame_samples = 0;
+               if (rigol_ds_channel_start(sdi) != SR_OK)
+                       return SR_ERR;
        } else {
                if (devc->enabled_analog_probes) {
                        if (devc->data_source == DATA_SOURCE_MEMORY)
index 0b60cbe0c27b44a403ccd817ca0718b8e4492a71..b5379bb9bf0568523945cc7274625b52f92ac9f8 100644 (file)
@@ -327,17 +327,28 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
        sr_dbg("Starting reading data from channel %d",
               devc->channel->index + 1);
 
-       if (sr_scpi_send(sdi->conn, ":WAV:SOUR CHAN%d",
-                         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)
-                       return SR_ERR;
-               if (sr_scpi_send(sdi->conn, ":WAV:BEG") != SR_OK)
+       if (devc->model->protocol == PROTOCOL_LEGACY) {
+               if (devc->channel->type == SR_DF_LOGIC) {
+                       if (sr_scpi_send(sdi->conn, ":WAV:DATA? DIG") != SR_OK)
+                               return SR_ERR;
+               } else {
+                       if (sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%c",
+                                       devc->channel->name[2]) != SR_OK)
+                               return SR_ERR;
+               }
+       } else {
+               if (sr_scpi_send(sdi->conn, ":WAV:SOUR CHAN%d",
+                                 devc->channel->index + 1) != SR_OK)
                        return SR_ERR;
-               rigol_ds_set_wait_event(devc, WAIT_BLOCK);
-       } else
-               rigol_ds_set_wait_event(devc, WAIT_NONE);
+               if (devc->data_source != DATA_SOURCE_LIVE) {
+                       if (sr_scpi_send(sdi->conn, ":WAV:RES") != SR_OK)
+                               return SR_ERR;
+                       if (sr_scpi_send(sdi->conn, ":WAV:BEG") != SR_OK)
+                               return SR_ERR;
+                       rigol_ds_set_wait_event(devc, WAIT_BLOCK);
+               } else
+                       rigol_ds_set_wait_event(devc, WAIT_NONE);
+       }
 
        devc->num_frame_samples = 0;
        devc->num_block_bytes = 0;
@@ -564,19 +575,14 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                        /* We got the frame for the first analog channel, but
                         * there's a second analog channel. */
                        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->name[2]);
-                       }
+                       rigol_ds_channel_start(sdi);
                } else {
                        /* Done with both analog channels in this frame. */
                        if (devc->enabled_digital_probes
                                        && devc->channel != devc->enabled_digital_probes->data) {
                                /* Now we need to get the digital data. */
                                devc->channel = devc->enabled_digital_probes->data;
-                               sr_scpi_send(sdi->conn, ":WAV:DATA? DIG");
+                               rigol_ds_channel_start(sdi);
                        } else if (++devc->num_frames == devc->limit_frames) {
                                /* End of last frame. */
                                packet.type = SR_DF_END;
@@ -584,21 +590,15 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                sdi->driver->dev_acquisition_stop(sdi, cb_data);
                        } else {
                                /* Get the next frame, starting with the first analog channel. */
-                               if (devc->model->protocol == PROTOCOL_IEEE488_2) {
-                                       if (devc->enabled_analog_probes) {
-                                               devc->channel = devc->enabled_analog_probes->data;
-                                               rigol_ds_capture_start(sdi);
-                                       }
-                               } else {
-                                       if (devc->enabled_analog_probes) {
-                                               devc->channel = devc->enabled_analog_probes->data;
-                                               sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%c",
-                                                               devc->channel->name[2]);
-                                       } else {
-                                               devc->channel = devc->enabled_digital_probes->data;
-                                               sr_scpi_send(sdi->conn, ":WAV:DATA? DIG");
-                                       }
-                               }
+                               if (devc->enabled_analog_probes)
+                                       devc->channel = devc->enabled_analog_probes->data;
+                               else
+                                       devc->channel = devc->enabled_digital_probes->data;
+
+                               if (devc->model->protocol == PROTOCOL_LEGACY)
+                                       rigol_ds_channel_start(sdi);
+                               else
+                                       rigol_ds_capture_start(sdi);
                        }
                }
        }
index 65b3d7eb1c895050e3057353b0c3328456e4afc6..1889f02012e8054b9efa61302ff050810f8469ef 100644 (file)
@@ -135,6 +135,7 @@ struct dev_context {
 };
 
 SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi);
+SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi);
 SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data);
 SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi);