Skip to content

Commit

Permalink
Support parsing SCPI commands in sigrok-cli.
Browse files Browse the repository at this point in the history
The support for sending custom SCPI commands to the device
has recently been added to libsigrok.

Add the corresponding support for parsing such commands in
sigrok-cli.
  • Loading branch information
gtrentalancia committed Jul 15, 2019
1 parent 6366add commit e212d53
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion parsers.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,22 @@ GHashTable *parse_generic_arg(const char *arg, gboolean sep_first)
GHashTable *hash;
int i;
char **elements, *e;
const struct sr_key_info *info;

if (!arg || !arg[0])
return NULL;

i = 0;
hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
elements = g_strsplit(arg, ":", 0);

/* In the SCPI command syntax the ":" character is reserved. */
info = sr_key_info_get(SR_KEY_CONFIG, SR_CONF_CUSTOM_CMD);
if (info && !strncmp(info->id, arg, strlen(info->id))) {
elements = g_strsplit(arg, "\n", 1);
} else {
elements = g_strsplit(arg, ":", 0);
}
if (sep_first)
g_hash_table_insert(hash, g_strdup("sigrok_key"),
g_strdup(elements[i++]));
Expand Down

0 comments on commit e212d53

Please sign in to comment.