pull/453/head
Michael Black W9MDB 2020-11-26 08:46:45 -06:00
commit d8be93350f
5 zmienionych plików z 25 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
*/

Wyświetl plik

@ -1446,6 +1446,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc,
/* only for rotctld */
if (interactive && !prompt)
{
rot_debug(RIG_DEBUG_TRACE, "%s: NETROTCTL_RET %d\n", __func__, retcode);
fprintf(fout, NETROTCTL_RET "%d\n", retcode);
// ext_resp = 0; // not used ?
resp_sep = '\n';
@ -1466,12 +1467,14 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc,
/* netrotctl RIG_OK */
if (!(cmd_entry->flags & ARG_OUT) && !ext_resp)
{
rot_debug(RIG_DEBUG_TRACE, "%s: NETROTCTL_RET 0\n", __func__);
fprintf(fout, NETROTCTL_RET "0\n");
}
/* Extended Response protocol */
else if (ext_resp && cmd != 0xf0)
{
rot_debug(RIG_DEBUG_TRACE, "%s: NETROTCTL_RET 0\n", __func__);
fprintf(fout, NETROTCTL_RET "0\n");
resp_sep = '\n';
}