astyle all files preparing for 4.3 release

This commit is contained in:
Mike Black W9MDB 2021-08-26 06:49:24 -05:00
parent ff61c407f0
commit 283281c4cb
38 changed files with 1078 additions and 648 deletions

View File

@ -155,25 +155,31 @@ static void init_chan(RIG *rig, vfo_t vfo, channel_t *chan)
chan->vfo = vfo;
strcpy(chan->channel_desc, rig_strvfo(vfo));
switch(vfo)
switch (vfo)
{
case RIG_VFO_A:
case RIG_VFO_MAIN_A:
case RIG_VFO_A:
case RIG_VFO_MAIN_A:
chan->freq = MHz(145);
break;
case RIG_VFO_B:
case RIG_VFO_MAIN_B:
case RIG_VFO_B:
case RIG_VFO_MAIN_B:
chan->freq = MHz(146);
break;
case RIG_VFO_SUB_A:
case RIG_VFO_SUB_A:
chan->freq = MHz(147);
break;
case RIG_VFO_SUB_B:
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));
default:
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;
@ -420,7 +426,7 @@ static int dummy_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// if needed for testing enable this to emulate a rig with 100hz resolution
#if 0
// we emulate a rig with 100Hz set freq interval limits -- truncation
freq = freq - fmod(freq,100);
freq = freq - fmod(freq, 100);
#endif
usleep(CMDSLEEP);
sprintf_freq(fstr, sizeof(fstr), 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,13 +487,17 @@ 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_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_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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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);
@ -355,7 +357,7 @@ read_another_frame:
gettimeofday(&current_time, NULL);
timersub(&current_time, &start_time, &elapsed_time);
elapsed_ms = (int) (elapsed_time.tv_sec * 1000 + elapsed_time.tv_usec / 1000);
elapsed_ms = (int)(elapsed_time.tv_sec * 1000 + elapsed_time.tv_usec / 1000);
if (elapsed_ms > rs->rigport.timeout)
{

File diff suppressed because it is too large Load Diff

View File

@ -631,7 +631,7 @@ int flex6k_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
if (ptt_cmd[4] != response[4])
{
rig_debug(RIG_DEBUG_ERR, "%s: %s != %s\n", __func__, ptt_cmd, response);
hl_usleep(20*1000); // takes a bit to do PTT off
hl_usleep(20 * 1000); // takes a bit to do PTT off
}
}
while (ptt_cmd[4] != response[4] && --retry);

View File

@ -220,7 +220,7 @@ const struct rig_caps k3_caps =
.max_xit = Hz(9990),
.max_ifshift = Hz(0),
.vfo_ops = K3_VFO_OP,
.targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE,
.targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
.transceive = RIG_TRN_RIG,
.bank_qty = 0,
.chan_desc_sz = 0,
@ -370,7 +370,7 @@ const struct rig_caps k3s_caps =
.max_xit = Hz(9990),
.max_ifshift = Hz(0),
.vfo_ops = K3_VFO_OP,
.targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE,
.targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
.transceive = RIG_TRN_RIG,
.bank_qty = 0,
.chan_desc_sz = 0,
@ -520,7 +520,7 @@ const struct rig_caps k4_caps =
.max_xit = Hz(9990),
.max_ifshift = Hz(0),
.vfo_ops = K3_VFO_OP,
.targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE,
.targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
.transceive = RIG_TRN_RIG,
.bank_qty = 0,
.chan_desc_sz = 0,
@ -669,7 +669,7 @@ const struct rig_caps kx3_caps =
.max_xit = Hz(9990),
.max_ifshift = Hz(0),
.vfo_ops = K3_VFO_OP,
.targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE,
.targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
.transceive = RIG_TRN_RIG,
.bank_qty = 0,
.chan_desc_sz = 0,
@ -818,7 +818,7 @@ const struct rig_caps kx2_caps =
.max_xit = Hz(9990),
.max_ifshift = Hz(0),
.vfo_ops = K3_VFO_OP,
.targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE,
.targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
.transceive = RIG_TRN_RIG,
.bank_qty = 0,
.chan_desc_sz = 0,
@ -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);
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,16 +1546,18 @@ 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) {
// split can get turned off when modes are changing
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.
*/
if (tx_mode == RIG_MODE_PKTLSB || tx_mode == RIG_MODE_PKTUSB
|| tx_mode == RIG_MODE_RTTY || tx_mode == RIG_MODE_RTTYR)
|| tx_mode == RIG_MODE_RTTY || tx_mode == RIG_MODE_RTTYR)
{
err = kenwood_transaction(rig, cmd_m, NULL, 0);
@ -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);

