]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds: Initial patch for Rigol DS4000 support
authorValentin Ochs <redacted>
Thu, 24 May 2018 20:30:05 +0000 (22:30 +0200)
committerUwe Hermann <redacted>
Thu, 21 Jun 2018 23:55:02 +0000 (01:55 +0200)
This fixes bug #1208.

src/hardware/rigol-ds/api.c
src/hardware/rigol-ds/protocol.c
src/hardware/rigol-ds/protocol.h
src/scpi/scpi_usbtmc_libusb.c

index 9514d6db888682c9567051c4a8d622359e521065..b34aeee6fea8d834943168b87fa05a06eae87e5f 100644 (file)
@@ -171,6 +171,7 @@ enum series {
        DS2000A,
        DSO1000,
        DS1000Z,
+       DS4000,
 };
 
 /* short name, full name */
@@ -195,6 +196,8 @@ static const struct rigol_ds_series supported_series[] = {
                {50, 1}, {2, 1000}, 12, 600, 20480},
        [DS1000Z] = {VENDOR(RIGOL), "DS1000Z", PROTOCOL_V4, FORMAT_IEEE488_2,
                {50, 1}, {1, 1000}, 12, 1200, 12000000},
+       [DS4000] = {VENDOR(RIGOL), "DS4000", PROTOCOL_V4, FORMAT_IEEE488_2,
+               {1000, 1}, {1, 1000}, 14, 1400, 14000},
 };
 
 #define SERIES(x) &supported_series[x]
@@ -252,6 +255,7 @@ static const struct rigol_ds_model supported_models[] = {
        {SERIES(DS1000Z), "MSO1104Z", {5, 1000000000}, CH_INFO(4, true)},
        {SERIES(DS1000Z), "MSO1074Z-S", {5, 1000000000}, CH_INFO(4, true)},
        {SERIES(DS1000Z), "MSO1104Z-S", {5, 1000000000}, CH_INFO(4, true)},
+       {SERIES(DS4000), "DS4024", {1, 1000000000}, CH_INFO(4, false)},
 };
 
 static struct sr_dev_driver rigol_ds_driver_info;
index 1344c8b420542398286f09b34f4c7345e15cd5ee..4a6c6d620f8e50c0b002df333f9f8a57aa0872fa 100644 (file)
@@ -474,10 +474,19 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
 
        if (devc->model->series->protocol >= PROTOCOL_V3 &&
                        ch->type == SR_CHANNEL_ANALOG) {
+               /* Vertical increment. */
+               if (sr_scpi_get_float(sdi->conn, ":WAV:YINC?",
+                               &devc->vert_inc[ch->index]) != SR_OK)
+                       /* Vertical origin. */
+                       if (sr_scpi_get_float(sdi->conn, ":WAV:YOR?",
+                               &devc->vert_origin[ch->index]) != SR_OK)
+                               return SR_ERR;
                /* Vertical reference. */
                if (sr_scpi_get_int(sdi->conn, ":WAV:YREF?",
                                &devc->vert_reference[ch->index]) != SR_OK)
                        return SR_ERR;
+       } else if (ch->type == SR_CHANNEL_ANALOG) {
+               devc->vert_inc[ch->index] = devc->vdiv[ch->index] / 25.6;
        }
 
        rigol_ds_set_wait_event(devc, WAIT_BLOCK);
@@ -557,7 +566,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
        struct sr_analog_meaning meaning;
        struct sr_analog_spec spec;
        struct sr_datafeed_logic logic;
-       double vdiv, offset;
+       double vdiv, offset, origin;
        int len, i, vref;
        struct sr_channel *ch;
        gsize expected_data_bytes;
@@ -677,11 +686,12 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
 
        if (ch->type == SR_CHANNEL_ANALOG) {
                vref = devc->vert_reference[ch->index];
-               vdiv = devc->vdiv[ch->index] / 25.6;
+               vdiv = devc->vert_inc[ch->index];
+               origin = devc->vert_origin[ch->index];
                offset = devc->vert_offset[ch->index];
                if (devc->model->series->protocol >= PROTOCOL_V3)
                        for (i = 0; i < len; i++)
-                               devc->data[i] = ((int)devc->buffer[i] - vref) * vdiv - offset;
+                               devc->data[i] = ((int)devc->buffer[i] - vref - origin) * vdiv;
                else
                        for (i = 0; i < len; i++)
                                devc->data[i] = (128 - devc->buffer[i]) * vdiv - offset;
index 840b1b274e2b17a0f917cf772bd6d4abfbd41e46..b8eb54e7a15f16264af4e67f2656d082b77c6ef5 100644 (file)
@@ -120,7 +120,9 @@ struct dev_context {
        float attenuation[MAX_ANALOG_CHANNELS];
        float vdiv[MAX_ANALOG_CHANNELS];
        int vert_reference[MAX_ANALOG_CHANNELS];
+       float vert_origin[MAX_ANALOG_CHANNELS];
        float vert_offset[MAX_ANALOG_CHANNELS];
+       float vert_inc[MAX_ANALOG_CHANNELS];
        char *trigger_source;
        float horiz_triggerpos;
        char *trigger_slope;
index dc17c8722b44c00100ffa4a700e1769bd6787205..c1d4029ca1e89fedaec057fb7a28d8e7639a3805 100644 (file)
@@ -105,6 +105,7 @@ struct usbtmc_blacklist {
 static struct usbtmc_blacklist blacklist_remote[] = {
        { 0x1ab1, 0x0588 }, /* Rigol DS1000 series */
        { 0x1ab1, 0x04b0 }, /* Rigol DS2000 series */
+       { 0x1ab1, 0x04b1 }, /* Rigol DS4000 series */
        { 0x0957, 0x0588 }, /* Agilent DSO1000 series (rebadged Rigol DS1000) */
        { 0x0b21, 0xffff }, /* All Yokogawa devices */
        { 0xf4ec, 0xffff }, /* All Siglent SDS devices */