Add --set-conf=tuner_control_pathname=hamlib_tuner_control

Program will be passed 0 or 1 (Off or On)
Example script in tests/hamlib_tuner_control
https://github.com/Hamlib/Hamlib/issues/1192
pull/1215/head
Mike Black W9MDB 2022-12-19 12:55:18 -06:00
rodzic ea29263f35
commit 04b18c9d5b
9 zmienionych plików z 102 dodań i 5 usunięć

4
NEWS
Wyświetl plik

@ -14,6 +14,10 @@ Version 5.x -- future
Version 4.6 Version 4.6
* 2023-11-XX -- Planned for Nov 2023 * 2023-11-XX -- Planned for Nov 2023
* Add --set-conf=tuner_control_pathname=hamlib_tuner_control (default)
If file exists then it will be called with 0/1 (Off/On) argument
with 'U TUNER 0' or 'U TUNER 1"
Default path is for current directory
* Add MDS 4710/9710 rigs * Add MDS 4710/9710 rigs
* Add FLIR PTU-D48, E46, D100, D300 rotors * Add FLIR PTU-D48, E46, D100, D300 rotors
* Fix FTDX3000 rig split * Fix FTDX3000 rig split

Wyświetl plik

@ -187,8 +187,30 @@ above. Note the dummy device has no serial parameters.
. .
.TP .TP
.BR \-C ", " \-\-set\-conf = \fIparm=val\fP [ \fI,parm=val\fP ] .BR \-C ", " \-\-set\-conf = \fIparm=val\fP [ \fI,parm=val\fP ]
Set radio configuration parameter(s), e.g. Set configuration parameter(s). Some common ones are:
.IR stop_bits=2 . .in +4n
.EX
.RB write_delay: "Delay in ms between each byte sent out"
.RB post_write_delay: "Delay in ms between each command sent out"
.RB timeout: "Timeout in ms"
.RB retry: "Max number of retry"
.RB ptt_type: "Push-To-Talk interface type override"
.RB ptt_pathname: "Path name to the device file of the Push-To-Talk"
.RB ptt_bitnum: "Push-To-Talk GPIO bit number"
.RB dcd_type: "Data Carrier Detect (or squelch) interface type override"
.RB dcd_pathname: "Path name to the device file of the Data Carrier Detect (or squelch)"
.RB lo_freq: "Frequency to add to the VFO frequency for use with a transverter"
.RB auto_power_on: "True enables compatible rigs to be powered up on open"
.RB auto_power_off: "True enables compatible rigs to be powered down on close"
.RB auto_disable_screensaver: "True enables compatible rigs to have their screen saver disabled on open"
.RB disable_yaesu_bandselect: "True disables the automatic band select on band change for Yaesu rigs"
.RB ptt_share: "True enables ptt port to be shared with other apps"
.RB twiddle_timeout: "For satellite ops when VFOB is twiddled will pause VFOB commands until timeout"
.RB twiddle_rit: "Suppress get_freq on VFOB for RIT tuning satellites"
.RB async: "True enables asynchronous data transfer for backends that support it. This allows use of transceive and spectrum data."
.RB tuner_control_pathname: "Path name to a script/program to control a tuner with 1 argument of 0/1 for Tuner Off/On"
.EE
.in
.IP .IP
Use the Use the
.B -L .B -L

Wyświetl plik

@ -293,8 +293,30 @@ above.
. .
.TP .TP
.BR \-C ", " \-\-set\-conf = \fIparm=val\fP [ \fI,parm=val\fP ] .BR \-C ", " \-\-set\-conf = \fIparm=val\fP [ \fI,parm=val\fP ]
Set radio configuration parameter(s), e.g. Set configuration parameter(s). Some common ones are:
.IR stop_bits=2 . .in +4
.EX
.RB write_delay: "Delay in ms between each byte sent out"
.RB post_write_delay: "Delay in ms between each command sent out"
.RB timeout: "Timeout in ms"
.RB retry: "Max number of retry"
.RB ptt_type: "Push-To-Talk interface type override"
.RB ptt_pathname: "Path name to the device file of the Push-To-Talk"
.RB ptt_bitnum: "Push-To-Talk GPIO bit number"
.RB dcd_type: "Data Carrier Detect (or squelch) interface type override"
.RB dcd_pathname: "Path name to the device file of the Data Carrier Detect (or squelch)"
.RB lo_freq: "Frequency to add to the VFO frequency for use with a transverter"
.RB auto_power_on: "True enables compatible rigs to be powered up on open"
.RB auto_power_off: "True enables compatible rigs to be powered down on close"
.RB auto_disable_screensaver: "True enables compatible rigs to have their screen saver disabled on open"
.RB disable_yaesu_bandselect: "True disables the automatic band select on band change for Yaesu rigs"
.RB ptt_share: "True enables ptt port to be shared with other apps"
.RB twiddle_timeout: "For satellite ops when VFOB is twiddled will pause VFOB commands until timeout"
.RB twiddle_rit: "Suppress get_freq on VFOB for RIT tuning satellites"
.RB async: "True enables asynchronous data transfer for backends that support it. This allows use of transceive and spectrum data."
.RB tuner_control_pathname: "Path name to a script/program to control a tuner with 1 argument of 0/1 for Tuner Off/On"
.EE
.in
.IP .IP
Use the Use the
.B -L .B -L

Wyświetl plik

