pull/345/head
c vw 2020-07-10 13:58:39 +02:00
commit fbc9f3508f
34 zmienionych plików z 445 dodań i 193 usunięć

Wyświetl plik

@ -410,12 +410,14 @@ static int dummy_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
if (vfo == RIG_VFO_A) { priv->curr->freq = freq; }
else if (vfo == RIG_VFO_B) { priv->curr->tx_freq = freq; }
if (!priv->split)
{
priv->curr->tx_freq = freq;
}
rig_debug(RIG_DEBUG_TRACE, "%s: curr->freq=%.0f, curr->tx_freq=%.0f\n", __func__,
rig_debug(RIG_DEBUG_TRACE, "%s: curr->freq=%.0f, curr->tx_freq=%.0f\n",
__func__,
priv->curr->freq, priv->curr->tx_freq);
return RIG_OK;
}

Wyświetl plik

@ -376,7 +376,7 @@ static char *xml_parse(char *xml, char *value, int value_len)
xml_parse2(next, value, value_len);
}
if (strstr(value, "faultString"))
if (value && strstr(value, "faultString"))
{
rig_debug(RIG_DEBUG_ERR, "%s error:\n%s\n", __func__, value);
value[0] = 0; /* truncate to give empty response */

Wyświetl plik

@ -106,15 +106,19 @@ static int netampctl_open(AMP *amp)
{
ret = read_string(&amp->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"));
if (ret <= 0)
if (ret > 0)
{
return (ret < 0) ? ret : -RIG_EPROTO;
rig_debug(RIG_DEBUG_VERBOSE, "%s called, string=%s\n", __func__, buf);
}
rig_debug(RIG_DEBUG_VERBOSE, "%s called, string=%s\n", __func__, buf);
}
while (ret > 0);
if (ret < 0)
{
return -RIG_EPROTO;
}
return RIG_OK;
}

Wyświetl plik

@ -718,7 +718,7 @@ static int netrigctl_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
return (ret < 0) ? ret : -RIG_EPROTO;
}
if (ret > 0 && buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
*mode = rig_parse_mode(buf);
@ -790,7 +790,7 @@ static int netrigctl_get_vfo(RIG *rig, vfo_t *vfo)
return (ret < 0) ? ret : -RIG_EPROTO;
}
if (ret > 0 && buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
*vfo = rig_parse_vfo(buf);
@ -935,7 +935,7 @@ static int netrigctl_get_rptr_shift(RIG *rig, vfo_t vfo,
return (ret < 0) ? ret : -RIG_EPROTO;
}
if (ret > 0 && buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
*rptr_shift = rig_parse_rptr_shift(buf);
@ -1329,7 +1329,7 @@ static int netrigctl_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
return (ret < 0) ? ret : -RIG_EPROTO;
}
if (ret > 0 && buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
*tx_mode = rig_parse_mode(buf);
@ -1407,7 +1407,7 @@ static int netrigctl_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
}
if (ret > 0 && buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
*tx_vfo = rig_parse_vfo(buf);

Wyświetl plik

@ -156,11 +156,12 @@
/*
* ITU Region 3: South Pacific and Southern Asia
* https://web.archive.org/web/20171216012537/http://www.iaru-r3.org/wp-content/files/R3-004%20Band%20Plans%20IARU%20Region%203.docx
*/
/* MF: 300 kHz - 3 MHz */
#define FRQ_RNG_160m_REGION3(md,lp,hp,v,a) \
{ kHz(1810),MHz(2), (md), (lp), (hp), (v), (a), "ITU3" }
{ kHz(1800),MHz(2), (md), (lp), (hp), (v), (a), "ITU3" }
/* HF: 3 MHz - 30 MHz */
#define FRQ_RNG_80m_REGION3(md,lp,hp,v,a) \
@ -170,7 +171,7 @@
{ kHz(5351.5),kHz(5366.5), (md), (lp), (hp), (v), (a), "ITU3" }
#define FRQ_RNG_40m_REGION3(md,lp,hp,v,a) \
{ MHz(7),kHz(7100), (md), (lp), (hp), (v), (a), "ITU3" }
{ MHz(7),kHz(7300), (md), (lp), (hp), (v), (a), "ITU3" }
#define FRQ_RNG_30m_REGION3(md,lp,hp,v,a) \
{ kHz(10100),kHz(10150), (md), (lp), (hp), (v), (a), "ITU3" }
@ -199,7 +200,7 @@
/* UHF: 300 MHz - 3 GHz */
#define FRQ_RNG_70cm_REGION3(md,lp,hp,v,a) \
{ MHz(430),MHz(440), (md), (lp), (hp), (v), (a), "ITU3" }
{ MHz(430),MHz(450), (md), (lp), (hp), (v), (a), "ITU3" }
#define FRQ_RNG_23cm_REGION3(md,lp,hp,v,a) \
{ MHz(1240),MHz(1300), (md), (lp), (hp), (v), (a), "ITU3" }

Wyświetl plik

@ -2028,6 +2028,11 @@ struct rig_state {
int twiddle_timeout; /*!< timeout to resume from twiddling */
struct rig_cache cache;
int vfo_opt; /*!< Is -o switch turned on? */
int auto_power_on; /*!< Allow Hamlib to power rig
automatically if supported */
int auto_disable_screensaver; /*!< Allow Hamlib to disable the
rig's screen saver automatically if
supported */
};
//! @cond Doxygen_Suppress

Wyświetl plik

@ -1488,7 +1488,7 @@ int adat_get_single_cmd_result(RIG *pRig)
pcPos = acBuf;
if ((nRC == RIG_OK) && (pcPos != NULL))
if ((nRC == RIG_OK))
{
int nBufLength = 0;

Wyświetl plik

@ -727,7 +727,7 @@ icom_rig_open(RIG *rig)
rig->caps->version);
retval = icom_get_usb_echo_off(rig);
if (retval != RIG_OK && priv->poweron == 0)
if (retval != RIG_OK && priv->poweron == 0 && rs->auto_power_on)
{
// maybe we need power on?
rig_debug(RIG_DEBUG_VERBOSE, "%s trying power on\n", __func__);
@ -1576,6 +1576,8 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode,
switch (mode)
{
case RIG_MODE_PKTUSB:
// xFE xFE x6E xE0 x1A x06 x01 xFD switchs mod input from MIC to ACC
// This apparently works for IC-756ProIII but nobody has asked for it yet
icom_mode = RIG_MODE_USB;
break;

Wyświetl plik

@ -232,7 +232,7 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data,
char buffer[KENWOOD_MAX_BUF_LEN]; /* use our own buffer since
verification may need a longer
buffer than the user supplied one */
char cmdtrm[2]; /* Default Command/Reply termination char */
char cmdtrm_str[2]; /* Default Command/Reply termination char */
int retval;
char *cmd;
int len;
@ -275,15 +275,15 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data,
}
if (strlen(cmdstr) > 2 || strcmp(cmdstr, "RX") == 0
|| strcmp(cmdstr, "TX") == 0 || strcmp(cmdstr, "ZZTX") == 0)
|| strncmp(cmdstr, "TX", 2) == 0 || strncmp(cmdstr, "ZZTX", 4) == 0)
{
// then we must be setting something so we'll invalidate the cache
rig_debug(RIG_DEBUG_TRACE, "%s: cache invalidated\n", __func__);
priv->cache_start.tv_sec = 0;
}
cmdtrm[0] = caps->cmdtrm;
cmdtrm[1] = '\0';
cmdtrm_str[0] = caps->cmdtrm;
cmdtrm_str[1] = '\0';
transaction_write:
@ -323,6 +323,13 @@ transaction_write:
}
}
// we're not going to do the verify on RX cmd
// Seems some rigs (like TS-480) return "?" when RX is done while PTT=OFF
// So we'll skip the checks just on this one command for now
// The TS-480 PC Control says RX; should return RX0; but it doesn't
// We may eventually want to verify PTT with rig_get_ptt instead
if (retval == RIG_OK && strncmp(cmdstr, "RX", 2) == 0) { goto transaction_quit; }
if (!datasize)
{
rig->state.hold_decode = 0;
@ -341,7 +348,7 @@ transaction_read:
/* allow room for most any response */
len = min(datasize ? datasize + 1 : strlen(priv->verify_cmd) + 32,
KENWOOD_MAX_BUF_LEN);
retval = read_string(&rs->rigport, buffer, len, cmdtrm, strlen(cmdtrm));
retval = read_string(&rs->rigport, buffer, len, cmdtrm_str, strlen(cmdtrm_str));
rig_debug(RIG_DEBUG_TRACE, "%s: read_string(len=%d)='%s'\n", __func__,
(int)strlen(buffer), buffer);
@ -368,7 +375,7 @@ transaction_read:
}
/* Check that command termination is correct */
if (strchr(cmdtrm, buffer[strlen(buffer) - 1]) == NULL)
if (strchr(cmdtrm_str, buffer[strlen(buffer) - 1]) == NULL)
{
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n",
__func__, buffer);
@ -662,7 +669,20 @@ int kenwood_init(RIG *rig)
priv = rig->state.priv;
memset(priv, 0x00, sizeof(struct kenwood_priv_data));
strcpy(priv->verify_cmd, RIG_IS_XG3 ? ";" : "ID;");
if (RIG_IS_XG3)
{
priv->verify_cmd[0] = caps->cmdtrm;
priv->verify_cmd[1] = '\0';
}
else
{
priv->verify_cmd[0] = 'I';
priv->verify_cmd[1] = 'D';
priv->verify_cmd[2] = caps->cmdtrm;
priv->verify_cmd[3] = '\0';
}
priv->split = RIG_SPLIT_OFF;
priv->trn_state = -1;
priv->curr_mode = 0;
@ -697,6 +717,7 @@ int kenwood_cleanup(RIG *rig)
int kenwood_open(RIG *rig)
{
struct kenwood_priv_data *priv = rig->state.priv;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
int err, i;
char *idptr;
char id[KENWOOD_MAX_BUF_LEN];
@ -713,7 +734,8 @@ int kenwood_open(RIG *rig)
rig_debug(RIG_DEBUG_TRACE, "%s: got ID so try PS\n", __func__);
err = rig_get_powerstat(rig, &powerstat);
if (err == RIG_OK && powerstat == 0 && priv->poweron == 0)
if (err == RIG_OK && powerstat == 0 && priv->poweron == 0
&& rig->state.auto_power_on)
{
rig_debug(RIG_DEBUG_TRACE, "%s: got PS0 so powerup\n", __func__);
rig_set_powerstat(rig, 1);
@ -724,18 +746,18 @@ int kenwood_open(RIG *rig)
err = RIG_OK; // reset our err back to OK for later checks
}
if (err == -RIG_ETIMEOUT)
if (err == -RIG_ETIMEOUT && rig->state.auto_power_on)
{
// Ensure rig is on
rig_set_powerstat(rig, 1);
/* Try get id again */
err = kenwood_get_id(rig, id);
}
if (RIG_OK != err)
{
rig_debug(RIG_DEBUG_ERR,
"%s: no response to get_id from rig...contintuing anyways.\n", __func__);
}
if (RIG_OK != err)
{
rig_debug(RIG_DEBUG_ERR,
"%s: no response to get_id from rig...contintuing anyways.\n", __func__);
}
if (RIG_IS_TS2000
@ -799,7 +821,10 @@ int kenwood_open(RIG *rig)
/* here we know there is something that responds to FA but not
to ID so use FA as the command verification command */
strcpy(priv->verify_cmd, "FA;");
priv->verify_cmd[0] = 'F';
priv->verify_cmd[1] = 'A';
priv->verify_cmd[2] = caps->cmdtrm;
priv->verify_cmd[3] = '\0';
strcpy(id, "ID019"); /* fake a TS-2000 */
}
else
@ -860,21 +885,30 @@ int kenwood_open(RIG *rig)
vfo_t tx_vfo;
/* get current AI state so it can be restored */
kenwood_get_trn(rig, &priv->trn_state); /* ignore errors */
/* Currently we cannot cope with AI mode so turn it off in
case last client left it on */
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case
it's not supported */
// call get_split to fill in current split and tx_vfo status
retval = kenwood_get_split_vfo_if(rig, RIG_VFO_A, &split, &tx_vfo);
if (retval != RIG_OK)
if (priv->trn_state != RIG_TRN_OFF)
{
rig_debug(RIG_DEBUG_ERR, "%s: %s\n", __func__, rigerror(retval));
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case
it's not supported */
}
if (!RIG_IS_THD74 && !RIG_IS_THD7A)
{
// call get_split to fill in current split and tx_vfo status
retval = kenwood_get_split_vfo_if(rig, RIG_VFO_A, &split, &tx_vfo);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: %s\n", __func__, rigerror(retval));
}
priv->tx_vfo = tx_vfo;
rig_debug(RIG_DEBUG_VERBOSE, "%s: priv->tx_vfo=%s\n", __func__,
rig_strvfo(priv->tx_vfo));
}
priv->tx_vfo = tx_vfo;
rig_debug(RIG_DEBUG_VERBOSE, "%s: priv->tx_vfo=%s\n", __func__,
rig_strvfo(priv->tx_vfo));
return RIG_OK;
}
@ -3402,6 +3436,7 @@ int kenwood_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
*/
int kenwood_set_trn(RIG *rig, int trn)
{
char buf[5];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (rig->caps->rig_model)
@ -3410,9 +3445,10 @@ int kenwood_set_trn(RIG *rig, int trn)
return kenwood_transaction(rig, (trn == RIG_TRN_RIG) ? "AI2" : "AI0", NULL, 0);
break;
case RIG_MODEL_THD7A:
case RIG_MODEL_THD74:
return kenwood_transaction(rig, (trn == RIG_TRN_RIG) ? "AI 1" : "AI 0", NULL,
4);
return kenwood_transaction(rig, (trn == RIG_TRN_RIG) ? "AI 1" : "AI 0", buf,
sizeof buf);
break;
default:
@ -3443,7 +3479,7 @@ int kenwood_get_trn(RIG *rig, int *trn)
return -RIG_ENAVAIL;
}
if (RIG_IS_THD74)
if (RIG_IS_THD74 || RIG_IS_THD7A)
{
retval = kenwood_safe_transaction(rig, "AI", trnbuf, 6, 4);
}
@ -3457,7 +3493,7 @@ int kenwood_get_trn(RIG *rig, int *trn)
return retval;
}
if (RIG_IS_THD74)
if (RIG_IS_THD74 || RIG_IS_THD7A)
{
*trn = trnbuf[3] != '0' ? RIG_TRN_RIG : RIG_TRN_OFF;
}

