mirror of
https://github.com/Hamlib/Hamlib.git
synced 2024-09-21 10:27:18 +00:00
astyle all files preparing for 4.3 release
This commit is contained in:
parent
ff61c407f0
commit
283281c4cb
@ -161,19 +161,25 @@ static void init_chan(RIG *rig, vfo_t vfo, channel_t *chan)
|
||||
case RIG_VFO_MAIN_A:
|
||||
chan->freq = MHz(145);
|
||||
break;
|
||||
|
||||
case RIG_VFO_B:
|
||||
case RIG_VFO_MAIN_B:
|
||||
chan->freq = MHz(146);
|
||||
break;
|
||||
|
||||
case RIG_VFO_SUB_A:
|
||||
chan->freq = MHz(147);
|
||||
break;
|
||||
|
||||
case RIG_VFO_SUB_B:
|
||||
chan->freq = MHz(148);
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d) unknown vfo=%s\n", __FILE__, __LINE__, rig_strvfo(vfo));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d) unknown vfo=%s\n", __FILE__, __LINE__,
|
||||
rig_strvfo(vfo));
|
||||
}
|
||||
|
||||
chan->mode = RIG_MODE_FM;
|
||||
chan->width = rig_passband_normal(rig, RIG_MODE_FM);
|
||||
chan->tx_freq = chan->freq;
|
||||
@ -431,12 +437,16 @@ static int dummy_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
{
|
||||
case RIG_VFO_MAIN:
|
||||
case RIG_VFO_A: priv->vfo_a.freq = freq; break;
|
||||
|
||||
case RIG_VFO_MAIN_A: priv->vfo_maina.freq = freq; break;
|
||||
|
||||
case RIG_VFO_MAIN_B: priv->vfo_mainb.freq = freq; break;
|
||||
|
||||
case RIG_VFO_SUB:
|
||||
case RIG_VFO_B: priv->vfo_b.freq = freq; break;
|
||||
|
||||
case RIG_VFO_SUB_A: priv->vfo_suba.freq = freq; break;
|
||||
|
||||
case RIG_VFO_SUB_B: priv->vfo_subb.freq = freq; break;
|
||||
|
||||
case RIG_VFO_C: priv->vfo_c.freq = freq; break;
|
||||
@ -477,12 +487,16 @@ static int dummy_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
{
|
||||
case RIG_VFO_MAIN:
|
||||
case RIG_VFO_A: *freq = priv->vfo_a.freq; break;
|
||||
|
||||
case RIG_VFO_MAIN_A: *freq = priv->vfo_maina.freq; break;
|
||||
|
||||
case RIG_VFO_MAIN_B: *freq = priv->vfo_mainb.freq; break;
|
||||
|
||||
case RIG_VFO_SUB:
|
||||
case RIG_VFO_B: *freq = priv->vfo_b.freq; break;
|
||||
|
||||
case RIG_VFO_SUB_A: *freq = priv->vfo_suba.freq; break;
|
||||
|
||||
case RIG_VFO_SUB_B: *freq = priv->vfo_subb.freq; break;
|
||||
|
||||
case RIG_VFO_C: *freq = priv->vfo_c.freq; break;
|
||||
@ -508,6 +522,7 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
rig_strvfo(vfo), rig_strrmode(mode), buf);
|
||||
|
||||
vfo = vfo_fixup(rig, vfo, rig->state.cache.split);
|
||||
|
||||
switch (vfo)
|
||||
{
|
||||
case RIG_VFO_MAIN:
|
||||
@ -517,6 +532,7 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
case RIG_VFO_B: priv->vfo_b.mode = mode; priv->vfo_b.width = width; break;
|
||||
|
||||
case RIG_VFO_C: priv->vfo_c.mode = mode; priv->vfo_c.width = width; break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unknown VFO=%s\n", __func__, rig_strvfo(vfo));
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
@ -589,13 +605,17 @@ static int dummy_set_vfo(RIG *rig, vfo_t vfo)
|
||||
|
||||
case RIG_VFO_RX:
|
||||
case RIG_VFO_MAIN: priv->curr = &priv->vfo_a; break;
|
||||
|
||||
case RIG_VFO_MAIN_A: priv->curr = &priv->vfo_maina; break;
|
||||
|
||||
case RIG_VFO_MAIN_B: priv->curr = &priv->vfo_mainb; break;
|
||||
|
||||
case RIG_VFO_A: priv->curr = &priv->vfo_a; break;
|
||||
|
||||
case RIG_VFO_SUB: priv->curr = &priv->vfo_b; break;
|
||||
|
||||
case RIG_VFO_SUB_A: priv->curr = &priv->vfo_suba; break;
|
||||
|
||||
case RIG_VFO_SUB_B: priv->curr = &priv->vfo_subb; break;
|
||||
|
||||
case RIG_VFO_B: priv->curr = &priv->vfo_b; break;
|
||||
@ -622,6 +642,7 @@ static int dummy_set_vfo(RIG *rig, vfo_t vfo)
|
||||
rig_strvfo(vfo));
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
rig->state.current_vfo = vfo;
|
||||
|
||||
RETURNFUNC(RIG_OK);
|
||||
|
@ -272,7 +272,8 @@ static int check_vfo(vfo_t vfo)
|
||||
* So we'll hand craft them
|
||||
* xml_build takes a value and return an xml string for FLRig
|
||||
*/
|
||||
static char *xml_build(RIG *rig, char *cmd, char *value, char *xmlbuf, int xmlbuflen)
|
||||
static char *xml_build(RIG *rig, char *cmd, char *value, char *xmlbuf,
|
||||
int xmlbuflen)
|
||||
{
|
||||
char xml[4096]; // we shouldn't need more the 4096 bytes for this
|
||||
char tmp[32];
|
||||
@ -297,7 +298,9 @@ static char *xml_build(RIG *rig, char *cmd, char *value, char *xmlbuf, int xmlbu
|
||||
__func__, (int)strlen(header), n);
|
||||
}
|
||||
|
||||
n = snprintf(xml, sizeof(xml), "<?xml version=\"1.0\"?>\r\n<?clientid=\"hamlib(%d)\"?>\r\n", rig->state.rigport.client_port);
|
||||
n = snprintf(xml, sizeof(xml),
|
||||
"<?xml version=\"1.0\"?>\r\n<?clientid=\"hamlib(%d)\"?>\r\n",
|
||||
rig->state.rigport.client_port);
|
||||
|
||||
if (n != strlen(xml))
|
||||
{
|
||||
@ -1414,13 +1417,17 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
}
|
||||
|
||||
// Set the mode
|
||||
if (modeMapGetFLRig(mode)) {
|
||||
if (modeMapGetFLRig(mode))
|
||||
{
|
||||
ttmode = strdup(modeMapGetFLRig(mode));
|
||||
}
|
||||
else {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: modeMapGetFlRig failed on mode=%d\n", __func__, (int)mode);
|
||||
else
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: modeMapGetFlRig failed on mode=%d\n", __func__,
|
||||
(int)mode);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: got ttmode = %s\n", __func__,
|
||||
ttmode == NULL ? "NULL" : ttmode);
|
||||
|
||||
|
@ -670,6 +670,7 @@ static int netrigctl_open(RIG *rig)
|
||||
rig->caps->ptt_type = temp;
|
||||
}
|
||||
}
|
||||
|
||||
// setting targetable_vfo this way breaks WSJTX in rig split with rigctld
|
||||
// Ends up putting VFOB freq on VFOA
|
||||
// Have to figure out why but disabling this fixes it for now
|
||||
@ -680,6 +681,7 @@ static int netrigctl_open(RIG *rig)
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: targetable_vfo=0x%2x\n", __func__,
|
||||
rig->caps->targetable_vfo);
|
||||
}
|
||||
|
||||
#endif
|
||||
else if (strcmp(setting, "has_set_vfo") == 0)
|
||||
{
|
||||
|
@ -101,7 +101,8 @@ int icom_frame_fix_preamble(int frame_len, unsigned char *frame)
|
||||
}
|
||||
else
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: invalid Icom CI-V frame, no preamble found\n", __func__);
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: invalid Icom CI-V frame, no preamble found\n",
|
||||
__func__);
|
||||
RETURNFUNC(-RIG_EPROTO);
|
||||
}
|
||||
|
||||
@ -284,6 +285,7 @@ read_another_frame:
|
||||
}
|
||||
|
||||
retval = icom_frame_fix_preamble(frm_len, buf);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
Unhold_Decode(rig);
|
||||
|
260
rigs/icom/icom.c
260
rigs/icom/icom.c
@ -47,7 +47,8 @@
|
||||
static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo);
|
||||
static int icom_set_default_vfo(RIG *rig);
|
||||
static int icom_get_spectrum_vfo(RIG *rig, vfo_t vfo);
|
||||
static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *range_id);
|
||||
static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo,
|
||||
int *range_id);
|
||||
|
||||
const cal_table_float_t icom_default_swr_cal =
|
||||
{
|
||||
@ -634,17 +635,21 @@ int icom_init(RIG *rig)
|
||||
priv = rig->state.priv;
|
||||
|
||||
priv->spectrum_scope_count = 0;
|
||||
|
||||
for (i = 0; caps->spectrum_scopes[i].name != NULL; i++)
|
||||
{
|
||||
priv->spectrum_scope_cache[i].spectrum_data = NULL;
|
||||
|
||||
if (priv_caps->spectrum_scope_caps.spectrum_line_length < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: no spectrum scope line length defined\n", __func__);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: no spectrum scope line length defined\n",
|
||||
__func__);
|
||||
RETURNFUNC(-RIG_ECONF);
|
||||
}
|
||||
|
||||
priv->spectrum_scope_cache[i].spectrum_data = calloc(1, priv_caps->spectrum_scope_caps.spectrum_line_length);
|
||||
priv->spectrum_scope_cache[i].spectrum_data = calloc(1,
|
||||
priv_caps->spectrum_scope_caps.spectrum_line_length);
|
||||
|
||||
if (!priv->spectrum_scope_cache[i].spectrum_data)
|
||||
{
|
||||
RETURNFUNC(-RIG_ENOMEM);
|
||||
@ -936,6 +941,7 @@ static int icom_set_default_vfo(RIG *rig)
|
||||
__func__);
|
||||
TRACE;
|
||||
retval = RIG_OK;
|
||||
|
||||
if (rig->state.current_vfo != RIG_VFO_A)
|
||||
{
|
||||
retval = rig_set_vfo(rig,
|
||||
@ -1058,6 +1064,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
if (rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ)
|
||||
{
|
||||
vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B;
|
||||
|
||||
// if we are on the "other" vfo already then we have to allow for that
|
||||
if (rig->state.current_vfo & vfo_unselected)
|
||||
{
|
||||
@ -1065,8 +1072,10 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
vfo_unselected = RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo=%s, currvfo=%s\n", __func__, __LINE__, rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo=%s, currvfo=%s\n", __func__, __LINE__,
|
||||
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
|
||||
subcmd = 0x00;
|
||||
|
||||
// if we ask for unselected but we're not on unselected subcmd2 changes
|
||||
if ((vfo & vfo_unselected) && !(rig->state.current_vfo & vfo_unselected))
|
||||
{
|
||||
@ -1085,6 +1094,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf,
|
||||
&ack_len);
|
||||
}
|
||||
|
||||
hl_usleep(50 * 1000); // pause for transceive message and we'll flush it
|
||||
|
||||
if (retval != RIG_OK)
|
||||
@ -1155,11 +1165,15 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
switch (vfo)
|
||||
{
|
||||
case RIG_VFO_A: priv->vfoa_freq = freq; break;
|
||||
|
||||
case RIG_VFO_MAIN_A: priv->maina_freq = freq; break;
|
||||
|
||||
case RIG_VFO_SUB_A: priv->suba_freq = freq; break;
|
||||
|
||||
case RIG_VFO_B: priv->vfob_freq = freq; break;
|
||||
|
||||
case RIG_VFO_MAIN_B: priv->mainb_freq = freq;
|
||||
|
||||
case RIG_VFO_SUB_B: priv->subb_freq = freq;
|
||||
|
||||
case RIG_VFO_MAIN: priv->main_freq = freq; break;
|
||||
@ -1313,6 +1327,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
int cmd2 = 0x25;
|
||||
int subcmd2 = 0x00;
|
||||
vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B;
|
||||
|
||||
// if we are on the "other" vfo already then we have to allow for that
|
||||
if (rig->state.current_vfo & vfo_unselected)
|
||||
{
|
||||
@ -1416,11 +1431,15 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
switch (vfo)
|
||||
{
|
||||
case RIG_VFO_A: priv->vfoa_freq = *freq; break;
|
||||
|
||||
case RIG_VFO_MAIN_A: priv->maina_freq = *freq; break;
|
||||
|
||||
case RIG_VFO_SUB_A: priv->suba_freq = *freq; break;
|
||||
|
||||
case RIG_VFO_B: priv->vfob_freq = *freq; break;
|
||||
|
||||
case RIG_VFO_MAIN_B: priv->mainb_freq = *freq; break;
|
||||
|
||||
case RIG_VFO_SUB_B: priv->subb_freq = *freq; break;
|
||||
|
||||
case RIG_VFO_MAIN: priv->main_freq = *freq; break;
|
||||
@ -1715,18 +1734,21 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width)
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode, int filter)
|
||||
static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode,
|
||||
int filter)
|
||||
{
|
||||
struct icom_priv_data *priv = rig->state.priv;
|
||||
int retval;
|
||||
unsigned char buf[3];
|
||||
|
||||
ENTERFUNC;
|
||||
if (priv->x26cmdfails) RETURNFUNC(-RIG_ENAVAIL);
|
||||
|
||||
if (priv->x26cmdfails) { RETURNFUNC(-RIG_ENAVAIL); }
|
||||
|
||||
int cmd2 = 0x26;
|
||||
int subcmd2 = 0x00;
|
||||
vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B;
|
||||
|
||||
// if we are on the "other" vfo already then we have to allow for that
|
||||
if (rig->state.current_vfo & vfo_unselected)
|
||||
{
|
||||
@ -1738,6 +1760,7 @@ static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode, in
|
||||
{
|
||||
subcmd2 = 0x01; // get unselected VFO
|
||||
}
|
||||
|
||||
buf[0] = mode;
|
||||
buf[1] = datamode;
|
||||
// filter fixed to filter 1 due to IC7300 bug defaulting to filter 2 on mode changed -- yuck!!
|
||||
@ -1809,7 +1832,8 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode,
|
||||
break;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s mode=%d, width=%d, curr_vfo=%s\n", __func__, (int)icom_mode,
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s mode=%d, width=%d, curr_vfo=%s\n", __func__,
|
||||
(int)icom_mode,
|
||||
(int)width, rig_strvfo(rig->state.current_vfo));
|
||||
retval = icom_set_mode(rig, vfo, icom_mode, width);
|
||||
|
||||
@ -1822,6 +1846,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode,
|
||||
signed char width_icom;
|
||||
|
||||
TRACE;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case RIG_MODE_PKTUSB:
|
||||
@ -1843,10 +1868,13 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode,
|
||||
if (filter_byte) // then we need the filter width byte too
|
||||
{
|
||||
TRACE;
|
||||
if (datamode[0] == 0) datamode[1]=0; // the only good combo possible according to manual
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(%d) mode_icom=%d, datamode[0]=%d, filter=%d\n", __func__, __LINE__, mode_icom, datamode[0], datamode[1]);
|
||||
if (datamode[0] == 0) { datamode[1] = 0; } // the only good combo possible according to manual
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(%d) mode_icom=%d, datamode[0]=%d, filter=%d\n",
|
||||
__func__, __LINE__, mode_icom, datamode[0], datamode[1]);
|
||||
retval = icom_set_mode_x26(rig, vfo, mode_icom, datamode[0], datamode[1]);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
retval =
|
||||
@ -1895,8 +1923,10 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
int ack_len = sizeof(ackbuf), retval, err;
|
||||
int swapvfos = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, mode=%s, width=%d, current_vfo=%s\n", __func__,
|
||||
rig_strvfo(vfo), rig_strrmode(mode), (int)width, rig_strvfo(rig->state.current_vfo));
|
||||
rig_debug(RIG_DEBUG_VERBOSE,
|
||||
"%s called vfo=%s, mode=%s, width=%d, current_vfo=%s\n", __func__,
|
||||
rig_strvfo(vfo), rig_strrmode(mode), (int)width,
|
||||
rig_strvfo(rig->state.current_vfo));
|
||||
rs = &rig->state;
|
||||
priv = (struct icom_priv_data *) rs->priv;
|
||||
|
||||
@ -1937,7 +1967,10 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
// some Icom rigs have seperate modes for VFOB/Sub
|
||||
// switching to VFOB should not matter for the other rigs
|
||||
// This needs to be improved for RIG_TARGETABLE_MODE rigs
|
||||
if ((vfo == RIG_VFO_B || vfo == RIG_VFO_SUB) && ((rig->state.current_vfo == RIG_VFO_A || rig->state.current_vfo == RIG_VFO_MAIN) || rig->state.current_vfo == RIG_VFO_CURR))
|
||||
if ((vfo == RIG_VFO_B || vfo == RIG_VFO_SUB)
|
||||
&& ((rig->state.current_vfo == RIG_VFO_A
|
||||
|| rig->state.current_vfo == RIG_VFO_MAIN)
|
||||
|| rig->state.current_vfo == RIG_VFO_CURR))
|
||||
{
|
||||
TRACE;
|
||||
swapvfos = 1;
|
||||
@ -2565,9 +2598,10 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
|
||||
ackbuf[0], ack_len);
|
||||
RETURNFUNC(-RIG_ERJCTED);
|
||||
}
|
||||
|
||||
// If SUB_A then we'll assume we're done and probably not in sat mode
|
||||
// If rig has SUB_B active this may be a problem
|
||||
if (vfo == RIG_VFO_SUB_A) return RIG_OK;
|
||||
if (vfo == RIG_VFO_SUB_A) { return RIG_OK; }
|
||||
|
||||
icvfo = vfo == RIG_VFO_SUB_A ? S_VFOA : S_VFOB;
|
||||
|
||||
@ -3109,15 +3143,19 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
case RIG_SPECTRUM_MODE_CENTER:
|
||||
icom_val = SCOPE_MODE_CENTER;
|
||||
break;
|
||||
|
||||
case RIG_SPECTRUM_MODE_FIXED:
|
||||
icom_val = SCOPE_MODE_FIXED;
|
||||
break;
|
||||
|
||||
case RIG_SPECTRUM_MODE_CENTER_SCROLL:
|
||||
icom_val = SCOPE_MODE_SCROLL_C;
|
||||
break;
|
||||
|
||||
case RIG_SPECTRUM_MODE_FIXED_SCROLL:
|
||||
icom_val = SCOPE_MODE_SCROLL_F;
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum mode %d\n", __func__, val.i);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
@ -3156,9 +3194,11 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
case 0:
|
||||
icom_val = SCOPE_SPEED_SLOW;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
icom_val = SCOPE_SPEED_MID;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
icom_val = SCOPE_SPEED_FAST;
|
||||
break;
|
||||
@ -3168,7 +3208,8 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
cmdbuf[1] = icom_val;
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_SPECTRUM_REF: {
|
||||
case RIG_LEVEL_SPECTRUM_REF:
|
||||
{
|
||||
float icom_db = (roundf(val.f * 2.0f) / 2.0f) * 100.0f;
|
||||
|
||||
lvl_cn = C_CTL_SCP;
|
||||
@ -3186,7 +3227,8 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
}
|
||||
|
||||
case RIG_LEVEL_SPECTRUM_EDGE_LOW:
|
||||
case RIG_LEVEL_SPECTRUM_EDGE_HIGH: {
|
||||
case RIG_LEVEL_SPECTRUM_EDGE_HIGH:
|
||||
{
|
||||
int range_id;
|
||||
value_t edge_number_value;
|
||||
value_t opposite_edge_value;
|
||||
@ -3200,14 +3242,17 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
|
||||
// Modify the frequency range currently active
|
||||
retval = icom_get_spectrum_edge_frequency_range(rig, vfo, &range_id);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error getting spectrum edge frequency range\n", __func__);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error getting spectrum edge frequency range\n",
|
||||
__func__);
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
|
||||
// Modify the edge number currently active
|
||||
retval = icom_get_ext_level(rig, vfo, TOK_SCOPE_EDG, &edge_number_value);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -3215,6 +3260,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
|
||||
// Get the current opposite edge frequency
|
||||
retval = icom_get_level(rig, vfo, level_opposite_edge, &opposite_edge_value);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -3233,6 +3279,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
to_bcd(cmdbuf + 2, opposite_edge_value.i, 5 * 2);
|
||||
to_bcd(cmdbuf + 7, val.i, 5 * 2);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3249,7 +3296,8 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
}
|
||||
}
|
||||
|
||||
if (val.i != 0 && (i == HAMLIB_MAXDBLSTSIZ || rig->caps->spectrum_attenuator[i] == 0))
|
||||
if (val.i != 0 && (i == HAMLIB_MAXDBLSTSIZ
|
||||
|| rig->caps->spectrum_attenuator[i] == 0))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum attenuator level %ddB\n",
|
||||
__func__, val.i);
|
||||
@ -3545,7 +3593,8 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_SPECTRUM_EDGE_LOW:
|
||||
case RIG_LEVEL_SPECTRUM_EDGE_HIGH: {
|
||||
case RIG_LEVEL_SPECTRUM_EDGE_HIGH:
|
||||
{
|
||||
int range_id;
|
||||
value_t edge_number_value;
|
||||
|
||||
@ -3555,14 +3604,17 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
|
||||
// Get the frequency range currently active
|
||||
retval = icom_get_spectrum_edge_frequency_range(rig, vfo, &range_id);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error getting spectrum edge frequency range\n", __func__);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error getting spectrum edge frequency range\n",
|
||||
__func__);
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
|
||||
// Get the edge number currently active
|
||||
retval = icom_get_ext_level(rig, vfo, TOK_SCOPE_EDG, &edge_number_value);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -3588,7 +3640,8 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
}
|
||||
|
||||
/* use cmdbuf and cmd_len for 'set mode' subcommand */
|
||||
retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, respbuf, &resp_len);
|
||||
retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
@ -3805,19 +3858,25 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
case SCOPE_MODE_CENTER:
|
||||
val->i = RIG_SPECTRUM_MODE_CENTER;
|
||||
break;
|
||||
|
||||
case SCOPE_MODE_FIXED:
|
||||
val->i = RIG_SPECTRUM_MODE_FIXED;
|
||||
break;
|
||||
|
||||
case SCOPE_MODE_SCROLL_C:
|
||||
val->i = RIG_SPECTRUM_MODE_CENTER_SCROLL;
|
||||
break;
|
||||
|
||||
case SCOPE_MODE_SCROLL_F:
|
||||
val->i = RIG_SPECTRUM_MODE_FIXED_SCROLL;
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum mode %d\n", __func__, icom_val);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum mode %d\n", __func__,
|
||||
icom_val);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_SPECTRUM_SPAN:
|
||||
@ -3832,19 +3891,25 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
case SCOPE_SPEED_SLOW:
|
||||
val->i = 0;
|
||||
break;
|
||||
|
||||
case SCOPE_SPEED_MID:
|
||||
val->i = 1;
|
||||
break;
|
||||
|
||||
case SCOPE_SPEED_FAST:
|
||||
val->i = 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum speed %d\n", __func__, icom_val);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum speed %d\n", __func__,
|
||||
icom_val);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_SPECTRUM_REF: {
|
||||
case RIG_LEVEL_SPECTRUM_REF:
|
||||
{
|
||||
unsigned char *icom_ref = respbuf + cmdhead;
|
||||
|
||||
// Spectrum reference level is represented at 0.01dB accuracy, but is rounded to nearest 0.5dB
|
||||
@ -3921,7 +3986,8 @@ int icom_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
|
||||
int lvl_cn, lvl_sc; /* Command Number, Subcommand */
|
||||
int i, retval;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called: token=%ld int=%d float=%f\n", __func__, token, val.i, val.f);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called: token=%ld int=%d float=%f\n", __func__,
|
||||
token, val.i, val.f);
|
||||
|
||||
switch (token)
|
||||
{
|
||||
@ -3950,6 +4016,7 @@ int icom_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
|
||||
break;
|
||||
|
||||
case TOK_SCOPE_STX:
|
||||
|
||||
// TODO: Should be a func?
|
||||
if (val.i < 0 || val.i > 1)
|
||||
{
|
||||
@ -4030,7 +4097,8 @@ int icom_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
|
||||
else { i++; }
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported set_ext_level token: %ld\n", __func__, token);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported set_ext_level token: %ld\n", __func__,
|
||||
token);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
@ -4136,12 +4204,14 @@ int icom_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
|
||||
else { i++; }
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported get_ext_level token: %ld\n", __func__, token);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported get_ext_level token: %ld\n", __func__,
|
||||
token);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
/* use cmdbuf and cmd_len for 'set mode' subcommand */
|
||||
retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, respbuf, &resp_len);
|
||||
retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
@ -4923,11 +4993,13 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
||||
|
||||
cmd = C_SEND_SEL_FREQ;
|
||||
subcmd = 0x01; // set the unselected vfo
|
||||
|
||||
// if we're already on the tx_vfo don't need the "other" vfo
|
||||
if (rig->state.current_vfo == rig->state.tx_vfo)
|
||||
{
|
||||
subcmd = 0x00;
|
||||
}
|
||||
|
||||
retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf,
|
||||
&ack_len);
|
||||
|
||||
@ -5004,7 +5076,9 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
||||
rig_strvfo(rx_vfo), rig_strvfo(tx_vfo));
|
||||
|
||||
TRACE;
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ)
|
||||
&& RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
@ -5015,6 +5089,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
||||
if (VFO_HAS_MAIN_SUB_A_B_ONLY)
|
||||
{
|
||||
// Then we return the VFO to the rx_vfo
|
||||
@ -5023,7 +5098,9 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
||||
priv->split_on, rig_strvfo(rx_vfo));
|
||||
|
||||
TRACE;
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) && RIG_OK != (retval = rig_set_vfo(rig, rx_vfo)))
|
||||
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ)
|
||||
&& RIG_OK != (retval = rig_set_vfo(rig, rx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
@ -5230,6 +5307,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
||||
if (RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -5241,6 +5319,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
||||
if (VFO_HAS_MAIN_SUB_A_B_ONLY)
|
||||
{
|
||||
// Then we return the VFO to where it was
|
||||
@ -5248,6 +5327,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
|
||||
rig_strvfo(rx_vfo));
|
||||
|
||||
TRACE;
|
||||
|
||||
if (RIG_OK != (retval = rig_set_vfo(rig, rx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -5354,7 +5434,9 @@ int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
|
||||
}
|
||||
|
||||
TRACE;
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE)
|
||||
&& RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
@ -5366,7 +5448,9 @@ int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
|
||||
}
|
||||
|
||||
TRACE;
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig_set_vfo(rig, rx_vfo)))
|
||||
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE)
|
||||
&& RIG_OK != (retval = rig_set_vfo(rig, rx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
@ -5466,6 +5550,7 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
||||
if (RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -5478,6 +5563,7 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
||||
if (RIG_OK != (retval = rig_set_vfo(rig, rx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -5540,7 +5626,8 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq,
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig->caps->set_mode(rig, RIG_VFO_CURR, tx_mode,
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE)
|
||||
&& RIG_OK != (retval = rig->caps->set_mode(rig, RIG_VFO_CURR, tx_mode,
|
||||
tx_width)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -5618,7 +5705,9 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq,
|
||||
}
|
||||
|
||||
TRACE;
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ)
|
||||
&& RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
@ -5629,7 +5718,9 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq,
|
||||
}
|
||||
|
||||
TRACE;
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE)
|
||||
&& RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
@ -5641,7 +5732,9 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq,
|
||||
}
|
||||
|
||||
TRACE;
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig_set_vfo(rig, rx_vfo)))
|
||||
|
||||
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE)
|
||||
&& RIG_OK != (retval = rig_set_vfo(rig, rx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
@ -5746,6 +5839,7 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq,
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
||||
if (RIG_OK != (retval = rig_set_vfo(rig, tx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -5763,6 +5857,7 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq,
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
||||
if (RIG_OK != (retval = rig_set_vfo(rig, rx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -5879,6 +5974,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
||||
case RIG_SPLIT_ON:
|
||||
split_sc = S_SPLT_ON;
|
||||
rig_debug(RIG_DEBUG_TRACE, "trace %s(%d)\n", __func__, __LINE__);
|
||||
|
||||
// the VFO adjusting here could probably be done in rig.c for all rigs
|
||||
/* If asking for Sub or Main on rig that doesn't have it map it */
|
||||
if (VFO_HAS_A_B_ONLY && ((tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB)
|
||||
@ -5901,11 +5997,13 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
||||
"%s: rx_vfo to VFO_A, tx_vfo to VFO_B because tx_vfo=%s\n", __func__,
|
||||
rig_strvfo(tx_vfo));
|
||||
|
||||
if (tx_vfo == RIG_VFO_B) {
|
||||
if (tx_vfo == RIG_VFO_B)
|
||||
{
|
||||
priv->tx_vfo = RIG_VFO_B;
|
||||
priv->rx_vfo = vfo = RIG_VFO_A;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
priv->tx_vfo = RIG_VFO_A;
|
||||
priv->rx_vfo = vfo = RIG_VFO_B;
|
||||
}
|
||||
@ -5927,12 +6025,14 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
||||
|
||||
// make sure we're on Main/VFOA
|
||||
TRACE;
|
||||
|
||||
if (RIG_OK != (retval = icom_set_vfo(rig, RIG_VFO_MAIN)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
||||
if (RIG_OK != (retval = icom_set_vfo(rig, RIG_VFO_A)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -5949,6 +6049,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
||||
#if 0 // do we need this for satmode?
|
||||
|
||||
TRACE;
|
||||
|
||||
if (RIG_OK != (retval = icom_set_vfo(rig, tx_vfo)))
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -5999,6 +6100,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
||||
priv->split_on = RIG_SPLIT_ON == split;
|
||||
|
||||
#if 0 // don't think we need this anymore -- 20210731
|
||||
|
||||
if (vfo_final != RIG_VFO_NONE && vfo_final != rig->state.current_vfo)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: vfo_final set %s\n", __func__,
|
||||
@ -6012,6 +6114,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
||||
rigerror(retval));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,
|
||||
@ -6083,9 +6186,11 @@ int icom_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
|
||||
if (rig->caps->has_get_func & RIG_FUNC_SATMODE)
|
||||
{
|
||||
rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode);
|
||||
|
||||
if (satmode != rig->state.cache.satmode)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): satmode changed to reset x25cmdfails\n", __func__, __LINE__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): satmode changed to reset x25cmdfails\n",
|
||||
__func__, __LINE__);
|
||||
priv->x25cmdfails = satmode; // reset this so it tries again
|
||||
}
|
||||
}
|
||||
@ -6702,6 +6807,7 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
||||
fct_cn = C_CTL_FUNC;
|
||||
fct_sc = S_MEM_SATMODE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -6710,7 +6816,8 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
retval = icom_transaction(rig, fct_cn, fct_sc, fctbuf, fct_len, ackbuf, &ack_len);
|
||||
retval = icom_transaction(rig, fct_cn, fct_sc, fctbuf, fct_len, ackbuf,
|
||||
&ack_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
@ -8086,7 +8193,8 @@ int icom_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq,
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char *frame_data)
|
||||
static int icom_parse_spectrum_frame(RIG *rig, int length,
|
||||
const unsigned char *frame_data)
|
||||
{
|
||||
struct rig_caps *caps = rig->caps;
|
||||
struct icom_priv_caps *priv_caps = (struct icom_priv_caps *) caps->priv;
|
||||
@ -8106,7 +8214,8 @@ static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char *
|
||||
|
||||
if (spectrum_id < 0 || spectrum_id >= priv->spectrum_scope_count)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: invalid spectrum scope ID from CI-V frame: %d\n", __func__, spectrum_id);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: invalid spectrum scope ID from CI-V frame: %d\n",
|
||||
__func__, spectrum_id);
|
||||
RETURNFUNC(-RIG_EPROTO);
|
||||
}
|
||||
|
||||
@ -8125,42 +8234,56 @@ static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char *
|
||||
cache->spectrum_mode = RIG_SPECTRUM_MODE_CENTER;
|
||||
cache->spectrum_center_freq = (freq_t) from_bcd(frame_data + 4, 5 * 2);
|
||||
cache->spectrum_span_freq = (freq_t) from_bcd(frame_data + 9, 5 * 2) * 2;
|
||||
cache->spectrum_low_edge_freq = cache->spectrum_center_freq - cache->spectrum_span_freq / 2;
|
||||
cache->spectrum_high_edge_freq = cache->spectrum_center_freq + cache->spectrum_span_freq / 2;
|
||||
cache->spectrum_low_edge_freq = cache->spectrum_center_freq -
|
||||
cache->spectrum_span_freq / 2;
|
||||
cache->spectrum_high_edge_freq = cache->spectrum_center_freq +
|
||||
cache->spectrum_span_freq / 2;
|
||||
break;
|
||||
|
||||
case SCOPE_MODE_FIXED:
|
||||
cache->spectrum_mode = RIG_SPECTRUM_MODE_FIXED;
|
||||
|
||||
case SCOPE_MODE_SCROLL_C:
|
||||
if (cache->spectrum_mode == RIG_SPECTRUM_MODE_NONE)
|
||||
{
|
||||
cache->spectrum_mode = RIG_SPECTRUM_MODE_CENTER_SCROLL;
|
||||
}
|
||||
|
||||
case SCOPE_MODE_SCROLL_F:
|
||||
if (cache->spectrum_mode == RIG_SPECTRUM_MODE_NONE)
|
||||
{
|
||||
cache->spectrum_mode = RIG_SPECTRUM_MODE_FIXED_SCROLL;
|
||||
}
|
||||
|
||||
cache->spectrum_low_edge_freq = (freq_t) from_bcd(frame_data + 4, 5 * 2);
|
||||
cache->spectrum_high_edge_freq = (freq_t) from_bcd(frame_data + 9, 5 * 2);
|
||||
cache->spectrum_span_freq = (cache->spectrum_high_edge_freq - cache->spectrum_low_edge_freq);
|
||||
cache->spectrum_center_freq = cache->spectrum_high_edge_freq - cache->spectrum_span_freq / 2;
|
||||
cache->spectrum_span_freq = (cache->spectrum_high_edge_freq -
|
||||
cache->spectrum_low_edge_freq);
|
||||
cache->spectrum_center_freq = cache->spectrum_high_edge_freq -
|
||||
cache->spectrum_span_freq / 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unknown Icom spectrum scope mode: %d\n", __func__, spectrum_scope_mode)
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unknown Icom spectrum scope mode: %d\n", __func__,
|
||||
spectrum_scope_mode)
|
||||
RETURNFUNC(-RIG_EPROTO);
|
||||
}
|
||||
|
||||
spectrum_data_length_in_frame = length - 15;
|
||||
spectrum_data_start_in_frame = frame_data + 15;
|
||||
|
||||
memset(cache->spectrum_data, 0, priv_caps->spectrum_scope_caps.spectrum_line_length);
|
||||
memset(cache->spectrum_data, 0,
|
||||
priv_caps->spectrum_scope_caps.spectrum_line_length);
|
||||
|
||||
cache->spectrum_data_length = 0;
|
||||
cache->spectrum_metadata_valid = 1;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: Spectrum line start: id=%d division=%d max_division=%d mode=%d center=%.0f span=%.0f low_edge=%.0f high_edge=%.0f oor=%d data_length=%d\n",
|
||||
__func__, spectrum_id, division, max_division, spectrum_scope_mode, cache->spectrum_center_freq, cache->spectrum_span_freq,
|
||||
cache->spectrum_low_edge_freq, cache->spectrum_high_edge_freq, out_of_range, spectrum_data_length_in_frame);
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: Spectrum line start: id=%d division=%d max_division=%d mode=%d center=%.0f span=%.0f low_edge=%.0f high_edge=%.0f oor=%d data_length=%d\n",
|
||||
__func__, spectrum_id, division, max_division, spectrum_scope_mode,
|
||||
cache->spectrum_center_freq, cache->spectrum_span_freq,
|
||||
cache->spectrum_low_edge_freq, cache->spectrum_high_edge_freq, out_of_range,
|
||||
spectrum_data_length_in_frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -8174,20 +8297,25 @@ static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char *
|
||||
int data_frame_index = (max_division > 1) ? (division - 2) : (division - 1);
|
||||
int offset = data_frame_index * frame_length;
|
||||
|
||||
if (offset + spectrum_data_length_in_frame > priv_caps->spectrum_scope_caps.spectrum_line_length)
|
||||
if (offset + spectrum_data_length_in_frame >
|
||||
priv_caps->spectrum_scope_caps.spectrum_line_length)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: too much spectrum scope data received: %d bytes > %d bytes expected\n",
|
||||
__func__, offset + spectrum_data_length_in_frame, priv_caps->spectrum_scope_caps.spectrum_line_length);
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: too much spectrum scope data received: %d bytes > %d bytes expected\n",
|
||||
__func__, offset + spectrum_data_length_in_frame,
|
||||
priv_caps->spectrum_scope_caps.spectrum_line_length);
|
||||
RETURNFUNC(-RIG_EPROTO);
|
||||
}
|
||||
|
||||
memcpy(cache->spectrum_data + offset, spectrum_data_start_in_frame, spectrum_data_length_in_frame);
|
||||
memcpy(cache->spectrum_data + offset, spectrum_data_start_in_frame,
|
||||
spectrum_data_length_in_frame);
|
||||
cache->spectrum_data_length = offset + spectrum_data_length_in_frame;
|
||||
}
|
||||
|
||||
if (cache->spectrum_metadata_valid && division == max_division)
|
||||
{
|
||||
struct rig_spectrum_line spectrum_line = {
|
||||
struct rig_spectrum_line spectrum_line =
|
||||
{
|
||||
.data_level_min = priv_caps->spectrum_scope_caps.data_level_min,
|
||||
.data_level_max = priv_caps->spectrum_scope_caps.data_level_max,
|
||||
.signal_strength_min = priv_caps->spectrum_scope_caps.signal_strength_min,
|
||||
@ -8220,10 +8348,12 @@ int icom_is_async_frame(RIG *rig, int frame_len, const unsigned char *frame)
|
||||
}
|
||||
|
||||
/* Spectrum scope data is not CI-V transceive data, but handled the same way as it is pushed by the rig */
|
||||
return frame[2] == BCASTID || (frame[2] == CTRLID && frame[4] == C_CTL_SCP && frame[5] == S_SCP_DAT);
|
||||
return frame[2] == BCASTID || (frame[2] == CTRLID && frame[4] == C_CTL_SCP
|
||||
&& frame[5] == S_SCP_DAT);
|
||||
}
|
||||
|
||||
int icom_process_async_frame(RIG *rig, int frame_len, const unsigned char *frame)
|
||||
int icom_process_async_frame(RIG *rig, int frame_len,
|
||||
const unsigned char *frame)
|
||||
{
|
||||
struct rig_state *rs = &rig->state;
|
||||
struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
|
||||
@ -8243,6 +8373,7 @@ int icom_process_async_frame(RIG *rig, int frame_len, const unsigned char *frame
|
||||
switch (frame[4])
|
||||
{
|
||||
case C_SND_FREQ:
|
||||
|
||||
/*
|
||||
* TODO: the freq length might be less than 4 or 5 bytes
|
||||
* on older rigs!
|
||||
@ -8280,6 +8411,7 @@ int icom_process_async_frame(RIG *rig, int frame_len, const unsigned char *frame
|
||||
{
|
||||
icom_parse_spectrum_frame(rig, frame_len - (6 + 1), frame + 6);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -8321,6 +8453,7 @@ int icom_decode_event(RIG *rig)
|
||||
}
|
||||
|
||||
retval = icom_frame_fix_preamble(frm_len, buf);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -8709,7 +8842,8 @@ static int icom_get_spectrum_vfo(RIG *rig, vfo_t vfo)
|
||||
RETURNFUNC(0);
|
||||
}
|
||||
|
||||
static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *range_id)
|
||||
static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo,
|
||||
int *range_id)
|
||||
{
|
||||
freq_t freq;
|
||||
rmode_t mode;
|
||||
@ -8718,7 +8852,9 @@ static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *rang
|
||||
int i, retval;
|
||||
struct icom_priv_caps *priv_caps = (struct icom_priv_caps *) rig->caps->priv;
|
||||
|
||||
retval = rig_get_cache(rig, vfo, &freq, &cache_ms_freq, &mode, &cache_ms_mode, &width, &cache_ms_width);
|
||||
retval = rig_get_cache(rig, vfo, &freq, &cache_ms_freq, &mode, &cache_ms_mode,
|
||||
&width, &cache_ms_width);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -8728,6 +8864,7 @@ static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *rang
|
||||
if (freq == 0 || cache_ms_freq >= 1000)
|
||||
{
|
||||
retval = rig_get_freq(rig, vfo, &freq);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(retval);
|
||||
@ -8737,11 +8874,14 @@ static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *rang
|
||||
for (i = 0; i < ICOM_MAX_SPECTRUM_FREQ_RANGES; i++)
|
||||
{
|
||||
int id = priv_caps->spectrum_edge_frequency_ranges[i].range_id;
|
||||
|
||||
if (id < 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (freq >= priv_caps->spectrum_edge_frequency_ranges[i].low_freq && freq < priv_caps->spectrum_edge_frequency_ranges[i].high_freq)
|
||||
|
||||
if (freq >= priv_caps->spectrum_edge_frequency_ranges[i].low_freq
|
||||
&& freq < priv_caps->spectrum_edge_frequency_ranges[i].high_freq)
|
||||
{
|
||||
*range_id = id;
|
||||
RETURNFUNC(RIG_OK);
|
||||
|
@ -1098,17 +1098,22 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
{
|
||||
vfo = rig->state.current_vfo;
|
||||
}
|
||||
|
||||
rmode_t tmode;
|
||||
pbwidth_t twidth;
|
||||
err = k3_get_mode(rig, vfo, &tmode, &twidth);
|
||||
|
||||
if (err == RIG_OK && tmode == mode && width == RIG_PASSBAND_NOCHANGE)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(%d): mode/width no change, skipping\n", __FILE__, __LINE__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(%d): mode/width no change, skipping\n", __FILE__,
|
||||
__LINE__);
|
||||
return RIG_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(%d): changing mode=%s, oldmode=%s, width=%ld, oldwidth=%ld\n", __FILE__, __LINE__, rig_strrmode(tmode), rig_strrmode(mode), twidth, width);
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s(%d): changing mode=%s, oldmode=%s, width=%ld, oldwidth=%ld\n", __FILE__,
|
||||
__LINE__, rig_strrmode(tmode), rig_strrmode(mode), twidth, width);
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
@ -1478,45 +1483,60 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
|
||||
tx_mode = RIG_MODE_RTTYR; // "DT0" RIG_MODE_RTTY = LSB
|
||||
snprintf(cmd_m, sizeof(cmd_m),
|
||||
"DT0;"); /* DATA A mode - DATA-R LSB, suppressed carrier */
|
||||
if (priv->is_k4d || priv->is_k4hd) {
|
||||
|
||||
if (priv->is_k4d || priv->is_k4hd)
|
||||
{
|
||||
strcat(cmd_m, "DT$0;");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIG_MODE_PKTUSB:
|
||||
tx_mode = RIG_MODE_RTTY; // "DT0" RIG_MODE_RTTYR = USB
|
||||
snprintf(cmd_m, sizeof(cmd_m),
|
||||
"DT0;"); /* DATA A mode - DATA on USB, suppressed carrier */
|
||||
if (priv->is_k4d || priv->is_k4hd) {
|
||||
|
||||
if (priv->is_k4d || priv->is_k4hd)
|
||||
{
|
||||
strcat(cmd_m, "DT$0;");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIG_MODE_RTTY:
|
||||
tx_mode = RIG_MODE_RTTY; // DT1" RIG_MODE_RTTY = LSB and RIG_MODE_RTTYR = USB
|
||||
snprintf(cmd_m, sizeof(cmd_m),
|
||||
"DT2;"); /* FSK D mode - direct FSK on LSB optimized for RTTY, VFO dial is MARK */
|
||||
if (priv->is_k4d || priv->is_k4hd) {
|
||||
|
||||
if (priv->is_k4d || priv->is_k4hd)
|
||||
{
|
||||
strcat(cmd_m, "DT$2;");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIG_MODE_RTTYR:
|
||||
tx_mode = RIG_MODE_RTTYR; // "DT2" RIG_MODE_RTTY = USB and RIG_MODE_RTTYR = USB
|
||||
snprintf(cmd_m, sizeof(cmd_m),
|
||||
"DT1;"); /* FSK D mode - direct FSK on USB optimized for RTTY, VFO dial is MARK */
|
||||
if (priv->is_k4d || priv->is_k4hd) {
|
||||
|
||||
if (priv->is_k4d || priv->is_k4hd)
|
||||
{
|
||||
strcat(cmd_m, "DT$1;");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIG_MODE_PSK:
|
||||
tx_mode = RIG_MODE_PSK;
|
||||
snprintf(cmd_m, sizeof(cmd_m),
|
||||
"DT3;FT1;"); /* PSK D Mode - direct PSK keying, USB is "normal", VFO dial is MARK */
|
||||
if (priv->is_k4d || priv->is_k4hd) {
|
||||
|
||||
if (priv->is_k4d || priv->is_k4hd)
|
||||
{
|
||||
strcat(cmd_m, "DT$3;");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1526,11 +1546,13 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
|
||||
// Enabling this clause for just the K4 for now
|
||||
#if 1
|
||||
|
||||
if (priv->is_k4d || priv->is_k4hd) {
|
||||
if (priv->is_k4d || priv->is_k4hd)
|
||||
{
|
||||
// split can get turned off when modes are changing
|
||||
// so if the rig did this independtly of us we turn it back on
|
||||
// even if the rig changes the split status should be the last thing we did
|
||||
if (priv->split) strcat(cmd_m, "FT1;");
|
||||
if (priv->split) { strcat(cmd_m, "FT1;"); }
|
||||
|
||||
/* Set data sub-mode. K3 needs to be in a DATA mode before setting
|
||||
* the sub-mode or switching to VFOB so we do this before the MD$ command.
|
||||
*/
|
||||
@ -1591,6 +1613,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
|
||||
{
|
||||
tx_width = rig_passband_normal(rig, tx_mode);
|
||||
}
|
||||
|
||||
#if 0
|
||||
else if (tx_width < pb_nar)
|
||||
{
|
||||
@ -1600,6 +1623,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
|
||||
{
|
||||
tx_width = pb_wid;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
snprintf(cmd_s, sizeof(cmd_s), "BW$%04ld", tx_width / 10);
|
||||
|
@ -762,6 +762,7 @@ int kenwood_open(RIG *rig)
|
||||
id[0] = 0;
|
||||
rig->state.rigport.retry = 0;
|
||||
err = kenwood_get_id(rig, id);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
// TS450S is flaky on the 1st ID call so we'll try again
|
||||
@ -962,7 +963,8 @@ int kenwood_open(RIG *rig)
|
||||
rig->state.rigport.retry = retry_save;
|
||||
|
||||
// Default to 1st VFO and split off
|
||||
if (rig->caps->set_vfo) {
|
||||
if (rig->caps->set_vfo)
|
||||
{
|
||||
rig_set_vfo(rig, vfo_fixup(rig, RIG_VFO_A, 0));
|
||||
}
|
||||
|
||||
@ -1115,9 +1117,10 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo)
|
||||
}
|
||||
|
||||
snprintf(cmdbuf, sizeof(cmdbuf), "FR%c", vfo_function);
|
||||
|
||||
// FR can turn off split on some Kenwood rigs
|
||||
// So we'll turn it back on just in case
|
||||
if (priv->split) strcat(cmdbuf,"FT1;");
|
||||
if (priv->split) { strcat(cmdbuf, "FT1;"); }
|
||||
|
||||
if (RIG_IS_TS50 || RIG_IS_TS940)
|
||||
{
|
||||
@ -1138,6 +1141,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo)
|
||||
{
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
// some rigs need split turned on after VFOA is set
|
||||
if (vfo == RIG_VFO_A && priv->split == RIG_SPLIT_ON)
|
||||
{
|
||||
@ -1254,9 +1258,11 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
|
||||
|
||||
/* set RX VFO */
|
||||
snprintf(cmdbuf, sizeof(cmdbuf), "FR%c", vfo_function);
|
||||
|
||||
// FR can turn off split on some Kenwood rigs
|
||||
// So we'll turn it back on just in case
|
||||
if (priv->split) strcat(cmdbuf,"FT1;");
|
||||
if (priv->split) { strcat(cmdbuf, "FT1;"); }
|
||||
|
||||
retval = kenwood_transaction(rig, cmdbuf, NULL, 0);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
@ -2072,8 +2078,10 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
{
|
||||
pbwidth_t twidth;
|
||||
err = rig_get_mode(rig, vfo, &priv->curr_mode, &twidth);
|
||||
|
||||
// only change mode if needed
|
||||
if (priv->curr_mode != mode) {
|
||||
if (priv->curr_mode != mode)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "MD%c", c);
|
||||
err = kenwood_transaction(rig, buf, NULL, 0);
|
||||
}
|
||||
|
@ -125,7 +125,8 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
}
|
||||
|
||||
sscanf(ackbuf + 3, "%d", &levelint);
|
||||
val->i = levelint * 3 / 2; /* 150ms units converted to 100ms units */
|
||||
val->i = levelint * 3 /
|
||||
2; /* 150ms units converted to 100ms units */
|
||||
return RIG_OK;
|
||||
|
||||
case RIG_LEVEL_RF:
|
||||
|
@ -88,16 +88,20 @@ static int rshfiq_open(RIG *rig)
|
||||
//There is a delay between when the port is open and the RS-HFIQ can receive and respond.
|
||||
//Make a few attempts at getting the version string just in case the RS-HFIQ has to catch up first.
|
||||
retval = -RIG_ETIMEOUT;
|
||||
for (int init_retry_count = 0; (init_retry_count < RSHFIQ_INIT_RETRY) && (retval == -RIG_ETIMEOUT); init_retry_count++)
|
||||
|
||||
for (int init_retry_count = 0; (init_retry_count < RSHFIQ_INIT_RETRY)
|
||||
&& (retval == -RIG_ETIMEOUT); init_retry_count++)
|
||||
{
|
||||
rig_flush(&rig->state.rigport);
|
||||
snprintf(versionstr, sizeof(versionstr), "*w\r");
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, versionstr);
|
||||
retval = write_block(&rig->state.rigport, versionstr, strlen(versionstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = read_string(&rig->state.rigport, versionstr, 20, stopset, 2);
|
||||
}
|
||||
|
||||
@ -117,20 +121,27 @@ static int rshfiq_open(RIG *rig)
|
||||
return -RIG_ECONF;
|
||||
}
|
||||
|
||||
retval = sscanf(versionstr, "RS-HFIQ FW %d.%d", &rshfiq_version_major, &rshfiq_version_minor);
|
||||
retval = sscanf(versionstr, "RS-HFIQ FW %d.%d", &rshfiq_version_major,
|
||||
&rshfiq_version_minor);
|
||||
|
||||
if (retval <= 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: Failed to parse RS-HFIQ firmware version string. Defaulting to 2.0.\n", __func__);
|
||||
rig_debug(RIG_DEBUG_WARN,
|
||||
"%s: Failed to parse RS-HFIQ firmware version string. Defaulting to 2.0.\n",
|
||||
__func__);
|
||||
rshfiq_version_major = 2;
|
||||
rshfiq_version_minor = 0;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "RS-HFIQ returned firmware version major=%d minor=%d\n", rshfiq_version_major, rshfiq_version_minor);
|
||||
rig_debug(RIG_DEBUG_VERBOSE,
|
||||
"RS-HFIQ returned firmware version major=%d minor=%d\n", rshfiq_version_major,
|
||||
rshfiq_version_minor);
|
||||
|
||||
if (rshfiq_version_major < 4)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: RS-HFIQ firmware major version is less than 4. RFPOWER_METER support will be unavailable.\n", __func__);
|
||||
rig_debug(RIG_DEBUG_WARN,
|
||||
"%s: RS-HFIQ firmware major version is less than 4. RFPOWER_METER support will be unavailable.\n",
|
||||
__func__);
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
@ -227,7 +238,8 @@ static int rshfiq_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||
|
||||
static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__, level);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__,
|
||||
level);
|
||||
|
||||
char cmdstr[15];
|
||||
char stopset[2];
|
||||
@ -320,8 +332,10 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
return RIG_OK;
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Unrecognized RIG_LEVEL_* enum: %"PRIll"\n", __func__, level);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Unrecognized RIG_LEVEL_* enum: %"PRIll"\n",
|
||||
__func__, level);
|
||||
return -RIG_EDOM;
|
||||
break;
|
||||
}
|
||||
|
@ -41,7 +41,8 @@
|
||||
#include "misc.h"
|
||||
#include "bandplan.h"
|
||||
|
||||
struct ft100_priv_data {
|
||||
struct ft100_priv_data
|
||||
{
|
||||
/* TODO: make use of cached data */
|
||||
FT100_STATUS_INFO status;
|
||||
FT100_FLAG_INFO flags;
|
||||
|
@ -41,7 +41,8 @@
|
||||
#include "misc.h"
|
||||
#include "bandplan.h"
|
||||
|
||||
struct ft600_priv_data {
|
||||
struct ft600_priv_data
|
||||
{
|
||||
FT600_STATUS_INFO status;
|
||||
FT600_FLAG_INFO flags;
|
||||
unsigned char s_meter;
|
||||
|
@ -65,7 +65,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
struct ft847_priv_data {
|
||||
struct ft847_priv_data
|
||||
{
|
||||
split_t sat_mode;
|
||||
|
||||
unsigned char rx_status; /* tx returned data */
|
||||
|
@ -74,7 +74,8 @@
|
||||
#include "tones.h"
|
||||
#include "bandplan.h"
|
||||
|
||||
struct ft857_priv_data {
|
||||
struct ft857_priv_data
|
||||
{
|
||||
yaesu_cmd_set_t pcs[FT857_NATIVE_SIZE]; /* TODO: why? */
|
||||
|
||||
/* rx status */
|
||||
|
@ -79,7 +79,8 @@
|
||||
#include "tones.h"
|
||||
#include "bandplan.h"
|
||||
|
||||
struct ft897_priv_data {
|
||||
struct ft897_priv_data
|
||||
{
|
||||
yaesu_cmd_set_t pcs[FT897_NATIVE_SIZE]; /* TODO: why? */
|
||||
|
||||
/* rx status */
|
||||
|
@ -921,18 +921,23 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
if (rig->state.current_vfo != vfo)
|
||||
{
|
||||
int vfo1 = 1, vfo2 = 0;
|
||||
if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) {
|
||||
|
||||
if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN)
|
||||
{
|
||||
vfo1 = 0;
|
||||
vfo2 = 1;
|
||||
}
|
||||
|
||||
// we need to change vfos, BS, and change back
|
||||
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "VS%d;BS%02d",
|
||||
vfo1, newcat_band_index(freq));
|
||||
|
||||
if (RIG_OK != (err = newcat_set_cmd(rig)))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected error with BS command#1=%s\n",
|
||||
__func__, rigerror(err));
|
||||
}
|
||||
|
||||
hl_usleep(50 * 1000); // wait for BS to do it's thing and swap back
|
||||
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "VS%d;", vfo2);
|
||||
}
|
||||
@ -4682,6 +4687,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_TEMP_METER:
|
||||
if (is_ftdx9000)
|
||||
{
|
||||
@ -4695,6 +4701,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
{
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -490,7 +490,11 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth,
|
||||
}
|
||||
|
||||
if (rot->state.rotport2.pathname[0] != 0)
|
||||
sprintf(cmdstr, "AP1%05.1f\r;", elevation); /* Total field width of 5 chars */
|
||||
{
|
||||
sprintf(cmdstr, "AP1%05.1f\r;",
|
||||
elevation); /* Total field width of 5 chars */
|
||||
}
|
||||
|
||||
err = rotorez_send_priv_cmd2(rot, cmdstr);
|
||||
|
||||
if (err != RIG_OK)
|
||||
|
@ -102,8 +102,9 @@ int main(int argc, char *argv[])
|
||||
while (1)
|
||||
{
|
||||
buf[0] = 0;
|
||||
if (getmyline(fd, buf) > 0) printf("Cmd:%s\n", buf);
|
||||
else return 0;
|
||||
|
||||
if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); }
|
||||
else { return 0; }
|
||||
|
||||
if (strcmp(buf, "RM5;") == 0)
|
||||
{
|
||||
@ -224,8 +225,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (strncmp(buf, "MD", 2) == 0)
|
||||
{
|
||||
if (buf[2]=='$') sscanf(buf,"MD$%d;",&modeb);
|
||||
else sscanf(buf,"MD%d;", &modea);
|
||||
if (buf[2] == '$') { sscanf(buf, "MD$%d;", &modeb); }
|
||||
else { sscanf(buf, "MD%d;", &modea); }
|
||||
}
|
||||
else if (strcmp(buf, "FA;") == 0)
|
||||
{
|
||||
|
@ -118,6 +118,7 @@ void frameParse(int fd, unsigned char *frame, int len)
|
||||
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { freqA = freq; }
|
||||
else { freqB = freq; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
write(fd, frame, 6);
|
||||
@ -126,6 +127,7 @@ void frameParse(int fd, unsigned char *frame, int len)
|
||||
case 0x06:
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { modeA = frame[6]; }
|
||||
else { modeB = frame[6]; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
write(fd, frame, 6);
|
||||
@ -169,9 +171,11 @@ void frameParse(int fd, unsigned char *frame, int len)
|
||||
ant_option = frame[6];
|
||||
dump_hex(frame, 8);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
printf("Get ant\n");
|
||||
}
|
||||
|
||||
frame[5] = ant_curr;
|
||||
frame[6] = ant_option;
|
||||
frame[7] = 0xfd;
|
||||
@ -195,6 +199,7 @@ void frameParse(int fd, unsigned char *frame, int len)
|
||||
break;
|
||||
|
||||
#if 1
|
||||
|
||||
case 0x25:
|
||||
if (frame[6] == 0xfd)
|
||||
{
|
||||
|
@ -102,8 +102,9 @@ int main(int argc, char *argv[])
|
||||
while (1)
|
||||
{
|
||||
buf[0] = 0;
|
||||
if (getmyline(fd, buf) > 0) printf("Cmd:%s\n", buf);
|
||||
else return 0;
|
||||
|
||||
if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); }
|
||||
else { return 0; }
|
||||
|
||||
if (strcmp(buf, "RM5;") == 0)
|
||||
{
|
||||
|
@ -100,8 +100,10 @@ int main(int argc, char *argv[])
|
||||
while (1)
|
||||
{
|
||||
if (getmyline(fd, buf))
|
||||
{
|
||||
printf("Cmd:%s\n", buf);
|
||||
else return 0;
|
||||
}
|
||||
else { return 0; }
|
||||
|
||||
if (strcmp(buf, "RM5;") == 0)
|
||||
{
|
||||
|
@ -323,7 +323,8 @@ static int search_rig_and_decode(RIG *rig, rig_ptr_t data)
|
||||
*/
|
||||
if (rig->state.hold_decode)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n", __func__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n",
|
||||
__func__);
|
||||
RETURNFUNC(-1);
|
||||
}
|
||||
|
||||
@ -365,7 +366,8 @@ static int search_rig_and_decode(RIG *rig, rig_ptr_t data)
|
||||
*/
|
||||
if (rig->state.hold_decode)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n", __func__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n",
|
||||
__func__);
|
||||
RETURNFUNC(-1);
|
||||
}
|
||||
|
||||
@ -724,7 +726,8 @@ int HAMLIB_API rig_set_pltune_callback(RIG *rig, pltune_cb_t cb, rig_ptr_t arg)
|
||||
*
|
||||
* \sa rig_set_trn()
|
||||
*/
|
||||
int HAMLIB_API rig_set_spectrum_callback(RIG *rig, spectrum_cb_t cb, rig_ptr_t arg)
|
||||
int HAMLIB_API rig_set_spectrum_callback(RIG *rig, spectrum_cb_t cb,
|
||||
rig_ptr_t arg)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
|
@ -76,7 +76,8 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: serial_open(%s) status=%d\n", __func__, p->pathname, status);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: serial_open(%s) status=%d\n", __func__,
|
||||
p->pathname, status);
|
||||
RETURNFUNC(status);
|
||||
}
|
||||
|
||||
|
@ -1761,6 +1761,7 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
|
||||
{
|
||||
split = rig->state.cache.split;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int satmode = rig->state.cache.satmode;
|
||||
|
@ -558,7 +558,8 @@ int network_multicast_server(RIG *rig, const char *multicast_addr,
|
||||
|
||||
if (strcmp(multicast_addr, "0.0.0.0") == 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(%d): not starting multicast\n", __FILE__, __LINE__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(%d): not starting multicast\n", __FILE__,
|
||||
__LINE__);
|
||||
return RIG_OK; // don't start it
|
||||
}
|
||||
|
||||
|
@ -297,11 +297,13 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model)
|
||||
// hmmm...no caps so did we already load the rigs?
|
||||
for (n = 0, i = 0; i < RIGLSTHASHSZ; i++)
|
||||
{
|
||||
if (rig_hash_table[i]) ++n;
|
||||
if (rig_hash_table[i]) { ++n; }
|
||||
}
|
||||
|
||||
if (n > 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig model %d not found and rig count=%d\n", __func__, rig_model, n);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig model %d not found and rig count=%d\n",
|
||||
__func__, rig_model, n);
|
||||
return -RIG_ENAVAIL;
|
||||
}
|
||||
|
||||
@ -329,6 +331,7 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model)
|
||||
{
|
||||
retval = RIG_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
|
59
src/rig.c
59
src/rig.c
@ -365,7 +365,9 @@ static void cache_show(RIG *rig, const char *func, int line)
|
||||
"%s(%d): freqMainB=%.0f, modeMainB=%s, widthMainB=%d\n", func, line,
|
||||
rig->state.cache.freqMainB, rig_strrmode(rig->state.cache.modeMainB),
|
||||
(int)rig->state.cache.widthMainB);
|
||||
if (rig->state.vfo_list & RIG_VFO_SUB_A) {
|
||||
|
||||
if (rig->state.vfo_list & RIG_VFO_SUB_A)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_CACHE,
|
||||
"%s(%d): freqSubA=%.0f, modeSubA=%s, widthSubA=%d\n", func, line,
|
||||
rig->state.cache.freqSubA, rig_strrmode(rig->state.cache.modeSubA),
|
||||
@ -1041,6 +1043,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
rs->current_vfo = RIG_VFO_CURR;
|
||||
|
||||
#if 0 // done in the back end
|
||||
|
||||
if (backend_num == RIG_ICOM)
|
||||
{
|
||||
TRACE;
|
||||
@ -1048,7 +1051,9 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: Icom rig so default vfo = %s\n", __func__,
|
||||
rig_strvfo(rs->current_vfo));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (rig->caps->set_vfo == NULL)
|
||||
{
|
||||
// for non-Icom rigs if there's no set_vfo then we need to set one
|
||||
@ -1136,6 +1141,7 @@ int HAMLIB_API rig_close(RIG *rig)
|
||||
|
||||
multicast_server_threadId = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (!rig || !rig->caps)
|
||||
@ -1983,7 +1989,8 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) called vfo=%s\n", __func__, __LINE__, rig_strvfo(vfo));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) called vfo=%s\n", __func__, __LINE__,
|
||||
rig_strvfo(vfo));
|
||||
cache_show(rig, __func__, __LINE__);
|
||||
|
||||
|
||||
@ -1991,7 +1998,8 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
|
||||
vfo = vfo_fixup(rig, vfo, rig->state.cache.split);
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) vfo=%s, curr_vfo=%s\n", __FILE__, __LINE__, rig_strvfo(vfo), rig_strvfo(curr_vfo));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) vfo=%s, curr_vfo=%s\n", __FILE__, __LINE__,
|
||||
rig_strvfo(vfo), rig_strvfo(curr_vfo));
|
||||
|
||||
if (vfo == RIG_VFO_CURR) { vfo = curr_vfo; }
|
||||
|
||||
@ -2124,6 +2132,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
retcode = caps->get_freq(rig, vfo, freq);
|
||||
/* try and revert even if we had an error above */
|
||||
rc2 = RIG_OK;
|
||||
|
||||
if (curr_vfo != RIG_VFO_NONE)
|
||||
{
|
||||
rc2 = caps->set_vfo(rig, curr_vfo);
|
||||
@ -2605,7 +2614,8 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
||||
|
||||
ENTERFUNC;
|
||||
#if BUILTINFUNC
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, called from %s\n", __func__, rig_strvfo(vfo),func);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, called from %s\n", __func__,
|
||||
rig_strvfo(vfo), func);
|
||||
#else
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo));
|
||||
#endif
|
||||
@ -2626,6 +2636,7 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
||||
if (vfo == RIG_VFO_CURR) { RETURNFUNC(RIG_OK); }
|
||||
|
||||
#if 0 // removing this check 20210801 -- should be mapped already
|
||||
|
||||
// make sure we are asking for a VFO that the rig actually has
|
||||
if ((vfo == RIG_VFO_A || vfo == RIG_VFO_B) && !VFO_HAS_A_B)
|
||||
{
|
||||
@ -2640,6 +2651,7 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
||||
rig_strvfo(vfo));
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
vfo = vfo_fixup(rig, vfo, rig->state.cache.split);
|
||||
@ -2661,7 +2673,9 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
||||
|
||||
TRACE;
|
||||
vfo_t vfo_save = rig->state.current_vfo;
|
||||
if (vfo != RIG_VFO_CURR) rig->state.current_vfo = vfo;
|
||||
|
||||
if (vfo != RIG_VFO_CURR) { rig->state.current_vfo = vfo; }
|
||||
|
||||
retcode = caps->set_vfo(rig, vfo);
|
||||
|
||||
if (retcode == RIG_OK)
|
||||
@ -2707,7 +2721,8 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
||||
elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE);
|
||||
#endif
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: return %d, vfo=%s, curr_vfo=%s\n", __func__, retcode,
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: return %d, vfo=%s, curr_vfo=%s\n", __func__,
|
||||
retcode,
|
||||
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
@ -3797,9 +3812,12 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
||||
{
|
||||
TRACE;
|
||||
retcode = RIG_OK;
|
||||
|
||||
if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ))
|
||||
{
|
||||
retcode = caps->set_vfo(rig, tx_vfo);
|
||||
}
|
||||
}
|
||||
else if (rig_has_vfo_op(rig, RIG_OP_TOGGLE) && caps->vfo_op)
|
||||
{
|
||||
retcode = caps->vfo_op(rig, vfo, RIG_OP_TOGGLE);
|
||||
@ -3842,9 +3860,12 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
||||
{
|
||||
TRACE;
|
||||
rc2 = RIG_OK;
|
||||
|
||||
if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ))
|
||||
{
|
||||
rc2 = caps->set_vfo(rig, curr_vfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rc2 = caps->vfo_op(rig, vfo, RIG_OP_TOGGLE);
|
||||
@ -3962,7 +3983,8 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
|
||||
else
|
||||
{
|
||||
TRACE;
|
||||
retcode = caps->get_freq ? caps->get_freq(rig, RIG_VFO_CURR, tx_freq) :-RIG_ENIMPL;
|
||||
retcode = caps->get_freq ? caps->get_freq(rig, RIG_VFO_CURR,
|
||||
tx_freq) : -RIG_ENIMPL;
|
||||
}
|
||||
|
||||
/* try and revert even if we had an error above */
|
||||
@ -4098,7 +4120,8 @@ int HAMLIB_API rig_set_split_mode(RIG *rig,
|
||||
else
|
||||
{
|
||||
TRACE;
|
||||
retcode = caps->set_mode ? caps->set_mode(rig, RIG_VFO_CURR, tx_mode, tx_width) : -RIG_ENIMPL;
|
||||
retcode = caps->set_mode ? caps->set_mode(rig, RIG_VFO_CURR, tx_mode,
|
||||
tx_width) : -RIG_ENIMPL;
|
||||
}
|
||||
|
||||
/* try and revert even if we had an error above */
|
||||
@ -4221,7 +4244,8 @@ int HAMLIB_API rig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
|
||||
else
|
||||
{
|
||||
TRACE;
|
||||
retcode = caps->get_mode ? caps->get_mode(rig, RIG_VFO_CURR, tx_mode, tx_width) : -RIG_ENIMPL;
|
||||
retcode = caps->get_mode ? caps->get_mode(rig, RIG_VFO_CURR, tx_mode,
|
||||
tx_width) : -RIG_ENIMPL;
|
||||
}
|
||||
|
||||
/* try and revert even if we had an error above */
|
||||
@ -4461,13 +4485,18 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
|
||||
|
||||
if (vfo != RIG_VFO_A && vfo != RIG_VFO_B)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: expected VFOA/B but got %s\n", __func__, rig_strvfo(vfo));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: expected VFOA/B but got %s\n", __func__,
|
||||
rig_strvfo(vfo));
|
||||
}
|
||||
|
||||
// set rig to the the requested RX VFO
|
||||
TRACE;
|
||||
|
||||
if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ))
|
||||
#if BUILTINFUNC
|
||||
rig_set_vfo(rig, vfo == RIG_VFO_B?RIG_VFO_B:RIG_VFO_A, __builtin_FUNCTION());
|
||||
rig_set_vfo(rig, vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A,
|
||||
__builtin_FUNCTION());
|
||||
|
||||
#else
|
||||
rig_set_vfo(rig, vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A);
|
||||
#endif
|
||||
@ -4496,6 +4525,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
|
||||
|
||||
curr_vfo = rig->state.current_vfo;
|
||||
TRACE;
|
||||
|
||||
if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ))
|
||||
{
|
||||
retcode = caps->set_vfo(rig, vfo);
|
||||
@ -4510,7 +4540,8 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
|
||||
retcode = caps->set_split_vfo(rig, vfo, split, tx_vfo);
|
||||
|
||||
/* try and revert even if we had an error above */
|
||||
if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) {
|
||||
if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ))
|
||||
{
|
||||
rc2 = caps->set_vfo(rig, curr_vfo);
|
||||
|
||||
if (RIG_OK == retcode)
|
||||
@ -4614,7 +4645,8 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig,
|
||||
TRACE;
|
||||
retcode = RIG_OK;
|
||||
//if (rig->caps->rig_model != RIG_MODEL_NETRIGCTL)
|
||||
{ // rigctld doesn't like nested calls
|
||||
{
|
||||
// rigctld doesn't like nested calls
|
||||
retcode = caps->get_split_vfo(rig, vfo, split, tx_vfo);
|
||||
rig->state.cache.split = *split;
|
||||
rig->state.cache.split_vfo = *tx_vfo;
|
||||
@ -6374,6 +6406,7 @@ void make_crc_table(unsigned long crcTable[])
|
||||
remainder = b;
|
||||
|
||||
unsigned long bit;
|
||||
|
||||
for (bit = 8; bit > 0; --bit)
|
||||
{
|
||||
if (remainder & 1)
|
||||
|
13
src/serial.c
13
src/serial.c
@ -225,15 +225,19 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
|
||||
* Open in Non-blocking mode. Watch for EAGAIN errors!
|
||||
*/
|
||||
int i = 1;
|
||||
do { // some serial ports fail to open 1st time for some unknown reason
|
||||
|
||||
do // some serial ports fail to open 1st time for some unknown reason
|
||||
{
|
||||
fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
|
||||
if (fd == -1) // some serial ports fail to open 1st time for some unknown reason
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#%d\n", __func__, __LINE__, i);
|
||||
hl_usleep(500 * 1000);
|
||||
fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
}
|
||||
} while(++i <= 4 && fd == -1);
|
||||
}
|
||||
while (++i <= 4 && fd == -1);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
@ -711,16 +715,19 @@ int ser_open(hamlib_port_t *p)
|
||||
* pathname is not uh_rig or uh_ptt: simply open()
|
||||
*/
|
||||
int i = 1;
|
||||
|
||||
do // some serial ports fail to open 1st time
|
||||
{
|
||||
ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
|
||||
if (ret == -1) // some serial ports fail to open 1st time
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#%d\n", __func__, __LINE__, i);
|
||||
hl_usleep(500 * 1000);
|
||||
ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
}
|
||||
} while(++i <= 4 && ret == -1);
|
||||
}
|
||||
while (++i <= 4 && ret == -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -727,7 +727,8 @@ int rot_sprintf_status(char *str, int nlen, rot_status_t status)
|
||||
return len;
|
||||
}
|
||||
|
||||
int rig_sprintf_spectrum_modes(char *str, int nlen, const enum rig_spectrum_mode_e *modes)
|
||||
int rig_sprintf_spectrum_modes(char *str, int nlen,
|
||||
const enum rig_spectrum_mode_e *modes)
|
||||
{
|
||||
int i, len = 0, lentmp;
|
||||
|
||||
@ -750,11 +751,13 @@ int rig_sprintf_spectrum_modes(char *str, int nlen, const enum rig_spectrum_mode
|
||||
}
|
||||
|
||||
lentmp = snprintf(str + len, nlen - len, "%d=%s ", modes[i], sm);
|
||||
|
||||
if (len < 0 || lentmp >= nlen - len)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): overflowed str buffer\n", __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
len += lentmp;
|
||||
|
||||
}
|
||||
@ -776,18 +779,21 @@ int rig_sprintf_spectrum_spans(char *str, int nlen, const freq_t *spans)
|
||||
}
|
||||
|
||||
lentmp = snprintf(str + len, nlen - len, "%.0f ", spans[i]);
|
||||
|
||||
if (len < 0 || lentmp >= nlen - len)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): overflowed str buffer\n", __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
len += lentmp;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int rig_sprintf_spectrum_avg_modes(char *str, int nlen, const struct rig_spectrum_avg_mode *avg_modes)
|
||||
int rig_sprintf_spectrum_avg_modes(char *str, int nlen,
|
||||
const struct rig_spectrum_avg_mode *avg_modes)
|
||||
{
|
||||
int i, len = 0, lentmp;
|
||||
|
||||
@ -800,12 +806,15 @@ int rig_sprintf_spectrum_avg_modes(char *str, int nlen, const struct rig_spectru
|
||||
break;
|
||||
}
|
||||
|
||||
lentmp = snprintf(str + len, nlen - len, "%d=\"%s\" ", avg_modes[i].id, avg_modes[i].name);
|
||||
lentmp = snprintf(str + len, nlen - len, "%d=\"%s\" ", avg_modes[i].id,
|
||||
avg_modes[i].name);
|
||||
|
||||
if (len < 0 || lentmp >= nlen - len)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): overflowed str buffer\n", __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
len += lentmp;
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,8 @@ int dumpcaps(RIG *rig, FILE *fout)
|
||||
|
||||
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && i < caps->agc_level_count; i++)
|
||||
{
|
||||
fprintf(fout, " %d=%s", caps->agc_levels[i], rig_stragclevel(caps->agc_levels[i]));
|
||||
fprintf(fout, " %d=%s", caps->agc_levels[i],
|
||||
rig_stragclevel(caps->agc_levels[i]));
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
@ -700,9 +701,11 @@ int dumpcaps(RIG *rig, FILE *fout)
|
||||
|
||||
fprintf(fout, "Spectrum scopes:");
|
||||
|
||||
for (i = 0; i < HAMLIB_MAX_SPECTRUM_SCOPES && caps->spectrum_scopes[i].name != NULL; i++)
|
||||
for (i = 0; i < HAMLIB_MAX_SPECTRUM_SCOPES
|
||||
&& caps->spectrum_scopes[i].name != NULL; i++)
|
||||
{
|
||||
fprintf(fout, " %d=\"%s\"", caps->spectrum_scopes[i].id, caps->spectrum_scopes[i].name);
|
||||
fprintf(fout, " %d=\"%s\"", caps->spectrum_scopes[i].id,
|
||||
caps->spectrum_scopes[i].name);
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
@ -718,7 +721,8 @@ int dumpcaps(RIG *rig, FILE *fout)
|
||||
rig_sprintf_spectrum_spans(prntbuf, sizeof(prntbuf), caps->spectrum_spans);
|
||||
fprintf(fout, "Spectrum spans: %s\n", prntbuf);
|
||||
|
||||
rig_sprintf_spectrum_avg_modes(prntbuf, sizeof(prntbuf), caps->spectrum_avg_modes);
|
||||
rig_sprintf_spectrum_avg_modes(prntbuf, sizeof(prntbuf),
|
||||
caps->spectrum_avg_modes);
|
||||
fprintf(fout, "Spectrum averaging modes: %s\n", prntbuf);
|
||||
|
||||
fprintf(fout, "Spectrum attenuator:");
|
||||
|
@ -156,7 +156,9 @@ int main(int argc, char *argv[])
|
||||
int i;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__);
|
||||
for(i=0;i<argc;++i) rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]);
|
||||
|
||||
for (i = 0; i < argc; ++i) { rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]); }
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s", "\n");
|
||||
|
||||
while (1)
|
||||
@ -181,6 +183,7 @@ int main(int argc, char *argv[])
|
||||
case '!':
|
||||
cookie_use = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage();
|
||||
exit(0);
|
||||
@ -558,7 +561,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
fprintf(stderr, "rig_open: error = %s %s %s \n", rigerror(retcode), rig_file, strerror(errno));
|
||||
fprintf(stderr, "rig_open: error = %s %s %s \n", rigerror(retcode), rig_file,
|
||||
strerror(errno));
|
||||
|
||||
if (!ignore_rig_open_error) { exit(2); }
|
||||
}
|
||||
|
@ -1143,6 +1143,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
||||
*/
|
||||
result = strtok(input_line, " ");
|
||||
readline_repeat:
|
||||
|
||||
/* parsed_input stores pointers into input_line where the token strings
|
||||
* start.
|
||||
*/
|
||||
@ -1735,7 +1736,9 @@ readline_repeat:
|
||||
fflush(fout);
|
||||
|
||||
#ifdef HAVE_LIBREADLINE
|
||||
if (input_line != NULL && (result = strtok(NULL, " "))) goto readline_repeat;
|
||||
|
||||
if (input_line != NULL && (result = strtok(NULL, " "))) { goto readline_repeat; }
|
||||
|
||||
#endif
|
||||
|
||||
if (sync_cb) { sync_cb(0); } /* unlock if necessary */
|
||||
@ -4058,7 +4061,8 @@ static int mydcd_event(RIG *rig, vfo_t vfo, dcd_t dcd, rig_ptr_t arg)
|
||||
}
|
||||
|
||||
|
||||
static int print_spectrum_line(char *str, size_t length, struct rig_spectrum_line *line)
|
||||
static int print_spectrum_line(char *str, size_t length,
|
||||
struct rig_spectrum_line *line)
|
||||
{
|
||||
int data_level_max = line->data_level_max / 2;
|
||||
int aggregate_count = line->spectrum_data_length / 120;
|
||||
@ -4081,7 +4085,9 @@ static int print_spectrum_line(char *str, size_t length, struct rig_spectrum_lin
|
||||
}
|
||||
|
||||
int level = aggregate_value * 10 / data_level_max;
|
||||
if (level >= 8) {
|
||||
|
||||
if (level >= 8)
|
||||
{
|
||||
strcpy(str + c, "█");
|
||||
c += charlen;
|
||||
}
|
||||
@ -4114,7 +4120,8 @@ static int print_spectrum_line(char *str, size_t length, struct rig_spectrum_lin
|
||||
}
|
||||
|
||||
|
||||
static int myspectrum_event(RIG *rig, struct rig_spectrum_line *line, rig_ptr_t arg)
|
||||
static int myspectrum_event(RIG *rig, struct rig_spectrum_line *line,
|
||||
rig_ptr_t arg)
|
||||
{
|
||||
ENTERFUNC;
|
||||
|
||||
@ -4122,7 +4129,8 @@ static int myspectrum_event(RIG *rig, struct rig_spectrum_line *line, rig_ptr_t
|
||||
{
|
||||
char spectrum_debug[line->spectrum_data_length * 4];
|
||||
print_spectrum_line(spectrum_debug, sizeof(spectrum_debug), line);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: ASCII Spectrum Scope: %s\n", __func__, spectrum_debug);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: ASCII Spectrum Scope: %s\n", __func__,
|
||||
spectrum_debug);
|
||||
}
|
||||
|
||||
// TODO: Push out spectrum data via multicast server once it is implemented
|
||||
@ -4501,7 +4509,8 @@ declare_proto_rig(dump_state)
|
||||
if (chk_vfo_executed) // for 3.3 compatiblility
|
||||
{
|
||||
fprintf(fout, "vfo_ops=0x%x\n", rig->caps->vfo_ops);
|
||||
fprintf(fout, "ptt_type=0x%x\n", rig->state.pttport.type.ptt==RIG_PTT_NONE?RIG_PTT_NONE:RIG_PTT_RIG);
|
||||
fprintf(fout, "ptt_type=0x%x\n",
|
||||
rig->state.pttport.type.ptt == RIG_PTT_NONE ? RIG_PTT_NONE : RIG_PTT_RIG);
|
||||
fprintf(fout, "targetable_vfo=0x%x\n", rig->caps->targetable_vfo);
|
||||
fprintf(fout, "has_set_vfo=%d\n", rig->caps->set_vfo != NULL);
|
||||
fprintf(fout, "has_get_vfo=%d\n", rig->caps->get_vfo != NULL);
|
||||
|
@ -653,7 +653,8 @@ static rmode_t ts2000_get_mode()
|
||||
{
|
||||
rmode_t mode;
|
||||
pbwidth_t width;
|
||||
rig_get_mode(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), &mode, &width);
|
||||
rig_get_mode(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split),
|
||||
&mode, &width);
|
||||
|
||||
// Perhaps we should emulate a rig that has PKT modes instead??
|
||||
switch (mode)
|
||||
@ -740,7 +741,8 @@ static int handle_ts2000(void *arg)
|
||||
int p13 = 0; // P13 Tone dummy value for now
|
||||
int p14 = 0; // P14 Tone Freq dummy value for now
|
||||
int p15 = 0; // P15 Shift status dummy value for now
|
||||
int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), &freq);
|
||||
int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split), &freq);
|
||||
char response[64];
|
||||
char *fmt =
|
||||
// cppcheck-suppress *
|
||||
@ -752,7 +754,8 @@ static int handle_ts2000(void *arg)
|
||||
}
|
||||
|
||||
mode = ts2000_get_mode();
|
||||
retval = rig_get_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), &ptt);
|
||||
retval = rig_get_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split), &ptt);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
@ -834,7 +837,8 @@ static int handle_ts2000(void *arg)
|
||||
freq_t freq = 0;
|
||||
char response[32];
|
||||
|
||||
int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), &freq);
|
||||
int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split), &freq);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
@ -850,7 +854,8 @@ static int handle_ts2000(void *arg)
|
||||
{
|
||||
char response[32];
|
||||
freq_t freq = 0;
|
||||
int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), &freq);
|
||||
int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B,
|
||||
my_rig->state.cache.split), &freq);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
@ -904,7 +909,8 @@ static int handle_ts2000(void *arg)
|
||||
}
|
||||
else if (strcmp(arg, "TX;") == 0)
|
||||
{
|
||||
return rig_set_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), 1);
|
||||
return rig_set_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split), 1);
|
||||
}
|
||||
else if (strcmp(arg, "AI0;") == 0)
|
||||
{
|
||||
@ -918,11 +924,13 @@ static int handle_ts2000(void *arg)
|
||||
}
|
||||
else if (strcmp(arg, "FR0;") == 0)
|
||||
{
|
||||
return rig_set_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split));
|
||||
return rig_set_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split));
|
||||
}
|
||||
else if (strcmp(arg, "FR1;") == 0)
|
||||
{
|
||||
return rig_set_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split));
|
||||
return rig_set_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B,
|
||||
my_rig->state.cache.split));
|
||||
}
|
||||
else if (strcmp(arg, "FR;") == 0)
|
||||
{
|
||||
@ -1018,7 +1026,8 @@ static int handle_ts2000(void *arg)
|
||||
{
|
||||
char response[32];
|
||||
int valA;
|
||||
int retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), RIG_FUNC_AIP,
|
||||
int retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split), RIG_FUNC_AIP,
|
||||
&valA);
|
||||
int valB;
|
||||
|
||||
@ -1037,7 +1046,8 @@ static int handle_ts2000(void *arg)
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), RIG_FUNC_AIP,
|
||||
retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B,
|
||||
my_rig->state.cache.split), RIG_FUNC_AIP,
|
||||
&valB);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
@ -1063,7 +1073,8 @@ static int handle_ts2000(void *arg)
|
||||
(char *)arg);
|
||||
}
|
||||
|
||||
retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), RIG_FUNC_AIP, valA);
|
||||
retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split), RIG_FUNC_AIP, valA);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
@ -1072,7 +1083,8 @@ static int handle_ts2000(void *arg)
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), RIG_FUNC_AIP, valB);
|
||||
retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B,
|
||||
my_rig->state.cache.split), RIG_FUNC_AIP, valB);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
@ -1487,12 +1499,14 @@ static int handle_ts2000(void *arg)
|
||||
}
|
||||
else if (strcmp(arg, "FT0;") == 0)
|
||||
{
|
||||
return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), vfo_fixup(my_rig,
|
||||
return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split), vfo_fixup(my_rig,
|
||||
RIG_VFO_A, my_rig->state.cache.split), 0);
|
||||
}
|
||||
else if (strcmp(arg, "FT1;") == 0)
|
||||
{
|
||||
return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), vfo_fixup(my_rig,
|
||||
return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B,
|
||||
my_rig->state.cache.split), vfo_fixup(my_rig,
|
||||
RIG_VFO_B, my_rig->state.cache.split), 0);
|
||||
}
|
||||
else if (strncmp(arg, "FA0", 3) == 0)
|
||||
@ -1500,14 +1514,16 @@ static int handle_ts2000(void *arg)
|
||||
freq_t freq;
|
||||
|
||||
sscanf((char *)arg + 2, "%"SCNfreq, &freq);
|
||||
return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), freq);
|
||||
return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A,
|
||||
my_rig->state.cache.split), freq);
|
||||
}
|
||||
else if (strncmp(arg, "FB0", 3) == 0)
|
||||
{
|
||||
freq_t freq;
|
||||
|
||||
sscanf((char *)arg + 2, "%"SCNfreq, &freq);
|
||||
return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), freq);
|
||||
return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B,
|
||||
my_rig->state.cache.split), freq);
|
||||
}
|
||||
else if (strncmp(arg, "MD", 2) == 0)
|
||||
{
|
||||
|
@ -270,7 +270,9 @@ int main(int argc, char *argv[])
|
||||
int i;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__);
|
||||
for(i=0;i<argc;++i) rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]);
|
||||
|
||||
for (i = 0; i < argc; ++i) { rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]); }
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s", "\n");
|
||||
|
||||
while (1)
|
||||
@ -1221,8 +1223,10 @@ handle_exit:
|
||||
if (retcode != 0) { rig_debug(RIG_DEBUG_ERR, "%s: fclose(fsockin) %s\n", __func__, strerror(retcode)); }
|
||||
|
||||
#endif
|
||||
if (fsockin) fclose(fsockin);
|
||||
if (fsockout) fclose(fsockout);
|
||||
|
||||
if (fsockin) { fclose(fsockin); }
|
||||
|
||||
if (fsockout) { fclose(fsockout); }
|
||||
|
||||
// for everybody else we close the handle after fclose
|
||||
#ifndef __MINGW32__
|
||||
|
@ -71,6 +71,7 @@ int test2()
|
||||
|
||||
if (retcode != RIG_OK) { printf("Test#2d OK\n"); }
|
||||
else {printf("Test#2d Failed cookie=%s\n", cookie); return 1;}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
163
tests/testlibusb.c
Executable file → Normal file
163
tests/testlibusb.c
Executable file → Normal file
@ -32,7 +32,8 @@
|
||||
|
||||
int verbose = 0;
|
||||
|
||||
static void print_endpoint_comp(const struct libusb_ss_endpoint_companion_descriptor *ep_comp)
|
||||
static void print_endpoint_comp(const struct
|
||||
libusb_ss_endpoint_companion_descriptor *ep_comp)
|
||||
{
|
||||
printf(" USB 3.0 Endpoint Companion:\n");
|
||||
printf(" bMaxBurst: %u\n", ep_comp->bMaxBurst);
|
||||
@ -52,13 +53,18 @@ static void print_endpoint(const struct libusb_endpoint_descriptor *endpoint)
|
||||
printf(" bRefresh: %u\n", endpoint->bRefresh);
|
||||
printf(" bSynchAddress: %u\n", endpoint->bSynchAddress);
|
||||
|
||||
for (i = 0; i < endpoint->extra_length;) {
|
||||
if (LIBUSB_DT_SS_ENDPOINT_COMPANION == endpoint->extra[i + 1]) {
|
||||
for (i = 0; i < endpoint->extra_length;)
|
||||
{
|
||||
if (LIBUSB_DT_SS_ENDPOINT_COMPANION == endpoint->extra[i + 1])
|
||||
{
|
||||
struct libusb_ss_endpoint_companion_descriptor *ep_comp;
|
||||
|
||||
ret = libusb_get_ss_endpoint_companion_descriptor(NULL, endpoint, &ep_comp);
|
||||
|
||||
if (LIBUSB_SUCCESS != ret)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
print_endpoint_comp(ep_comp);
|
||||
|
||||
@ -69,7 +75,8 @@ static void print_endpoint(const struct libusb_endpoint_descriptor *endpoint)
|
||||
}
|
||||
}
|
||||
|
||||
static void print_altsetting(const struct libusb_interface_descriptor *interface)
|
||||
static void print_altsetting(const struct libusb_interface_descriptor
|
||||
*interface)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
@ -83,17 +90,22 @@ static void print_altsetting(const struct libusb_interface_descriptor *interface
|
||||
printf(" iInterface: %u\n", interface->iInterface);
|
||||
|
||||
for (i = 0; i < interface->bNumEndpoints; i++)
|
||||
{
|
||||
print_endpoint(&interface->endpoint[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_2_0_ext_cap(struct libusb_usb_2_0_extension_descriptor *usb_2_0_ext_cap)
|
||||
static void print_2_0_ext_cap(struct libusb_usb_2_0_extension_descriptor
|
||||
*usb_2_0_ext_cap)
|
||||
{
|
||||
printf(" USB 2.0 Extension Capabilities:\n");
|
||||
printf(" bDevCapabilityType: %u\n", usb_2_0_ext_cap->bDevCapabilityType);
|
||||
printf(" bDevCapabilityType: %u\n",
|
||||
usb_2_0_ext_cap->bDevCapabilityType);
|
||||
printf(" bmAttributes: %08xh\n", usb_2_0_ext_cap->bmAttributes);
|
||||
}
|
||||
|
||||
static void print_ss_usb_cap(struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap)
|
||||
static void print_ss_usb_cap(struct libusb_ss_usb_device_capability_descriptor
|
||||
*ss_usb_cap)
|
||||
{
|
||||
printf(" USB 3.0 Capabilities:\n");
|
||||
printf(" bDevCapabilityType: %u\n", ss_usb_cap->bDevCapabilityType);
|
||||
@ -111,31 +123,46 @@ static void print_bos(libusb_device_handle *handle)
|
||||
int ret;
|
||||
|
||||
ret = libusb_get_bos_descriptor(handle, &bos);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
printf(" Binary Object Store (BOS):\n");
|
||||
printf(" wTotalLength: %u\n", bos->wTotalLength);
|
||||
printf(" bNumDeviceCaps: %u\n", bos->bNumDeviceCaps);
|
||||
|
||||
for (i = 0; i < bos->bNumDeviceCaps; i++) {
|
||||
for (i = 0; i < bos->bNumDeviceCaps; i++)
|
||||
{
|
||||
struct libusb_bos_dev_capability_descriptor *dev_cap = bos->dev_capability[i];
|
||||
|
||||
if (dev_cap->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION) {
|
||||
if (dev_cap->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION)
|
||||
{
|
||||
struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension;
|
||||
|
||||
ret = libusb_get_usb_2_0_extension_descriptor(NULL, dev_cap, &usb_2_0_extension);
|
||||
ret = libusb_get_usb_2_0_extension_descriptor(NULL, dev_cap,
|
||||
&usb_2_0_extension);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
print_2_0_ext_cap(usb_2_0_extension);
|
||||
libusb_free_usb_2_0_extension_descriptor(usb_2_0_extension);
|
||||
} else if (dev_cap->bDevCapabilityType == LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) {
|
||||
}
|
||||
else if (dev_cap->bDevCapabilityType == LIBUSB_BT_SS_USB_DEVICE_CAPABILITY)
|
||||
{
|
||||
struct libusb_ss_usb_device_capability_descriptor *ss_dev_cap;
|
||||
|
||||
ret = libusb_get_ss_usb_device_capability_descriptor(NULL, dev_cap, &ss_dev_cap);
|
||||
ret = libusb_get_ss_usb_device_capability_descriptor(NULL, dev_cap,
|
||||
&ss_dev_cap);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
print_ss_usb_cap(ss_dev_cap);
|
||||
libusb_free_ss_usb_device_capability_descriptor(ss_dev_cap);
|
||||
@ -150,8 +177,10 @@ static void print_interface(const struct libusb_interface *interface)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < interface->num_altsetting; i++)
|
||||
{
|
||||
print_altsetting(&interface->altsetting[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_configuration(struct libusb_config_descriptor *config)
|
||||
{
|
||||
@ -166,8 +195,10 @@ static void print_configuration(struct libusb_config_descriptor *config)
|
||||
printf(" MaxPower: %u\n", config->MaxPower);
|
||||
|
||||
for (i = 0; i < config->bNumInterfaces; i++)
|
||||
{
|
||||
print_interface(&config->interface[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_device(libusb_device *dev, libusb_device_handle *handle)
|
||||
{
|
||||
@ -177,17 +208,25 @@ static void print_device(libusb_device *dev, libusb_device_handle *handle)
|
||||
int ret;
|
||||
uint8_t i;
|
||||
|
||||
switch (libusb_get_device_speed(dev)) {
|
||||
switch (libusb_get_device_speed(dev))
|
||||
{
|
||||
case LIBUSB_SPEED_LOW: speed = "1.5M"; break;
|
||||
|
||||
case LIBUSB_SPEED_FULL: speed = "12M"; break;
|
||||
|
||||
case LIBUSB_SPEED_HIGH: speed = "480M"; break;
|
||||
|
||||
case LIBUSB_SPEED_SUPER: speed = "5G"; break;
|
||||
|
||||
case LIBUSB_SPEED_SUPER_PLUS: speed = "10G"; break;
|
||||
|
||||
default: speed = "Unknown";
|
||||
}
|
||||
|
||||
ret = libusb_get_device_descriptor(dev, &desc);
|
||||
if (ret < 0) {
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "failed to get device descriptor");
|
||||
return;
|
||||
}
|
||||
@ -197,34 +236,56 @@ static void print_device(libusb_device *dev, libusb_device_handle *handle)
|
||||
desc.idVendor, desc.idProduct, speed);
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
libusb_open(dev, &handle);
|
||||
}
|
||||
|
||||
if (handle)
|
||||
{
|
||||
if (desc.iManufacturer)
|
||||
{
|
||||
ret = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string,
|
||||
sizeof(string));
|
||||
|
||||
if (handle) {
|
||||
if (desc.iManufacturer) {
|
||||
ret = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string, sizeof(string));
|
||||
if (ret > 0)
|
||||
{
|
||||
printf(" Manufacturer: %s\n", (char *)string);
|
||||
}
|
||||
|
||||
if (desc.iProduct) {
|
||||
ret = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, sizeof(string));
|
||||
if (ret > 0)
|
||||
printf(" Product: %s\n", (char *)string);
|
||||
}
|
||||
|
||||
if (desc.iSerialNumber && verbose) {
|
||||
ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, sizeof(string));
|
||||
if (desc.iProduct)
|
||||
{
|
||||
ret = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string,
|
||||
sizeof(string));
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
printf(" Product: %s\n", (char *)string);
|
||||
}
|
||||
}
|
||||
|
||||
if (desc.iSerialNumber && verbose)
|
||||
{
|
||||
ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string,
|
||||
sizeof(string));
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
printf(" Serial Number: %s\n", (char *)string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
for (i = 0; i < desc.bNumConfigurations; i++) {
|
||||
if (verbose)
|
||||
{
|
||||
for (i = 0; i < desc.bNumConfigurations; i++)
|
||||
{
|
||||
struct libusb_config_descriptor *config;
|
||||
|
||||
ret = libusb_get_config_descriptor(dev, i, &config);
|
||||
if (LIBUSB_SUCCESS != ret) {
|
||||
|
||||
if (LIBUSB_SUCCESS != ret)
|
||||
{
|
||||
printf(" Couldn't retrieve descriptors\n");
|
||||
continue;
|
||||
}
|
||||
@ -235,12 +296,16 @@ static void print_device(libusb_device *dev, libusb_device_handle *handle)
|
||||
}
|
||||
|
||||
if (handle && desc.bcdUSB >= 0x0201)
|
||||
{
|
||||
print_bos(handle);
|
||||
}
|
||||
}
|
||||
|
||||
if (handle)
|
||||
{
|
||||
libusb_close(handle);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000107)
|
||||
|
||||
@ -254,16 +319,22 @@ static int test_wrapped_device(const char *device_name)
|
||||
int r, fd;
|
||||
|
||||
fd = open(device_name, O_RDWR);
|
||||
if (fd < 0) {
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
printf("Error could not open %s: %s\n", device_name, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
r = libusb_wrap_sys_device(NULL, fd, &handle);
|
||||
if (r) {
|
||||
|
||||
if (r)
|
||||
{
|
||||
printf("Error wrapping device: %s: %s\n", device_name, libusb_strerror(r));
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
print_device(libusb_get_device(handle), handle);
|
||||
close(fd);
|
||||
return 0;
|
||||
@ -285,13 +356,19 @@ int main(int argc, char *argv[])
|
||||
ssize_t cnt;
|
||||
int r, i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "-v")) {
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (!strcmp(argv[i], "-v"))
|
||||
{
|
||||
verbose = 1;
|
||||
} else if (!strcmp(argv[i], "-d") && (i + 1) < argc) {
|
||||
}
|
||||
else if (!strcmp(argv[i], "-d") && (i + 1) < argc)
|
||||
{
|
||||
i++;
|
||||
device_name = argv[i];
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Usage %s [-v] [-d </dev/bus/usb/...>]\n", argv[0]);
|
||||
printf("Note use -d to test libusb_wrap_sys_device()\n");
|
||||
return 1;
|
||||
@ -299,20 +376,30 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
r = libusb_init(NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (device_name) {
|
||||
if (r < 0)
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
if (device_name)
|
||||
{
|
||||
r = test_wrapped_device(device_name);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cnt = libusb_get_device_list(NULL, &devs);
|
||||
if (cnt < 0) {
|
||||
|
||||
if (cnt < 0)
|
||||
{
|
||||
libusb_exit(NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; devs[i]; i++)
|
||||
{
|
||||
print_device(devs[i], NULL);
|
||||
}
|
||||
|
||||
libusb_free_device_list(devs, 1);
|
||||
}
|
||||
|
@ -140,10 +140,13 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
printf("rig_set_freq: error exptect %.0f got %.0f\n", 296290000.0, freq);
|
||||
}
|
||||
|
||||
if (rmode != RIG_MODE_FM || width != rig_passband_narrow(my_rig, RIG_MODE_FM))
|
||||
{
|
||||
printf("rig_set_mode: error expected FM/%d, got %s/%d\n", (int)rig_passband_narrow(my_rig, RIG_MODE_FM), rig_strrmode(rmode), (int)width);
|
||||
printf("rig_set_mode: error expected FM/%d, got %s/%d\n",
|
||||
(int)rig_passband_narrow(my_rig, RIG_MODE_FM), rig_strrmode(rmode), (int)width);
|
||||
}
|
||||
|
||||
sleep(1); /* so you can see it -- FS */
|
||||
|
||||
/* 15m USB */
|
||||
|
Loading…
Reference in New Issue
Block a user