From: Gerhard Sittig Date: Sun, 14 Aug 2022 18:19:01 +0000 (+0200) Subject: asix-omega-rtm-cli: add support for "probe names" scan option X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c18f4891912718a8fea61eb1ea98c86b99995bd3;p=libsigrok.git asix-omega-rtm-cli: add support for "probe names" scan option Add support for the SR_CONF_PROBE_NAMES scan option. Optionally assign user specified channel names instead of the driver's builtin names. --- diff --git a/src/hardware/asix-omega-rtm-cli/api.c b/src/hardware/asix-omega-rtm-cli/api.c index 71e92254..60c3bfea 100644 --- a/src/hardware/asix-omega-rtm-cli/api.c +++ b/src/hardware/asix-omega-rtm-cli/api.c @@ -126,9 +126,10 @@ static const uint32_t devopts[] = { static GSList *scan(struct sr_dev_driver *di, GSList *options) { - const char *conn, *serno, *exe; - GSList *devices; - size_t argc, chidx; + const char *conn, *probe_names, *serno, *exe; + GSList *devices, *l; + struct sr_config *src; + size_t argc, chmax, chidx; gchar **argv, *output, *vers_text, *eol; GSpawnFlags flags; GError *error; @@ -139,9 +140,18 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) /* Extract optional serial number from conn= spec. */ conn = NULL; + probe_names = NULL; (void)sr_serial_extract_options(options, &conn, NULL); if (!conn || !*conn) conn = NULL; + for (l = options; l; l = l->next) { + src = l->data; + switch (src->key) { + case SR_CONF_PROBE_NAMES: + probe_names = g_variant_get_string(src->data, NULL); + break; + } + } serno = NULL; if (conn) { if (!g_str_has_prefix(conn, "sn=")) { @@ -242,13 +252,16 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->serial_num = g_strdup(serno); if (conn) sdi->connection_id = g_strdup(conn); - for (chidx = 0; chidx < ARRAY_SIZE(channel_names); chidx++) { + devc = g_malloc0(sizeof(*devc)); + sdi->priv = devc; + devc->channel_names = sr_parse_probe_names(probe_names, + channel_names, ARRAY_SIZE(channel_names), + ARRAY_SIZE(channel_names), &chmax); + for (chidx = 0; chidx < chmax; chidx++) { sr_channel_new(sdi, chidx, SR_CHANNEL_LOGIC, - TRUE, channel_names[chidx]); + TRUE, devc->channel_names[chidx]); } - devc = g_malloc0(sizeof(*devc)); - sdi->priv = devc; sr_sw_limits_init(&devc->limits); argc = 1; g_free(argv[argc]); diff --git a/src/hardware/asix-omega-rtm-cli/protocol.h b/src/hardware/asix-omega-rtm-cli/protocol.h index 2f4641c8..b55f5f18 100644 --- a/src/hardware/asix-omega-rtm-cli/protocol.h +++ b/src/hardware/asix-omega-rtm-cli/protocol.h @@ -32,6 +32,7 @@ #define FEED_QUEUE_DEPTH (256 * 1024) struct dev_context { + char **channel_names; struct sr_sw_limits limits; struct { gchar **argv;