Wyświetl plik

@ -27,7 +27,7 @@
#include <string.h>
#include "token.h"
#define BACKEND_VER "20200624"
#define BACKEND_VER "20200707"
#define EOM_KEN ';'
#define EOM_TH '\r'
@ -80,6 +80,7 @@ extern const struct confparams kenwood_cfg_params[];
#define RIG_IS_HPSDR (rig->caps->rig_model == RIG_MODEL_HPSDR)
#define RIG_IS_K2 (rig->caps->rig_model == RIG_MODEL_K2)
#define RIG_IS_K3 (rig->caps->rig_model == RIG_MODEL_K3)
#define RIG_IS_THD7A (rig->caps->rig_model == RIG_MODEL_THD7A)
#define RIG_IS_THD74 (rig->caps->rig_model == RIG_MODEL_THD74)
#define RIG_IS_TS2000 (rig->caps->rig_model == RIG_MODEL_TS2000)
#define RIG_IS_TS50 (rig->caps->rig_model == RIG_MODEL_TS50)

Wyświetl plik

@ -245,7 +245,7 @@ th_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// cppcheck-suppress *
sprintf(buf, "FQ %011"PRIll",%X", (int64_t) freq_sent, step);
return kenwood_transaction(rig, buf, NULL, 0);
return kenwood_transaction(rig, buf, buf, sizeof buf);
}
/*
@ -293,7 +293,6 @@ int
th_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
char kmode, mdbuf[8];
int retval;
const struct kenwood_priv_caps *priv = (const struct kenwood_priv_caps *)
rig->caps->priv;
@ -338,14 +337,7 @@ th_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
sprintf(mdbuf, "MD %c", kmode);
retval = kenwood_transaction(rig, mdbuf, NULL, 0);
if (retval != RIG_OK)
{
return retval;
}
return RIG_OK;
return kenwood_transaction(rig, mdbuf, mdbuf, sizeof mdbuf);
}
/*
@ -422,7 +414,8 @@ th_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
int
th_set_vfo(RIG *rig, vfo_t vfo)
{
const char *cmd;
int retval;
char cmd[8];
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -437,31 +430,24 @@ th_set_vfo(RIG *rig, vfo_t vfo)
/* set band */
if (vfo != RIG_VFO_MEM)
{
int retval;
switch (vfo)
{
case RIG_VFO_A:
case RIG_VFO_VFO:
case RIG_VFO_MAIN:
cmd = "BC 0";
strncpy(cmd, "BC 0", sizeof cmd);
break;
case RIG_VFO_B:
case RIG_VFO_SUB:
cmd = "BC 1";
strncpy(cmd, "BC 1", sizeof cmd);
break;
default:
return kenwood_wrong_vfo(__func__, vfo);
}
retval = kenwood_simple_transaction(rig, cmd, 5);
if (retval != RIG_OK)
{
return retval;
}
return kenwood_transaction(rig, cmd, cmd, sizeof cmd);
}
/* No "VMC" cmd on THD72A/THD74 */
@ -477,23 +463,31 @@ th_set_vfo(RIG *rig, vfo_t vfo)
case RIG_VFO_A:
case RIG_VFO_VFO:
case RIG_VFO_MAIN:
cmd = "VMC 0,0";
strncpy(cmd, "VMC 0,0", sizeof cmd);
break;
case RIG_VFO_B:
case RIG_VFO_SUB:
cmd = "VMC 1,0";
strncpy(cmd, "VMC 1,0", sizeof cmd);
break;
case RIG_VFO_MEM:
strncpy(cmd, "BC", sizeof cmd);
retval = kenwood_transaction(rig, cmd, cmd, sizeof cmd);
if (retval != RIG_OK)
{
return retval;
}
if (rig->caps->rig_model == RIG_MODEL_THF7E ||
rig->caps->rig_model == RIG_MODEL_THF6A)
{
cmd = "VMC 0,1";
snprintf(cmd, sizeof cmd, "VMC %c,1", cmd[3]);
}
else
{
cmd = "VMC 0,2";
snprintf(cmd, sizeof cmd, "VMC %c,2", cmd[3]);
}
break;
@ -502,7 +496,7 @@ th_set_vfo(RIG *rig, vfo_t vfo)
return kenwood_wrong_vfo(__func__, vfo);
}
return kenwood_transaction(rig, cmd, NULL, 0);
return kenwood_transaction(rig, cmd, cmd, sizeof cmd);
}
int
@ -636,7 +630,7 @@ th_get_vfo(RIG *rig, vfo_t *vfo)
int tm_set_vfo_bc2(RIG *rig, vfo_t vfo)
{
struct kenwood_priv_data *priv = rig->state.priv;
char vfobuf[16], ackbuf[16];
char cmd[16];
int vfonum, txvfonum, vfomode = 0;
int retval;
@ -661,15 +655,15 @@ int tm_set_vfo_bc2(RIG *rig, vfo_t vfo)
case RIG_VFO_MEM:
/* get current band */
sprintf(vfobuf, "BC");
retval = kenwood_transaction(rig, vfobuf, ackbuf, sizeof(ackbuf));
snprintf(cmd, sizeof cmd, "BC");
retval = kenwood_transaction(rig, cmd, cmd, sizeof cmd);
if (retval != RIG_OK)
{
return retval;
}
txvfonum = vfonum = ackbuf[3] - '0';
txvfonum = vfonum = cmd[3] - '0';
vfomode = 2;
break;
@ -678,8 +672,8 @@ int tm_set_vfo_bc2(RIG *rig, vfo_t vfo)
return -RIG_EVFO;
}
sprintf(vfobuf, "VMC %d,%d", vfonum, vfomode);
retval = kenwood_transaction(rig, vfobuf, NULL, 0);
snprintf(cmd, sizeof cmd, "VMC %d,%d", vfonum, vfomode);
retval = kenwood_transaction(rig, cmd, cmd, sizeof cmd);
if (retval != RIG_OK)
{
@ -691,15 +685,8 @@ int tm_set_vfo_bc2(RIG *rig, vfo_t vfo)
return RIG_OK;
}
sprintf(vfobuf, "BC %d,%d", vfonum, txvfonum);
retval = kenwood_transaction(rig, vfobuf, NULL, 0);
if (retval != RIG_OK)
{
return retval;
}
return RIG_OK;
snprintf(cmd, sizeof cmd, "BC %d,%d", vfonum, txvfonum);
return kenwood_transaction(rig, cmd, cmd, sizeof cmd);
}
@ -752,15 +739,15 @@ int th_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
}
/* Set VFO mode. To be done for TX vfo also? */
sprintf(vfobuf, "VMC %d,0", vfonum);
retval = kenwood_transaction(rig, vfobuf, NULL, 0);
snprintf(vfobuf, sizeof vfobuf, "VMC %d,0", vfonum);
retval = kenwood_transaction(rig, vfobuf, vfobuf, sizeof vfobuf);
if (retval != RIG_OK)
{
return retval;
}
sprintf(vfobuf, "BC %d,%d", vfonum, txvfonum);
snprintf(vfobuf, sizeof vfobuf, "BC %d,%d", vfonum, txvfonum);
retval = kenwood_transaction(rig, vfobuf, NULL, 0);
if (retval != RIG_OK)
@ -818,8 +805,9 @@ int th_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *txvfo)
int
th_set_trn(RIG *rig, int trn)
{
return kenwood_transaction(rig, (trn == RIG_TRN_RIG) ? "AI 1" : "AI 0", NULL,
0);
char buf[5];
snprintf(buf, sizeof buf, "AI %c", RIG_TRN_RIG == trn ? '1' : '0');
return kenwood_transaction(rig, buf, buf, sizeof buf);
}
/*
@ -1411,7 +1399,7 @@ th_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
{
const struct rig_caps *caps;
char tonebuf[16];
int i, retval;
int i;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -1431,15 +1419,8 @@ th_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
}
i += (i == 0) ? 1 : 2; /* Correct for TH-D7A index anomally */
sprintf(tonebuf, "TN %02d", i);
retval = kenwood_transaction(rig, tonebuf, NULL, 0);
if (retval != RIG_OK)
{
return retval;
}
return RIG_OK;
snprintf(tonebuf, sizeof tonebuf, "TN %02d", i);
return kenwood_transaction(rig, tonebuf, tonebuf, sizeof tonebuf);
}
/*
@ -1496,7 +1477,7 @@ th_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
{
const struct rig_caps *caps;
char tonebuf[16];
int i, retval;
int i;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -1516,15 +1497,8 @@ th_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
}
i += (i == 0) ? 1 : 2; /* Correct for TH-D7A index anomally */
sprintf(tonebuf, "CTN %02d", i);
retval = kenwood_transaction(rig, tonebuf, NULL, 0);
if (retval != RIG_OK)
{
return retval;
}
return RIG_OK;
snprintf(tonebuf, sizeof tonebuf, "CTN %02d", i);
return kenwood_transaction(rig, tonebuf, tonebuf, sizeof tonebuf);
}
/*
@ -1593,7 +1567,8 @@ th_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code)
if (code == 0)
{
return kenwood_transaction(rig, "DCS 0", NULL, 0);
snprintf(codebuf, sizeof codebuf, "DCS 0");
return kenwood_transaction(rig, codebuf, codebuf, sizeof codebuf);
}
for (i = 0; caps->dcs_list[i] != 0; i++)
@ -1609,22 +1584,16 @@ th_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code)
return -RIG_EINVAL;
}
retval = kenwood_transaction(rig, "DCS 1", NULL, 0);
snprintf(codebuf, sizeof codebuf, "DCS 1");
if (retval != RIG_OK)
if ((retval = kenwood_transaction(rig, codebuf, codebuf,
sizeof codebuf)) != RIG_OK)
{
return retval;
}
sprintf(codebuf, "DCSN %04d", (i + 1) * 10);
retval = kenwood_transaction(rig, codebuf, NULL, 0);
if (retval != RIG_OK)
{
return retval;
}
return RIG_OK;
snprintf(codebuf, sizeof codebuf, "DCSN %04d", (i + 1) * 10);
return kenwood_transaction(rig, codebuf, codebuf, sizeof codebuf);
}
/*
@ -1730,7 +1699,7 @@ int
th_set_mem(RIG *rig, vfo_t vfo, int ch)
{
unsigned char vsel;
char membuf[10], ackbuf[10];
char membuf[10];
int retval;
vfo_t tvfo;
@ -1754,23 +1723,13 @@ th_set_mem(RIG *rig, vfo_t vfo, int ch)
return kenwood_wrong_vfo(__func__, vfo);
}
retval = rig_set_vfo(rig, RIG_VFO_MEM);
if (retval != RIG_OK)
if ((retval = rig_set_vfo(rig, RIG_VFO_MEM)) != RIG_OK)
{
return retval;
}
sprintf(membuf, "MC %c,%03i", vsel, ch);
retval = kenwood_safe_transaction(rig, membuf, ackbuf, 10, 8);
if (retval != RIG_OK)
{
return retval;
}
return RIG_OK;
snprintf(membuf, sizeof membuf, "MC %c,%03i", vsel, ch);
return kenwood_transaction(rig, membuf, membuf, sizeof membuf);
}
/* Get mem works only when the display is
@ -1844,9 +1803,10 @@ th_get_mem(RIG *rig, vfo_t vfo, int *ch)
int
th_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
char buf[3];
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
return kenwood_transaction(rig, (ptt == RIG_PTT_ON) ? "TX" : "RX", NULL, 0);
return kenwood_transaction(rig, (ptt == RIG_PTT_ON) ? "TX" : "RX", buf,
sizeof buf);
}
int th_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
@ -2482,7 +2442,7 @@ int th_set_channel(RIG *rig, const channel_t *chan)
);
}
retval = kenwood_transaction(rig, membuf, NULL, 0);
retval = kenwood_transaction(rig, membuf, membuf, sizeof membuf);
if (retval != RIG_OK)
{
@ -2498,7 +2458,7 @@ int th_set_channel(RIG *rig, const channel_t *chan)
req[3 + strlen(mr_extra)] = '1';
sprintf(membuf, "%s,%011"PRIll",%X", req, (int64_t)chan->tx_freq, step);
retval = kenwood_transaction(rig, membuf, NULL, 0);
retval = kenwood_transaction(rig, membuf, membuf, sizeof membuf);
if (retval != RIG_OK)
{
@ -2519,7 +2479,7 @@ int th_set_channel(RIG *rig, const channel_t *chan)
sprintf(membuf, "MNA %s%03d,%s", mr_extra, channel_num, channel_desc);
}
retval = kenwood_transaction(rig, membuf, NULL, 0);
retval = kenwood_transaction(rig, membuf, membuf, sizeof membuf);
if (retval != RIG_OK)
{
@ -2535,29 +2495,29 @@ int th_set_channel(RIG *rig, const channel_t *chan)
*/
int th_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
{
const char *cmd;
char cmd[6];
rig_debug(RIG_DEBUG_TRACE, "%s: ant = %d\n", __func__, ant);
switch (ant)
{
case RIG_ANT_1:
cmd = "ANT 0";
strncpy(cmd, "ANT 0", sizeof cmd);
break;
case RIG_ANT_2:
cmd = "ANT 1";
strncpy(cmd, "ANT 1", sizeof cmd);
break;
case RIG_ANT_3:
cmd = "ANT 2";
strncpy(cmd, "ANT 2", sizeof cmd);
break;
default:
return -RIG_EINVAL;
}
return kenwood_transaction(rig, cmd, NULL, 0);
return kenwood_transaction(rig, cmd, cmd, sizeof cmd);
}