View File

@ -762,10 +762,11 @@ 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
hl_usleep(200*1000);
hl_usleep(200 * 1000);
err = kenwood_get_id(rig, id);
}
@ -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);
}

View File

@ -120,12 +120,13 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
retval = kenwood_safe_transaction(rig, "VD0", ackbuf, sizeof(ackbuf), 6);
if (retval != RIG_OK)
{
{
return retval;
}
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:

View File

@ -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];
@ -238,90 +250,92 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return -RIG_EINVAL;
}
switch (level)
switch (level)
{
//Requires RS-HFIQ firmware version 4 or later
case RIG_LEVEL_RFPOWER_METER:
if (rshfiq_version_major <= 3)
{
//Requires RS-HFIQ firmware version 4 or later
case RIG_LEVEL_RFPOWER_METER:
return -RIG_ENAVAIL;
}
if (rshfiq_version_major <= 3)
{
return -RIG_ENAVAIL;
}
rig_flush(&rig->state.rigport);
rig_flush(&rig->state.rigport);
snprintf(cmdstr, sizeof(cmdstr), "*L\r");
snprintf(cmdstr, sizeof(cmdstr), "*L\r");
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER command=%s\n", cmdstr);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER command=%s\n", cmdstr);
retval = write_block(&rig->state.rigport, cmdstr, strlen(cmdstr));
retval = write_block(&rig->state.rigport, cmdstr, strlen(cmdstr));
if (retval != RIG_OK)
{
return retval;
}
if (retval != RIG_OK)
{
return retval;
}
stopset[0] = '\r';
stopset[1] = '\n';
stopset[0] = '\r';
stopset[1] = '\n';
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2);
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER reply=%s\n", cmdstr);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER reply=%s\n", cmdstr);
if (retval <= 0)
{
return retval;
}
if (retval <= 0)
{
return retval;
}
cmdstr[retval] = 0;
cmdstr[retval] = 0;
//Range is 0-110. Unit is percent
val->i = atoi(cmdstr);
val->f = (float)(val->i) / 100;
//Range is 0-110. Unit is percent
val->i = atoi(cmdstr);
val->f = (float)(val->i) / 100;
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER val=%f\n", val->f);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER val=%f\n", val->f);
return RIG_OK;
break;
case RIG_LEVEL_TEMP_METER:
rig_flush(&rig->state.rigport);
snprintf(cmdstr, sizeof(cmdstr), "*T\r");
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER command=%s\n", cmdstr);
retval = write_block(&rig->state.rigport, cmdstr, strlen(cmdstr));
if (retval != RIG_OK)
{
return retval;
}
stopset[0] = '\r';
stopset[1] = '\n';
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER reply=%s\n", cmdstr);
if (retval <= 0)
{
return retval;
}
cmdstr[retval] = 0;
sscanf(cmdstr, "%d.", &val->i);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER val=%d\n", val->i);
return RIG_OK;
break;
return RIG_OK;
break;
case RIG_LEVEL_TEMP_METER:
rig_flush(&rig->state.rigport);
snprintf(cmdstr, sizeof(cmdstr), "*T\r");
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER command=%s\n", cmdstr);
retval = write_block(&rig->state.rigport, cmdstr, strlen(cmdstr));
if (retval != RIG_OK)
{
return retval;
}
stopset[0] = '\r';
stopset[1] = '\n';
retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER reply=%s\n", cmdstr);
if (retval <= 0)
{
return retval;
}
cmdstr[retval] = 0;
sscanf(cmdstr, "%d.", &val->i);
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER val=%d\n", val->i);
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;
}
@ -373,7 +387,7 @@ const struct rig_caps rshfiq_caps =
.get_freq = rshfiq_get_freq,
.set_freq = rshfiq_set_freq,
.set_ptt = rshfiq_set_ptt,
.get_level= rshfiq_get_level,
.get_level = rshfiq_get_level,
};

View File

