kopia lustrzana https://github.com/Hamlib/Hamlib
Add expected_len to read_string function for potential serial I/O speedup
https://github.com/Hamlib/Hamlib/issues/850Hamlib-4.4
rodzic
e58db5cd52
commit
d820ee9dbf
|
@ -126,7 +126,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
|
|||
|
||||
if (err != RIG_OK) { return err; }
|
||||
|
||||
len = read_string(&rs->ampport, response, response_len, ";", 1, 0);
|
||||
len = read_string(&rs->ampport, response, response_len, ";", 1, 0, 1);
|
||||
|
||||
if (len < 0) { return len; }
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
|
|||
if (response) // if response expected get it
|
||||
{
|
||||
response[0] = 0;
|
||||
len = read_string(&rs->ampport, response, response_len, ";", 1, 0);
|
||||
len = read_string(&rs->ampport, response, response_len, ";", 1, 0, 1);
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
|
@ -166,7 +166,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
|
|||
|
||||
if (err != RIG_OK) { return err; }
|
||||
|
||||
len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1, 0);
|
||||
len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1, 0, 1);
|
||||
|
||||
if (len < 0) { return len; }
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
|
|||
//
|
||||
do
|
||||
{
|
||||
retval = read_string(&rs->ampport, responsebuf, sizeof(responsebuf), ";", 1, 0);
|
||||
retval = read_string(&rs->ampport, responsebuf, sizeof(responsebuf), ";", 1, 0, 1);
|
||||
|
||||
if (retval != RIG_OK) { return retval; }
|
||||
|
||||
|
|
|
@ -1294,7 +1294,7 @@ int adat_receive(RIG *pRig,
|
|||
"*** ADAT: %d %s (%s:%d): ENTRY. Params: pRig = %p\n",
|
||||
gFnLevel, __func__, __FILE__, __LINE__, pRig);
|
||||
|
||||
nRC = read_string(&pRigState->rigport, pcData, ADAT_RESPSZ, ADAT_EOL, 1, 0);
|
||||
nRC = read_string(&pRigState->rigport, pcData, ADAT_RESPSZ, ADAT_EOL, 1, 0, 1);
|
||||
|
||||
if (nRC > 0)
|
||||
{
|
||||
|
@ -3726,7 +3726,7 @@ DECLARE_PROBERIG_BACKEND(adat)
|
|||
nRC = write_block(port,
|
||||
ADAT_CMD_DEF_STRING_GET_ID_CODE,
|
||||
strlen(ADAT_CMD_DEF_STRING_GET_ID_CODE));
|
||||
nRead = read_string(port, acBuf, ADAT_RESPSZ, ADAT_EOM, 1, 0);
|
||||
nRead = read_string(port, acBuf, ADAT_RESPSZ, ADAT_EOM, 1, 0, 1);
|
||||
close(port->fd);
|
||||
|
||||
if ((nRC != RIG_OK || nRead < 0))
|
||||
|
|
|
@ -321,7 +321,7 @@ int dx77_transaction(RIG *rig,
|
|||
* Transceiver sends an echo of cmd followed by a CR/LF
|
||||
* TODO: check whether cmd and echobuf match (optional)
|
||||
*/
|
||||
retval = read_string(&rs->rigport, echobuf, BUFSZ, LF, strlen(LF), 0);
|
||||
retval = read_string(&rs->rigport, echobuf, BUFSZ, LF, strlen(LF), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -337,7 +337,7 @@ int dx77_transaction(RIG *rig,
|
|||
/* no data expected, check for OK returned */
|
||||
if (data == NULL)
|
||||
{
|
||||
retval = read_string(&rs->rigport, echobuf, BUFSZ, LF, strlen(LF), 0);
|
||||
retval = read_string(&rs->rigport, echobuf, BUFSZ, LF, strlen(LF), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -358,7 +358,7 @@ int dx77_transaction(RIG *rig,
|
|||
}
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, LF, strlen(LF), 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, LF, strlen(LF), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -264,7 +264,7 @@ int dxsr8_transaction(RIG *rig,
|
|||
* Transceiver sends an echo of cmd followed by a CR/LF
|
||||
* TODO: check whether cmd and echobuf match (optional)
|
||||
*/
|
||||
retval = read_string(&rs->rigport, replybuf, BUFSZ, LF, strlen(LF), 0);
|
||||
retval = read_string(&rs->rigport, replybuf, BUFSZ, LF, strlen(LF), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -272,7 +272,7 @@ int dxsr8_transaction(RIG *rig,
|
|||
}
|
||||
|
||||
|
||||
retval = read_string(&rs->rigport, replybuf, BUFSZ, LF, strlen(LF), 0);
|
||||
retval = read_string(&rs->rigport, replybuf, BUFSZ, LF, strlen(LF), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -102,7 +102,7 @@ static int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
/*
|
||||
* Do wait for a reply
|
||||
*/
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -1428,7 +1428,7 @@ int aor_get_chan_all_cb(RIG *rig, vfo_t vfo, chan_cb_t chan_cb, rig_ptr_t arg)
|
|||
/*
|
||||
* get next line
|
||||
*/
|
||||
retval = read_string(&rig->state.rigport, chanbuf, BUFSZ, EOM, strlen(EOM), 0);
|
||||
retval = read_string(&rig->state.rigport, chanbuf, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -211,7 +211,7 @@ static int ar3k_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
|
|
@ -247,7 +247,7 @@ static int ar3030_transaction(RIG *rig, const char *cmd, int cmd_len,
|
|||
if (data)
|
||||
{
|
||||
/* expecting 0x0d0x0a on all commands so wait for the 0x0a */
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, "\x0a", 1, 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, "\x0a", 1, 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
|
|
@ -307,7 +307,7 @@ static int sr2200_transaction(RIG *rig, const char *cmd, int cmd_len,
|
|||
/*
|
||||
* Do wait for a reply
|
||||
*/
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -244,7 +244,7 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
|
|||
{
|
||||
// response format is 0x11,data...,0x0d,0x0a,0x13
|
||||
retval = read_string(&rs->rigport, priv->ret_data, sizeof(priv->ret_data),
|
||||
"\x11", 1, 0);
|
||||
"\x11", 1, 0, 1);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: resultlen=%d\n", __func__,
|
||||
(int)strlen(priv->ret_data));
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ struct dra818_priv
|
|||
static int dra818_response(RIG *rig, const char *expected)
|
||||
{
|
||||
char response[80];
|
||||
int r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1, 0);
|
||||
int r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1, 0, 1);
|
||||
|
||||
if (r != strlen(expected))
|
||||
{
|
||||
|
@ -294,7 +294,7 @@ int dra818_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
|
|||
(int)(priv->rx_freq / 1000000), (int)((priv->rx_freq % 1000000) / 100));
|
||||
write_block(&rig->state.rigport, cmd, strlen(cmd));
|
||||
|
||||
r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1, 0);
|
||||
r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1, 0, 1);
|
||||
|
||||
if (r != 5)
|
||||
{
|
||||
|
|
|
@ -84,7 +84,7 @@ int drake_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, LF, 1, 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, LF, 1, 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
@ -1252,7 +1252,7 @@ DECLARE_PROBERIG_BACKEND(drake)
|
|||
}
|
||||
|
||||
retval = write_block(port, "ID" EOM, 3);
|
||||
id_len = read_string(port, idbuf, BUFSZ, LF, 1, 0);
|
||||
id_len = read_string(port, idbuf, BUFSZ, LF, 1, 0, 1);
|
||||
|
||||
close(port->fd);
|
||||
|
||||
|
|
|
@ -456,7 +456,7 @@ static int read_transaction(RIG *rig, char *xml, int xml_len)
|
|||
}
|
||||
|
||||
int len = read_string(&rs->rigport, tmp_buf, sizeof(tmp_buf), delims,
|
||||
strlen(delims), 0);
|
||||
strlen(delims), 0, 1);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: string='%s'\n", __func__, tmp_buf);
|
||||
|
||||
// if our first response we should see the HTTP header
|
||||
|
|
|
@ -52,7 +52,7 @@ static int netampctl_transaction(AMP *amp, char *cmd, int len, char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ static int netampctl_open(AMP *amp)
|
|||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ static int netampctl_open(AMP *amp)
|
|||
|
||||
do
|
||||
{
|
||||
ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ static int netrigctl_transaction(RIG *rig, char *cmd, int len, char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -312,14 +312,14 @@ static int netrigctl_open(RIG *rig)
|
|||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -330,7 +330,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
for (i = 0; i < HAMLIB_FRQRANGESIZ; i++)
|
||||
{
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -360,7 +360,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
for (i = 0; i < HAMLIB_FRQRANGESIZ; i++)
|
||||
{
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -402,7 +402,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
for (i = 0; i < HAMLIB_TSLSTSIZ; i++)
|
||||
{
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -426,7 +426,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
for (i = 0; i < HAMLIB_FLTLSTSIZ; i++)
|
||||
{
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -453,7 +453,7 @@ static int netrigctl_open(RIG *rig)
|
|||
chan_t chan_list[HAMLIB_CHANLSTSIZ]; /*!< Channel list, zero ended */
|
||||
#endif
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -462,7 +462,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->max_rit = rs->max_rit = atol(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -471,7 +471,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->max_xit = rs->max_xit = atol(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -480,7 +480,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->max_ifshift = rs->max_ifshift = atol(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -489,7 +489,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rs->announces = atoi(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -516,7 +516,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->preamp[ret] = rs->preamp[ret] = RIG_DBLST_END;
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -543,7 +543,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->attenuator[ret] = rs->attenuator[ret] = RIG_DBLST_END;
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -552,7 +552,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->has_get_func = rs->has_get_func = strtoll(buf, NULL, 0);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -561,7 +561,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->has_set_func = rs->has_set_func = strtoll(buf, NULL, 0);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -583,7 +583,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
#endif
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -592,7 +592,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->has_set_level = rs->has_set_level = strtoll(buf, NULL, 0);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -601,7 +601,7 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rs->has_get_parm = strtoll(buf, NULL, 0);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -641,7 +641,7 @@ static int netrigctl_open(RIG *rig)
|
|||
do
|
||||
{
|
||||
char setting[32], value[1024];
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
strtok(buf, "\r\n"); // chop the EOL
|
||||
|
||||
if (ret <= 0)
|
||||
|
@ -892,7 +892,7 @@ static int netrigctl_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
CHKSCN1ARG(num_sscanf(buf, "%"SCNfreq, freq));
|
||||
|
||||
#if 0 // implement set_freq VFO later if it can be detected
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -963,7 +963,7 @@ static int netrigctl_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
|
|||
|
||||
*mode = rig_parse_mode(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -1576,7 +1576,7 @@ static int netrigctl_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
|
|||
|
||||
*tx_mode = rig_parse_mode(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -1642,7 +1642,7 @@ static int netrigctl_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
|
|||
|
||||
*split = atoi(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -2164,7 +2164,7 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
|
|||
ret);
|
||||
}
|
||||
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0);
|
||||
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ static int netrotctl_transaction(ROT *rot, char *cmd, int len, char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -100,14 +100,14 @@ static int netrotctl_open(ROT *rot)
|
|||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ static int netrotctl_open(ROT *rot)
|
|||
|
||||
rs->min_az = atof(buf);
|
||||
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ static int netrotctl_open(ROT *rot)
|
|||
|
||||
rs->max_az = atof(buf);
|
||||
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ static int netrotctl_open(ROT *rot)
|
|||
|
||||
rs->min_el = atof(buf);
|
||||
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ static int netrotctl_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
|||
|
||||
*az = atof(buf);
|
||||
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
|
|
@ -243,7 +243,7 @@ static int read_transaction(RIG *rig, char *response, int response_len)
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
|
||||
|
||||
len = read_string(&rs->rigport, response, response_len, delims,
|
||||
strlen(delims), 0);
|
||||
strlen(delims), 0, 1);
|
||||
|
||||
if (len <= 0)
|
||||
{
|
||||
|
|
|
@ -253,7 +253,7 @@ transaction_read:
|
|||
/* allow one extra byte for terminator we don't return */
|
||||
len = min(datasize ? datasize + 1 : strlen(priv->verify_cmd) + 13,
|
||||
ELAD_MAX_BUF_LEN);
|
||||
retval = read_string(&rs->rigport, buffer, len, cmdtrm, strlen(cmdtrm), 0);
|
||||
retval = read_string(&rs->rigport, buffer, len, cmdtrm, strlen(cmdtrm), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -3739,7 +3739,7 @@ DECLARE_PROBERIG_BACKEND(elad)
|
|||
}
|
||||
|
||||
retval = write_block(port, "ID;", 3);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0, 1);
|
||||
close(port->fd);
|
||||
|
||||
if (retval != RIG_OK || id_len < 0)
|
||||
|
@ -3800,7 +3800,7 @@ DECLARE_PROBERIG_BACKEND(elad)
|
|||
}
|
||||
|
||||
retval = write_block(port, "K2;", 3);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0, 1);
|
||||
close(port->fd);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
|
|
@ -288,7 +288,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
|
|||
/*
|
||||
* Transceiver sends an echo of cmd followed by a CR/LF
|
||||
*/
|
||||
retval = read_string(&rs->rigport, respbuf, BUFSZ, LF, strlen(LF), 0);
|
||||
retval = read_string(&rs->rigport, respbuf, BUFSZ, LF, strlen(LF), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -490,7 +490,7 @@ int read_icom_frame(hamlib_port_t *p, unsigned char rxbuffer[],
|
|||
do
|
||||
{
|
||||
int i = read_string(p, rx_ptr, MAXFRAMELEN - read,
|
||||
icom_block_end, icom_block_end_length, 0);
|
||||
icom_block_end, icom_block_end_length, 0, 1);
|
||||
|
||||
if (i < 0 && i != RIG_BUSBUSY) /* die on errors */
|
||||
{
|
||||
|
|
|
@ -93,7 +93,7 @@ static int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
|
||||
Unhold_Decode(rig);
|
||||
|
||||
|
@ -1632,7 +1632,7 @@ int jrc_decode_event(RIG *rig)
|
|||
//#define SETUP_STATUS_LEN 17
|
||||
|
||||
//count = read_string(&rs->rigport, buf, SETUP_STATUS_LEN, "", 0);
|
||||
count = read_string(&rs->rigport, buf, priv->info_len, "", 0, 0);
|
||||
count = read_string(&rs->rigport, buf, priv->info_len, "", 0, 0, 1);
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
|
|
|
@ -93,7 +93,7 @@ static int kachina_transaction(RIG *rig, unsigned char cmd1, unsigned char cmd2)
|
|||
return retval;
|
||||
}
|
||||
|
||||
count = read_string(&rs->rigport, (char *) buf4, 1, "", 0, 0);
|
||||
count = read_string(&rs->rigport, (char *) buf4, 1, "", 0, 0, 1);
|
||||
|
||||
if (count != 1)
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ static int kachina_trans_n(RIG *rig, unsigned char cmd1, const char *data,
|
|||
return retval;
|
||||
}
|
||||
|
||||
count = read_string(&rs->rigport, (char *) buf, 1, "", 0, 0);
|
||||
count = read_string(&rs->rigport, (char *) buf, 1, "", 0, 0, 1);
|
||||
|
||||
if (count != 1)
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ int kachina_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
rig_flush(&rig->state.rigport);
|
||||
|
||||
count = read_string(&rig->state.rigport, (char *) buf, 31, rcv_signal_range,
|
||||
128, 0);
|
||||
128, 0, 1);
|
||||
|
||||
if (count < 1)
|
||||
{
|
||||
|
|
|
@ -135,7 +135,7 @@ int elecraft_open(RIG *rig)
|
|||
return err;
|
||||
}
|
||||
|
||||
err = read_string(&rs->rigport, buf, sizeof(buf), ";", 1, 0);
|
||||
err = read_string(&rs->rigport, buf, sizeof(buf), ";", 1, 0, 1);
|
||||
|
||||
if (err < 0)
|
||||
{
|
||||
|
|
|
@ -110,7 +110,7 @@ transaction:
|
|||
}
|
||||
|
||||
// this should be the ID response
|
||||
retval = read_string(&rs->rigport, buffer, sizeof(buffer), ";", 1, 0);
|
||||
retval = read_string(&rs->rigport, buffer, sizeof(buffer), ";", 1, 0, 1);
|
||||
|
||||
// might be ?; too
|
||||
if (buffer[0] == '?' && retry_cmd++ < rs->rigport.retry)
|
||||
|
@ -129,7 +129,7 @@ transaction:
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, 50, ";", 1, 0);
|
||||
retval = read_string(&rs->rigport, data, 50, ";", 1, 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
|
|
@ -369,7 +369,7 @@ transaction_read:
|
|||
/* allow room for most any response */
|
||||
len = min(datasize ? datasize + 1 : strlen(priv->verify_cmd) + 48,
|
||||
KENWOOD_MAX_BUF_LEN);
|
||||
retval = read_string(&rs->rigport, buffer, len, cmdtrm_str, strlen(cmdtrm_str), 0);
|
||||
retval = read_string(&rs->rigport, buffer, len, cmdtrm_str, strlen(cmdtrm_str), 0, 1);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read_string(len=%d)='%s'\n", __func__,
|
||||
(int)strlen(buffer), buffer);
|
||||
|
||||
|
@ -2601,7 +2601,7 @@ static int kenwood_get_micgain_minmax(RIG *rig, int *micgain_now,
|
|||
|
||||
if (retval != RIG_OK) { RETURNFUNC(retval); }
|
||||
|
||||
retval = read_string(&rs->rigport, levelbuf, sizeof(levelbuf), NULL, 0, 0);
|
||||
retval = read_string(&rs->rigport, levelbuf, sizeof(levelbuf), NULL, 0, 0, 1);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval);
|
||||
|
||||
|
@ -2700,7 +2700,7 @@ static int kenwood_get_power_minmax(RIG *rig, int *power_now, int *power_min,
|
|||
|
||||
if (retval != RIG_OK) { RETURNFUNC(retval); }
|
||||
|
||||
retval = read_string(&rs->rigport, levelbuf, sizeof(levelbuf), NULL, 0, 0);
|
||||
retval = read_string(&rs->rigport, levelbuf, sizeof(levelbuf), NULL, 0, 0, 1);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval);
|
||||
|
||||
|
@ -5367,7 +5367,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
}
|
||||
|
||||
retval = write_block(port, "ID;", 3);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0, 1);
|
||||
close(port->fd);
|
||||
|
||||
if (retval != RIG_OK || id_len < 0)
|
||||
|
@ -5434,7 +5434,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
}
|
||||
|
||||
retval = write_block(port, "K2;", 3);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0, 1);
|
||||
close(port->fd);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
|
|
@ -442,7 +442,7 @@ static int ts480_read_meters(RIG *rig, int *swr, int *comp, int *alc)
|
|||
|
||||
// TS-480 returns values for all meters at the same time, for example: RM10000;RM20000;RM30000;
|
||||
|
||||
retval = read_string(&rs->rigport, ackbuf, expected_len + 1, NULL, 0, 0);
|
||||
retval = read_string(&rs->rigport, ackbuf, expected_len + 1, NULL, 0, 0, 1);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read_string retval=%d\n", __func__, retval);
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ int xg3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
return retval;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, replybuf, replysize, ";", 1, 0);
|
||||
retval = read_string(&rs->rigport, replybuf, replysize, ";", 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -462,7 +462,7 @@ int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
return retval;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, freqbuf, freqsize, ";", 1, 0);
|
||||
retval = read_string(&rs->rigport, freqbuf, freqsize, ";", 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -514,7 +514,7 @@ int xg3_get_powerstat(RIG *rig, powerstat_t *status)
|
|||
if (retval == RIG_OK)
|
||||
{
|
||||
char reply[32];
|
||||
retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1, 0);
|
||||
retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1, 0, 1);
|
||||
*status = RIG_POWER_ON;
|
||||
priv->powerstat = RIG_POWER_ON;
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ int xg3_get_mem(RIG *rig, vfo_t vfo, int *ch)
|
|||
return retval;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1, 0);
|
||||
retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -102,7 +102,7 @@ static int rshfiq_open(RIG *rig)
|
|||
return retval;
|
||||
}
|
||||
|
||||
retval = read_string(&rig->state.rigport, versionstr, 20, stopset, 2, 0);
|
||||
retval = read_string(&rig->state.rigport, versionstr, 20, stopset, 2, 0, 1);
|
||||
}
|
||||
|
||||
if (retval <= 0)
|
||||
|
@ -191,7 +191,7 @@ static int rshfiq_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
return retval;
|
||||
}
|
||||
|
||||
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0);
|
||||
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0, 1);
|
||||
|
||||
if (retval <= 0)
|
||||
{
|
||||
|
@ -276,7 +276,7 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
stopset[0] = '\r';
|
||||
stopset[1] = '\n';
|
||||
|
||||
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0);
|
||||
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0, 1);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER reply=%s\n", cmdstr);
|
||||
|
||||
|
@ -314,7 +314,7 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
stopset[0] = '\r';
|
||||
stopset[1] = '\n';
|
||||
|
||||
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0);
|
||||
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0, 1);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER reply=%s\n", cmdstr);
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ int lowe_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ DECLARE_PROBERIG_BACKEND(lowe)
|
|||
}
|
||||
|
||||
retval = write_block(port, "TYP?" EOM, 4);
|
||||
id_len = read_string(port, idbuf, BUFSZ, CR, 2, 0);
|
||||
id_len = read_string(port, idbuf, BUFSZ, CR, 2, 0, 1);
|
||||
|
||||
close(port->fd);
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ static int read_prompt_and_send(hamlib_port_t *rigport,
|
|||
|
||||
buflen = (data_len == NULL) ? sizeof(buf) : *data_len;
|
||||
|
||||
retval = read_string(rigport, data, buflen, delimiter, 1, 0);
|
||||
retval = read_string(rigport, data, buflen, delimiter, 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -230,7 +230,7 @@ static int prm80_wait_for_prompt(hamlib_port_t *rigport)
|
|||
int retval;
|
||||
|
||||
// Read up to the '>' prompt and discard content.
|
||||
retval = read_string(rigport, buf, sizeof(buf), ">", 1, 0);
|
||||
retval = read_string(rigport, buf, sizeof(buf), ">", 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -910,7 +910,7 @@ int prm80_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
if (ret == 3 && buf[2] == 'T')
|
||||
{
|
||||
// Read the question
|
||||
ret = read_string(&rs->rigport, buf, sizeof(buf), "?", 1, 0);
|
||||
ret = read_string(&rs->rigport, buf, sizeof(buf), "?", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -1126,7 +1126,7 @@ static int prm80_get_rawstr_RAM(RIG *rig, value_t *val)
|
|||
}
|
||||
|
||||
// Read CRLF
|
||||
ret = read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0);
|
||||
ret = read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -1142,7 +1142,7 @@ static int prm80_get_rawstr_RAM(RIG *rig, value_t *val)
|
|||
|
||||
for (i = 0; i < (RSSI_HOLD_ADDR / 16) + 1; i++)
|
||||
{
|
||||
ret = read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0);
|
||||
ret = read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -1158,7 +1158,7 @@ static int prm80_get_rawstr_RAM(RIG *rig, value_t *val)
|
|||
// discard the remaining content of RAM print
|
||||
for (i = 0; i < (16 - RSSI_HOLD_ADDR / 16) - 1; i++)
|
||||
{
|
||||
read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0);
|
||||
read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0, 1);
|
||||
}
|
||||
|
||||
prm80_wait_for_prompt(&rs->rigport);
|
||||
|
@ -1281,7 +1281,7 @@ const char *prm80_get_info(RIG *rig)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ret = read_string(&rs->rigport, s_buf, BUFSZ, ">", 1, 0);
|
||||
ret = read_string(&rs->rigport, s_buf, BUFSZ, ">", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
@ -122,7 +122,7 @@ static int ra37xx_one_transaction(RIG *rig, const char *cmd, char *data,
|
|||
|
||||
do
|
||||
{
|
||||
retval = read_string(&rs->rigport, respbuf, BUFSZ, EOM, strlen(EOM), 0);
|
||||
retval = read_string(&rs->rigport, respbuf, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -100,7 +100,7 @@ static int racal_transaction(RIG *rig, const char *cmd, char *data,
|
|||
return retval;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (retval <= 0)
|
||||
{
|
||||
|
|
|
@ -71,7 +71,7 @@ int rft_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
|
|
@ -89,7 +89,7 @@ gp2000_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, RESPSZ, CR, 1, 0);
|
||||
retval = read_string(&rs->rigport, data, RESPSZ, CR, 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -80,7 +80,7 @@ int rs_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -88,7 +88,7 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
|
|||
* Transceiver sends back ">"
|
||||
*/
|
||||
char retbuf[BUFSZ + 1];
|
||||
retval = read_string(&rs->rigport, retbuf, BUFSZ, PROMPT, strlen(PROMPT), 0);
|
||||
retval = read_string(&rs->rigport, retbuf, BUFSZ, PROMPT, strlen(PROMPT), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
|
|||
}
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, LF, strlen(LF), 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, LF, strlen(LF), 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
|
|
@ -288,7 +288,7 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
|
||||
if (data)
|
||||
{
|
||||
retval = read_string(&rs->rigport, data, (*data_len) + 1, term, strlen(term), 0);
|
||||
retval = read_string(&rs->rigport, data, (*data_len) + 1, term, strlen(term), 0, 1);
|
||||
|
||||
if (retval != -RIG_ETIMEOUT)
|
||||
{
|
||||
|
@ -310,7 +310,7 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
write_block(&rs->rigport, "XX" EOM,
|
||||
3); // we wont' worry about the response here
|
||||
retval = read_string(&rs->rigport, xxbuf, sizeof(xxbuf), "",
|
||||
0, 0); // this should timeout
|
||||
0, 0, 1); // this should timeout
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -156,7 +156,7 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
#endif
|
||||
*data_len = data_len_init; /* restore orig. buffer length */
|
||||
*data_len = read_string(&rs->rigport, data, *data_len,
|
||||
EOM, strlen(EOM), 0);
|
||||
EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (!strncmp(data, "Z!", 2)) // command unrecognized??
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
passcount, itry);
|
||||
*data_len = data_len_init; /* restore orig. buffer length */
|
||||
read_string(&rs->rigport, data, *data_len,
|
||||
EOM, strlen(EOM), 0); // purge the input stream...
|
||||
EOM, strlen(EOM), 0, 1); // purge the input stream...
|
||||
continue; // now go retry the full command
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, 1, 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -219,7 +219,7 @@ static int rx340_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, 1, 0);
|
||||
retval = read_string(&rs->rigport, data, BUFSZ, EOM, 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ int tentec_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, *data_len, NULL, 0, 0);
|
||||
retval = read_string(&rs->rigport, data, *data_len, NULL, 0, 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
|
|
@ -103,7 +103,7 @@ tt550_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, data, *data_len, NULL, 0, 0);
|
||||
retval = read_string(&rs->rigport, data, *data_len, NULL, 0, 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
@ -1699,7 +1699,7 @@ tt550_decode_event(RIG *rig)
|
|||
priv = (struct tt550_priv_data *) rs->priv;
|
||||
|
||||
|
||||
data_len = read_string(&rs->rigport, (char *) buf, MAXFRAMELEN, "\n\r", 2, 0);
|
||||
data_len = read_string(&rs->rigport, (char *) buf, MAXFRAMELEN, "\n\r", 2, 0, 1);
|
||||
|
||||
|
||||
if (data_len == -RIG_ETIMEOUT)
|
||||
|
|
|
@ -156,7 +156,7 @@ transaction_write:
|
|||
}
|
||||
|
||||
memset(data, 0, *datasize);
|
||||
retval = read_string(&rs->rigport, data, *datasize, EOM, strlen(EOM), 0);
|
||||
retval = read_string(&rs->rigport, data, *datasize, EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -838,7 +838,7 @@ DECLARE_PROBERIG_BACKEND(uniden)
|
|||
}
|
||||
|
||||
retval = write_block(port, "SI"EOM, 3);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, EOM, 1, 0);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, EOM, 1, 0, 1);
|
||||
close(port->fd);
|
||||
|
||||
if (retval != RIG_OK || id_len < 0)
|
||||
|
|
|
@ -138,7 +138,7 @@ transaction_write:
|
|||
}
|
||||
|
||||
memset(data, 0, *datasize);
|
||||
retval = read_string(&rs->rigport, data, *datasize, EOM, strlen(EOM), 0);
|
||||
retval = read_string(&rs->rigport, data, *datasize, EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -9851,7 +9851,7 @@ int newcat_get_cmd(RIG *rig)
|
|||
|
||||
/* read the reply */
|
||||
if ((rc = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data),
|
||||
&cat_term, sizeof(cat_term), 0)) <= 0)
|
||||
&cat_term, sizeof(cat_term), 0, 1)) <= 0)
|
||||
{
|
||||
continue; /* usually a timeout - retry */
|
||||
}
|
||||
|
@ -10051,7 +10051,7 @@ int newcat_set_cmd_validate(RIG *rig)
|
|||
if (strlen(valcmd) == 0) { RETURNFUNC(RIG_OK); }
|
||||
|
||||
bytes = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data),
|
||||
&cat_term, sizeof(cat_term), 0);
|
||||
&cat_term, sizeof(cat_term), 0, 1);
|
||||
|
||||
// FA and FB success is now verified in rig.c with a followup query
|
||||
// so no validation is needed
|
||||
|
@ -10179,7 +10179,7 @@ int newcat_set_cmd(RIG *rig)
|
|||
|
||||
/* read the reply */
|
||||
if ((rc = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data),
|
||||
&cat_term, sizeof(cat_term), 0)) <= 0)
|
||||
&cat_term, sizeof(cat_term), 0, 1)) <= 0)
|
||||
{
|
||||
continue; /* usually a timeout - retry */
|
||||
}
|
||||
|
@ -10249,7 +10249,7 @@ int newcat_set_cmd(RIG *rig)
|
|||
|
||||
/* read/flush the verify command reply which should still be there */
|
||||
if ((rc = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data),
|
||||
&cat_term, sizeof(cat_term), 0)) > 0)
|
||||
&cat_term, sizeof(cat_term), 0, 1)) > 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s\n",
|
||||
__func__, rc, priv->ret_data);
|
||||
|
|
|
@ -92,7 +92,7 @@ transaction_write:
|
|||
|
||||
/* the answer */
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, data, data_len, ACK, strlen(ACK), 0);
|
||||
retval = read_string(&rs->rotport, data, data_len, ACK, strlen(ACK), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ easycomm_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
|
|||
return RIG_OK; /* don't want a reply */
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rotport, data, data_len, "\n", 1, 0);
|
||||
retval = read_string(&rs->rotport, data, data_len, "\n", 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ static int ether_transaction(ROT *rot, char *cmd, int len, char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0);
|
||||
ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "function %s(2): ret=%d || receive=%s\n", __func__,
|
||||
ret, buf);
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ transaction_write:
|
|||
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM,
|
||||
strlen(REPLY_EOM), 0);
|
||||
strlen(REPLY_EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -104,7 +104,7 @@ transaction_write:
|
|||
{
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM,
|
||||
strlen(REPLY_EOM), 0);
|
||||
strlen(REPLY_EOM), 0, 1);
|
||||
|
||||
if (strncmp(data, "\r\n", 2) == 0
|
||||
|| strchr(data, '>'))
|
||||
|
|
|
@ -104,7 +104,7 @@ transaction_write:
|
|||
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, data, data_len, REPLY_EOM,
|
||||
strlen(REPLY_EOM), 0);
|
||||
strlen(REPLY_EOM), 0, 1);
|
||||
|
||||
if (strncmp(data, "\r\n", 2) == 0 || strchr(data, '>'))
|
||||
{
|
||||
|
|
|
@ -108,7 +108,7 @@ transaction_write:
|
|||
|
||||
/** the answer */
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, data, data_len, ACK, strlen(ACK), 0);
|
||||
retval = read_string(&rs->rotport, data, data_len, ACK, strlen(ACK), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -204,13 +204,13 @@ transaction_write:
|
|||
|
||||
/* then comes the answer */
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, data, data_len, CR, strlen(CR), 0);
|
||||
retval = read_string(&rs->rotport, data, data_len, CR, strlen(CR), 0, 1);
|
||||
|
||||
// some models seem to echo -- so we'll check and read again if echoed
|
||||
if (cmdstr && strcmp(data, cmdstr) == 0)
|
||||
{
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, data, data_len, CR, strlen(CR), 0);
|
||||
retval = read_string(&rs->rotport, data, data_len, CR, strlen(CR), 0, 1);
|
||||
}
|
||||
|
||||
if (retval < 0)
|
||||
|
|
|
@ -129,7 +129,7 @@ transaction:
|
|||
if (data != NULL)
|
||||
{
|
||||
return_value = read_string(&rs->rotport, data, expected_return_length + 1,
|
||||
"\r\n", strlen("\r\n"), 0);
|
||||
"\r\n", strlen("\r\n"), 0, 1);
|
||||
|
||||
if (return_value > 0)
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ transaction_write:
|
|||
}
|
||||
|
||||
// Remember to check for STXA,G,R or STXA,?,XXX,R 10 bytes
|
||||
retval = read_string(&rs->rotport, data, 20, CR, strlen(CR), 0);
|
||||
retval = read_string(&rs->rotport, data, 20, CR, strlen(CR), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ radant_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
|
|||
return RIG_OK; /* don't want a reply */
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rotport, data, data_len, "\n", 1, 0);
|
||||
retval = read_string(&rs->rotport, data, data_len, "\n", 1, 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -763,7 +763,7 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
|
||||
rs = &rot->state;
|
||||
|
||||
err = read_string(&rs->rotport, az, RT21_AZ_LEN + 1, ";", strlen(";"), 0);
|
||||
err = read_string(&rs->rotport, az, RT21_AZ_LEN + 1, ";", strlen(";"), 0, 1);
|
||||
|
||||
if (err < 0) /* read_string returns negative on error. */
|
||||
{
|
||||
|
|
|
@ -137,7 +137,7 @@ static int satel_cmd(ROT *rot, char *cmd, int cmdlen, char *res, int reslen)
|
|||
|
||||
if (reslen > 0 && res != NULL)
|
||||
{
|
||||
ret = read_string(&rs->rotport, res, reslen, "\n", 1, 0);
|
||||
ret = read_string(&rs->rotport, res, reslen, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
|
||||
|
||||
// read motion state
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0);
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
stat->motion_enabled = strcmp(resbuf, "Motion ENABLED") == 0 ? true : false;
|
||||
|
||||
// XXX skip mode
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0);
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
}
|
||||
|
||||
// XXX skip time
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0);
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
}
|
||||
|
||||
// read azimuth line
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0);
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
stat->az = (int)strtof(p, NULL);
|
||||
|
||||
// read elevation line
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0);
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
stat->el = (int)strtof(p, NULL);
|
||||
|
||||
// skip blank line
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0);
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -221,7 +221,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
}
|
||||
|
||||
// XXX skip stored position count
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0);
|
||||
ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
@ -672,7 +672,8 @@ int HAMLIB_API read_string(hamlib_port_t *p,
|
|||
size_t rxmax,
|
||||
const char *stopset,
|
||||
int stopset_len,
|
||||
int flush_flag)
|
||||
int flush_flag,
|
||||
int expected_len)
|
||||
{
|
||||
fd_set rfds, efds;
|
||||
struct timeval tv, tv_timeout, start_time, end_time, elapsed_time;
|
||||
|
|
|
@ -43,6 +43,7 @@ extern HAMLIB_EXPORT(int) read_string(hamlib_port_t *p,
|
|||
size_t rxmax,
|
||||
const char *stopset,
|
||||
int stopset_len,
|
||||
int flush_flag);
|
||||
int flush_flag,
|
||||
int expected_len);
|
||||
|
||||
#endif /* _IOFUNC_H */
|
||||
|
|
|
@ -678,7 +678,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
|
|||
// we pass an empty stopset so read_string can determine
|
||||
// the appropriate stopset for async data
|
||||
char stopset[1];
|
||||
len = read_string(p, (char*)buf, sizeof(buf)-1, stopset, 0, 1);
|
||||
len = read_string(p, (char*)buf, sizeof(buf)-1, stopset, 0, 1, 1);
|
||||
if (len > 0)
|
||||
{
|
||||
int i, binary=0;
|
||||
|
|
|
@ -1957,7 +1957,7 @@ declare_proto_amp(send_cmd)
|
|||
* assumes CR or LF is end of line char
|
||||
* for all ascii protocols
|
||||
*/
|
||||
retval = read_string(&rs->ampport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0);
|
||||
retval = read_string(&rs->ampport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -4959,7 +4959,7 @@ declare_proto_rig(send_cmd)
|
|||
|
||||
/* Assumes CR or LF is end of line char for all ASCII protocols. */
|
||||
retval = read_string(&rs->rigport, (char *)buf, rxbytes, eom_buf,
|
||||
strlen(eom_buf), 0);
|
||||
strlen(eom_buf), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -626,7 +626,8 @@ int main(int argc, char *argv[])
|
|||
sizeof(ts2000),
|
||||
stop_set,
|
||||
strlen(stop_set),
|
||||
0);
|
||||
0,
|
||||
1);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: status=%d\n", __func__, status);
|
||||
|
||||
|
|
|
@ -2499,7 +2499,7 @@ declare_proto_rot(send_cmd)
|
|||
* assumes CR or LF is end of line char
|
||||
* for all ascii protocols
|
||||
*/
|
||||
retval = read_string(&rs->rotport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0);
|
||||
retval = read_string(&rs->rotport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue