Add flushx option for MicroHam devices to allow flushing by read instead of tcflush.

The special name of uh-rig only works on Linux and has other purposes apparently for ptt use
https://github.com/Hamlib/Hamlib/issues/446
pull/453/head
Michael Black W9MDB 2020-11-25 08:40:24 -06:00
rodzic a475ebf017
commit 8827f081dd
4 zmienionych plików z 22 dodań i 4 usunięć

Wyświetl plik

@ -1901,6 +1901,7 @@ typedef struct hamlib_port {
int value; /*!< Toggle PTT ON or OFF */
} gpio; /*!< GPIO attributes */
} parm; /*!< Port parameter union */
int flushx; /*!< If true flush is done with read instead of TCFLUSH - MicroHam */
} hamlib_port_t;
//! @endcond

Wyświetl plik

@ -143,6 +143,11 @@ static const struct confparams frontend_cfg_params[] =
"True enables ptt port to be shared with other apps",
"0", RIG_CONF_CHECKBUTTON, { }
},
{
TOK_FLUSHX, "flushx", "Flush with read instead of TCFLUSH",
"True enables flushing serial port with read instead of TCFLUSH -- MicroHam",
"0", RIG_CONF_CHECKBUTTON, { }
},
{ RIG_CONF_END, NULL, }
};
@ -594,6 +599,14 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
rs->ptt_share = val_i ? 1 : 0;
break;
case TOK_FLUSHX:
if (1 != sscanf(val, "%d", &val_i))
{
return -RIG_EINVAL; //value format error
}
rs->rigport.flushx = val_i ? 1 : 0;
break;
default:
return -RIG_EINVAL;

Wyświetl plik

@ -607,7 +607,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd || p->flushx)
{
unsigned char buf[32];
/*
@ -615,24 +615,26 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
* if fd corresponds to a microHam device drain the line
* (which is a socket) by reading until it is empty.
*/
int n;
int n, nbytes=0;
rig_debug(RIG_DEBUG_TRACE, "%s: flushing: ", __func__);
rig_debug(RIG_DEBUG_TRACE, "%s: flushing\n", __func__);
while ((n = read(p->fd, buf, 32)) > 0)
{
nbytes += n;
//int i;
//for (i = 0; i < n; ++i) { printf("0x%02x(%c) ", buf[i], isprint(buf[i]) ? buf[i] : '~'); }
/* do nothing */
}
rig_debug(RIG_DEBUG_TRACE, "read flushed %d bytes\n", nbytes);
return RIG_OK;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s: tcflush\n", __func__);
rig_debug(RIG_DEBUG_VERBOSE, "tcflush%s\n", "");
tcflush(p->fd, TCIFLUSH);
return RIG_OK;
}

Wyświetl plik

@ -89,6 +89,8 @@
#define TOK_PTT_BITNUM TOKEN_FRONTEND(34)
/** \brief PTT share with other applications */
#define TOK_PTT_SHARE TOKEN_FRONTEND(35)
/** \brief PTT share with other applications */
#define TOK_FLUSHX TOKEN_FRONTEND(36)
/*
* rig specific tokens
*/