]> sigrok.org Git - libsigrok.git/blobdiff - input/input_binary.c
probe names: Fix cosmetics, add docs, fix off-by-one.
[libsigrok.git] / input / input_binary.c
index 4286a6c3459a1bcd5eaf7e1be1b863f8159be4dd..b83ea6f5ea58ed46aad482c19031f2b47fe94416 100644 (file)
@@ -28,7 +28,6 @@
 #define CHUNKSIZE          4096
 #define DEFAULT_NUM_PROBES    8
 
-
 static int format_match(const char *filename)
 {
        /* suppress compiler warning */
@@ -40,17 +39,25 @@ static int format_match(const char *filename)
 
 static int init(struct sr_input *in)
 {
-       int num_probes;
+       int num_probes, i;
+       char name[SR_MAX_PROBENAME_LEN + 1];
 
        if (in->param && in->param[0]) {
                num_probes = strtoul(in->param, NULL, 10);
                if (num_probes < 1)
                        return SR_ERR;
-       } else
+       } else {
                num_probes = DEFAULT_NUM_PROBES;
+       }
 
-       /* create a virtual device */
-       in->vdevice = sr_device_new(NULL, 0, num_probes);
+       /* Create a virtual device. */
+       in->vdevice = sr_device_new(NULL, 0);
+
+       for (i = 0; i < num_probes; i++) {
+               snprintf(name, SR_MAX_PROBENAME_LEN, "%d", i);
+               /* TODO: Check return value. */
+               sr_device_probe_add(in->vdevice, name);
+       }
 
        return SR_OK;
 }