]> sigrok.org Git - libsigrok.git/blobdiff - hardware/demo/demo.c
rigol-ds1xx2: More selective Rigol DS1xx2 scan
[libsigrok.git] / hardware / demo / demo.c
index ff7ba06b7ce39ea3d1f7274f9690a260cf2345cf..b02e668c01b020327a08b024c30c3e9fe4b81f94 100644 (file)
@@ -111,14 +111,7 @@ static const char *pattern_strings[] = {
 
 /* We name the probes 0-7 on our demo driver. */
 static const char *probe_names[NUM_PROBES + 1] = {
-       "0",
-       "1",
-       "2",
-       "3",
-       "4",
-       "5",
-       "6",
-       "7",
+       "0", "1", "2", "3", "4", "5", "6", "7",
        NULL,
 };
 
@@ -138,7 +131,7 @@ static uint8_t pattern_sigrok[] = {
 
 /* List of struct sr_dev_inst, maintained by dev_open()/dev_close(). */
 SR_PRIV struct sr_dev_driver demo_driver_info;
-static struct sr_dev_driver *ddi = &demo_driver_info;
+static struct sr_dev_driver *di = &demo_driver_info;
 static uint64_t cur_samplerate = SR_KHZ(200);
 static uint64_t limit_samples = 0;
 static uint64_t limit_msec = 0;
@@ -161,7 +154,8 @@ static int hw_init(struct sr_context *sr_ctx)
                sr_err("Driver context malloc failed.");
                return SR_ERR_MALLOC;
        }
-       ddi->priv = drvc;
+       drvc->sr_ctx = sr_ctx;
+       di->priv = drvc;
 
        return SR_OK;
 }
@@ -176,7 +170,7 @@ static GSList *hw_scan(GSList *options)
 
        (void)options;
 
-       drvc = ddi->priv;
+       drvc = di->priv;
        devices = NULL;
 
        sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
@@ -184,7 +178,7 @@ static GSList *hw_scan(GSList *options)
                sr_err("%s: sr_dev_inst_new failed", __func__);
                return 0;
        }
-       sdi->driver = ddi;
+       sdi->driver = di;
 
        for (i = 0; probe_names[i]; i++) {
                if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
@@ -203,7 +197,7 @@ static GSList *hw_dev_list(void)
 {
        struct drv_context *drvc;
 
-       drvc = ddi->priv;
+       drvc = di->priv;
 
        return drvc->instances;
 }
@@ -388,11 +382,8 @@ static int receive_data(int fd, int revents, void *cb_data)
                devc->samples_counter += sending_now;
        }
 
-
-       if (devc->samples_counter >= limit_samples) {
-               sr_spew("We sent a total of %" PRIu64 " samples.",
-                       devc->samples_counter);
-               /* Make sure we don't receive more packets. */
+       if (limit_samples && devc->samples_counter >= limit_samples) {
+               sr_info("Requested number of samples reached.");
                hw_dev_acquisition_stop(NULL, cb_data);
                return TRUE;
        }