X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fdemo%2Fapi.c;h=c5259b286144621d6f763ec611b7045df7ab49f2;hb=be702d16d0e37602a312b00d06f6c4e2c3a7e55a;hp=fcf61cb3f54d1c2b9727a50cd4e7579d835fb2b6;hpb=53012da658ae94b245240c8a3e115723eede4c7d;p=libsigrok.git diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index fcf61cb3..c5259b28 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -197,8 +197,8 @@ static int dev_clear(const struct sr_dev_driver *di) return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } -static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_get(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; struct sr_channel *ch; @@ -257,16 +257,14 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s return SR_OK; } -static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_set(uint32_t key, GVariant *data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; struct analog_gen *ag; struct sr_channel *ch; GSList *l; int logic_pattern, analog_pattern; - unsigned int i; - const char *stropt; devc = sdi->priv; @@ -293,21 +291,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd case SR_CONF_PATTERN_MODE: if (!cg) return SR_ERR_CHANNEL_GROUP; - stropt = g_variant_get_string(data, NULL); - logic_pattern = analog_pattern = -1; - for (i = 0; i < ARRAY_SIZE(logic_pattern_str); i++) { - if (!strcmp(stropt, logic_pattern_str[i])) { - logic_pattern = i; - break; - } - } - for (i = 0; i < ARRAY_SIZE(analog_pattern_str); i++) { - if (!strcmp(stropt, analog_pattern_str[i])) { - analog_pattern = i; - break; - } - } - if (logic_pattern == -1 && analog_pattern == -1) + logic_pattern = std_str_idx(data, ARRAY_AND_SIZE(logic_pattern_str)); + analog_pattern = std_str_idx(data, ARRAY_AND_SIZE(analog_pattern_str)); + if (logic_pattern < 0 && analog_pattern < 0) return SR_ERR_ARG; for (l = cg->channels; l; l = l->next) { ch = l->data; @@ -351,8 +337,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd return SR_OK; } -static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_list(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct sr_channel *ch; @@ -414,6 +400,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) devc = sdi->priv; devc->sent_samples = 0; + devc->sent_frame_samples = 0; /* * Determine the numbers of logic and analog channels that are @@ -467,6 +454,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) std_session_send_df_header(sdi); + if (SAMPLES_PER_FRAME > 0) + std_session_send_frame_begin(sdi); + /* We use this timestamp to decide how many more samples to send. */ devc->start_us = g_get_monotonic_time(); devc->spent_us = 0; @@ -478,6 +468,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { sr_session_source_remove(sdi->session, -1); + + if (SAMPLES_PER_FRAME > 0) + std_session_send_frame_end(sdi); + std_session_send_df_end(sdi); return SR_OK;