kopia lustrzana https://github.com/Hamlib/Hamlib
Fix a state machine defect with repeated PTT reset calls
When the PTT serial port is not the control port the intention is to free the port when PTT is reset so that other applications can share it. This logic was faulty with attempts to call port functions on an unopened port when repeatedly calling the rig_set_ptt API. Thanks to Christoph van Wullen, DL1YCF, for finding and analyzing this defect.astyle-formatting
rodzic
14a74b1275
commit
62fb76019f
14
src/rig.c
14
src/rig.c
|
@ -1333,9 +1333,14 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PTT_SERIAL_DTR:
|
case RIG_PTT_SERIAL_DTR:
|
||||||
|
/* when the PTT port is not the control port we want to free the
|
||||||
|
port when PTT is reset and seize the port when PTT is set,
|
||||||
|
this allows limited sharing of the PTT port between
|
||||||
|
applications so long as there is no contention */
|
||||||
if (strcmp(rs->pttport.pathname, rs->rigport.pathname)
|
if (strcmp(rs->pttport.pathname, rs->rigport.pathname)
|
||||||
&& ptt!=RIG_PTT_OFF && rs->pttport.fd < 0)
|
&& rs->pttport.fd < 0)
|
||||||
{
|
{
|
||||||
|
if (RIG_PTT_OFF == ptt) return RIG_OK; /* nothing to do here */
|
||||||
rs->pttport.fd = ser_open(&rs->pttport);
|
rs->pttport.fd = ser_open(&rs->pttport);
|
||||||
if (rs->pttport.fd < 0)
|
if (rs->pttport.fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -1359,9 +1364,14 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||||
return retcode;
|
return retcode;
|
||||||
|
|
||||||
case RIG_PTT_SERIAL_RTS:
|
case RIG_PTT_SERIAL_RTS:
|
||||||
|
/* when the PTT port is not the control port we want to free the
|
||||||
|
port when PTT is reset and seize the port when PTT is set,
|
||||||
|
this allows limited sharing of the PTT port between
|
||||||
|
applications so long as there is no contention */
|
||||||
if (strcmp(rs->pttport.pathname, rs->rigport.pathname)
|
if (strcmp(rs->pttport.pathname, rs->rigport.pathname)
|
||||||
&& ptt!=RIG_PTT_OFF && rs->pttport.fd < 0)
|
&& rs->pttport.fd < 0)
|
||||||
{
|
{
|
||||||
|
if (RIG_PTT_OFF == ptt) return RIG_OK; /* nothing to do here */
|
||||||
rs->pttport.fd = ser_open(&rs->pttport);
|
rs->pttport.fd = ser_open(&rs->pttport);
|
||||||
if (rs->pttport.fd < 0)
|
if (rs->pttport.fd < 0)
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue