Skip to content

Commit b1c805f

Browse files
committed
Support parsing SCPI commands in sigrok-cli.
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. Signed-off-by: Guido Trentalancia <guido@trentalancia.com> --- parsers.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
1 parent 6451abf commit b1c805f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

parsers.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,22 @@ GHashTable *parse_generic_arg(const char *arg, gboolean sep_first)
272272
GHashTable *hash;
273273
int i;
274274
char **elements, *e;
275+
const struct sr_key_info *info;
275276

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

279280
i = 0;
280281
hash = g_hash_table_new_full(g_str_hash, g_str_equal,
281282
g_free, g_free);
282-
elements = g_strsplit(arg, ":", 0);
283+
284+
/* In the SCPI command syntax the ":" character is reserved. */
285+
info = sr_key_info_get(SR_KEY_CONFIG, SR_CONF_CUSTOM_CMD);
286+
if (info && !strncmp(info->id, arg, strlen(info->id))) {
287+
elements = g_strsplit(arg, "\n", 1);
288+
} else {
289+
elements = g_strsplit(arg, ":", 0);
290+
}
283291
if (sep_first)
284292
g_hash_table_insert(hash, g_strdup("sigrok_key"),
285293
g_strdup(elements[i++]));

0 commit comments

Comments
 (0)