X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fdemo%2Fdemo.c;h=b02e668c01b020327a08b024c30c3e9fe4b81f94;hb=df92e5cf6b1caad0d1d43eb890d84af1ef79cd18;hp=ff7ba06b7ce39ea3d1f7274f9690a260cf2345cf;hpb=34f06b903e3529a73feb7a6e74fae934a999f821;p=libsigrok.git diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index ff7ba06b..b02e668c 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -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; }