On Tue, Jan 01, 2013 at 03:03:35PM +0000, Martin Ling wrote:
>
> - The hardware scan routine needs to be tamed. It should find a Rigol
> DS1xx2 if you have one plugged in, but it will also grab any other
> usbtmc device that responds to an "*IDN?" query. This is easy to fix
> but will have to wait till I have a device handy again.
...and here's a patch to fix that, tested on a DS1102D.
The driver should now safely ignore any device that isn't from Rigol, or
isn't in the list of known supported models.
Supported models are currently considered to be DS1052E, DS1052D,
DS1102E, and DS1102D.
Martin
diff --git a/hardware/rigol-ds1xx2/api.c b/hardware/rigol-ds1xx2/api.c
index a04fe77..65752b3 100644
--- a/hardware/rigol-ds1xx2/api.c
+++ b/hardware/rigol-ds1xx2/api.c
@@ -117,6 +117,13 @@ static const char *coupling[] = {
NULL,
};
+static const char *supported_models[] = {
+ "DS1052E",
+ "DS1102E",
+ "DS1052D",
+ "DS1102D"
+};
+
SR_PRIV struct sr_dev_driver 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;
const gchar *delimiter = ",";
gchar **tokens;
+ const char *manufacturer, *model, *version;
+ int num_models;
+ gboolean matched = FALSE;
char buf[256];
(void)options;
@@ -214,13 +224,38 @@ static GSList *hw_scan(GSList *options)
for (num_tokens = 0; tokens[num_tokens] != NULL; num_tokens++);
- if (!(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, tokens[0],
- num_tokens > 1 ? tokens[1] : NULL,
- num_tokens > 3 ? tokens[3] : NULL))) {
+ if (num_tokens < 4) {
+ g_strfreev(tokens);
+ g_free(device);
+ 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);
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel