From c73c728b5e8f08435399ac697125ca8a62e241fd Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 22 May 2024 11:44:54 -0500 Subject: [PATCH] Allow rigctl w command to quote arg1 for use by SmartSDR e.g. w "C0|set slice 0 tx=1" --- doc/man1/rigctl.1 | 3 ++- tests/rigctl_parse.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/man1/rigctl.1 b/doc/man1/rigctl.1 index 55c96bbae..373be6610 100644 --- a/doc/man1/rigctl.1 +++ b/doc/man1/rigctl.1 @@ -1273,7 +1273,8 @@ For binary protocols enter values as \\0xAA\\0xBB. Expect a .RI \(aq Reply \(aq from the radio which will likely be a binary block or an ASCII string depending on the radio's protocol (see your radio's computer control -documentation). +documentation). If you are testing a protocol like SmartSDR where there +are spaces in the commands use quote, e.g. w "C0|set slice 0 tx=1" .IP The command terminator, set by the .B send-cmd-term diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 78bc27fbf..5b8333c12 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -495,6 +495,19 @@ void hash_delete_all() } } + +// modifies s to remove quotes +void strip_quotes(char *s) +{ + char *s2 = strdup(s); + char *p; + if (s[0] != '\"') return; // no quotes + s2 = strdup(&s[1]); + p = strrchr(s2,'"'); + if (p) *p = 0; + strcpy(s,s2); +} + #ifdef HAVE_LIBREADLINE /* Frees allocated memory and sets pointers to NULL before calling readline * and then parses the input into space separated tokens. @@ -1726,6 +1739,7 @@ readline_repeat: * Extended Response protocol: output received command name and arguments * response. Don't send command header on '\chk_vfo' command. */ + if (p1) strip_quotes(p1); if (interactive && *ext_resp_ptr && !prompt && cmd != 0xf0) { char a1[MAXARGSZ + 2];