Wyświetl plik

@ -23,7 +23,7 @@
#include "idx_builtin.h"
#define TH_VER "20200212"
#define TH_VER "20200701"
extern int th_transaction (RIG *rig, const char *cmdstr, char *data, size_t datasize);
extern int th_get_vfo_char(RIG *rig, vfo_t *vfo, char *vfoch);

Wyświetl plik

@ -88,7 +88,7 @@ const struct rig_caps thd7a_caps =
.mfg_name = "Kenwood",
.version = TH_VER ".0",
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_HANDHELD | RIG_FLAG_APRS | RIG_FLAG_TNC | RIG_FLAG_DXCLUSTER,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_RIG,
@ -195,7 +195,7 @@ const struct rig_caps thd7a_caps =
.get_parm = th_get_parm,
.get_info = th_get_info,
.get_dcd = kenwood_get_dcd,
.get_dcd = th_get_dcd,
.decode_event = th_decode_event,
};

Wyświetl plik

@ -850,52 +850,72 @@ int ft1000mp_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
case RIG_MODE_AM:
cmd_index = FT1000MP_NATIVE_MODE_SET_AM;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_AM_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_AM_B; }
break;
case RIG_MODE_CW:
cmd_index = FT1000MP_NATIVE_MODE_SET_CWR;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_CWR_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_CWR_B; }
break;
case RIG_MODE_CWR:
cmd_index = FT1000MP_NATIVE_MODE_SET_CW;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_CW_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_CW_B; }
break;
case RIG_MODE_USB:
cmd_index = FT1000MP_NATIVE_MODE_SET_USB;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_USB_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_USB_B; }
break;
case RIG_MODE_LSB:
cmd_index = FT1000MP_NATIVE_MODE_SET_LSB;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_LSB_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_LSB_B; }
break;
case RIG_MODE_FM:
cmd_index = FT1000MP_NATIVE_MODE_SET_FM;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_FM_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_FM_B; }
break;
case RIG_MODE_RTTY:
cmd_index = FT1000MP_NATIVE_MODE_SET_RTTY_LSB;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_RTTY_LSB_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_RTTY_LSB_B; }
break;
case RIG_MODE_RTTYR:
cmd_index = FT1000MP_NATIVE_MODE_SET_RTTY_USB;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_RTTY_USB_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_RTTY_USB_B; }
break;
case RIG_MODE_PKTLSB:
cmd_index = FT1000MP_NATIVE_MODE_SET_DATA_LSB;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_DATA_LSB_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_DATA_LSB_B; }
break;
case RIG_MODE_PKTFM:
cmd_index = FT1000MP_NATIVE_MODE_SET_DATA_FM;
if (vfo == RIG_VFO_B) cmd_index = FT1000MP_NATIVE_MODE_SET_FM_B;
if (vfo == RIG_VFO_B) { cmd_index = FT1000MP_NATIVE_MODE_SET_FM_B; }
break;
default:
@ -1558,14 +1578,14 @@ int ft1000mp_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
return -RIG_EINVAL; /* sorry, wrong VFO */
}
rig_get_freq(rig,RIG_VFO_B,&tx_freq);
rig_get_freq(rig, RIG_VFO_B, &tx_freq);
// manual says VFO_A=Tx and VFO_B=Rx but testing shows otherwise
rig->state.current_vfo = RIG_VFO_A;
rig->state.tx_vfo = RIG_VFO_B;
ft1000mp_send_priv_cmd(rig, FT1000MP_NATIVE_AB); // Copy A to B
ft1000mp_send_priv_cmd(rig, FT1000MP_NATIVE_VFO_A); // make A active
ft1000mp_send_priv_cmd(rig, cmd_index);
rig_set_freq(rig,RIG_VFO_B,tx_freq); // restore orig frequency
rig_set_freq(rig, RIG_VFO_B, tx_freq); // restore orig frequency
return RIG_OK;
}

