From e212d5381f5b178fcbb5efa745856b825f29c1fb Mon Sep 17 00:00:00 2001 From: Guido Trentalancia Date: Sat, 22 Dec 2018 14:16:22 +0100 Subject: [PATCH] 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. --- parsers.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/parsers.c b/parsers.c index 5ec655f..69f7bde 100644 --- a/parsers.c +++ b/parsers.c @@ -272,6 +272,7 @@ 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; @@ -279,7 +280,14 @@ GHashTable *parse_generic_arg(const char *arg, gboolean sep_first) 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++]));