@ -41,10 +41,11 @@
#include "misc.h"
#include "bandplan.h"
struct ft100_priv_data {
/* TODO: make use of cached data */
FT100_STATUS_INFO status;
FT100_FLAG_INFO flags;
struct ft100_priv_data
{
/* TODO: make use of cached data */
FT100_STATUS_INFO status;
FT100_FLAG_INFO flags;
};

View File

@ -41,10 +41,11 @@
#include "misc.h"
#include "bandplan.h"
struct ft600_priv_data {
FT600_STATUS_INFO status;
FT600_FLAG_INFO flags;
unsigned char s_meter;
struct ft600_priv_data
{
FT600_STATUS_INFO status;
FT600_FLAG_INFO flags;
unsigned char s_meter;
};

View File

@ -65,17 +65,18 @@
*
*/
struct ft847_priv_data {
split_t sat_mode;
struct ft847_priv_data
{
split_t sat_mode;
unsigned char rx_status; /* tx returned data */
unsigned char tx_status; /* rx returned data */
/* for early ft847's we keep our own memory items */
/* Early rigs are one-way com to the rig */
freq_t freqA,freqB;
mode_t mode;
pbwidth_t width;
ptt_t ptt;
unsigned char rx_status; /* tx returned data */
unsigned char tx_status; /* rx returned data */
/* for early ft847's we keep our own memory items */
/* Early rigs are one-way com to the rig */
freq_t freqA, freqB;
mode_t mode;
pbwidth_t width;
ptt_t ptt;
};

View File

@ -74,20 +74,21 @@
#include "tones.h"
#include "bandplan.h"
struct ft857_priv_data {
yaesu_cmd_set_t pcs[FT857_NATIVE_SIZE]; /* TODO: why? */
struct ft857_priv_data
{
yaesu_cmd_set_t pcs[FT857_NATIVE_SIZE]; /* TODO: why? */
/* rx status */
struct timeval rx_status_tv;
unsigned char rx_status;
/* rx status */
struct timeval rx_status_tv;
unsigned char rx_status;
/* tx status */
struct timeval tx_status_tv;
unsigned char tx_status;
/* tx status */
struct timeval tx_status_tv;
unsigned char tx_status;
/* freq & mode status */
struct timeval fm_status_tv;
unsigned char fm_status[YAESU_CMD_LENGTH+1];
/* freq & mode status */
struct timeval fm_status_tv;
unsigned char fm_status[YAESU_CMD_LENGTH + 1];
};

View File

@ -79,20 +79,21 @@
#include "tones.h"
#include "bandplan.h"
struct ft897_priv_data {
yaesu_cmd_set_t pcs[FT897_NATIVE_SIZE]; /* TODO: why? */
struct ft897_priv_data
{
yaesu_cmd_set_t pcs[FT897_NATIVE_SIZE]; /* TODO: why? */
/* rx status */
struct timeval rx_status_tv;
unsigned char rx_status;
/* rx status */
struct timeval rx_status_tv;
unsigned char rx_status;
/* tx status */
struct timeval tx_status_tv;
unsigned char tx_status;
/* tx status */
struct timeval tx_status_tv;
unsigned char tx_status;
/* freq & mode status */
struct timeval fm_status_tv;
unsigned char fm_status[YAESU_CMD_LENGTH+1];
/* freq & mode status */
struct timeval fm_status_tv;
unsigned char fm_status[YAESU_CMD_LENGTH + 1];
};

View File

@ -921,19 +921,24 @@ 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));
__func__, rigerror(err));
}
hl_usleep(50*1000); // wait for BS to do it's thing and swap back
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);
}
else
@ -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:

View File

@ -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)

View File

