Change get_ptt RTS/DTR to keep serial port open

New option --set-conf=ptt_share=1 to revert to old behavior where serial port is opened/closed every get_ptt
https://github.com/Hamlib/Hamlib/issues/383
pull/420/head
Michael Black W9MDB 2020-10-12 23:27:13 -05:00
rodzic 70a448fe85
commit 4faad82da7
5 zmienionych plików z 23 dodań i 4 usunięć

1
NEWS
Wyświetl plik

@ -30,6 +30,7 @@ Version 4.0
* New rig backend for Elecraft K4.
* New rig backend for PowerSDR (Flex and Apache users).
* Many fixes and enhancements. Mike, W9MDB and many contributors
* PTT port is no longer shared by default, use --set-conf=ptt_share=1 to enable
Version 3.3
2018-08-12

Wyświetl plik

@ -2039,6 +2039,7 @@ struct rig_state {
int auto_disable_screensaver; /*!< Allow Hamlib to disable the
rig's screen saver automatically if
supported */
int ptt_share; /*!< Share ptt port by open/close during get_ptt, set_ptt hogs the port while active */
int power_now; /*!< Current RF power level in rig units */
int power_min; /*!< Minimum RF power level in rig units */
int power_max; /*!< Maximum RF power level in rig units */

Wyświetl plik

@ -138,6 +138,11 @@ static const struct confparams frontend_cfg_params[] =
"True enables compatible rigs to have their screen saver disabled on open",
"0", RIG_CONF_CHECKBUTTON, { }
},
{
TOK_PTT_SHARE, "ptt_share", "Share ptt port with other apps",
"True enables ptt port to be shared with other apps",
"0", RIG_CONF_CHECKBUTTON, { }
},
{ RIG_CONF_END, NULL, }
};
@ -580,6 +585,16 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
rs->auto_disable_screensaver = val_i ? 1 : 0;
break;
case TOK_PTT_SHARE:
if (1 != sscanf(val, "%d", &val_i))
{
return -RIG_EINVAL; //value format error
}
rs->ptt_share = val_i ? 1 : 0;
break;
default:
return -RIG_EINVAL;
}

Wyświetl plik

@ -2233,9 +2233,9 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
retcode = ser_set_dtr(&rig->state.pttport, ptt != RIG_PTT_OFF);
if (strcmp(rs->pttport.pathname, rs->rigport.pathname)
&& ptt == RIG_PTT_OFF)
&& ptt == RIG_PTT_OFF && rs->ptt_share != 0)
{
rig_debug(RIG_DEBUG_TRACE, "%s: ptt_share=%d\n", __func__, rs->ptt_share);
/* free the port */
ser_close(&rs->pttport);
}
@ -2280,9 +2280,9 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
retcode = ser_set_rts(&rig->state.pttport, ptt != RIG_PTT_OFF);
if (strcmp(rs->pttport.pathname, rs->rigport.pathname)
&& ptt == RIG_PTT_OFF)
&& ptt == RIG_PTT_OFF && rs->ptt_share != 0)
{
rig_debug(RIG_DEBUG_TRACE, "%s: ptt_share=%d\n", __func__, rs->ptt_share);
/* free the port */
ser_close(&rs->pttport);
}

Wyświetl plik

@ -87,6 +87,8 @@
#define TOK_DCD_PATHNAME TOKEN_FRONTEND(33)
/** \brief CM108 GPIO bit number for PTT */
#define TOK_PTT_BITNUM TOKEN_FRONTEND(34)
/** \brief PTT share with other applications */
#define TOK_PTT_SHARE TOKEN_FRONTEND(35)
/*
* rig specific tokens
*/