cli: use probe numbers starting from 0
authorBert Vermeulen <bert@biot.com>
Mon, 23 Jul 2012 01:03:07 +0000 (03:03 +0200)
committerBert Vermeulen <bert@biot.com>
Fri, 3 Aug 2012 09:28:59 +0000 (11:28 +0200)
parsers.c
sigrok-cli.c

index 8d0bbe5da8df7803c1f74855db7e26617d843897..794e4b56c3e73d36dbb0b8ed9fa342fa2f2df982 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -51,7 +51,7 @@ char **parse_probestring(int max_probes, const char *probestring)
 
                        b = strtol(range[0], NULL, 10);
                        e = strtol(range[1], NULL, 10);
-                       if (b < 1 || e > max_probes || b >= e) {
+                       if (b < 0 || e >= max_probes || b >= e) {
                                g_critical("Invalid probe range '%s'.", tokens[i]);
                                error = TRUE;
                                break;
@@ -59,24 +59,24 @@ char **parse_probestring(int max_probes, const char *probestring)
 
                        while (b <= e) {
                                snprintf(str, 7, "%d", b);
-                               probelist[b - 1] = g_strdup(str);
+                               probelist[b] = g_strdup(str);
                                b++;
                        }
                } else {
                        tmp = strtol(tokens[i], NULL, 10);
-                       if (tmp < 1 || tmp > max_probes) {
+                       if (tmp < 0 || tmp >= max_probes) {
                                g_critical("Invalid probe %d.", tmp);
                                error = TRUE;
                                break;
                        }
 
                        if ((name = strchr(tokens[i], '='))) {
-                               probelist[tmp - 1] = g_strdup(++name);
-                               if (strlen(probelist[tmp - 1]) > SR_MAX_PROBENAME_LEN)
-                                       probelist[tmp - 1][SR_MAX_PROBENAME_LEN] = 0;
+                               probelist[tmp] = g_strdup(++name);
+                               if (strlen(probelist[tmp]) > SR_MAX_PROBENAME_LEN)
+                                       probelist[tmp][SR_MAX_PROBENAME_LEN] = 0;
                        } else {
                                snprintf(str, 7, "%d", tmp);
-                               probelist[tmp - 1] = g_strdup(str);
+                               probelist[tmp] = g_strdup(str);
                        }
                }
        }
index bcdeb3e9fb7151771f6376383b1329eb0b89116c..19a2480be5e4dca9d105d88aa477dc7799bb973c 100644 (file)
@@ -622,6 +622,7 @@ static void datafeed_in(const struct sr_dev_inst *sdi,
                        if (probe->enabled)
                                logic_probelist[num_enabled_probes++] = probe->index;
                }
+               logic_probelist[num_enabled_probes] = -1;
                /* How many bytes we need to store num_enabled_probes bits */
                unitsize = (num_enabled_probes + 7) / 8;