@ -101,9 +101,10 @@ int main(int argc, char *argv[])
while (1)
{
buf[0]=0;
if (getmyline(fd, buf) > 0) printf("Cmd:%s\n", buf);
else return 0;
buf[0] = 0;
if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); }
else { return 0; }
if (strcmp(buf, "RM5;") == 0)
{
@ -141,7 +142,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf);
usleep(50 * 1000);
int id = 24;
snprintf(buf,sizeof(buf),"ID%03d;", id);
snprintf(buf, sizeof(buf), "ID%03d;", id);
n = snprintf(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);
@ -186,7 +187,7 @@ int main(int argc, char *argv[])
if (n < 0) { perror("EX032"); }
}
else if (strcmp(buf,"OM;") == 0)
else if (strcmp(buf, "OM;") == 0)
{
// KPA3 snprintf(buf, sizeof(buf), "OM AP----L-----;");
// K4+KPA3
@ -196,55 +197,55 @@ int main(int argc, char *argv[])
if (n < 0) { perror("OM"); }
}
else if (strcmp(buf,"K2;") == 0)
else if (strcmp(buf, "K2;") == 0)
{
write(fd, "K20;", 4);
}
else if (strcmp(buf,"K3;") == 0)
else if (strcmp(buf, "K3;") == 0)
{
write(fd, "K30;", 4);
}
else if (strcmp(buf,"RVM;") == 0)
else if (strcmp(buf, "RVM;") == 0)
{
write(fd, "RV02.37;", 8);
}
else if (strcmp(buf,"AI;") == 0)
else if (strcmp(buf, "AI;") == 0)
{
write(fd, "AI0;", 4);
}
else if (strcmp(buf,"MD;") == 0)
else if (strcmp(buf, "MD;") == 0)
{
snprintf(buf, sizeof(buf), "MD%d;", modea);
write(fd, buf, strlen(buf));
}
else if (strcmp(buf,"MD$;") == 0)
else if (strcmp(buf, "MD$;") == 0)
{
snprintf(buf, sizeof(buf), "MD$%d;", modeb);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf,"MD", 2) == 0)
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)
else if (strcmp(buf, "FA;") == 0)
{
sprintf(buf, "FA%011d;", freqa);
write(fd, buf, strlen(buf));
}
else if (strcmp(buf,"FB;")==0)
else if (strcmp(buf, "FB;") == 0)
{
sprintf(buf, "FB%011d;", freqb);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf,"FA",2)==0)
else if (strncmp(buf, "FA", 2) == 0)
{
sscanf(buf,"FA%d",&freqa);
sscanf(buf, "FA%d", &freqa);
}
else if (strncmp(buf,"FB",2)==0)
else if (strncmp(buf, "FB", 2) == 0)
{
sscanf(buf,"FB%d",&freqb);
sscanf(buf, "FB%d", &freqb);
}
else if (strlen(buf) > 0)
{

View File

@ -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);
@ -167,20 +169,22 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("Set ant %d\n", -1);
ant_curr = frame[5];
ant_option = frame[6];
dump_hex(frame,8);
dump_hex(frame, 8);
}
else {
else
{
printf("Get ant\n");
}
frame[5] = ant_curr;
frame[6] = ant_option;
frame[7]=0xfd;
frame[7] = 0xfd;
printf("write 8 bytes\n");
dump_hex(frame,8);
dump_hex(frame, 8);
write(fd, frame, 8);
break;
case 0x1a: // miscellaneous things
case 0x1a: // miscellaneous things
switch (frame[5])
{
case 0x03: // width
@ -195,6 +199,7 @@ void frameParse(int fd, unsigned char *frame, int len)
break;
#if 1
case 0x25:
if (frame[6] == 0xfd)
{

View File

@ -96,14 +96,15 @@ int main(int argc, char *argv[])
char *pbuf;
int n;
int fd = openPort(argv[1]);
int freqa=14074000, freqb=140735000;
int modea=0,modeb=0;
int freqa = 14074000, freqb = 140735000;
int modea = 0, modeb = 0;
while (1)
{
buf[0]=0;
if (getmyline(fd, buf) > 0) printf("Cmd:%s\n", buf);
else return 0;
buf[0] = 0;
if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); }
else { return 0; }
if (strcmp(buf, "RM5;") == 0)
{
@ -141,7 +142,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf);
usleep(50 * 1000);
int id = 24;
snprintf(buf,sizeof(buf),"ID%03d;", id);
snprintf(buf, sizeof(buf), "ID%03d;", id);
n = snprintf(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);
@ -196,15 +197,15 @@ int main(int argc, char *argv[])
sprintf(buf, "FA%011d;", freqa);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf,"FA",2)==0)
else if (strncmp(buf, "FA", 2) == 0)
{
sscanf(buf,"FA%d",&freqa);
sscanf(buf, "FA%d", &freqa);
}
else if (strncmp(buf,"FB",2)==0)
else if (strncmp(buf, "FB", 2) == 0)
{
sscanf(buf,"FB%d",&freqb);
sscanf(buf, "FB%d", &freqb);
}
else if (strncmp(buf,"AI;",2)==0)
else if (strncmp(buf, "AI;", 2) == 0)
{
sprintf(buf, "AI0;");
write(fd, buf, strlen(buf));

View File

@ -99,9 +99,11 @@ int main(int argc, char *argv[])
while (1)
{
if(getmyline(fd, buf))
printf("Cmd:%s\n", buf);
else return 0;
if (getmyline(fd, buf))
{
printf("Cmd:%s\n", buf);
}
else { return 0; }
if (strcmp(buf, "RM5;") == 0)
{
@ -139,7 +141,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf);
usleep(50 * 1000);
int id = NC_RIGID_FTDX3000;
snprintf(buf,sizeof(buf),"ID%03d;", id);
snprintf(buf, sizeof(buf), "ID%03d;", id);
n = snprintf(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);

View File

@ -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__);

View File

@ -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);
}