@ -2588,6 +2588,7 @@ struct rig_state {
int depth; /*<! a depth counter to use for debug indentation and such */ int depth; /*<! a depth counter to use for debug indentation and such */
int lock_mode; /*<! flag that prevents mode changes if ~= 0 -- see set/get_lock_mode */ int lock_mode; /*<! flag that prevents mode changes if ~= 0 -- see set/get_lock_mode */
powerstat_t powerstat; /*<! power status */ powerstat_t powerstat; /*<! power status */
char *tuner_control_pathname; /*<! Path to external tuner control program that get 0/1 (Off/On) argument */
}; };
//! @cond Doxygen_Suppress //! @cond Doxygen_Suppress

Wyświetl plik

@ -170,6 +170,11 @@ static const struct confparams frontend_cfg_params[] =
"True enables asynchronous data transfer for backends that support it. This allows use of transceive and spectrum data.", "True enables asynchronous data transfer for backends that support it. This allows use of transceive and spectrum data.",
"0", RIG_CONF_CHECKBUTTON, { } "0", RIG_CONF_CHECKBUTTON, { }
}, },
{
TOK_TUNER_CONTROL_PATHNAME, "tuner_control_pathname", "Tuner script/program path name",
"Path name to a script/program to control a tuner with 1 argument of 0/1 for Tuner Off/On",
"hamlib_tuner_control", RIG_CONF_STRING,
},
{ RIG_CONF_END, NULL, } { RIG_CONF_END, NULL, }
}; };
@ -715,6 +720,11 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
rs->async_data_enabled = val_i ? 1 : 0; rs->async_data_enabled = val_i ? 1 : 0;
break; break;
case TOK_TUNER_CONTROL_PATHNAME:
rs->tuner_control_pathname = strdup(val); // yeah -- need to free it
break;
default: default:
return -RIG_EINVAL; return -RIG_EINVAL;
} }

Wyświetl plik

@ -143,6 +143,8 @@ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */
# define DEFAULT_CM108_PORT "/dev/hidraw0" # define DEFAULT_CM108_PORT "/dev/hidraw0"
#endif #endif
#define DEFAULT_TUNER_CONTROL_PATHNAME "hamlib_tuner_control"
#if defined(WIN32) && !defined(__CYGWIN__) #if defined(WIN32) && !defined(__CYGWIN__)
/* FIXME: Determine correct GPIO bit number for W32 using MinGW. */ /* FIXME: Determine correct GPIO bit number for W32 using MinGW. */
# define DEFAULT_CM108_PTT_BITNUM 2 # define DEFAULT_CM108_PTT_BITNUM 2
@ -564,6 +566,8 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
rs->rigport.asyncio = 0; rs->rigport.asyncio = 0;
#endif #endif
rs->tuner_control_pathname = DEFAULT_TUNER_CONTROL_PATHNAME;
switch (caps->port_type) switch (caps->port_type)
{ {
case RIG_PORT_SERIAL: case RIG_PORT_SERIAL:

Wyświetl plik

@ -39,6 +39,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> /* Error number definitions */ #include <errno.h> /* Error number definitions */
#include <unistd.h>
#include <hamlib/rig.h> #include <hamlib/rig.h>
#include "cal.h" #include "cal.h"
@ -488,11 +489,34 @@ int HAMLIB_API rig_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
caps = rig->caps; caps = rig->caps;
if (caps->set_func == NULL || !rig_has_set_func(rig, func)) if ((caps->set_func == NULL || !rig_has_set_func(rig, func))
&& access(rig->state.tuner_control_pathname, X_OK) == -1)
{ {
return -RIG_ENAVAIL; return -RIG_ENAVAIL;
} }
if (access(rig->state.tuner_control_pathname, X_OK) != -1)
{
char cmd[1024];
snprintf(cmd, sizeof(cmd), "%s %d", rig->state.tuner_control_pathname, status);
rig_debug(RIG_DEBUG_TRACE, "%s: Calling external script '%s'\n", __func__,
rig->state.tuner_control_pathname);
retcode = system(cmd);
if (retcode != 0) { rig_debug(RIG_DEBUG_ERR, "%s: executing %s failed\n", __func__, rig->state.tuner_control_pathname); }
return (retcode == 0 ? RIG_OK : -RIG_ERJCTED);
}
else
{
if (strcmp(rig->state.tuner_control_pathname, "hamlib_tuner_control"))
{
rig_debug(RIG_DEBUG_ERR, "%s: unable to find '%s'\n", __func__,
rig->state.tuner_control_pathname);
return -RIG_EINVAL;
}
}
if ((caps->targetable_vfo & RIG_TARGETABLE_FUNC) if ((caps->targetable_vfo & RIG_TARGETABLE_FUNC)
|| vfo == RIG_VFO_CURR || vfo == RIG_VFO_CURR
|| vfo == rig->state.current_vfo) || vfo == rig->state.current_vfo)

Wyświetl plik

@ -93,6 +93,8 @@
#define TOK_FLUSHX TOKEN_FRONTEND(36) #define TOK_FLUSHX TOKEN_FRONTEND(36)
/** \brief Asynchronous data transfer support */ /** \brief Asynchronous data transfer support */
#define TOK_ASYNC TOKEN_FRONTEND(37) #define TOK_ASYNC TOKEN_FRONTEND(37)
/** \brief Tuner external control pathname */
#define TOK_TUNER_CONTROL_PATHNAME TOKEN_FRONTEND(38)
/* /*
* rig specific tokens * rig specific tokens

Wyświetl plik

@ -0,0 +1,8 @@
#!/bin/sh
if [ "$#" -eq 0 ]
then
echo "Expected arg 0 or 1...got nothing"
exit 1
fi
echo Tuner Control $1
echo `date` " " Tuner Control $1 >>tuner_control.log