X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fdemo%2Fdemo.c;h=b2f3a50915227ee4b96cd4b9dd7d45b2a0a1262f;hb=102f12396660e0784134bccce5cc0679db325751;hp=3c6585dd0086d81fad2a7e5957a5c2357a8ff171;hpb=ba7dd8bbb8168cba432a844259a3e239aa5f36d7;p=libsigrok.git diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 3c6585dd..b2f3a509 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -34,8 +34,8 @@ #define LOG_PREFIX "demo" -#define DEFAULT_NUM_LOGIC_PROBES 8 -#define DEFAULT_NUM_ANALOG_PROBES 4 +#define DEFAULT_NUM_LOGIC_CHANNELS 8 +#define DEFAULT_NUM_ANALOG_CHANNELS 4 /* The size in bytes of chunks to send through the session bus. */ #define LOGIC_BUFSIZE 4096 @@ -50,7 +50,7 @@ enum { /** * Spells "sigrok" across 8 channels using '0's (with '1's as * "background") when displayed using the 'bits' output format. - * The pattern is repeasted every 8 channels, shifted to the right + * The pattern is repeated every 8 channels, shifted to the right * in time by one bit. */ PATTERN_SIGROK, @@ -59,7 +59,7 @@ enum { PATTERN_RANDOM, /** - * Incrementing number across 8 channels. The pattern is repeasted + * Incrementing number across 8 channels. The pattern is repeated * every 8 channels, shifted to the right in time by one bit. */ PATTERN_INC, @@ -127,8 +127,8 @@ struct dev_context { }; static const int32_t scanopts[] = { - SR_CONF_NUM_LOGIC_PROBES, - SR_CONF_NUM_ANALOG_PROBES, + SR_CONF_NUM_LOGIC_CHANNELS, + SR_CONF_NUM_ANALOG_CHANNELS, }; static const int devopts[] = { @@ -265,15 +265,15 @@ static GSList *scan(GSList *options) drvc = di->priv; - num_logic_channels = DEFAULT_NUM_LOGIC_PROBES; - num_analog_channels = DEFAULT_NUM_ANALOG_PROBES; + num_logic_channels = DEFAULT_NUM_LOGIC_CHANNELS; + num_analog_channels = DEFAULT_NUM_ANALOG_CHANNELS; for (l = options; l; l = l->next) { src = l->data; switch (src->key) { - case SR_CONF_NUM_LOGIC_PROBES: + case SR_CONF_NUM_LOGIC_CHANNELS: num_logic_channels = g_variant_get_int32(src->data); break; - case SR_CONF_NUM_ANALOG_PROBES: + case SR_CONF_NUM_ANALOG_CHANNELS: num_analog_channels = g_variant_get_int32(src->data); break; } @@ -309,7 +309,7 @@ static GSList *scan(GSList *options) cg->priv = NULL; for (i = 0; i < num_logic_channels; i++) { sprintf(channel_name, "D%d", i); - if (!(ch = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, channel_name))) + if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, channel_name))) return NULL; sdi->channels = g_slist_append(sdi->channels, ch); cg->channels = g_slist_append(cg->channels, ch); @@ -321,8 +321,8 @@ static GSList *scan(GSList *options) pattern = 0; for (i = 0; i < num_analog_channels; i++) { sprintf(channel_name, "A%d", i); - if (!(ch = sr_probe_new(i + num_logic_channels, - SR_PROBE_ANALOG, TRUE, channel_name))) + if (!(ch = sr_channel_new(i + num_logic_channels, + SR_CHANNEL_ANALOG, TRUE, channel_name))) return NULL; sdi->channels = g_slist_append(sdi->channels, ch); @@ -407,20 +407,20 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, if (!cg) return SR_ERR_CHANNEL_GROUP; ch = cg->channels->data; - if (ch->type == SR_PROBE_LOGIC) { + if (ch->type == SR_CHANNEL_LOGIC) { pattern = devc->logic_pattern; *data = g_variant_new_string(logic_pattern_str[pattern]); - } else if (ch->type == SR_PROBE_ANALOG) { + } else if (ch->type == SR_CHANNEL_ANALOG) { ag = cg->priv; pattern = ag->pattern; *data = g_variant_new_string(analog_pattern_str[pattern]); } else return SR_ERR_BUG; break; - case SR_CONF_NUM_LOGIC_PROBES: + case SR_CONF_NUM_LOGIC_CHANNELS: *data = g_variant_new_int32(devc->num_logic_channels); break; - case SR_CONF_NUM_ANALOG_PROBES: + case SR_CONF_NUM_ANALOG_CHANNELS: *data = g_variant_new_int32(devc->num_analog_channels); break; default: @@ -467,7 +467,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, stropt = g_variant_get_string(data, NULL); ch = cg->channels->data; pattern = -1; - if (ch->type == SR_PROBE_LOGIC) { + if (ch->type == SR_CHANNEL_LOGIC) { for (i = 0; i < ARRAY_SIZE(logic_pattern_str); i++) { if (!strcmp(stropt, logic_pattern_str[i])) { pattern = i; @@ -485,7 +485,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, memset(devc->logic_data, 0xff, LOGIC_BUFSIZE); sr_dbg("Setting logic pattern to %s", logic_pattern_str[pattern]); - } else if (ch->type == SR_PROBE_ANALOG) { + } else if (ch->type == SR_CHANNEL_ANALOG) { for (i = 0; i < ARRAY_SIZE(analog_pattern_str); i++) { if (!strcmp(stropt, analog_pattern_str[i])) { pattern = i; @@ -550,10 +550,10 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(int32_t)); break; case SR_CONF_PATTERN_MODE: - if (ch->type == SR_PROBE_LOGIC) + if (ch->type == SR_CHANNEL_LOGIC) *data = g_variant_new_strv(logic_pattern_str, ARRAY_SIZE(logic_pattern_str)); - else if (ch->type == SR_PROBE_ANALOG) + else if (ch->type == SR_CHANNEL_ANALOG) *data = g_variant_new_strv(analog_pattern_str, ARRAY_SIZE(analog_pattern_str)); else @@ -692,6 +692,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) GSList *l; struct dev_context *devc; + (void)cb_data; + if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -726,11 +728,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Make channels to unbuffered. */ g_io_channel_set_buffered(devc->channel, FALSE); - sr_session_source_add_channel(devc->channel, G_IO_IN | G_IO_ERR, + sr_session_source_add_channel(sdi->session, devc->channel, G_IO_IN | G_IO_ERR, 40, prepare_data, (void *)sdi); /* Send header packet to the session bus. */ - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* We use this timestamp to decide how many more samples to send. */ devc->starttime = g_get_monotonic_time(); @@ -748,7 +750,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) devc = sdi->priv; sr_dbg("Stopping acquisition."); - sr_session_source_remove_channel(devc->channel); + sr_session_source_remove_channel(sdi->session, devc->channel); g_io_channel_shutdown(devc->channel, FALSE, NULL); g_io_channel_unref(devc->channel); devc->channel = NULL;