]> sigrok.org Git - libsigrok.git/commitdiff
sr: fix session loading for 0-numbered probes
authorBert Vermeulen <redacted>
Mon, 23 Jul 2012 12:55:43 +0000 (14:55 +0200)
committerBert Vermeulen <redacted>
Fri, 3 Aug 2012 09:28:59 +0000 (11:28 +0200)
They're still numbered starting from 1 in the current version (1)
of the sigrok file format, we just work around that for now.

session_file.c

index 0d455971fa4f1306310b6ceffe23e6f646eec397..90f671e91feb53c9efc103352ee229498e6082d6 100644 (file)
@@ -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);
                }