Add -# --skip_init option to rigctl

pull/1458/head
Mike Black W9MDB 2023-12-18 15:26:46 -06:00
rodzic 48b6b4910c
commit af5ea58350
5 zmienionych plików z 25 dodań i 4 usunięć

1
NEWS
Wyświetl plik

@ -13,6 +13,7 @@ Version 5.x -- future
* Change FT1000MP Mark V model names to align with FT1000MP
Version 4.6
* Add -# --skip_init option to rigctl to skip rig initialization -- useful for executing commands quickly
* rig_caps is no longer constant -- this may break some 3rd party relying on the "const" declaration. Here's an example of how to handle compatiblity.
#ifdef RIGCAPS_NOT_CONST
static int add_to_list(struct rig_caps* rc, void*)

Wyświetl plik

@ -1424,6 +1424,11 @@ Can also use 1,2,3,4
Reads GPIO1, GPIO2, GPIO3, GPIO4 on the GPIO ptt port
Can also use 1,2,3,4
.
.TP
.BR skip_init
.EX
Skips rig initialization -- useful when executing commands with rigctl to speed up things
.
.SH READLINE
.
If

Wyświetl plik

@ -156,6 +156,7 @@ typedef struct
// cookie is 26-char time code plus 10-char (2^31-1) random number
#define HAMLIB_COOKIE_SIZE 37
extern int cookie_use; // this is global as once one client requests it everybody needs to honor it
extern int skip_init; // allow rigctl to skip any radio commands at startup
//! @cond Doxygen_Suppress
extern HAMLIB_EXPORT_VAR(const char) hamlib_version[];

Wyświetl plik

@ -100,6 +100,7 @@ const char hamlib_version[21] = "Hamlib " PACKAGE_VERSION;
const char *hamlib_version2 = "Hamlib " PACKAGE_VERSION " " HAMLIBDATETIME " "
ARCHBITS;
HAMLIB_EXPORT_VAR(int) cookie_use;
HAMLIB_EXPORT_VAR(int) skip_init;
HAMLIB_EXPORT_VAR(int) lock_mode; // for use by rigctld
HAMLIB_EXPORT_VAR(powerstat_t)
rig_powerstat; // for use by both rigctld and rigctl
@ -1326,6 +1327,8 @@ int HAMLIB_API rig_open(RIG *rig)
}
#if defined(HAVE_PTHREAD)
if (!skip_init)
{
status = async_data_handler_start(rig);
if (status < 0)
@ -1334,7 +1337,7 @@ int HAMLIB_API rig_open(RIG *rig)
rig->state.comm_status = RIG_COMM_STATUS_ERROR;
RETURNFUNC2(status);
}
}
#endif
rs->comm_state = 1;
@ -1354,7 +1357,7 @@ int HAMLIB_API rig_open(RIG *rig)
if (caps->rig_open != NULL)
{
if (caps->get_powerstat != NULL)
if (caps->get_powerstat != NULL && !skip_init)
{
powerstat_t powerflag;
status = rig_get_powerstat(rig, &powerflag);
@ -1388,8 +1391,11 @@ int HAMLIB_API rig_open(RIG *rig)
{
remove_opened_rig(rig);
#if defined(HAVE_PTHREAD)
if (!skip_init)
{
async_data_handler_stop(rig);
morse_data_handler_stop(rig);
}
#endif
port_close(&rs->rigport, rs->rigport.type.rig);
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
@ -1443,6 +1449,7 @@ int HAMLIB_API rig_open(RIG *rig)
rig_strvfo(rs->current_vfo));
}
}
if (skip_init) return RIG_OK;
#if defined(HAVE_PTHREAD)
status = morse_data_handler_start(rig);
@ -1595,11 +1602,14 @@ int HAMLIB_API rig_close(RIG *rig)
rig->state.comm_status = RIG_COMM_STATUS_DISCONNECTED;
#if defined(HAVE_PTHREAD)
if (!skip_init)
{
morse_data_handler_stop(rig);
async_data_handler_stop(rig);
rig_poll_routine_stop(rig);
network_multicast_receiver_stop(rig);
network_multicast_publisher_stop(rig);
}
#endif
/*

Wyświetl plik

@ -79,7 +79,7 @@ static void usage(void);
* NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file
*/
#define SHORT_OPTIONS "+m:r:p:d:P:D:s:c:t:lC:LuonvhVYZ!"
#define SHORT_OPTIONS "+m:r:p:d:P:D:s:c:t:lC:LuonvhVYZ!#"
static struct option long_options[] =
{
{"model", 1, 0, 'm'},
@ -107,6 +107,7 @@ static struct option long_options[] =
{"help", 0, 0, 'h'},
{"version", 0, 0, 'V'},
{"cookie", 0, 0, '!'},
{"skipinit", 0, 0, '#'},
{0, 0, 0, 0}
};
@ -254,6 +255,9 @@ int main(int argc, char *argv[])
switch (c)
{
case '#':
skip_init = 1;
break;
case '!':
cookie_use = 1;
break;
@ -679,7 +683,7 @@ int main(int argc, char *argv[])
my_rig->caps->model_name);
}
if (my_rig->caps->get_powerstat)
if (!skip_init && my_rig->caps->get_powerstat)
{
rig_get_powerstat(my_rig, &rig_powerstat);
my_rig->state.powerstat = rig_powerstat;