From: Martin Ling Date: Fri, 27 Dec 2013 16:03:13 +0000 (+0100) Subject: rigol-ds: Use rigol_ds_channel_start() function for legacy protocol too. X-Git-Tag: libsigrok-0.3.0~393 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=677f85d00bacfce05ad50ec2e9f6d7c47a761a43;p=libsigrok.git rigol-ds: Use rigol_ds_channel_start() function for legacy protocol too. --- diff --git a/hardware/rigol-ds/api.c b/hardware/rigol-ds/api.c index d4ae829a..5a78b67c 100644 --- a/hardware/rigol-ds/api.c +++ b/hardware/rigol-ds/api.c @@ -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) diff --git a/hardware/rigol-ds/protocol.c b/hardware/rigol-ds/protocol.c index 0b60cbe0..b5379bb9 100644 --- a/hardware/rigol-ds/protocol.c +++ b/hardware/rigol-ds/protocol.c @@ -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); } } } diff --git a/hardware/rigol-ds/protocol.h b/hardware/rigol-ds/protocol.h index 65b3d7eb..1889f020 100644 --- a/hardware/rigol-ds/protocol.h +++ b/hardware/rigol-ds/protocol.h @@ -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);