From: Valentin Ochs Date: Thu, 24 May 2018 20:30:05 +0000 (+0200) Subject: rigol-ds: Initial patch for Rigol DS4000 support X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6b04525ba2ffe72742e5cbe25da8bc3dc65b2453;p=libsigrok.git rigol-ds: Initial patch for Rigol DS4000 support This fixes bug #1208. --- diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index 9514d6db..b34aeee6 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -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; diff --git a/src/hardware/rigol-ds/protocol.c b/src/hardware/rigol-ds/protocol.c index 1344c8b4..4a6c6d62 100644 --- a/src/hardware/rigol-ds/protocol.c +++ b/src/hardware/rigol-ds/protocol.c @@ -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; diff --git a/src/hardware/rigol-ds/protocol.h b/src/hardware/rigol-ds/protocol.h index 840b1b27..b8eb54e7 100644 --- a/src/hardware/rigol-ds/protocol.h +++ b/src/hardware/rigol-ds/protocol.h @@ -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; diff --git a/src/scpi/scpi_usbtmc_libusb.c b/src/scpi/scpi_usbtmc_libusb.c index dc17c872..c1d4029c 100644 --- a/src/scpi/scpi_usbtmc_libusb.c +++ b/src/scpi/scpi_usbtmc_libusb.c @@ -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 */