View File

@ -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;

View File

@ -556,9 +556,10 @@ int network_multicast_server(RIG *rig, const char *multicast_addr,
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):ADDR=%s, port=%d\n", __FILE__, __LINE__,
multicast_addr, default_port);
if (strcmp(multicast_addr,"0.0.0.0")==0)
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
}

View File

@ -261,7 +261,7 @@ static int rig_lookup_backend(rig_model_t rig_model)
for (i = 0; i < RIG_BACKEND_MAX && rig_backend_list[i].be_name; i++)
{
if (RIG_BACKEND_NUM(rig_model) ==
rig_backend_list[i].be_num)
rig_backend_list[i].be_num)
{
return i;
@ -284,7 +284,7 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model)
const struct rig_caps *caps;
int be_idx;
int retval;
int i,n;
int i, n;
/* already loaded ? */
caps = rig_get_caps(rig_model);
@ -295,13 +295,15 @@ 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++)
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;

View File

@ -173,7 +173,7 @@ static struct opened_rig_l *opened_rig_list = { NULL };
* Careful, the order must be the same as their RIG_E* counterpart!
* TODO: localise the messages..
*/
static const char * const rigerror_table[] =
static const char *const rigerror_table[] =
{
"Command completed successfully",
"Invalid parameter",
@ -365,15 +365,17 @@ 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) {
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),
(int)rig->state.cache.widthSubA);
rig_debug(RIG_DEBUG_CACHE,
"%s(%d): freqSubB=%.0f, modeSubB=%s, widthSubB=%d\n", func, line,
rig->state.cache.freqSubB, rig_strrmode(rig->state.cache.modeSubB),
(int)rig->state.cache.widthSubB);
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),
(int)rig->state.cache.widthSubA);
rig_debug(RIG_DEBUG_CACHE,
"%s(%d): freqSubB=%.0f, modeSubB=%s, widthSubB=%d\n", func, line,
rig->state.cache.freqSubB, rig_strrmode(rig->state.cache.modeSubB),
(int)rig->state.cache.widthSubB);
}
}
@ -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,8 +3812,11 @@ 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)
{
@ -3842,8 +3860,11 @@ 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
{
@ -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,15 +4485,20 @@ 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);
rig_set_vfo(rig, vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A);
#endif
if (vfo == RIG_VFO_CURR
@ -4496,28 +4525,30 @@ 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);
if (retcode != RIG_OK)
{
RETURNFUNC(retcode);
}
if (retcode != RIG_OK)
{
RETURNFUNC(retcode);
}
}
TRACE;
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)
{
/* return the first error code */
retcode = rc2;
}
if (RIG_OK == retcode)
{
/* return the first error code */
retcode = rc2;
}
}
if (retcode == RIG_OK)
@ -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)

View File

@ -224,16 +224,20 @@ 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
int i = 1;
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);
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)
{
@ -710,17 +714,20 @@ int ser_open(hamlib_port_t *p)
/*
* pathname is not uh_rig or uh_ptt: simply open()
*/
int i=1;
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);
hl_usleep(500 * 1000);
ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY);
}
} while(++i <= 4 && ret == -1);
}
while (++i <= 4 && ret == -1);
}
}

View File

@ -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__);
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__);
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__);
rig_debug(RIG_DEBUG_ERR, "%s(%d): overflowed str buffer\n", __FILE__, __LINE__);
break;
}
len += lentmp;
}

View File

@ -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:");

View File

@ -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); }
}

View File

@ -671,7 +671,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
RETURNFUNC(RIGCTL_PARSE_ERROR);
}
if (cmd != 0xa && cmd !=0xd)
if (cmd != 0xa && cmd != 0xd)
{
rig_debug(RIG_DEBUG_TRACE, "%s: cmd=%c(%02x)\n", __func__,
isprint(cmd) ? cmd : ' ', cmd);
@ -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);

View File

@ -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,27 +1499,31 @@ 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,
RIG_VFO_A, my_rig->state.cache.split), 0);
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,
RIG_VFO_B, my_rig->state.cache.split), 0);
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)
{
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)
{

View File

@ -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__

View File

@ -64,10 +64,10 @@ int main(int argc, char *argv[])
if (info_buf)
{
char *s = strdup(info_buf);
char *s = strdup(info_buf);
strtok(s, "\r\n");
printf("Rig_info: '%s'\n", s);
free(s);
free(s);
}
vfo_t vfo;

View File

@ -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;
}

