diff --git a/NEWS b/NEWS index 730d37798..36502060b 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,10 @@ Version 5.x -- future Version 4.6 * 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 FLIR PTU-D48, E46, D100, D300 rotors * Fix FTDX3000 rig split diff --git a/doc/man1/rigctl.1 b/doc/man1/rigctl.1 index 73bc13207..33e75464f 100644 --- a/doc/man1/rigctl.1 +++ b/doc/man1/rigctl.1 @@ -187,8 +187,30 @@ above. Note the dummy device has no serial parameters. . .TP .BR \-C ", " \-\-set\-conf = \fIparm=val\fP [ \fI,parm=val\fP ] -Set radio configuration parameter(s), e.g. -.IR stop_bits=2 . +Set configuration parameter(s). Some common ones are: +.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 Use the .B -L diff --git a/doc/man1/rigctld.1 b/doc/man1/rigctld.1 index 391920a7b..0e82f40da 100644 --- a/doc/man1/rigctld.1 +++ b/doc/man1/rigctld.1 @@ -293,8 +293,30 @@ above. . .TP .BR \-C ", " \-\-set\-conf = \fIparm=val\fP [ \fI,parm=val\fP ] -Set radio configuration parameter(s), e.g. -.IR stop_bits=2 . +Set configuration parameter(s). Some common ones are: +.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 Use the .B -L diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 6c768168d..d93e7986f 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2588,6 +2588,7 @@ struct rig_state { int depth; /*async_data_enabled = val_i ? 1 : 0; break; + case TOK_TUNER_CONTROL_PATHNAME: + rs->tuner_control_pathname = strdup(val); // yeah -- need to free it + break; + + default: return -RIG_EINVAL; } diff --git a/src/rig.c b/src/rig.c index 52a7a393c..87876dcbf 100644 --- a/src/rig.c +++ b/src/rig.c @@ -143,6 +143,8 @@ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */ # define DEFAULT_CM108_PORT "/dev/hidraw0" #endif +#define DEFAULT_TUNER_CONTROL_PATHNAME "hamlib_tuner_control" + #if defined(WIN32) && !defined(__CYGWIN__) /* FIXME: Determine correct GPIO bit number for W32 using MinGW. */ # define DEFAULT_CM108_PTT_BITNUM 2 @@ -564,6 +566,8 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model) rs->rigport.asyncio = 0; #endif + rs->tuner_control_pathname = DEFAULT_TUNER_CONTROL_PATHNAME; + switch (caps->port_type) { case RIG_PORT_SERIAL: diff --git a/src/settings.c b/src/settings.c index 73d1fc98c..33c24b76d 100644 --- a/src/settings.c +++ b/src/settings.c @@ -39,6 +39,7 @@ #include #include #include /* Error number definitions */ +#include #include #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; - 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; } + 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) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) diff --git a/src/token.h b/src/token.h index 46b80f19e..186f9b1ed 100644 --- a/src/token.h +++ b/src/token.h @@ -93,6 +93,8 @@ #define TOK_FLUSHX TOKEN_FRONTEND(36) /** \brief Asynchronous data transfer support */ #define TOK_ASYNC TOKEN_FRONTEND(37) +/** \brief Tuner external control pathname */ +#define TOK_TUNER_CONTROL_PATHNAME TOKEN_FRONTEND(38) /* * rig specific tokens diff --git a/tests/hamlib_tuner_control b/tests/hamlib_tuner_control new file mode 100755 index 000000000..4f5b923e9 --- /dev/null +++ b/tests/hamlib_tuner_control @@ -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