Wyświetl plik

@ -629,7 +629,6 @@ static int ft817_get_status(RIG *rig, int status)
int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
int n;
freq_t f1 = 0, f2 = 0;
int retries = rig->state.rigport.retry +
1; // +1 because, because 2 steps are needed even in best scenario
@ -638,6 +637,7 @@ int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
while ((f1 == 0 || f1 != f2) && retries-- > 0)
{
int n;
rig_debug(RIG_DEBUG_TRACE, "%s: retries=%d\n", __func__, retries);
if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0)
@ -955,13 +955,11 @@ int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
int ft817_read_ack(RIG *rig)
{
char dummy;
int n;
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
if (rig->state.rigport.post_write_delay == 0)
{
if ((n = read_block(&rig->state.rigport, &dummy, 1)) < 0)
if (read_block(&rig->state.rigport, &dummy, 1) < 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: error reading ack\n", __func__);
rig_debug(RIG_DEBUG_ERR, "%s: adjusting post_write_delay to avoid ack\n",

Wyświetl plik

@ -202,8 +202,10 @@ const struct rig_caps ft857_caps =
},
.tx_range_list1 = {
FRQ_RNG_HF(1, FT857_OTHER_TX_MODES, W(10), W(100), FT857_VFO_ALL, FT857_ANTS),
FRQ_RNG_6m(1, FT857_OTHER_TX_MODES, W(10), W(100), FT857_VFO_ALL, FT857_ANTS),
/* AM class */
FRQ_RNG_HF(1, FT857_AM_TX_MODES, W(2.5), W(25), FT857_VFO_ALL, FT857_ANTS),
FRQ_RNG_6m(1, FT857_AM_TX_MODES, W(2.5), W(25), FT857_VFO_ALL, FT857_ANTS),
FRQ_RNG_2m(1, FT857_OTHER_TX_MODES, W(5), W(50), FT857_VFO_ALL, FT857_ANTS),
/* AM class */
FRQ_RNG_2m(1, FT857_AM_TX_MODES, W(2.5), W(25), FT857_VFO_ALL, FT857_ANTS),
@ -913,6 +915,9 @@ int ft857_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (vfo != RIG_VFO_CURR)
{
rig_debug(RIG_DEBUG_ERR, "%s: must have RIG_VFO_CURR, got %s\n",
rig_strvfo(RIG_VFO_CURR), rig_strvfo(vfo));
return -RIG_ENTARGET;
}

Wyświetl plik

@ -239,8 +239,11 @@ const struct rig_caps ft897_caps =
},
.tx_range_list1 = {
FRQ_RNG_HF(1, FT897_OTHER_TX_MODES, W(10), W(100), FT897_VFO_ALL, FT897_ANTS),
FRQ_RNG_6m(1, FT897_OTHER_TX_MODES, W(10), W(100), FT897_VFO_ALL, FT897_ANTS),
/* AM class */
FRQ_RNG_HF(1, FT897_AM_TX_MODES, W(2.5), W(25), FT897_VFO_ALL, FT897_ANTS),
FRQ_RNG_6m(1, FT897_AM_TX_MODES, W(2.5), W(25), FT897_VFO_ALL, FT897_ANTS),
FRQ_RNG_2m(1, FT897_OTHER_TX_MODES, W(5), W(50), FT897_VFO_ALL, FT897_ANTS),
/* AM class */
FRQ_RNG_2m(1, FT897_AM_TX_MODES, W(2.5), W(25), FT897_VFO_ALL, FT897_ANTS),

Wyświetl plik

@ -366,10 +366,10 @@ int newcat_open(RIG *rig)
__func__, rig_s->rigport.post_write_delay);
/* Ensure rig is powered on */
if (priv->poweron == 0)
if (priv->poweron == 0 && rig_s->auto_power_on)
{
priv->poweron = 1;
rig_set_powerstat(rig, 1);
priv->poweron = 1;
}
/* get current AI state so it can be restored */

Wyświetl plik

@ -227,8 +227,10 @@ gs232b_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
*/
// There's a 12PR1A rotor that only returns AZ so we may only get AZ=xxx
if (sscanf(posbuf, "AZ=%d EL=%d", &int_az, &int_el) == 0)
{ // only give error if we didn't parse anything
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s', expected AZ=xxx EL=xxx\n", __func__,
{
// only give error if we didn't parse anything
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply '%s', expected AZ=xxx EL=xxx\n",
__func__,
posbuf);
return -RIG_EPROTO;
}

Wyświetl plik

@ -552,7 +552,7 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth,
err = -RIG_EINVAL;
}
}
else if (err == AZ_READ_LEN && az[0] == ';')
else if (err == AZ_READ_LEN)
{
/* Check if remaining chars are digits if az[0] == ';' */
for (p = az + 1; p < az + 4; p++)

Wyświetl plik

@ -128,6 +128,16 @@ static const struct confparams frontend_cfg_params[] =
"Cache timeout, value of 0 disables caching",
"500", RIG_CONF_NUMERIC, { .n = {0, 5000, 1}}
},
{
TOK_AUTO_POWER_ON, "auto_power_on", "Auto power on",
"True enables compatible rigs to be powered up on open",
"0", RIG_CONF_CHECKBUTTON, { }
},
{
TOK_AUTO_DISABLE_SCREENSAVER, "auto_disable_screensaver", "Auto disable screen saver",
"True enables compatible rigs to have their screen saver disabled on open",
"0", RIG_CONF_CHECKBUTTON, { }
},
{ RIG_CONF_END, NULL, }
};
@ -552,6 +562,24 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_ALL, atol(val));
break;
case TOK_AUTO_POWER_ON:
if (1 != sscanf(val, "%d", &val_i))
{
return -RIG_EINVAL; //value format error
}
rs->auto_power_on = val_i ? 1 : 0;
break;
case TOK_AUTO_DISABLE_SCREENSAVER:
if (1 != sscanf(val, "%d", &val_i))
{
return -RIG_EINVAL; //value format error
}
rs->auto_disable_screensaver = val_i ? 1 : 0;
break;
default:
return -RIG_EINVAL;
}
@ -864,6 +892,14 @@ static int frontend_get_conf(RIG *rig, token_t token, char *val)
sprintf(val, "%d", rig_get_cache_timeout_ms(rig, HAMLIB_CACHE_ALL));
break;
case TOK_AUTO_POWER_ON:
sprintf(val, "%d", rs->auto_power_on);
break;
case TOK_AUTO_DISABLE_SCREENSAVER:
sprintf(val, "%d", rs->auto_disable_screensaver);
break;
default:
return -RIG_EINVAL;
}

