Add -R option to rigctld to close the rig when no clients are connected

The FT-736 has to lock the rig for CAT control so this allows it to unlock when rigctld is idle
https://github.com/Hamlib/Hamlib/issues/1117
pull/1119/head
Mike Black W9MDB 2022-09-16 08:33:51 -05:00
rodzic 4985d9ab26
commit b1d132dd27
2 zmienionych plików z 22 dodań i 8 usunięć

Wyświetl plik

@ -372,6 +372,10 @@ option as it generates no output on its own.
Sets password on rigctld which requires hamlib to use rig_set_password and rigctl to use \\password to access rigctld. A 32-char shared secret will be displayed to be used on the client side.
.
.TP
.BR \-R ", " \-\-rigctld_idle
Will make rigctld close the rig when no clients are connected. Normally remains connected to speed up connects.
.
.TP
.BR \-h ", " \-\-help
Show a summary of these options and exit.
.

Wyświetl plik

@ -83,7 +83,7 @@
* keep up to date SHORT_OPTIONS, usage()'s output and man page. thanks.
* TODO: add an option to read from a file
*/
#define SHORT_OPTIONS "m:r:p:d:P:D:s:S:c:T:t:C:W:w:x:z:lLuovhVZMA:n:"
#define SHORT_OPTIONS "m:r:R:p:d:P:D:s:S:c:T:t:C:W:w:x:z:lLuovhVZMA:n:"
static struct option long_options[] =
{
{"model", 1, 0, 'm'},
@ -112,6 +112,7 @@ static struct option long_options[] =
{"multicast-addr", 1, 0, 'M'},
{"multicast-port", 1, 0, 'n'},
{"password", 1, 0, 'A'},
{"rigctld-idle", 0, 0, 'R'},
{0, 0, 0, 0}
};
@ -261,6 +262,7 @@ int main(int argc, char *argv[])
int twiddle_timeout = 0;
int twiddle_rit = 0;
int uplink = 0;
int rigctld_idle = 0; // if true then rig will close when no clients are connected
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
char rigstartup[1024];
@ -306,6 +308,10 @@ int main(int argc, char *argv[])
printf("rigctl %s\n", hamlib_version2);
exit(0);
case 'R':
rigctld_idle = 1;
break;
case 'A':
strncpy(rigctld_password, optarg, sizeof(rigctld_password) - 1);
//char *md5 = rig_make_m d5(rigctld_password);
@ -762,18 +768,21 @@ int main(int argc, char *argv[])
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
#if 0
rig_close(my_rig); /* we will reopen for clients */
if (verbose > RIG_DEBUG_ERR)
// Normally we keep the rig open to speed up the 1st client connect
// But some rigs like the FT-736 have to lock the rig for CAT control
// So they need to release the rig when no clients are connected
if (rigctld_idle)
{
printf("Closed rig model %d, '%s - will reopen for clients'\n",
rig_close(my_rig); /* we will reopen for clients */
if (verbose > RIG_DEBUG_ERR)
{
printf("Closed rig model %d, '%s - will reopen for clients'\n",
my_rig->caps->rig_model,
my_rig->caps->model_name);
}
}
#endif
#ifdef __MINGW32__
# ifndef SO_OPENTYPE
# define SO_OPENTYPE 0x7008
@ -1405,6 +1414,7 @@ void usage(void)
" -M, --multicast-addr=addr set multicast UDP address, default 0.0.0.0 (off), recommend 224.0.1.1\n"
" -n, --multicast-port=port set multicast UDP port, default 4532\n"
" -A, --password set password for rigctld access\n"
" -R, --rigctld-idle make rigctld close the rig when no clients are connected\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n\n",
portno);