kopia lustrzana https://github.com/Hamlib/Hamlib
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/446pull/453/head
rodzic
a475ebf017
commit
8827f081dd
|
@ -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
|
||||
|
||||
|
|
13
src/conf.c
13
src/conf.c
|
@ -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;
|
||||
|
|
10
src/serial.c
10
src/serial.c
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Ładowanie…
Reference in New Issue