}
}
- fmtargs = parse_generic_arg(opt_output_format, TRUE);
+ fmtargs = parse_generic_arg(opt_output_format, TRUE, NULL);
fmtspec = g_hash_table_lookup(fmtargs, "sigrok_key");
if (!fmtspec)
g_critical("Invalid output format.");
g_hash_table_remove(fmtargs, "sigrok_key");
if ((options = sr_output_options_get(omod))) {
fmtopts = generic_arg_to_opt(options, fmtargs);
+ (void)warn_unknown_keys(options, fmtargs, NULL);
sr_output_options_free(options);
- } else
+ } else {
fmtopts = NULL;
+ }
o = sr_output_new(omod, fmtopts, sdi, opt_output_file);
if (opt_output_file) {
GHashTable *fmtargs, *fmtopts;
char *fmtspec;
- fmtargs = parse_generic_arg(opt_transform_module, TRUE);
+ fmtargs = parse_generic_arg(opt_transform_module, TRUE, NULL);
fmtspec = g_hash_table_lookup(fmtargs, "sigrok_key");
if (!fmtspec)
g_critical("Invalid transform module.");
g_hash_table_remove(fmtargs, "sigrok_key");
if ((options = sr_transform_options_get(tmod))) {
fmtopts = generic_arg_to_opt(options, fmtargs);
+ (void)warn_unknown_keys(options, fmtargs, NULL);
sr_transform_options_free(options);
- } else
+ } else {
fmtopts = NULL;
+ }
t = sr_transform_new(tmod, fmtopts, sdi);
if (fmtopts)
g_hash_table_destroy(fmtopts);
if (packet->type == SR_DF_END) {
g_debug("cli: Received SR_DF_END.");
+#if defined HAVE_SRD_SESSION_SEND_EOF && HAVE_SRD_SESSION_SEND_EOF
+ (void)srd_session_send_eof(srd_sess);
+#endif
+
if (do_props) {
props_dump_details(df_arg);
props_cleanup(df_arg);
return ret;
}
+int set_dev_options_array(struct sr_dev_inst *sdi, char **opts)
+{
+ size_t opt_idx;
+ const char *opt_text;
+ GHashTable *args;
+ int ret;
+
+ for (opt_idx = 0; opts && opts[opt_idx]; opt_idx++) {
+ opt_text = opts[opt_idx];
+ args = parse_generic_arg(opt_text, FALSE, "channel_group");
+ if (!args)
+ continue;
+ ret = set_dev_options(sdi, args);
+ g_hash_table_destroy(args);
+ if (ret != SR_OK)
+ return ret;
+ }
+
+ return SR_OK;
+}
+
int set_dev_options(struct sr_dev_inst *sdi, GHashTable *args)
{
struct sr_config src;
+ const char *cg_name;
struct sr_channel_group *cg;
GHashTableIter iter;
gpointer key, value;
int ret;
+ /*
+ * Not finding the 'sigrok_key' key (optional user specified
+ * channel group name) in the current options group's hash table
+ * is perfectly fine. In that case the -g selection is used,
+ * which defaults to "the device" (global parameters).
+ */
+ cg_name = g_hash_table_lookup(args, "sigrok_key");
+ cg = lookup_channel_group(sdi, cg_name);
+
g_hash_table_iter_init(&iter, args);
while (g_hash_table_iter_next(&iter, &key, &value)) {
+ if (g_ascii_strcasecmp(key, "sigrok_key") == 0)
+ continue;
if ((ret = opt_to_gvar(key, value, &src)) != 0)
return ret;
- cg = lookup_channel_group(sdi);
if ((ret = maybe_config_set(sr_dev_inst_driver_get(sdi), sdi, cg,
src.key, src.data)) != SR_OK) {
g_critical("Failed to set device option '%s': %s.",
{
struct df_arg_desc df_arg;
GSList *devices, *real_devices, *sd;
- GHashTable *devargs;
GVariant *gvar;
struct sr_session *session;
struct sr_trigger *trigger;
return;
}
- if (opt_config) {
- if ((devargs = parse_generic_arg(opt_config, FALSE))) {
- if (set_dev_options(sdi, devargs) != SR_OK)
- return;
- g_hash_table_destroy(devargs);
- }
+ if (opt_configs) {
+ if (set_dev_options_array(sdi, opt_configs) != SR_OK)
+ return;
}
if (select_channels(sdi) != SR_OK) {