Wyświetl plik

@ -1606,6 +1606,7 @@ const chan_t *HAMLIB_API rig_lookup_mem_caps(RIG *rig, int ch)
*/
for (j = 0; j < sizeof(channel_cap_t); j++)
{
// cppcheck-suppress *
p1[j] |= p2[j];
}

Wyświetl plik

@ -1313,7 +1313,8 @@ int HAMLIB_API rig_get_cache_timeout_ms(RIG *rig, hamlib_cache_t selection)
return rig->state.cache.timeout_ms;
}
int HAMLIB_API rig_set_cache_timeout_ms(RIG *rig, hamlib_cache_t selection, int ms)
int HAMLIB_API rig_set_cache_timeout_ms(RIG *rig, hamlib_cache_t selection,
int ms)
{
rig_debug(RIG_DEBUG_TRACE, "%s: called selection=%d, ms=%d\n", __func__,
selection, ms);
@ -1382,7 +1383,7 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo)
int HAMLIB_API parse_hoststr(char *hoststr, char host[256], char port[6])
{
unsigned int net1, net2, net3, net4, net5, net6, net7, net8;
char dummy[2], link[32], *p;
char dummy[6], link[32], *p;
host[0] = 0;
port[0] = 0;
dummy[0] = 0;
@ -1392,6 +1393,9 @@ int HAMLIB_API parse_hoststr(char *hoststr, char host[256], char port[6])
if (strncasecmp(hoststr, "com", 3) == 0) { return -1; }
// escaped COM port like \\.\COM3
if (strstr(hoststr, "\\\\.\\")) { return -1; }
// bracketed IPV6 with optional port
int n = sscanf(hoststr, "[%255[^]]]:%5s", host, port);
@ -1471,7 +1475,7 @@ int HAMLIB_API parse_hoststr(char *hoststr, char host[256], char port[6])
return RIG_OK;
}
if (sscanf(hoststr, ":%5[0-9]%s", port,
if (sscanf(hoststr, ":%5[0-9]%1s", port,
dummy) == 1) // just a port if you please
{
sprintf(hoststr, "%s:%s\n", "localhost", port);

Wyświetl plik

@ -299,7 +299,7 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model)
if (be_idx == -1)
{
rig_debug(RIG_DEBUG_VERBOSE,
"rig_check_backend: unsupported backend %d for model %u\n",
"rig_check_backend: unsupported backend %u for model %u\n",
RIG_BACKEND_NUM(rig_model),
rig_model);
return -RIG_ENAVAIL;

Wyświetl plik

@ -925,10 +925,13 @@ int HAMLIB_API rig_open(RIG *rig)
}
}
// try to turn off the screensaver if possible
// don't care about the return here...it's just a nice-to-have
parm_value.i = 0;
rig_set_parm(rig, RIG_PARM_SCREENSAVER, parm_value);
if (rs->auto_disable_screensaver)
{
// try to turn off the screensaver if possible
// don't care about the return here...it's just a nice-to-have
parm_value.i = 0;
rig_set_parm(rig, RIG_PARM_SCREENSAVER, parm_value);
}
#if 0
@ -1362,6 +1365,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// we'll try this all the time and if it works out OK eliminate the #else
if ((unsigned long long)freq % 100 != 0 // only need to do if < 100Hz interval
|| freq > 100e6 // or if we are in the VHF and up range
#if 0
// do we need to only do this when cache is turned on? 2020-07-02 W9MDB
&& rig->state.cache.timeout_ms > 0

Wyświetl plik

@ -66,6 +66,7 @@ int hl_usleep(rig_useconds_t usec)
}
#ifdef HAVE_NANOSLEEP
#ifndef HAVE_SLEEP
/**
* \brief sleep
* \param secs is seconds to sleep
@ -83,6 +84,7 @@ unsigned int sleep(unsigned int secs)
return 0;
}
#endif
#if 0

Wyświetl plik

@ -104,6 +104,10 @@
#define TOK_RANGE_NAME TOKEN_FRONTEND(122)
/** \brief rig: Cache timeout */
#define TOK_CACHE_TIMEOUT TOKEN_FRONTEND(123)
/** \brief rig: Auto power on rig_open when supported */
#define TOK_AUTO_POWER_ON TOKEN_FRONTEND(124)
/** \brief rig: Auto disable screensaver */
#define TOK_AUTO_DISABLE_SCREENSAVER TOKEN_FRONTEND(125)
/*
* rotator specific tokens
* (strictly, should be documented as rotator_internal)

Wyświetl plik

@ -598,6 +598,7 @@ int main(int argc, char *argv[])
handle_socket(arg);
#endif
}
// cppcheck-suppress *
while (retcode == 0);
amp_close(my_amp); /* close port */

Wyświetl plik

@ -47,7 +47,7 @@ int main(int argc, char *argv[])
int model;
int baud;
int loops;
int cache_timeout;
int cache_timeout = 500;
int i;
struct timespec start, startall;

Wyświetl plik

@ -290,7 +290,7 @@ static char *mystrtok(char *s, char delim)
{
}
if (str[ pos + 1 ] == '\0')
if (str && str[ pos + 1 ] == '\0')
{
return NULL;
}
@ -311,6 +311,7 @@ static char *mystrtok(char *s, char delim)
}
}
// cppcheck-suppress *
return str + ent_pos;
}
@ -1038,6 +1039,11 @@ int find_on_list(char **list, char *what)
return -1;
}
if (!list[i])
{
return -1;
}
while (list[i] != NULL)
{
if (strcmp(list[i], what) == 0)
@ -1050,12 +1056,5 @@ int find_on_list(char **list, char *what)
}
}
if (!list[i])
{
return -1;
}
else
{
return i;
}
return i;
}

