X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=output%2Fhex.c;h=a49d9d9283b32be70b71114f2449e1e39255baf2;hp=85ce90697033c091000e412786be87e7a20b92c2;hb=dba3e6826e3d37309ed49dd77cde346b369bc5a9;hpb=7e7b7fb7d323f7600958bf29025ca089a15829e3 diff --git a/output/hex.c b/output/hex.c index 85ce9069..a49d9d92 100644 --- a/output/hex.c +++ b/output/hex.c @@ -47,6 +47,8 @@ static int init(struct sr_output *o) struct sr_channel *ch; GSList *l; GVariant *gvar; + GHashTableIter iter; + gpointer key, value; uint64_t samplerate; unsigned int i, j; int spl, num_channels; @@ -54,15 +56,24 @@ static int init(struct sr_output *o) if (!o || !o->sdi) return SR_ERR_ARG; + + spl = DEFAULT_SAMPLES_PER_LINE; + g_hash_table_iter_init(&iter, o->params); + while (g_hash_table_iter_next(&iter, &key, &value)) { + if (!strcmp(key, "width")) { + if ((spl = strtoul(value, NULL, 10)) < 1) { + sr_err("Invalid width."); + return SR_ERR_ARG; + } + } else { + sr_err("Unknown parameter '%s'.", key); + return SR_ERR_ARG; + } + } + ctx = g_malloc0(sizeof(struct context)); o->internal = ctx; ctx->trigger = -1; - - if (o->param && o->param[0]) { - if ((spl = strtoul(o->param, NULL, 10)) < 1) - return SR_ERR_ARG; - } else - spl = DEFAULT_SAMPLES_PER_LINE; ctx->samples_per_line = spl; for (l = o->sdi->channels; l; l = l->next) { @@ -109,8 +120,8 @@ static int init(struct sr_output *o) return SR_OK; } -static int receive(struct sr_output *o, const struct sr_dev_inst *sdi, - const struct sr_datafeed_packet *packet, GString **out) +static int receive(struct sr_output *o, const struct sr_datafeed_packet *packet, + GString **out) { const struct sr_datafeed_logic *logic; struct context *ctx; @@ -118,8 +129,6 @@ static int receive(struct sr_output *o, const struct sr_dev_inst *sdi, uint64_t i, j; gchar *p; - (void)sdi; - *out = NULL; if (!o || !o->sdi) return SR_ERR_ARG;