]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/rigol-ds/api.c
rigol-ds: Get correct samplerate for Memory and Segmented sources
[libsigrok.git] / src / hardware / rigol-ds / api.c
index 6846068965c4b9a31aa13de4786ee57ade64f4d2..af15587db2e36fef02c2a6c1963e01ad56e81542 100644 (file)
@@ -242,6 +242,7 @@ static const struct rigol_ds_model supported_models[] = {
        {SERIES(DS1000), "DS1052E", {5, 1000000000}, CH_INFO(2, false), std_cmd},
        {SERIES(DS1000), "DS1102E", {2, 1000000000}, CH_INFO(2, false), std_cmd},
        {SERIES(DS1000), "DS1152E", {2, 1000000000}, CH_INFO(2, false), std_cmd},
+       {SERIES(DS1000), "DS1152E-EDU", {2, 1000000000}, CH_INFO(2, false), std_cmd},
        {SERIES(DS1000), "DS1052D", {5, 1000000000}, CH_INFO(2, true), std_cmd},
        {SERIES(DS1000), "DS1102D", {2, 1000000000}, CH_INFO(2, true), std_cmd},
        {SERIES(DS1000), "DS1152D", {2, 1000000000}, CH_INFO(2, true), std_cmd},
@@ -274,6 +275,7 @@ static const struct rigol_ds_model supported_models[] = {
        {SERIES(DS1000Z), "DS1104Z-S", {5, 1000000000}, CH_INFO(4, false), std_cmd},
        {SERIES(DS1000Z), "DS1074Z Plus", {5, 1000000000}, CH_INFO(4, false), std_cmd},
        {SERIES(DS1000Z), "DS1104Z Plus", {5, 1000000000}, CH_INFO(4, false), std_cmd},
+       {SERIES(DS1000Z), "DS1202Z-E", {2, 1000000000}, CH_INFO(2, false), std_cmd},
        {SERIES(DS1000Z), "MSO1074Z", {5, 1000000000}, CH_INFO(4, true), std_cmd},
        {SERIES(DS1000Z), "MSO1104Z", {5, 1000000000}, CH_INFO(4, true), std_cmd},
        {SERIES(DS1000Z), "MSO1074Z-S", {5, 1000000000}, CH_INFO(4, true), std_cmd},
@@ -524,7 +526,6 @@ static int config_get(uint32_t key, GVariant **data,
        struct dev_context *devc;
        struct sr_channel *ch;
        const char *tmp_str;
-       uint64_t samplerate;
        int analog_channel = -1;
        float smallest_diff = INFINITY;
        int idx = -1;
@@ -568,14 +569,7 @@ static int config_get(uint32_t key, GVariant **data,
                        *data = g_variant_new_string("Segmented");
                break;
        case SR_CONF_SAMPLERATE:
-               if (devc->data_source == DATA_SOURCE_LIVE) {
-                       samplerate = analog_frame_size(sdi) /
-                               (devc->timebase * devc->model->series->num_horizontal_divs);
-                       *data = g_variant_new_uint64(samplerate);
-               } else {
-                       sr_dbg("Unknown data source: %d.", devc->data_source);
-                       return SR_ERR_NA;
-               }
+               *data = g_variant_new_uint64(devc->sample_rate);
                break;
        case SR_CONF_TRIGGER_SOURCE:
                if (!strcmp(devc->trigger_source, "ACL"))
@@ -877,7 +871,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        struct sr_scpi_dev_inst *scpi;
        struct dev_context *devc;
        struct sr_channel *ch;
-       struct sr_datafeed_packet packet;
        gboolean some_digital;
        GSList *l;
        char *cmd;
@@ -989,12 +982,25 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
        devc->channel_entry = devc->enabled_channels;
 
+       if (devc->data_source == DATA_SOURCE_LIVE)
+               devc->sample_rate = analog_frame_size(sdi) / 
+                       (devc->timebase * devc->model->series->num_horizontal_divs);
+       else {
+               float xinc;
+               if (devc->model->series->protocol >= PROTOCOL_V3 && 
+                               sr_scpi_get_float(sdi->conn, "WAV:XINC?", &xinc) != SR_OK) {
+                       sr_err("Couldn't get sampling rate");
+                       return SR_ERR;
+               }
+               devc->sample_rate = 1. / xinc;
+       }
+
+
        if (rigol_ds_capture_start(sdi) != SR_OK)
                return SR_ERR;
 
        /* Start of first frame. */
-       packet.type = SR_DF_FRAME_BEGIN;
-       sr_session_send(sdi, &packet);
+       std_session_send_df_frame_begin(sdi);
 
        return SR_OK;
 }