Skip to content

Commit

Permalink
Allow rigctld to close the rig with the -R option when client disconn…
Browse files Browse the repository at this point in the history
…ects.

This makes it close when any one client disconnects.
Should only close when no clients are connected -- that will be the next patch
This is for the FT736R and gpredict
#1187
  • Loading branch information
mdblack98 committed Dec 13, 2022
1 parent 46f3034 commit 01799cb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/rigctld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:R:p:d:P:D:s:S:c:T:t:C:W:w:x:z:lLuovhVZMA:n:"
#define SHORT_OPTIONS "m:r:p:d:P:D:s:S:c:T:t:C:W:w:x:z:lLuovhVZMRA:n:"
static struct option long_options[] =
{
{"model", 1, 0, 'm'},
Expand Down Expand Up @@ -154,6 +154,8 @@ extern char rigctld_password[65];
char resp_sep = '\n';
extern int lock_mode;
extern powerstat_t rig_powerstat;
static int rigctld_idle =
0; // if true then rig will close when no clients are connected

#define MAXCONFLEN 1024

Expand Down Expand Up @@ -262,8 +264,6 @@ 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];
Expand Down Expand Up @@ -1313,6 +1313,13 @@ void *handle_socket(void *arg)
}
while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(-retcode)));

if (rigctld_idle)
{
rig_close(my_rig);

if (verbose > RIG_DEBUG_ERR) { printf("Closed rig model %s. Will reopen for new clients\n", my_rig->caps->model_name); }
}

#ifdef HAVE_PTHREAD
#if 0
mutex_rigctld(1);
Expand Down

0 comments on commit 01799cb

Please sign in to comment.