Add get_separator and set_separator to rigctld

This allows rigctld clients to change the reponse format
Multi-line response will use the new separator for fields and a newline at the end of message.
The allows node-red tcprequest to wait for newline and then parse the fields in one message.
https://github.com/Hamlib/Hamlib/issues/1015
pull/1042/head
Mike Black W9MDB 2022-05-21 12:33:00 -05:00
rodzic c9d31337b9
commit 11bcf03229
3 zmienionych plików z 44 dodań i 2 usunięć

Wyświetl plik

@ -1183,6 +1183,23 @@ This is the same as using the -o switch for rigctl and ritctld.
This can be dyamically changed while running.
.
.TP
.BR get_separator
Get
.RI \(aq SeparatorChar \(aq
.IP
Shows the current SeparatorChar
.
.TP
.BR set_separator " \(aq" \fISeparatorChar\fP \(aq
Set
.RI \(aq SeparatorChar \(aq
.IP
Change rigctld response to use a special char intead of newline (recommend #).
This can be dyamically changed while running.
Handy for node-red's tcprequest node.
This can be dyamically changed while running.
.
.TP
.BR pause " \(aq" \fISeconds\fP \(aq
Pause for the given whole (integer) number of
.RI \(aq Seconds \(aq

Wyświetl plik

@ -116,6 +116,8 @@ static struct option long_options[] =
};
extern char rig_resp_sep;
#define MAXCONFLEN 1024
int main(int argc, char *argv[])
@ -150,7 +152,6 @@ int main(int argc, char *argv[])
int vfo_opt = 0; /* vfo_opt = 0 means target VFO is 'currVFO' */
char send_cmd_term = '\r'; /* send_cmd termination char */
int ext_resp = 0;
char resp_sep = '\n';
int i;
char rigstartup[1024];
@ -648,7 +649,7 @@ int main(int argc, char *argv[])
retcode = rigctl_parse(my_rig, stdin, stdout, argv, argc, NULL,
interactive, prompt, &vfo_opt, send_cmd_term,
&ext_resp, &resp_sep, 0);
&ext_resp, &rig_resp_sep, 0);
// if we get a hard error we try to reopen the rig again
// this should cover short dropouts that can occur

Wyświetl plik

@ -250,6 +250,8 @@ declare_proto_rig(password);
//declare_proto_rig(set_password);
declare_proto_rig(set_clock);
declare_proto_rig(get_clock);
declare_proto_rig(set_separator);
declare_proto_rig(get_separator);
/*
@ -358,6 +360,8 @@ static struct test_table test_list[] =
{ 0x98, "password", ACTION(password), ARG_IN | ARG_NOVFO, "Password" },
// { 0x99, "set_password", ACTION(set_password), ARG_IN | ARG_NOVFO, "Password" },
{ 0xf7, "get_mode_bandwidths", ACTION(get_mode_bandwidths), ARG_IN | ARG_NOVFO, "Mode" },
{ 0xa0, "set_separator", ACTION(set_separator), ARG_IN | ARG_NOVFO, "Separator" },
{ 0xa1, "get_separator", ACTION(get_separator), ARG_OUT | ARG_NOVFO, "Separator" },
{ 0x00, "", NULL },
};
@ -5174,3 +5178,23 @@ declare_proto_rig(get_clock)
return retval;
}
char rig_resp_sep = '\n';
/* '0xa0' */
declare_proto_rig(set_separator)
{
CHKSCN1ARG(sscanf(arg1, "%c", &rig_resp_sep));
rig_debug(RIG_DEBUG_ERR, "%s: arg1=%s, resp_sep=0x%x, %p\n", __func__, arg1, (unsigned int)rig_resp_sep, &rig_resp_sep);
return RIG_OK;
}
/* '0xa1' */
declare_proto_rig(get_separator)
{
char buf[32];
if (isprint(rig_resp_sep))
sprintf(buf,"%c",rig_resp_sep);
else sprintf(buf,"0x%x %p",rig_resp_sep, &rig_resp_sep);
fprintf(fout,"%s\n", buf);
return RIG_OK;
}