From: Bert Vermeulen Date: Mon, 23 Jul 2012 01:03:07 +0000 (+0200) Subject: cli: use probe numbers starting from 0 X-Git-Tag: sigrok-cli-0.4.0~91 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8c8056b5a08ae49b9e58f05d3c26462bfa0cc8aa;p=sigrok-cli.git cli: use probe numbers starting from 0 --- diff --git a/parsers.c b/parsers.c index 8d0bbe5..794e4b5 100644 --- 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); } } } diff --git a/sigrok-cli.c b/sigrok-cli.c index bcdeb3e..19a2480 100644 --- a/sigrok-cli.c +++ b/sigrok-cli.c @@ -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;