From: Bert Vermeulen Date: Mon, 23 Jul 2012 12:55:43 +0000 (+0200) Subject: sr: fix session loading for 0-numbered probes X-Git-Tag: dsupstream~764 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fb381e4d713fcd3fdec99b4deff3a75e809df825;p=libsigrok.git sr: fix session loading for 0-numbered probes They're still numbered starting from 1 in the current version (1) of the sigrok file format, we just work around that for now. --- diff --git a/session_file.c b/session_file.c index 0d455971..90f671e9 100644 --- a/session_file.c +++ b/session_file.c @@ -134,7 +134,7 @@ SR_API int sr_session_load(const char *filename) sdi->driver->dev_config_set(sdi, SR_HWCAP_CAPTURE_NUM_PROBES, &total_probes); for (p = 0; p < total_probes; p++) { snprintf(probename, SR_MAX_PROBENAME_LEN, "%" PRIu64, p); - if (!(probe = sr_probe_new(j, SR_PROBE_LOGIC, TRUE, + if (!(probe = sr_probe_new(p, SR_PROBE_LOGIC, TRUE, probename))) return SR_ERR; sdi->probes = g_slist_append(sdi->probes, probe); @@ -144,13 +144,15 @@ SR_API int sr_session_load(const char *filename) continue; enabled_probes++; tmp_u64 = strtoul(keys[j]+5, NULL, 10); - sr_dev_probe_name_set(sdi, tmp_u64, val); + /* sr_session_save() */ + sr_dev_probe_name_set(sdi, tmp_u64 - 1, val); } else if (!strncmp(keys[j], "trigger", 7)) { probenum = strtoul(keys[j]+7, NULL, 10); sr_dev_trigger_set(sdi, probenum, val); } } g_strfreev(keys); + /* Disable probes not specifically listed. */ for (p = enabled_probes; p < total_probes; p++) sr_dev_probe_enable(sdi, p, FALSE); }