rigol-ds1xx2: More selective Rigol DS1xx2 scan
Patch submitted by Martin Ling.
This commit is contained in:
parent
5635705c83
commit
512bb890df
|
@ -117,6 +117,13 @@ static const char *coupling[] = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *supported_models[] = {
|
||||||
|
"DS1052E",
|
||||||
|
"DS1102E",
|
||||||
|
"DS1052D",
|
||||||
|
"DS1102D"
|
||||||
|
};
|
||||||
|
|
||||||
SR_PRIV struct sr_dev_driver rigol_ds1xx2_driver_info;
|
SR_PRIV struct sr_dev_driver rigol_ds1xx2_driver_info;
|
||||||
static struct sr_dev_driver *di = &rigol_ds1xx2_driver_info;
|
static struct sr_dev_driver *di = &rigol_ds1xx2_driver_info;
|
||||||
|
|
||||||
|
@ -180,6 +187,9 @@ static GSList *hw_scan(GSList *options)
|
||||||
int len, num_tokens, fd, i;
|
int len, num_tokens, fd, i;
|
||||||
const gchar *delimiter = ",";
|
const gchar *delimiter = ",";
|
||||||
gchar **tokens;
|
gchar **tokens;
|
||||||
|
const char *manufacturer, *model, *version;
|
||||||
|
int num_models;
|
||||||
|
gboolean matched = FALSE;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
(void)options;
|
(void)options;
|
||||||
|
@ -211,16 +221,42 @@ static GSList *hw_scan(GSList *options)
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
tokens = g_strsplit(buf, delimiter, 0);
|
tokens = g_strsplit(buf, delimiter, 0);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
sr_dbg("response: %s %d [%s]", device, len, buf);
|
||||||
|
|
||||||
for (num_tokens = 0; tokens[num_tokens] != NULL; num_tokens++);
|
for (num_tokens = 0; tokens[num_tokens] != NULL; num_tokens++);
|
||||||
|
|
||||||
if (!(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, tokens[0],
|
if (num_tokens < 4) {
|
||||||
num_tokens > 1 ? tokens[1] : NULL,
|
|
||||||
num_tokens > 3 ? tokens[3] : NULL))) {
|
|
||||||
g_strfreev(tokens);
|
g_strfreev(tokens);
|
||||||
g_free(device);
|
g_free(device);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manufacturer = tokens[0];
|
||||||
|
model = tokens[1];
|
||||||
|
version = tokens[3];
|
||||||
|
|
||||||
|
if (strcmp(manufacturer, "Rigol Technologies")) {
|
||||||
|
g_strfreev(tokens);
|
||||||
|
g_free(device);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
num_models = sizeof(supported_models) / sizeof(supported_models[0]);
|
||||||
|
|
||||||
|
for (i = 0; i < num_models; i++) {
|
||||||
|
if (!strcmp(model, supported_models[i])) {
|
||||||
|
matched = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!matched || !(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE,
|
||||||
|
manufacturer, model, version))) {
|
||||||
|
g_strfreev(tokens);
|
||||||
|
g_free(device);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
g_strfreev(tokens);
|
g_strfreev(tokens);
|
||||||
|
|
||||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
||||||
|
|
Loading…
Reference in New Issue