Make retries in case of read timeout optional and configurable via set-conf option. When not absolutely necessary, they will significantly slow down flushing and normal serial communications with a rig

pull/1289/head
Mikael Nousiainen 2023-05-14 11:52:48 +03:00
rodzic e89687668d
commit c75fdeb3e4
4 zmienionych plików z 28 dodań i 8 usunięć

Wyświetl plik

@ -2292,8 +2292,8 @@ typedef struct hamlib_port {
int value; /*!< Toggle PTT ON or OFF */
} gpio; /*!< GPIO attributes */
} parm; /*!< Port parameter union */
int client_port; /*!< client socket port for tcp connection */
RIG *rig; /*!< our parent RIG device */
int client_port; /*!< client socket port for tcp connection */
RIG *rig; /*!< our parent RIG device */
int asyncio; /*!< enable asynchronous data handling if true -- async collides with python keyword so _async is used */
#if defined(_WIN32)
hamlib_async_pipe_t *sync_data_pipe; /*!< pipe data structure for synchronous data */
@ -2304,6 +2304,7 @@ typedef struct hamlib_port {
int fd_sync_error_write; /*!< file descriptor for writing synchronous data error codes */
int fd_sync_error_read; /*!< file descriptor for reading synchronous data error codes */
#endif
short timeout_retry; /*!< number of retries to make in case of read timeout errors, some serial interfaces may require this, 0 to disable */
} hamlib_port_t;

Wyświetl plik

@ -69,6 +69,11 @@ static const struct confparams frontend_cfg_params[] =
TOK_RETRY, "retry", "Retry", "Max number of retry",
"0", RIG_CONF_NUMERIC, { .n = { 0, 10, 1 } }
},
{
TOK_TIMEOUT_RETRY, "timeout_retry", "Number of retries for read timeouts",
"Set the number of retries for data read timeouts that may occur especially with some serial interfaces",
"0", RIG_CONF_NUMERIC, { .n = { 0, 100, 1 } }
},
{
TOK_RANGE_SELECTED, "Selected range list", "Range list#",
"The tx/rx range list in use",
@ -738,6 +743,15 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
rs->tuner_control_pathname = strdup(val); // yeah -- need to free it
break;
case TOK_TIMEOUT_RETRY:
if (1 != sscanf(val, "%ld", &val_i))
{
return -RIG_EINVAL;
}
rs->rigport.timeout_retry = val_i;
break;
case TOK_OFFSET_VFOA:
if (1 != sscanf(val, "%ld", &val_i))
{
@ -1111,6 +1125,10 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
SNPRINTF(val, val_len, "%d", rs->async_data_enabled);
break;
case TOK_TIMEOUT_RETRY:
SNPRINTF(val, val_len, "%d", rs->rigport.timeout_retry);
break;
default:
return -RIG_EINVAL;
}

Wyświetl plik

@ -1321,7 +1321,7 @@ static int read_string_generic(hamlib_port_t *p,
memset(rxbuffer, 0, rxmax);
int flag = 0; // we will allow one timeout
short timeout_retries = p->timeout_retry;
while (total_count < rxmax - 1) // allow 1 byte for end-of-string
{
@ -1332,12 +1332,11 @@ static int read_string_generic(hamlib_port_t *p,
if (result == -RIG_ETIMEOUT)
{
rig_debug(RIG_DEBUG_CACHE, "%s: flag=%d\n", __func__, flag);
if (flag == 0)
if (timeout_retries > 0)
{
flag = 1;
hl_usleep(50 * 1000);
rig_debug(RIG_DEBUG_CACHE, "%s: retrying read timeout %d/%d\n", __func__,
timeout_retries + 1, p->timeout_retry);
hl_usleep(10 * 1000);
continue;
}

Wyświetl plik

@ -95,6 +95,8 @@
#define TOK_ASYNC TOKEN_FRONTEND(37)
/** \brief Tuner external control pathname */
#define TOK_TUNER_CONTROL_PATHNAME TOKEN_FRONTEND(38)
/** \brief Number of retries permitted in case of read timeouts */
#define TOK_TIMEOUT_RETRY TOKEN_FRONTEND(39)
/*
* rig specific tokens