481
tests/testlibusb.c Executable file → Normal file
View File

@ -32,214 +32,279 @@
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);
printf(" bmAttributes: %02xh\n", ep_comp->bmAttributes);
printf(" wBytesPerInterval: %u\n", ep_comp->wBytesPerInterval);
printf(" USB 3.0 Endpoint Companion:\n");
printf(" bMaxBurst: %u\n", ep_comp->bMaxBurst);
printf(" bmAttributes: %02xh\n", ep_comp->bmAttributes);
printf(" wBytesPerInterval: %u\n", ep_comp->wBytesPerInterval);
}
static void print_endpoint(const struct libusb_endpoint_descriptor *endpoint)
{
int i, ret;
int i, ret;
printf(" Endpoint:\n");
printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress);
printf(" bmAttributes: %02xh\n", endpoint->bmAttributes);
printf(" wMaxPacketSize: %u\n", endpoint->wMaxPacketSize);
printf(" bInterval: %u\n", endpoint->bInterval);
printf(" bRefresh: %u\n", endpoint->bRefresh);
printf(" bSynchAddress: %u\n", endpoint->bSynchAddress);
printf(" Endpoint:\n");
printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress);
printf(" bmAttributes: %02xh\n", endpoint->bmAttributes);
printf(" wMaxPacketSize: %u\n", endpoint->wMaxPacketSize);
printf(" bInterval: %u\n", endpoint->bInterval);
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]) {
struct libusb_ss_endpoint_companion_descriptor *ep_comp;
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;
ret = libusb_get_ss_endpoint_companion_descriptor(NULL, endpoint, &ep_comp);
print_endpoint_comp(ep_comp);
if (LIBUSB_SUCCESS != ret)
{
continue;
}
libusb_free_ss_endpoint_companion_descriptor(ep_comp);
}
print_endpoint_comp(ep_comp);
i += endpoint->extra[i];
}
libusb_free_ss_endpoint_companion_descriptor(ep_comp);
}
i += endpoint->extra[i];
}
}
static void print_altsetting(const struct libusb_interface_descriptor *interface)
static void print_altsetting(const struct libusb_interface_descriptor
*interface)
{
uint8_t i;
uint8_t i;
printf(" Interface:\n");
printf(" bInterfaceNumber: %u\n", interface->bInterfaceNumber);
printf(" bAlternateSetting: %u\n", interface->bAlternateSetting);
printf(" bNumEndpoints: %u\n", interface->bNumEndpoints);
printf(" bInterfaceClass: %u\n", interface->bInterfaceClass);
printf(" bInterfaceSubClass: %u\n", interface->bInterfaceSubClass);
printf(" bInterfaceProtocol: %u\n", interface->bInterfaceProtocol);
printf(" iInterface: %u\n", interface->iInterface);
printf(" Interface:\n");
printf(" bInterfaceNumber: %u\n", interface->bInterfaceNumber);
printf(" bAlternateSetting: %u\n", interface->bAlternateSetting);
printf(" bNumEndpoints: %u\n", interface->bNumEndpoints);
printf(" bInterfaceClass: %u\n", interface->bInterfaceClass);
printf(" bInterfaceSubClass: %u\n", interface->bInterfaceSubClass);
printf(" bInterfaceProtocol: %u\n", interface->bInterfaceProtocol);
printf(" iInterface: %u\n", interface->iInterface);
for (i = 0; i < interface->bNumEndpoints; i++)
print_endpoint(&interface->endpoint[i]);
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(" bmAttributes: %08xh\n", usb_2_0_ext_cap->bmAttributes);
printf(" USB 2.0 Extension Capabilities:\n");
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);
printf(" bmAttributes: %02xh\n", ss_usb_cap->bmAttributes);
printf(" wSpeedSupported: %u\n", ss_usb_cap->wSpeedSupported);
printf(" bFunctionalitySupport: %u\n", ss_usb_cap->bFunctionalitySupport);
printf(" bU1devExitLat: %u\n", ss_usb_cap->bU1DevExitLat);
printf(" bU2devExitLat: %u\n", ss_usb_cap->bU2DevExitLat);
printf(" USB 3.0 Capabilities:\n");
printf(" bDevCapabilityType: %u\n", ss_usb_cap->bDevCapabilityType);
printf(" bmAttributes: %02xh\n", ss_usb_cap->bmAttributes);
printf(" wSpeedSupported: %u\n", ss_usb_cap->wSpeedSupported);
printf(" bFunctionalitySupport: %u\n", ss_usb_cap->bFunctionalitySupport);
printf(" bU1devExitLat: %u\n", ss_usb_cap->bU1DevExitLat);
printf(" bU2devExitLat: %u\n", ss_usb_cap->bU2DevExitLat);
}
static void print_bos(libusb_device_handle *handle)
{
struct libusb_bos_descriptor *bos;
uint8_t i;
int ret;
struct libusb_bos_descriptor *bos;
uint8_t i;
int ret;
ret = libusb_get_bos_descriptor(handle, &bos);
if (ret < 0)
return;
ret = libusb_get_bos_descriptor(handle, &bos);
printf(" Binary Object Store (BOS):\n");
printf(" wTotalLength: %u\n", bos->wTotalLength);
printf(" bNumDeviceCaps: %u\n", bos->bNumDeviceCaps);
if (ret < 0)
{
return;
}
for (i = 0; i < bos->bNumDeviceCaps; i++) {
struct libusb_bos_dev_capability_descriptor *dev_cap = bos->dev_capability[i];
printf(" Binary Object Store (BOS):\n");
printf(" wTotalLength: %u\n", bos->wTotalLength);
printf(" bNumDeviceCaps: %u\n", bos->bNumDeviceCaps);
if (dev_cap->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION) {
struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension;
for (i = 0; i < bos->bNumDeviceCaps; i++)
{
struct libusb_bos_dev_capability_descriptor *dev_cap = bos->dev_capability[i];
ret = libusb_get_usb_2_0_extension_descriptor(NULL, dev_cap, &usb_2_0_extension);
if (ret < 0)
return;
if (dev_cap->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION)
{
struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension;
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) {
struct libusb_ss_usb_device_capability_descriptor *ss_dev_cap;
ret = libusb_get_usb_2_0_extension_descriptor(NULL, dev_cap,
&usb_2_0_extension);
ret = libusb_get_ss_usb_device_capability_descriptor(NULL, dev_cap, &ss_dev_cap);
if (ret < 0)
return;
if (ret < 0)
{
return;
}
print_ss_usb_cap(ss_dev_cap);
libusb_free_ss_usb_device_capability_descriptor(ss_dev_cap);
}
}
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)
{
struct libusb_ss_usb_device_capability_descriptor *ss_dev_cap;
libusb_free_bos_descriptor(bos);
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);
}
}
libusb_free_bos_descriptor(bos);
}
static void print_interface(const struct libusb_interface *interface)
{
int i;
int i;
for (i = 0; i < interface->num_altsetting; i++)
print_altsetting(&interface->altsetting[i]);
for (i = 0; i < interface->num_altsetting; i++)
{
print_altsetting(&interface->altsetting[i]);
}
}
static void print_configuration(struct libusb_config_descriptor *config)
{
uint8_t i;
uint8_t i;
printf(" Configuration:\n");
printf(" wTotalLength: %u\n", config->wTotalLength);
printf(" bNumInterfaces: %u\n", config->bNumInterfaces);
printf(" bConfigurationValue: %u\n", config->bConfigurationValue);
printf(" iConfiguration: %u\n", config->iConfiguration);
printf(" bmAttributes: %02xh\n", config->bmAttributes);
printf(" MaxPower: %u\n", config->MaxPower);
printf(" Configuration:\n");
printf(" wTotalLength: %u\n", config->wTotalLength);
printf(" bNumInterfaces: %u\n", config->bNumInterfaces);
printf(" bConfigurationValue: %u\n", config->bConfigurationValue);
printf(" iConfiguration: %u\n", config->iConfiguration);
printf(" bmAttributes: %02xh\n", config->bmAttributes);
printf(" MaxPower: %u\n", config->MaxPower);
for (i = 0; i < config->bNumInterfaces; i++)
print_interface(&config->interface[i]);
for (i = 0; i < config->bNumInterfaces; i++)
{
print_interface(&config->interface[i]);
}
}
static void print_device(libusb_device *dev, libusb_device_handle *handle)
{
struct libusb_device_descriptor desc;
unsigned char string[256];
const char *speed;
int ret;
uint8_t i;
struct libusb_device_descriptor desc;
unsigned char string[256];
const char *speed;
int ret;
uint8_t i;
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";
}
switch (libusb_get_device_speed(dev))
{
case LIBUSB_SPEED_LOW: speed = "1.5M"; break;
ret = libusb_get_device_descriptor(dev, &desc);
if (ret < 0) {
fprintf(stderr, "failed to get device descriptor");
return;
}
case LIBUSB_SPEED_FULL: speed = "12M"; break;
printf("Dev (bus %u, device %u): %04X - %04X speed: %s\n",
libusb_get_bus_number(dev), libusb_get_device_address(dev),
desc.idVendor, desc.idProduct, speed);
case LIBUSB_SPEED_HIGH: speed = "480M"; break;
if (!handle)
libusb_open(dev, &handle);
case LIBUSB_SPEED_SUPER: speed = "5G"; break;
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);
}
case LIBUSB_SPEED_SUPER_PLUS: speed = "10G"; break;
if (desc.iProduct) {
ret = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, sizeof(string));
if (ret > 0)
printf(" Product: %s\n", (char *)string);
}
default: speed = "Unknown";
}
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);
}
}
ret = libusb_get_device_descriptor(dev, &desc);
if (verbose) {
for (i = 0; i < desc.bNumConfigurations; i++) {
struct libusb_config_descriptor *config;
if (ret < 0)
{
fprintf(stderr, "failed to get device descriptor");
return;
}
ret = libusb_get_config_descriptor(dev, i, &config);
if (LIBUSB_SUCCESS != ret) {
printf(" Couldn't retrieve descriptors\n");
continue;
}
printf("Dev (bus %u, device %u): %04X - %04X speed: %s\n",
libusb_get_bus_number(dev), libusb_get_device_address(dev),
desc.idVendor, desc.idProduct, speed);
print_configuration(config);
if (!handle)
{
libusb_open(dev, &handle);
}
libusb_free_config_descriptor(config);
}
if (handle)
{
if (desc.iManufacturer)
{
ret = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string,
sizeof(string));
if (handle && desc.bcdUSB >= 0x0201)
print_bos(handle);
}
if (ret > 0)
{
printf(" Manufacturer: %s\n", (char *)string);
}
}
if (handle)
libusb_close(handle);
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++)
{
struct libusb_config_descriptor *config;
ret = libusb_get_config_descriptor(dev, i, &config);
if (LIBUSB_SUCCESS != ret)
{
printf(" Couldn't retrieve descriptors\n");
continue;
}
print_configuration(config);
libusb_free_config_descriptor(config);
}
if (handle && desc.bcdUSB >= 0x0201)
{
print_bos(handle);
}
}
if (handle)
{
libusb_close(handle);
}
}
#if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000107)
@ -250,73 +315,95 @@ static void print_device(libusb_device *dev, libusb_device_handle *handle)
static int test_wrapped_device(const char *device_name)
{
libusb_device_handle *handle;
int r, fd;
libusb_device_handle *handle;
int r, fd;
fd = open(device_name, O_RDWR);
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) {
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;
fd = open(device_name, O_RDWR);
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)
{
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;
}
#else
#warning LIBUSB-1.0.23 will be required in Hamlib > 4.3
static int test_wrapped_device(const char *device_name)
{
(void)device_name;
printf("Testing wrapped devices is not supported on your platform\n");
return 1;
(void)device_name;
printf("Testing wrapped devices is not supported on your platform\n");
return 1;
}
#endif
int main(int argc, char *argv[])
{
const char *device_name = NULL;
libusb_device **devs;
ssize_t cnt;
int r, i;
const char *device_name = NULL;
libusb_device **devs;
ssize_t cnt;
int r, i;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-v")) {
verbose = 1;
} else if (!strcmp(argv[i], "-d") && (i + 1) < argc) {
i++;
device_name = argv[i];
} 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;
}
}
for (i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "-v"))
{
verbose = 1;
}
else if (!strcmp(argv[i], "-d") && (i + 1) < argc)
{
i++;
device_name = argv[i];
}
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;
}
}
r = libusb_init(NULL);
if (r < 0)
return r;
r = libusb_init(NULL);
if (device_name) {
r = test_wrapped_device(device_name);
} else {
cnt = libusb_get_device_list(NULL, &devs);
if (cnt < 0) {
libusb_exit(NULL);
return 1;
}
if (r < 0)
{
return r;
}
for (i = 0; devs[i]; i++)
print_device(devs[i], NULL);
if (device_name)
{
r = test_wrapped_device(device_name);
}
else
{
cnt = libusb_get_device_list(NULL, &devs);
libusb_free_device_list(devs, 1);
}
if (cnt < 0)
{
libusb_exit(NULL);
return 1;
}
libusb_exit(NULL);
return r;
for (i = 0; devs[i]; i++)
{
print_device(devs[i], NULL);
}
libusb_free_device_list(devs, 1);
}
libusb_exit(NULL);
return r;
}

View File

@ -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 */