Wyświetl plik

@ -736,6 +736,8 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
break;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd==0x%02x\n", __func__, cmd);
if (cmd == 0x0a || cmd == 0x0d)
{
if (last_was_ret)
@ -935,12 +937,17 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (interactive)
{
rig_debug(RIG_DEBUG_TRACE, "%s: debug4\n", __func__);
int c = fgetc(fin);
rig_debug(RIG_DEBUG_TRACE, "%s: debug4 c=%02x\n", __func__, c);
if (prompt)
if (prompt && c == 0x0a)
{
fprintf_flush(fout, "%s: ", cmd_entry->arg1);
}
else
{
ungetc(c, fin);
}
if (scanfc(fin, "%s", arg1) < 1)
{

Wyświetl plik

@ -306,7 +306,7 @@ void hash_sort_by_model_id()
/* Delete hash */
void hash_delete_all()
{
struct mod_lst *current_model, *tmp;
struct mod_lst *current_model, *tmp=NULL;
HASH_ITER(hh, models, current_model, tmp)
{

Wyświetl plik

@ -611,6 +611,7 @@ int main(int argc, char *argv[])
handle_socket(arg);
#endif
}
// cppcheck-suppress *
while (retcode == 0);
rot_close(my_rot); /* close port */

154
tests/testnet.c 100644
Wyświetl plik

@ -0,0 +1,154 @@
/* Test network address variations in hamlib */
#include <stdlib.h>
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <sys/time.h>
#include <sys/types.h>
#include <signal.h>
#define HAVE_NETINET_IN_H
#define HAVE_NETDB_H
#define HAVE_ARPA_INET_H
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
int rig_network_addr(char *hoststr, char *portstr)
{
struct in6_addr serveraddr;
struct addrinfo hints, *res;
int status;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
status = getaddrinfo(hoststr, portstr, &hints, &res);
if (status == 0 && res->ai_family == AF_INET6)
{
printf("Using IPV6 for %s:%s\n", hoststr, portstr);
}
else if (status == 0)
{
printf("Using IPV4 for %s:%s\n", hoststr, portstr);
}
if (status != 0)
{
printf("%s: cannot get host \"%s\": %s\n",
__func__,
hoststr,
gai_strerror(errno));
return 1;
}
status = inet_pton(AF_INET, hoststr, &serveraddr);
if (status != 1) /* not valid IPv4 address, maybe IPV6? */
{
status = inet_pton(AF_INET6, hoststr, &serveraddr);
if (status != 1) /* nope */
{
return 1;
}
}
return 0;
}
int test_host(char *hoststr, char host[256], char port[6])
{
int status;
char host2[256], port2[6];
status = parse_hoststr(hoststr, host2, port2);
printf("---------------------\n");
if (status == 0)
{
if (strcmp(host, host2) || strcmp(port, port2))
{
printf("%s: Mismatch, expected host=%s, port=%s, got host=%s, port=%s\n",
__func__,
host, port, host2, port2);
return -1;
}
else
{
rig_network_addr(host, port);
}
printf("%s: %s, host=%s, port=%s\n", __func__, hoststr, host, port);
return 0;
}
else
{
printf("%s: ERROR!! %s, host=%s, port=%s\n", __func__, hoststr, host, port);
return -1;
}
}
int
main(int argc, char *argv[])
{
// IPV4
test_host("127.0.0.1", "127.0.0.1", "");
test_host("127.0.0.1:4532", "127.0.0.1", "4532");
test_host("192.168.1.1", "192.168.1.1", "");
test_host("192.168.1.1:4532", "192.168.1.1", "4532");
test_host("mdblack-VirtualBox", "mdblack-VirtualBox", "");
test_host("mdblack-VirtualBox:4532", "mdblack-VirtualBox", "4532");
test_host("localhost", "localhost", "");
test_host("localhost:4532", "localhost", "4532");
// IPV6 with brackets
test_host("[fe80::e034:55ef:ce2a:dc83]", "fe80::e034:55ef:ce2a:dc83", "");
test_host("[fe80::e034:55ef:ce2a:dc83]:4532", "fe80::e034:55ef:ce2a:dc83",
"4532");
test_host("fe80::e034:55ef:ce2a:dc83", "fe80::e034:55ef:ce2a:dc83", "");
test_host("fe80::e034:55ef:ce2a:dc83:4532", "fe80::e034:55ef:ce2a:dc83",
"4532");
test_host("fe80:e034:55ef:ce2a:dc83:1234:5678:9abc",
"fe80:e034:55ef:ce2a:dc83:1234:5678:9abc", "");
test_host("fe80:e034:55ef:ce2a:dc83:1234:5678:9abc:4532",
"fe80:e034:55ef:ce2a:dc83:1234:5678:9abc",
"4532");
test_host("::1", "::1", "");
test_host("::1:4532", "::1", "4532");
#if 1 // server side addresses with IPV6
test_host("fe80::e034:55ef:ce2a:dc83%eth0", "fe80::e034:55ef:ce2a:dc83%eth0",
"");
test_host("[fe80::e034:55ef:ce2a:dc83%1]", "fe80::e034:55ef:ce2a:dc83%1", "");
test_host("[fe80::e034:55ef:ce2a:dc83%1]:4532", "fe80::e034:55ef:ce2a:dc83%1",
"4532");
test_host("fe80::e034:55ef:ce2a:dc83%eth0:4532",
"fe80::e034:55ef:ce2a:dc83%eth0", "4532");
test_host("fe80::e034:55ef:ce2a:dc83%1", "fe80::e034:55ef:ce2a:dc83%1", "");
test_host("fe80::e034:55ef:ce2a:dc83%1:4532", "fe80::e034:55ef:ce2a:dc83%1",
"4532");
test_host("[fe80::e034:55ef:ce2a:dc83%eth0]",
"fe80::e034:55ef:ce2a:dc83%eth0", "");
test_host("[fe80::e034:55ef:ce2a:dc83%eth0]:4532",
"fe80::e034:55ef:ce2a:dc83%eth0", "4532");
#endif
return 0;
}