We're in luck, the protocol is quite similar.
Attached is a patch adding support for GDS-2000 series oscilloscopes.
Tested on GDS-2102 and GDS-2104.
Should we rename it gwinstek-gds-scope?
On Thu, Jun 21, 2018 at 7:50 PM, Uwe Hermann <u...@hermann-uwe.de> wrote:
> Hi,
>
> On Wed, Jun 20, 2018 at 09:52:57PM -0500, Richard Allen wrote:
>> I have a GW Instek GDS-2102, a member of the GDS-2000 series, that I
>> would like to support with sigrok. API-wise, these are very similar to
>> the GDS-800 series that is already supported. Would it be best to
>> augment the GDS-800 driver to handle GDS-2000, or create a new
>> GDS-2000 driver?
>
> If the protocol/driver is similar, adding support within the existing
> GDS-800 driver is usually better, yes. A new driver would mean way too
> much duplicated code in such a case.
>
>
> Cheers, Uwe.
> --
> http://hermann-uwe.de | http://randomprojects.org | http://sigrok.org
From 6a123400d637bc2df3ab611373838dc613a2ba0e Mon Sep 17 00:00:00 2001
From: Richard <rsa...@rsaxvc.net>
Date: Thu, 21 Jun 2018 21:24:23 -0500
Subject: [PATCH] gwinstek-gds-800: Support GDS-2000 Series
Tested on GDS-2102 and GDS-2104 oscilloscopes.
---
src/hardware/gwinstek-gds-800/api.c | 20 ++++++++++++++++++--
src/hardware/gwinstek-gds-800/protocol.c | 5 ++---
src/hardware/gwinstek-gds-800/protocol.h | 4 +++-
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/hardware/gwinstek-gds-800/api.c b/src/hardware/gwinstek-gds-800/api.c
index 2926bf07..8e4209f6 100644
--- a/src/hardware/gwinstek-gds-800/api.c
+++ b/src/hardware/gwinstek-gds-800/api.c
@@ -49,7 +49,8 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
}
if (strcmp(hw_info->manufacturer, "GW") != 0 ||
- strncmp(hw_info->model, "GDS-8", 5) != 0) {
+ !(strncmp(hw_info->model, "GDS-8", 5) == 0 ||
+ strncmp(hw_info->model, "GDS-2", 5) == 0 )) {
sr_scpi_hw_info_free(hw_info);
return NULL;
}
@@ -71,15 +72,30 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
devc->frame_limit = 1;
devc->sample_rate = 0.0;
devc->df_started = FALSE;
+ if ( strncmp(sdi->model, "GDS-2", 5) == 0 &&
+ strlen(sdi->model) == 8 &&
+ sdi->model[7] == '4' ) {
+ devc->num_acq_channel = 4;
+ } else {
+ devc->num_acq_channel = 2;
+ }
sdi->priv = devc;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1");
sr_channel_new(sdi, 1, SR_CHANNEL_ANALOG, TRUE, "CH2");
+ if( devc->num_acq_channel == 4 ) {
+ sr_channel_new(sdi, 2, SR_CHANNEL_ANALOG, TRUE, "CH3");
+ sr_channel_new(sdi, 3, SR_CHANNEL_ANALOG, TRUE, "CH4");
+ }
cg = g_malloc0(sizeof(struct sr_channel_group));
cg->name = g_strdup("");
cg->channels = g_slist_append(cg->channels, g_slist_nth_data(sdi->channels, 0));
cg->channels = g_slist_append(cg->channels, g_slist_nth_data(sdi->channels, 1));
+ if( devc->num_acq_channel == 4 ) {
+ cg->channels = g_slist_append(cg->channels, g_slist_nth_data(sdi->channels, 2));
+ cg->channels = g_slist_append(cg->channels, g_slist_nth_data(sdi->channels, 3));
+ }
cg->priv = NULL;
sdi->channel_groups = g_slist_append(NULL, cg);
@@ -210,7 +226,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
static struct sr_dev_driver gwinstek_gds_800_driver_info = {
.name = "gwinstek-gds-800",
- .longname = "GW Instek GDS-800 series",
+ .longname = "GW Instek GDS-800/2000 series",
.api_version = 1,
.init = std_init,
.cleanup = std_cleanup,
diff --git a/src/hardware/gwinstek-gds-800/protocol.c b/src/hardware/gwinstek-gds-800/protocol.c
index ce9e8d41..642d971b 100644
--- a/src/hardware/gwinstek-gds-800/protocol.c
+++ b/src/hardware/gwinstek-gds-800/protocol.c
@@ -21,7 +21,6 @@
#include <math.h>
#include <string.h>
-#define ANALOG_CHANNELS 2
#define VERTICAL_DIVISIONS 10
static int read_data(struct sr_dev_inst *sdi,
@@ -129,7 +128,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
devc->cur_rcv_buffer_position = 0;
} else {
/* All channels acquired. */
- if (devc->cur_acq_channel == ANALOG_CHANNELS - 1) {
+ if (devc->cur_acq_channel == devc->num_acq_channel - 1) {
sr_spew("All channels acquired.");
if (devc->cur_acq_frame == devc->frame_limit - 1) {
@@ -260,7 +259,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
g_slist_free(analog.meaning->channels);
/* All channels acquired. */
- if (devc->cur_acq_channel == ANALOG_CHANNELS - 1) {
+ if (devc->cur_acq_channel == devc->num_acq_channel - 1) {
sr_spew("All channels acquired.");
if (devc->cur_acq_frame == devc->frame_limit - 1) {
diff --git a/src/hardware/gwinstek-gds-800/protocol.h b/src/hardware/gwinstek-gds-800/protocol.h
index d5c2e5a0..8b421331 100644
--- a/src/hardware/gwinstek-gds-800/protocol.h
+++ b/src/hardware/gwinstek-gds-800/protocol.h
@@ -29,7 +29,8 @@
#define LOG_PREFIX "gwinstek-gds-800"
#define MAX_SAMPLES 125000
-#define MAX_RCV_BUFFER_SIZE (MAX_SAMPLES * 2)
+#define MAX_CHANNELS 4
+#define MAX_RCV_BUFFER_SIZE (MAX_SAMPLES * MAX_CHANNELS)
enum gds_state
{
@@ -49,6 +50,7 @@ struct dev_context {
uint64_t cur_acq_frame;
uint64_t frame_limit;
int cur_acq_channel;
+ int num_acq_channel;
int cur_rcv_buffer_position;
char rcv_buffer[MAX_RCV_BUFFER_SIZE];
int data_size_digits;
--
2.11.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel