Merge remote-tracking branch 'Hamlib/master'

merge latest upstream
This commit is contained in:
Malcolm Herring 2020-01-04 06:00:03 +00:00
commit 4975150611
160 changed files with 2517 additions and 6840 deletions

View File

@ -21,7 +21,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
@ -49,23 +48,6 @@
#include "register.h"
#include "num_stdio.h"
/* HAVE_SSLEEP is defined when Windows Sleep is found
* HAVE_SLEEP is defined when POSIX sleep is found
* _WIN32 is defined when compiling with MinGW
*
* When cross-compiling from POSIX to Windows using MinGW, HAVE_SLEEP
* will often be defined by configure although it is not supported by
* MinGW. So substitute the sleep definition below in such a case and
* when compiling on Windows using MinGW where HAVE_SLEEP will be
* undefined.
*
* FIXME: Needs better handling for all versions of MinGW.
*
*/
#if (defined(HAVE_SSLEEP) || defined(_WIN32)) && (!defined(HAVE_SLEEP))
# include "hl_sleep.h"
#endif
// ---------------------------------------------------------------------------
// ADAT INCLUDES
// ---------------------------------------------------------------------------
@ -2590,6 +2572,11 @@ int adat_transaction(RIG *pRig,
nRC = adat_receive(pRig, acBuf);
}
if (pPriv->pcResult != NULL)
{
free(pPriv->pcResult);
}
pPriv->pcResult = strdup(acBuf);
}
}
@ -3145,7 +3132,7 @@ int adat_set_mode(RIG *pRig, vfo_t vfo, rmode_t mode, pbwidth_t width)
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
pPriv->nRIGMode = mode;
nRC = adat_vfo_rnr2anr(vfo, &(pPriv->nCurrentVFO));
adat_vfo_rnr2anr(vfo, &(pPriv->nCurrentVFO));
if (width != RIG_PASSBAND_NOCHANGE)
{
@ -3533,6 +3520,7 @@ int adat_set_conf(RIG *pRig, token_t token, const char *val)
switch (token)
{
case TOKEN_ADAT_PRODUCT_NAME:
if (pPriv->pcProductName != NULL) free(pPriv->pcProductName);
pPriv->pcProductName = strdup(val);
break;

View File

@ -815,6 +815,7 @@ int alinco_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
return alinco_transaction(rig, cmdbuf, cmd_len, NULL, NULL);
case RIG_LEVEL_CWPITCH:
lvl = 4;
if (val.i < 426)
{
lvl = 5;
@ -867,10 +868,6 @@ int alinco_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
lvl = 4;
}
else
{
lvl = 4;
}
cmd_len = sprintf(cmdbuf, AL CMD_SDATA "M%02d" EOM, lvl);

View File

@ -100,6 +100,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
int err;
int len = 0;
char responsebuf[KPABUFSZ];
int loop;
rig_debug(RIG_DEBUG_VERBOSE, "%s called, cmd=%s\n", __func__, cmd);
@ -109,12 +110,12 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
rs = &amp->state;
int loop = 3;
loop = 3;
do // wake up the amp by sending ; until we receive ;
{
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
char c = ';';
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
err = write_block(&rs->ampport, &c, 1);
if (err != RIG_OK) { return err; }
@ -133,7 +134,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
if (response) // if response expected get it
{
responsebuf[0] = 0;
int len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1);
len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1);
if (len < 0)
{
@ -151,13 +152,13 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
do
{
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
char c = ';';
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
err = write_block(&rs->ampport, &c, 1);
if (err != RIG_OK) { return err; }
int len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1);
len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1);
if (len < 0) { return len; }
}
@ -187,17 +188,19 @@ const char *kpa_get_info(AMP *amp)
int kpa_get_freq(AMP *amp, freq_t *freq)
{
char responsebuf[KPABUFSZ];
int retval;
unsigned long tfreq;
int nargs;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!amp) { return -RIG_EINVAL; }
int retval = kpa_transaction(amp, "^FR;", responsebuf, sizeof(responsebuf));
retval = kpa_transaction(amp, "^FR;", responsebuf, sizeof(responsebuf));
if (retval != RIG_OK) { return retval; }
unsigned long tfreq;
int nargs = sscanf(responsebuf, "^FR%lu", &tfreq);
nargs = sscanf(responsebuf, "^FR%lu", &tfreq);
if (nargs != 1)
{
@ -213,19 +216,21 @@ int kpa_get_freq(AMP *amp, freq_t *freq)
int kpa_set_freq(AMP *amp, freq_t freq)
{
char responsebuf[KPABUFSZ];
int retval;
unsigned long tfreq;
int nargs;
char cmd[KPABUFSZ];
rig_debug(RIG_DEBUG_VERBOSE, "%s called, freq=%"PRIfreq"\n", __func__, freq);
if (!amp) { return -RIG_EINVAL; }
char cmd[KPABUFSZ];
sprintf(cmd, "^FR%05ld;", (long)freq / 1000);
int retval = kpa_transaction(amp, cmd, NULL, 0);
retval = kpa_transaction(amp, cmd, NULL, 0);
if (retval != RIG_OK) { return retval; }
unsigned long tfreq;
int nargs = sscanf(responsebuf, "^FR%lu", &tfreq);
nargs = sscanf(responsebuf, "^FR%lu", &tfreq);
if (nargs != 1)
{
@ -249,19 +254,31 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
{
char responsebuf[KPABUFSZ];
char *cmd;
int retval;
int fault;
int i;
int nargs;
int antenna;
int pwrpeak;
int pwrref;
int pwrfwd;
int pwrinput;
float float_value = 0;
int int_value = 0, int_value2 = 0;
struct amp_state *rs = &amp->state;
struct kpa_priv_data *priv = amp->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!amp) { return -RIG_EINVAL; }
// get the current antenna selected
cmd = "^AE;";
int retval = kpa_transaction(amp, cmd, responsebuf, sizeof(responsebuf));
retval = kpa_transaction(amp, cmd, responsebuf, sizeof(responsebuf));
if (retval != RIG_OK) { return retval; }
int antenna = 0;
int nargs = sscanf(responsebuf, "^AE%d", &antenna);
antenna = 0;
nargs = sscanf(responsebuf, "^AE%d", &antenna);
if (nargs != 1)
{
@ -312,10 +329,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
if (retval != RIG_OK) { return retval; }
float float_value = 0;
int int_value = 0, int_value2 = 0;
struct amp_state *rs = &amp->state;
switch (level)
{
case AMP_LEVEL_SWR:
@ -381,7 +394,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_PWR_INPUT:
cmd = "^PWI;";
int pwrinput;
nargs = sscanf(responsebuf, "^SW%d", &pwrinput);
if (nargs != 1)
@ -398,7 +410,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_PWR_FWD:
cmd = "^PWF;";
int pwrfwd;
nargs = sscanf(responsebuf, "^SW%d", &pwrfwd);
if (nargs != 1)
@ -415,7 +426,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_PWR_REFLECTED:
cmd = "^PWR;";
int pwrref;
nargs = sscanf(responsebuf, "^SW%d", &pwrref);
if (nargs != 1)
@ -432,7 +442,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_PWR_PEAK:
cmd = "^PWK;";
int pwrpeak;
nargs = sscanf(responsebuf, "^SW%d", &pwrpeak);
if (nargs != 1)
@ -449,7 +458,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_FAULT:
cmd = "^SF;";
int fault;
nargs = sscanf(responsebuf, "^SW%d", &fault);
if (nargs != 1)
@ -459,8 +467,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
return -RIG_EPROTO;
}
int i;
for (i = 0; kpa_fault_list[i].errmsg != NULL; ++i)
{
if (kpa_fault_list[i].code == fault)
@ -471,7 +477,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
}
rig_debug(RIG_DEBUG_ERR, "%s unknown fault from %s\n", __func__, responsebuf);
struct kpa_priv_data *priv = amp->state.priv;
sprintf(priv->tmpbuf, "Unknown fault code=0x%02x", fault);
val->s = priv->tmpbuf;
return RIG_OK;
@ -490,6 +495,11 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
int kpa_get_powerstat(AMP *amp, powerstat_t *status)
{
char responsebuf[KPABUFSZ];
int retval;
int operate;
int ampon;
int nargs = sscanf(responsebuf, "^ON%d", &ampon);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -497,13 +507,10 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status)
if (!amp) { return -RIG_EINVAL; }
int retval = kpa_transaction(amp, "^ON;", responsebuf, sizeof(responsebuf));
retval = kpa_transaction(amp, "^ON;", responsebuf, sizeof(responsebuf));
if (retval != RIG_OK) { return retval; }
int ampon;
int nargs = sscanf(responsebuf, "^ON%d", &ampon);
if (nargs != 1)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s Error: ^ON response='%s'\n", __func__,
@ -527,7 +534,6 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status)
if (retval != RIG_OK) { return retval; }
int operate;
nargs = sscanf(responsebuf, "^ON%d", &operate);
if (nargs != 1)
@ -544,12 +550,13 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status)
int kpa_set_powerstat(AMP *amp, powerstat_t status)
{
int retval;
char *cmd = NULL;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!amp) { return -RIG_EINVAL; }
char *cmd = NULL;
switch (status)
{
case RIG_POWER_UNKNOWN: break;
@ -568,7 +575,7 @@ int kpa_set_powerstat(AMP *amp, powerstat_t status)
}
int retval = kpa_transaction(amp, cmd, NULL, 0);
retval = kpa_transaction(amp, cmd, NULL, 0);
if (retval != RIG_OK) { return retval; }
@ -577,10 +584,12 @@ int kpa_set_powerstat(AMP *amp, powerstat_t status)
int kpa_reset(AMP *amp, amp_reset_t reset)
{
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// toggling from standby to operate supposed to reset
int retval = kpa_set_powerstat(amp, RIG_POWER_STANDBY);
retval = kpa_set_powerstat(amp, RIG_POWER_STANDBY);
if (retval != RIG_OK)
{

View File

@ -47,7 +47,7 @@ struct kpa_priv_data
int kpa_init(AMP *amp);
int kpa_reset(AMP *amp, amp_reset_t reset);
int kpa_flush_buffer(AMP *amp);
int kpa_transaction(AMP *amp, const char *cmd, char *reponse, int reponse_len);
int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len);
const char *kpa_get_info (AMP *amp);
int kpa_get_freq (AMP *amp, freq_t *freq);
int kpa_set_freq (AMP *amp, freq_t freq);

View File

@ -70,13 +70,18 @@ char *getlibpath(void)
return libpath;
}
#ifdef XXREMOVEDXX
// Not referenced anywhere
int lt_dlinit(void)
{
// __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "lt_dlinit");
return 0;
}
#endif
// not called from hamlib
#ifdef XXREMOVEDXX
// Not referenced anywhere
int lt_dlexit(void)
{
// __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "lt_dlexit");
@ -89,12 +94,15 @@ int lt_dlexit(void)
return 0;
}
#endif
#ifdef XXREMOVEDXX
int lt_dladdsearchdir(const char *search_dir)
{
// __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "lt_dladdsearchdir");
return 0;
}
#endif
lt_dlhandle adlopen(const char *filename)
{
@ -119,34 +127,49 @@ lt_dlhandle adlopen(const char *filename)
return ret;
}
#ifdef XXREMOVEDXX
// Not referenced anywhere
lt_dlhandle lt_dlopen(const char *filename)
{
// __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "lt_dlopen(%s)", filename);
return adlopen(filename);
}
#endif
#ifdef XXREMOVEDXX
// Not referenced anywhere
lt_dlhandle lt_dlopenext(const char *filename)
{
// __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "lt_dlopenext(%s)", filename);
return adlopen(filename);
}
#endif
#ifdef XXREMOVEDXX
// Not referenced anywhere
int lt_dlclose(lt_dlhandle handle)
{
// __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "lt_dlclose");
return dlclose(handle);
}
#endif
#ifdef XXREMOVEDXX
// Not referenced anywhere
void *lt_dlsym(lt_dlhandle handle, const char *name)
{
void *ret = dlsym(handle, name);
// __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "lt_dlsym(%s)=%p", name, ret);
return ret;
}
#endif
#ifdef XXREMOVEDXX
// Not referenced anywhere
const char *lt_dlerror(void)
{
const char *ret = dlerror();
// __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "lt_dlerror=%s", ret);
return ret;
}
#endif

View File

@ -1143,6 +1143,7 @@ static int parse_chan_line(RIG *rig, channel_t *chan, char *basep,
/* mode and width */
if (mem_caps->mode && mem_caps->width)
{
int retval;
char *tag2p;
tagp = strstr(basep, "MD");
@ -1161,7 +1162,7 @@ static int parse_chan_line(RIG *rig, channel_t *chan, char *basep,
tag2p = tagp;
}
int retval = priv->parse_aor_mode(rig, tagp[2], tag2p[2], &chan->mode,
retval = priv->parse_aor_mode(rig, tagp[2], tag2p[2], &chan->mode,
&chan->width);
if (retval != RIG_OK)
@ -1254,6 +1255,8 @@ int aor_get_channel(RIG *rig, channel_t *chan)
}
else
{
int mem_num;
char bank_base;
/*
* find mem_caps in caps, we'll need it later
@ -1280,8 +1283,7 @@ int aor_get_channel(RIG *rig, channel_t *chan)
* MW should be called the first time instead,
* and sizing memorized.
*/
int mem_num = channel_num % 100;
char bank_base;
mem_num = channel_num % 100;
if (mem_num >= 50 && priv->bank_base1 != priv->bank_base2)
{
bank_base = priv->bank_base2;

View File

@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -402,6 +401,7 @@ int ar3030_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
char *rfp;
int freq_len, retval;
char freqbuf[BUFSZ];
long lfreq;
/*
* D Rn Gn Bn Tn Fnnnnnnnn C
@ -422,7 +422,6 @@ int ar3030_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
return -RIG_EPROTO;
}
long lfreq;
sscanf(rfp + 1, "%ld", &lfreq);
*freq = lfreq;
rig_debug(RIG_DEBUG_ERR, "%s: read lfreq=%ld, freq=%.6f\n", __func__, lfreq,

View File

@ -268,6 +268,8 @@ static int ar7030p_init(RIG *rig)
}
else
{
int i;
rig->state.priv = (void *) priv;
rig->state.rigport.type.rig = RIG_PORT_SERIAL;
@ -279,8 +281,6 @@ static int ar7030p_init(RIG *rig)
memset(priv->mem, 0, sizeof(priv->mem));
int i;
for (i = 0; i < NB_CHAN; i++)
{
priv->mem[ i ].channel_num = i;
@ -377,11 +377,11 @@ static int ar7030p_open(RIG *rig)
if (RIG_OK == rc)
{
int i;
/* Load calibration table */
rig->state.str_cal.size = rig->caps->str_cal.size;
int i;
for (i = 0; i < rig->state.str_cal.size; i++)
{
rc = readByte(rig, EEPROM1, SM_CAL + i, &v);
@ -514,6 +514,13 @@ static int ar7030p_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rc = -RIG_EINVAL;
}
// this RIG_OK check added to clear cppcheck warnings
// not sure if it's needed but seem like RIG_OK should be expected
// if this debug prints out when things are working need to reexamine
if (rc != RIG_OK) {
rig_debug(RIG_DEBUG_ERR, "%s: unexpected error?? %s\n", __func__, rigerror(rc));
}
rc = execRoutine(rig, SET_ALL);
if (rc == RIG_OK) { rc = lockRx(rig, LOCK_0); }
@ -564,6 +571,13 @@ static int ar7030p_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
break;
}
// this RIG_OK check added to clear cppcheck warnings
// not sure if it's needed but seem like RIG_OK should be expected
// if this debug prints out when things are working need to reexamine
if (rc != RIG_OK) {
rig_debug(RIG_DEBUG_ERR, "%s: unexpected error?? %s\n", __func__, rigerror(rc));
}
rc = lockRx(rig, LOCK_0);
}
@ -603,11 +617,11 @@ static int ar7030p_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
}
else
{
int i;
/* TODO - get filter BWs at startup */
ar_filter = (unsigned char) 6;
int i;
for (i = 1; i <= 6; i++)
{
if (width <= filterTab[ i ])
@ -631,6 +645,13 @@ static int ar7030p_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
}
}
// this RIG_OK check added to clear cppcheck warnings
// not sure if it's needed but seem like RIG_OK should be expected
// if this debug prints out when things are working need to reexamine
if (rc != RIG_OK) {
rig_debug(RIG_DEBUG_ERR, "%s: unexpected error?? %s\n", __func__, rigerror(rc));
}
rc = lockRx(rig, LOCK_0);
}
@ -968,6 +989,13 @@ static int ar7030p_set_level(RIG *rig, vfo_t vfo, setting_t level,
break;
}
// this RIG_OK check added to clear cppcheck warnings
// not sure if it's needed but seem like RIG_OK should be expected
// if this debug prints out when things are working need to reexamine
if (rc != RIG_OK) {
rig_debug(RIG_DEBUG_ERR, "%s: unexpected error?? %s\n", __func__, rigerror(rc));
}
rc = lockRx(rig, LOCK_0);
}
@ -1632,6 +1660,8 @@ static int ar7030p_get_channel(RIG *rig, channel_t *chan)
if (RIG_OK == rc)
{
int i;
/* Squelch values */
/* TODO - fix magic numbers */
if (100 > ch)
@ -1704,8 +1734,6 @@ static int ar7030p_get_channel(RIG *rig, channel_t *chan)
/* Memory ID values */
p = (unsigned char *) chan->channel_desc;
int i;
for (i = 0; i < 14; i++)
{
if (176 > ch)

View File

@ -428,7 +428,7 @@ int execRoutine(RIG *rig, enum ROUTINE_e rtn)
*/
static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr)
{
int rc = RIG_OK;
int rc=RIG_OK;
unsigned char v;
assert(NULL != rig);
@ -458,14 +458,10 @@ static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr)
{
v = SRH((0x0f0 & addr) >> 4);
if (0 == write_block(&rig->state.rigport, (char *) &v, 1))
rc = write_block(&rig->state.rigport, (char *) &v, 1);
if (rc != RIG_OK)
{
rc = RIG_OK;
}
else
{
rc = -RIG_EIO;
return rc;
return -RIG_EIO;
}
v = ADR((0x00f & addr));
@ -528,7 +524,7 @@ static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr)
*/
int writeByte(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned char x)
{
int rc = -RIG_EIO;
int rc;
unsigned char hi = SRH((x & 0xf0) >> 4);
unsigned char lo = WRD(x & 0x0f);
@ -568,7 +564,7 @@ int writeByte(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned char x)
*/
int writeShort(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned short x)
{
int rc = -RIG_EIO;
int rc;
unsigned char v = (unsigned char)((x & 0xff00) >> 8);
rc = writeByte(rig, page, addr, v);
@ -595,7 +591,7 @@ int writeShort(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned short x)
*/
int write3Bytes(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned int x)
{
int rc = -RIG_EIO;
int rc;
unsigned char v = (unsigned char)((x & 0xff0000) >> 16);
rc = writeByte(rig, page, addr, v);
@ -630,7 +626,7 @@ int write3Bytes(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned int x)
*/
int writeInt(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned int x)
{
int rc = -RIG_EIO;
int rc;
unsigned char v = (unsigned char)((x & 0xff000000) >> 24);
rc = writeByte(rig, page, addr, v);
@ -836,7 +832,7 @@ int readInt(RIG *rig, enum PAGE_e page, unsigned int addr, unsigned int *x)
*/
int readSignal(RIG *rig, unsigned char *x)
{
int rc = -RIG_EIO;
int rc;
assert(NULL != rig);
assert(NULL != x);
@ -1479,7 +1475,7 @@ int pageSize(const enum PAGE_e page)
*/
int sendIRCode(RIG *rig, enum IR_CODE_e code)
{
int rc = -RIG_EIO;
int rc;
unsigned char v = (unsigned char) code;
assert(NULL != rig);

View File

@ -343,6 +343,7 @@ int sr2200_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
char freqbuf[BUFSZ], ackbuf[BUFSZ], *rfp;
int freq_len, ret_freq_len;
int retval;
ret_freq_len = BUFSZ;
@ -367,7 +368,7 @@ int sr2200_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
strcpy(freqbuf + freq_len, EOM);
freq_len += strlen(EOM);
int retval = sr2200_transaction(rig, freqbuf, freq_len, ackbuf, &ret_freq_len);
retval = sr2200_transaction(rig, freqbuf, freq_len, ackbuf, &ret_freq_len);
if (retval != RIG_OK)
{
@ -728,6 +729,7 @@ int sr2200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
switch (level)
{
float tmp;
case RIG_LEVEL_STRENGTH:
if (ack_len < 7 || ackbuf[0] != 'L' || ackbuf[1] != 'B')
{
@ -802,7 +804,6 @@ int sr2200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return -RIG_EPROTO;
}
float tmp;
sscanf(ackbuf + 2, "%f", &tmp);
if (tmp != 0.0)

View File

@ -437,7 +437,7 @@ static void *handle_set_position(void *arg)
if (!priv->set_pos_active)
{
/* TODO: replace polling period by cond var */
usleep(100 * 1000);
usleep(100 * 1000 - 1);
continue;
}

View File

@ -60,7 +60,7 @@ static int barrett_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq);
static int barrett_set_split_vfo(RIG *rig, vfo_t rxvfo, split_t split,
vfo_t txvfo);
static int barrett_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
static int barrett_get_split_vfo(RIG *rig, vfo_t rxvfo, split_t *split,
vfo_t *txvfo);
static int barrett_get_level(RIG *rig, vfo_t vfo, setting_t level,
@ -221,11 +221,14 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
{
char cmd_buf[MAXCMDLEN];
int retval, cmd_len;
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s\n", __func__, cmd);
char *p;
char xon;
char xoff;
struct rig_state *rs = &rig->state;
struct barrett_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s\n", __func__, cmd);
cmd_len = snprintf(cmd_buf, sizeof(cmd_buf), "%s%s", cmd, EOM);
serial_flush(&rs->rigport);
@ -261,9 +264,9 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
rig_debug(RIG_DEBUG_VERBOSE, "%s: retval=%d\n", __func__, retval);
dump_hex((const unsigned char *)priv->ret_data, strlen(priv->ret_data));
char *p = priv->ret_data;
char xon = p[0];
char xoff = p[strlen(p) - 1];
p = priv->ret_data;
xon = p[0];
xoff = p[strlen(p) - 1];
if (xon == 0x13 && xoff == 0x11)
{
@ -288,6 +291,8 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
if (result != NULL)
{
int n = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s: setting result\n", __func__);
if (priv->ret_data[0] == 0x13) // we'll return from the 1st good char
@ -300,8 +305,6 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
}
// See how many CR's we have
int n = 0;
for (p = *result; *p; ++p)
{
if (*p == 0x0d)
@ -314,7 +317,8 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
// Several commands can return multiline strings and we'll leave them alone
if (n == 1)
{
strtok(*result, "\r");
char *dummy;
strtok_r(*result, "\r", &dummy);
}
dump_hex((const unsigned char *)*result, strlen(*result));
@ -334,21 +338,15 @@ int barrett_init(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s version %s\n", __func__,
rig->caps->version);
// cppcheck claims leak here but it's freed in cleanup
rig->state.priv = (struct barrett_priv_data *)calloc(1,
sizeof(struct barrett_priv_data));
if (!rig || !rig->caps)
{
return -RIG_EINVAL;
}
struct barrett_priv_data *priv = (struct barrett_priv_data *)calloc(1, sizeof(struct barrett_priv_data));
if (!priv)
if (!rig->state.priv)
{
return -RIG_ENOMEM;
}
rig->state.priv = (void *)priv;
return RIG_OK;
}
@ -386,12 +384,11 @@ int barrett_cleanup(RIG *rig)
int barrett_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int retval;
char *response = NULL;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
*freq = 0;
char *response = NULL;
if (vfo == RIG_VFO_B) // We treat the TX VFO as VFO_B and RX VFO as VFO_A
{
retval = barrett_transaction(rig, "IT", 0, &response);
@ -435,8 +432,8 @@ int barrett_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// If we are not explicity asking for VFO_B then we'll set the receive side also
if (vfo != RIG_VFO_B)
{
sprintf((char *) cmd_buf, "TR%08.0f", freq);
char *response = NULL;
sprintf((char *) cmd_buf, "TR%08.0f", freq);
retval = barrett_transaction(rig, cmd_buf, 0, &response);
if (retval < 0)
@ -457,8 +454,8 @@ int barrett_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|| vfo == RIG_VFO_B) // if we aren't in split mode we have to set the TX VFO too
{
sprintf((char *) cmd_buf, "TT%08.0f", freq);
char *response = NULL;
sprintf((char *) cmd_buf, "TT%08.0f", freq);
retval = barrett_transaction(rig, cmd_buf, 0, &response);
if (retval < 0)
@ -485,6 +482,7 @@ int barrett_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char cmd_buf[MAXCMDLEN];
char *response;
rig_debug(RIG_DEBUG_VERBOSE, "%s: ptt=%d\n", __func__, ptt);
@ -493,7 +491,7 @@ int barrett_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
// WSJT-X is just a little faster without the network timing
usleep(100 * 1000);
sprintf(cmd_buf, "XP%d", ptt);
char *response = NULL;
response = NULL;
retval = barrett_transaction(rig, cmd_buf, 0, &response);
if (retval < 0)
@ -522,6 +520,7 @@ int barrett_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
int retval;
char *response = NULL;
char c;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
@ -533,7 +532,7 @@ int barrett_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
return retval;
}
char c = response[0];
c = response[0];
if (c == '1' || c == '0')
{
@ -612,10 +611,12 @@ int barrett_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
*/
int barrett_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
char *result = NULL;
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
char *result = NULL;
int retval = barrett_transaction(rig, "IB", 0, &result);
retval = barrett_transaction(rig, "IB", 0, &result);
if (retval != RIG_OK)
{
@ -686,13 +687,14 @@ int barrett_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
{
// The 2050 only has one RX and one TX VFO -- it's not treated as VFOA/VFOB
char cmd_buf[MAXCMDLEN];
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s freq=%g\n", __func__,
rig_strvfo(vfo), tx_freq);
sprintf((char *) cmd_buf, "TT%08.0f" EOM, tx_freq);
int retval = barrett_transaction(rig, cmd_buf, 0, NULL);
retval = barrett_transaction(rig, cmd_buf, 0, NULL);
if (retval < 0)
{
@ -742,6 +744,9 @@ int barrett_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
switch (level)
{
int strength;
int n;
case RIG_LEVEL_STRENGTH:
retval = barrett_transaction(rig, "IAL", 0, &response);
@ -752,8 +757,7 @@ int barrett_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return retval;
}
int strength;
int n = sscanf(response, "%2d", &strength);
n = sscanf(response, "%2d", &strength);
if (n == 1)
{
@ -787,10 +791,11 @@ int barrett_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
const char *barrett_get_info(RIG *rig)
{
char *response = NULL;
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int retval = barrett_transaction(rig, "IVF", 0, &response);
retval = barrett_transaction(rig, "IVF", 0, &response);
if (retval == RIG_OK)
{

View File

@ -51,7 +51,7 @@ cnctrk_set_position(ROT *rot, azimuth_t az, elevation_t el)
}
sprintf(axcmd, "/usr/bin/axis-remote --mdi 'G00 X %6.2f Y %6.2f' \n", az, el);
return retval = system(axcmd);
return system(axcmd);
}

View File

@ -27,6 +27,8 @@ AC_CONFIG_HEADERS([include/config.h])
dnl Place build system provided programs in this directory.
AC_CONFIG_AUX_DIR([build-aux])
AC_USE_SYSTEM_EXTENSIONS
## ------------------------ ##
## Automake Initialisation. ##
@ -299,6 +301,7 @@ AS_CASE(["$host_os"],
dnl Check if C99 struct initializers are supported
AC_MSG_CHECKING([whether C99 struct/array initializers are supported])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
[[struct{char a;int b;}s[8]={[3]={.b=5}};]])],
[AC_MSG_RESULT(yes)],
@ -307,7 +310,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
"Have you considered GCC lately?."])
])
dnl Check for libusb, treat LIBUSB_LIBS and LIBUSB_CFLAGS as precious variables
AC_MSG_CHECKING([whether to build USB dependent backends])
AC_ARG_WITH([libusb],

View File

@ -1077,6 +1077,25 @@ option above, will terminate each command string sent to the radio. This
character should not be a part of the input string.
.
.TP
.BR W ", " send_cmd_rx " \(aq" \fICmd\fP \(aq
Send a raw command string to the radio and expect a number of bytes returned.
.IP
This is useful for testing and troubleshooting radio commands and responses when
developing a backend. If the # of bytes requested is <= the number actually returnead no timeout will occur.
.IP
The command argument can have no spaces in it.
For binary protocols enter values as \\0xAA\\0xBB. Expect a
.RI \(aq Reply \(aq
from the radio which will likely be a binary block or an ASCII string
depending on the radio's protocol (see your radio's computer control
documentation).
.IP
The command terminator, set by the
.B send-cmd-term
option above, will terminate each command string sent to the radio. This
character should not be a part of the input string.
.
.TP
.BR pause " \(aq" \fISeconds\fP \(aq
Pause for the given whole (integer) number of
.RI \(aq Seconds \(aq

View File

@ -137,10 +137,10 @@ static int dra818_setvolume(RIG *rig)
int dra818_init(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: dra818_init called\n", __func__);
struct dra818_priv *priv = calloc(sizeof(*priv), 1);
rig_debug(RIG_DEBUG_VERBOSE, "%s: dra818_init called\n", __func__);
if (!priv)
{
return -RIG_ENOMEM;
@ -285,13 +285,14 @@ int dra818_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
{
struct dra818_priv *priv = rig->state.priv;
char cmd[80];
char response[8];
int r;
sprintf(cmd, "S+%03d.%04d\r\n",
(int)(priv->rx_freq / 1000000), (int)((priv->rx_freq % 1000000) / 100));
write_block(&rig->state.rigport, cmd, strlen(cmd));
char response[8];
int r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1);
r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1);
if (r != 5)
{

View File

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -234,6 +234,9 @@ static int check_vfo(vfo_t vfo)
static char *xml_build(char *cmd, char *value, char *xmlbuf, int xmlbuflen)
{
char xml[4096]; // we shouldn't need more the 4096 bytes for this
char tmp[32];
char *header;
int n;
// We want at least a 4K buf to play with
if (xmlbuflen < 4096)
@ -242,10 +245,10 @@ static char *xml_build(char *cmd, char *value, char *xmlbuf, int xmlbuflen)
return NULL;
}
char *header =
header =
"POST /RPC2 HTTP/1.1\r\n" "User-Agent: XMLRPC++ 0.8\r\n"
"Host: 127.0.0.1:12345\r\n" "Content-type: text/xml\r\n";
int n = snprintf(xmlbuf, xmlbuflen, "%s", header);
n = snprintf(xmlbuf, xmlbuflen, "%s", header);
if (n != strlen(header))
{
@ -272,7 +275,6 @@ static char *xml_build(char *cmd, char *value, char *xmlbuf, int xmlbuflen)
strncat(xml, "</methodCall>\r\n", sizeof(xml) - 1);
strncat(xmlbuf, "Content-length: ", xmlbuflen - 1);
char tmp[32];
snprintf(tmp, sizeof(tmp), "%d\r\n\r\n", (int)strlen(xml));
strncat(xmlbuf, tmp, xmlbuflen - 1);
strncat(xmlbuf, xml, xmlbuflen - 1);
@ -347,6 +349,9 @@ static char *xml_parse2(char *xml, char *value, int valueLen)
*/
static char *xml_parse(char *xml, char *value, int value_len)
{
char *next;
char *pxml;
/* first off we should have an OK on the 1st line */
if (strstr(xml, " 200 OK") == NULL)
{
@ -356,14 +361,14 @@ static char *xml_parse(char *xml, char *value, int value_len)
rig_debug(RIG_DEBUG_TRACE, "%s XML:\n%s\n", __func__, xml);
// find the xml skipping the other stuff above it
char *pxml = strstr(xml, "<?xml");
pxml = strstr(xml, "<?xml");
if (pxml == NULL)
{
return NULL;
}
char *next = strchr(pxml + 1, '<');
next = strchr(pxml + 1, '<');
if (value != NULL)
{
@ -386,15 +391,17 @@ static char *xml_parse(char *xml, char *value, int value_len)
static int read_transaction(RIG *rig, char *xml, int xml_len)
{
int retval;
int retry;
char *delims;
char *terminator = "</methodResponse>";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct rig_state *rs = &rig->state;
rs->rigport.timeout = 1000; // 2 second read string timeout
int retry = 5;
char *delims = "\n";
retry = 5;
delims = "\n";
xml[0] = 0;
do
@ -491,11 +498,11 @@ static int write_transaction(RIG *rig, char *xml, int xml_len)
*/
static int flrig_init(RIG *rig)
{
struct flrig_priv_data *priv = (struct flrig_priv_data *)malloc(sizeof(
struct flrig_priv_data));
rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
struct flrig_priv_data *priv = (struct flrig_priv_data *)malloc(sizeof(
struct flrig_priv_data));
if (!priv)
{
@ -585,18 +592,21 @@ static rmode_t modeMapGetHamlib(const char *modeFLRig)
static void modeMapAdd(rmode_t *modes, rmode_t mode_hamlib, char *mode_flrig)
{
int i;
int len1;
rig_debug(RIG_DEBUG_TRACE, "%s:mode_flrig=%s\n", __func__, mode_flrig);
// if we already have it just return
// We get ERROR if the mode is not known so non-ERROR is OK
if (modeMapGetHamlib(mode_flrig) != RIG_MODE_NONE) { return; }
int len1 = strlen(mode_flrig) + 3; /* bytes needed for allocating */
len1 = strlen(mode_flrig) + 3; /* bytes needed for allocating */
for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
{
if (modeMap[i].mode_hamlib == mode_hamlib)
{
int len2;
*modes |= modeMap[i].mode_hamlib;
/* we will pipe delimit all the entries for easier matching */
@ -613,7 +623,7 @@ static void modeMapAdd(rmode_t *modes, rmode_t mode_hamlib, char *mode_flrig)
}
}
int len2 = strlen(modeMap[i].mode_flrig); /* current len w/o null */
len2 = strlen(modeMap[i].mode_flrig); /* current len w/o null */
modeMap[i].mode_flrig = realloc(modeMap[i].mode_flrig,
strlen(modeMap[i].mode_flrig) + len1);
@ -636,13 +646,16 @@ static int flrig_open(RIG *rig)
{
int retval;
char xml[MAXXMLLEN];
char *pxml;
char value[MAXXMLLEN];
rmode_t modes;
char *p;
char *pr;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char *pxml = xml_build("rig.get_xcvr", NULL, xml, sizeof(xml));
pxml = xml_build("rig.get_xcvr", NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -658,6 +671,9 @@ static int flrig_open(RIG *rig)
/* see if get_modeA is available */
pxml = xml_build("rig.get_modeA", NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval != RIG_OK) { return retval; }
read_transaction(rig, xml, sizeof(xml));
xml_parse(xml, value, sizeof(value));
@ -727,9 +743,8 @@ static int flrig_open(RIG *rig)
read_transaction(rig, xml, sizeof(xml));
xml_parse(xml, value, sizeof(value));
rig_debug(RIG_DEBUG_TRACE, "%s: modes=%s\n", __func__, value);
rmode_t modes = 0;
char *p;
char *pr = value;
modes = 0;
pr = value;
/* The following modes in FLRig are not implemented yet
A1A
@ -831,10 +846,17 @@ static int flrig_open(RIG *rig)
}
rig->state.mode_list = modes;
rig_debug(RIG_DEBUG_VERBOSE, "%s: hamlib modes=%s\n", __func__,
rig_strrmode(modes));
return RIG_OK;
retval = rig_strrmodes(modes, value, sizeof(value));
if (retval != RIG_OK) // we might get TRUNC but we can still print the debug
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: %s\n", __func__, rigerror(retval));
}
rig_debug(RIG_DEBUG_VERBOSE, "%s: hamlib modes=%s\n", __func__, value);
return retval;
}
/*
@ -877,10 +899,14 @@ static int flrig_cleanup(RIG *rig)
*/
static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int retries = 10;
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
@ -896,13 +922,10 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
__func__, rig_strvfo(vfo));
}
int retries = 10;
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
do
{
char *pxml;
int retval;
if (vfo == RIG_VFO_A)
{
@ -913,7 +936,7 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
pxml = xml_build("rig.get_vfoB", NULL, xml, sizeof(xml));
}
int retval = write_transaction(rig, pxml, strlen(pxml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
{
@ -963,12 +986,14 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
static int flrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int retval;
char value[MAXXMLLEN];
char xml[MAXXMLLEN];
char *pxml;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.0f\n", __func__,
rig_strvfo(vfo), freq);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -985,11 +1010,8 @@ static int flrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
vfo = RIG_VFO_B; // if split always TX on VFOB
}
char value[MAXXMLLEN];
sprintf(value,
"<params><param><value><double>%.0f</double></value></param></params>", freq);
char xml[MAXXMLLEN];
char *pxml;
if (vfo == RIG_VFO_B)
{
@ -1032,10 +1054,13 @@ static int flrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
static int flrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char xml[MAXXMLLEN];
char *pxml;
char cmd_buf[MAXCMDLEN];
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: ptt=%d\n", __func__, ptt);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
@ -1044,12 +1069,10 @@ static int flrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
return -RIG_EINVAL;
}
char cmd_buf[MAXCMDLEN];
sprintf(cmd_buf,
"<params><param><value><i4>%d</i4></value></param></params>",
ptt);
char xml[MAXXMLLEN];
char *pxml = xml_build("rig.set_ptt", cmd_buf, xml, sizeof(xml));
pxml = xml_build("rig.set_ptt", cmd_buf, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1071,14 +1094,16 @@ static int flrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
static int flrig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
int retval;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
char *pxml;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char xml[MAXXMLLEN];
char *pxml = xml_build("rig.get_ptt", NULL, xml, sizeof(xml));
pxml = xml_build("rig.get_ptt", NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
@ -1088,7 +1113,6 @@ static int flrig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
}
read_transaction(rig, xml, sizeof(xml));
char value[MAXCMDLEN];
xml_parse(xml, value, sizeof(value));
*ptt = atoi(value);
rig_debug(RIG_DEBUG_TRACE, "%s: '%s'\n", __func__, value);
@ -1106,11 +1130,11 @@ static int flrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode,
pbwidth_t width)
{
int retval;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
__func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
switch (vfo)
{
case RIG_VFO_CURR:
@ -1147,11 +1171,19 @@ static int flrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode,
static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
int retval;
int needBW;
int vfoSwitched;
char xml[MAXXMLLEN];
char *pxml = NULL;
char cmd_buf[MAXCMDLEN];
char *p;
char *pttmode;
char *ttmode;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
__func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
// if ptt is on do not set mode
if (priv->ptt)
@ -1181,7 +1213,7 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
// Switch to VFOB if appropriate since we can't set mode directly
// MDB
int vfoSwitched = 0;
vfoSwitched = 0;
rig_debug(RIG_DEBUG_TRACE, "%s: curr_vfo = %s\n", __func__,
rig_strvfo(priv->curr_vfo));
@ -1206,22 +1238,20 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
}
// Set the mode
char *ttmode = strdup(modeMapGetFLRig(mode));
ttmode = strdup(modeMapGetFLRig(mode));
rig_debug(RIG_DEBUG_TRACE, "%s: got ttmode = %s\n", __func__,
ttmode == NULL ? "NULL" : ttmode);
char *pttmode = ttmode;
pttmode = ttmode;
if (ttmode[0] == '|') { pttmode = &ttmode[1]; } // remove first pipe symbol
char *p = strchr(pttmode, '|');
p = strchr(pttmode, '|');
if (p) { *p = 0; } // remove any other pipe
char cmd_buf[MAXCMDLEN];
sprintf(cmd_buf, "<params><param><value>%s</value></param></params>", pttmode);
free(ttmode);
char xml[MAXXMLLEN];
char *pxml = NULL;
pxml = NULL;
if (!priv->has_get_modeA)
{
@ -1235,6 +1265,11 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
cmd = "rig.set_modeB";
}
else
{
// we make VFO_B mode unknown so it expires the cache
priv->curr_modeB = RIG_MODE_NONE;
}
pxml = xml_build(cmd, cmd_buf, xml, sizeof(xml));
}
@ -1253,7 +1288,7 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
rig_debug(RIG_DEBUG_TRACE, "%s: response=%s\n", __func__, xml);
// Determine if we need to update the bandwidth
int needBW = 0;
needBW = 0;
if (vfo == RIG_VFO_A)
{
@ -1336,12 +1371,17 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
int retval;
int vfoSwitched;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
char *pxml;
char *cmdp;
vfo_t curr_vfo;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -1349,7 +1389,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
return -RIG_EINVAL;
}
vfo_t curr_vfo = priv->curr_vfo;
curr_vfo = priv->curr_vfo;
if (vfo == RIG_VFO_CURR)
{
@ -1369,7 +1409,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
}
// Switch to VFOB if appropriate
int vfoSwitched = 0;
vfoSwitched = 0;
if (priv->has_get_modeA == 0 && vfo == RIG_VFO_B && curr_vfo != RIG_VFO_B)
{
@ -1388,8 +1428,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
}
}
char xml[MAXXMLLEN];
char *cmdp = "rig.get_mode"; /* default to old way */
cmdp = "rig.get_mode"; /* default to old way */
if (priv->has_get_modeA) /* change to new way if we can */
{
@ -1402,7 +1441,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
if (vfo == RIG_VFO_B) { cmdp = "rig.get_modeB"; }
}
char *pxml = xml_build(cmdp, NULL, xml, sizeof(xml));
pxml = xml_build(cmdp, NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1411,7 +1450,6 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
}
read_transaction(rig, xml, sizeof(xml));
char value[MAXCMDLEN];
xml_parse(xml, value, sizeof(value));
retval = modeMapGetHamlib(value);
@ -1502,12 +1540,15 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
static int flrig_set_vfo(RIG *rig, vfo_t vfo)
{
int retval;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
char *pxml;
struct rig_state *rs = &rig->state;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct rig_state *rs = &rig->state;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
@ -1527,11 +1568,9 @@ static int flrig_set_vfo(RIG *rig, vfo_t vfo)
vfo = priv->curr_vfo;
}
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
sprintf(value, "<params><param><value>%s</value></param></params>",
vfo == RIG_VFO_A ? "A" : "B");
char *pxml = xml_build("rig.set_AB", value, xml, sizeof(xml));
pxml = xml_build("rig.set_AB", value, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1570,13 +1609,15 @@ static int flrig_set_vfo(RIG *rig, vfo_t vfo)
static int flrig_get_vfo(RIG *rig, vfo_t *vfo)
{
int retval;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
char *pxml;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char xml[MAXXMLLEN];
char *pxml = xml_build("rig.get_AB", NULL, xml, sizeof(xml));
pxml = xml_build("rig.get_AB", NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1585,7 +1626,6 @@ static int flrig_get_vfo(RIG *rig, vfo_t *vfo)
}
read_transaction(rig, xml, sizeof(xml));
char value[MAXCMDLEN];
xml_parse(xml, value, sizeof(value));
rig_debug(RIG_DEBUG_TRACE, "%s: vfo value=%s\n", __func__, value);
@ -1626,12 +1666,15 @@ static int flrig_get_vfo(RIG *rig, vfo_t *vfo)
static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
{
int retval;
char xml[MAXXMLLEN];
char *pxml;
char value[MAXCMDLEN];
freq_t qtx_freq;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
rig_strvfo(vfo), tx_freq);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -1640,19 +1683,16 @@ static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
}
// we always split on VFOB so if no change just return
freq_t qtx_freq;
retval = flrig_get_freq(rig, RIG_VFO_B, &qtx_freq);
if (retval != RIG_OK) { return retval; }
if (tx_freq == qtx_freq) { return RIG_OK; }
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
sprintf(value,
"<params><param><value><double>%.6f</double></value></param></params>",
tx_freq);
char *pxml = xml_build("rig.set_vfoB", value, xml, sizeof(xml));
pxml = xml_build("rig.set_vfoB", value, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1673,12 +1713,13 @@ static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
*/
static int flrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
{
int retval;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
int retval = flrig_get_freq(rig, RIG_VFO_B, tx_freq);
retval = flrig_get_freq(rig, RIG_VFO_B, tx_freq);
priv->curr_freqB = *tx_freq;
return retval;
}
@ -1690,19 +1731,22 @@ static int flrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
{
int retval;
vfo_t qtx_vfo;
split_t qsplit;
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char *pxml;
rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo=%s\n", __func__,
rig_strvfo(tx_vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (tx_vfo == RIG_VFO_SUB || tx_vfo == RIG_VFO_TX)
{
tx_vfo = RIG_VFO_B;
}
vfo_t qtx_vfo;
split_t qsplit;
retval = flrig_get_split_vfo(rig, RIG_VFO_A, &qsplit, &qtx_vfo);
if (retval != RIG_OK) { return retval; }
@ -1715,11 +1759,9 @@ static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
return RIG_OK; // just return OK and ignore this
}
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
sprintf(value, "<params><param><value><i4>%d</i4></value></param></params>",
split);
char *pxml = xml_build("rig.set_split", value, xml, sizeof(xml));
pxml = xml_build("rig.set_split", value, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1742,12 +1784,14 @@ static int flrig_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
vfo_t *tx_vfo)
{
int retval;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char *pxml;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char xml[MAXXMLLEN];
char *pxml = xml_build("rig.get_split", NULL, xml, sizeof(xml));
pxml = xml_build("rig.get_split", NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1755,7 +1799,6 @@ static int flrig_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
return retval;
}
char value[MAXCMDLEN];
read_transaction(rig, xml, sizeof(xml));
xml_parse(xml, value, sizeof(value));
@ -1775,10 +1818,12 @@ static int flrig_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
rmode_t mode, pbwidth_t width)
{
int retval;
rmode_t qmode;
pbwidth_t qwidth;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX)
{
@ -1800,8 +1845,6 @@ static int flrig_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
}
// Make VFOB mode match VFOA mode, keep VFOB width
rmode_t qmode;
pbwidth_t qwidth;
retval = flrig_get_mode(rig, RIG_VFO_B, &qmode, &qwidth);
if (retval != RIG_OK) { return retval; }

View File

@ -28,7 +28,7 @@
#include <sys/time.h>
#endif
#define BACKEND_VER "1.11"
#define BACKEND_VER "1.12"
#define EOM "\r"
#define TRUE 1

View File

@ -106,6 +106,8 @@ static int netrigctl_transaction(RIG *rig, char *cmd, int len, char *buf)
*/
static int netrigctl_vfostr(RIG *rig, char *vfostr, int len, vfo_t vfo)
{
struct netrigctl_priv_data *priv;
if (len < 5)
{
rig_debug(RIG_DEBUG_ERR, "%s: len must be >=5, len=%d\n", __func__, len);
@ -114,7 +116,6 @@ static int netrigctl_vfostr(RIG *rig, char *vfostr, int len, vfo_t vfo)
vfostr[0] = 0;
struct netrigctl_priv_data *priv;
priv = (struct netrigctl_priv_data *)rig->state.priv;
if (vfo == RIG_VFO_CURR)
@ -132,13 +133,15 @@ static int netrigctl_vfostr(RIG *rig, char *vfostr, int len, vfo_t vfo)
static int netrigctl_init(RIG *rig)
{
// cppcheck says leak here but it's freed in cleanup
struct netrigctl_priv_data *priv = (struct netrigctl_priv_data *)malloc(sizeof(
struct netrigctl_priv_data));
if (!rig || !rig->caps)
{
return -RIG_EINVAL;
}
struct netrigctl_priv_data *priv = (struct netrigctl_priv_data *)malloc(sizeof(
struct netrigctl_priv_data));
if (!priv)
@ -177,11 +180,11 @@ static int netrigctl_open(RIG *rig)
int prot_ver;
char cmd[CMD_MAX];
char buf[BUF_MAX];
struct netrigctl_priv_data *priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct netrigctl_priv_data *priv;
priv = (struct netrigctl_priv_data *)rig->state.priv;
len = sprintf(cmd, "\\chk_vfo\n");
@ -519,10 +522,10 @@ static int netrigctl_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -546,10 +549,10 @@ static int netrigctl_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -575,10 +578,10 @@ static int netrigctl_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -605,10 +608,10 @@ static int netrigctl_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -644,10 +647,10 @@ static int netrigctl_set_vfo(RIG *rig, vfo_t vfo)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -672,13 +675,13 @@ static int netrigctl_get_vfo(RIG *rig, vfo_t *vfo)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
struct netrigctl_priv_data *priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct netrigctl_priv_data *priv;
priv = (struct netrigctl_priv_data *)rig->state.priv;
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -709,10 +712,10 @@ static int netrigctl_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -737,10 +740,10 @@ static int netrigctl_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -764,10 +767,10 @@ static int netrigctl_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -793,10 +796,10 @@ static int netrigctl_set_rptr_shift(RIG *rig, vfo_t vfo,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -822,10 +825,10 @@ static int netrigctl_get_rptr_shift(RIG *rig, vfo_t vfo,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -852,10 +855,10 @@ static int netrigctl_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -880,10 +883,10 @@ static int netrigctl_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -908,10 +911,10 @@ static int netrigctl_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -936,10 +939,10 @@ static int netrigctl_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -964,10 +967,10 @@ static int netrigctl_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -992,10 +995,10 @@ static int netrigctl_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1020,10 +1023,10 @@ static int netrigctl_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1048,10 +1051,10 @@ static int netrigctl_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1076,10 +1079,10 @@ static int netrigctl_set_dcs_sql(RIG *rig, vfo_t vfo, unsigned int code)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1103,10 +1106,10 @@ static int netrigctl_get_dcs_sql(RIG *rig, vfo_t vfo, unsigned int *code)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1131,10 +1134,10 @@ static int netrigctl_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1159,10 +1162,10 @@ static int netrigctl_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1187,10 +1190,10 @@ static int netrigctl_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1216,10 +1219,10 @@ static int netrigctl_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1255,10 +1258,10 @@ static int netrigctl_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1284,10 +1287,10 @@ static int netrigctl_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1323,10 +1326,10 @@ static int netrigctl_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1351,10 +1354,10 @@ static int netrigctl_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1379,10 +1382,10 @@ static int netrigctl_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1407,10 +1410,10 @@ static int netrigctl_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1435,10 +1438,10 @@ static int netrigctl_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1463,10 +1466,10 @@ static int netrigctl_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1491,10 +1494,10 @@ static int netrigctl_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1519,10 +1522,10 @@ static int netrigctl_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1549,6 +1552,7 @@ static int netrigctl_set_level(RIG *rig, vfo_t vfo, setting_t level,
char cmd[CMD_MAX];
char buf[BUF_MAX];
char lstr[32];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -1561,7 +1565,6 @@ static int netrigctl_set_level(RIG *rig, vfo_t vfo, setting_t level,
sprintf(lstr, "%d", val.i);
}
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1589,10 +1592,10 @@ static int netrigctl_get_level(RIG *rig, vfo_t vfo, setting_t level,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1733,10 +1736,10 @@ static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1761,10 +1764,10 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t *ant)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1812,10 +1815,10 @@ static int netrigctl_set_mem(RIG *rig, vfo_t vfo, int ch)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1840,10 +1843,10 @@ static int netrigctl_get_mem(RIG *rig, vfo_t vfo, int *ch)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }

View File

@ -236,13 +236,14 @@ static int vfo_curr(RIG *rig, vfo_t vfo)
*/
static int read_transaction(RIG *rig, char *response, int response_len)
{
struct rig_state *rs = &rig->state;
char *delims = "\n";
int len;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct rig_state *rs = &rig->state;
char *delims = "\n";
int len = read_string(&rs->rigport, response, response_len, delims,
strlen(delims));
len = read_string(&rs->rigport, response, response_len, delims,
strlen(delims));
if (len <= 0)
{
@ -259,12 +260,11 @@ static int read_transaction(RIG *rig, char *response, int response_len)
*/
static int trxmanager_init(RIG *rig)
{
rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)malloc(
sizeof(struct trxmanager_priv_data));
rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
if (!priv)
{
return -RIG_ENOMEM;
@ -297,14 +297,14 @@ static int trxmanager_init(RIG *rig)
static int trxmanager_open(RIG *rig)
{
int retval;
char *cmd;
char response[MAXCMDLEN] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s version %s\n", __func__, BACKEND_VER);
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s version %s\n", __func__, BACKEND_VER);
rs->rigport.timeout = 10000; // long timeout for antenna switching/tuning
retval = read_transaction(rig, response, sizeof(response));
@ -325,7 +325,7 @@ static int trxmanager_open(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s connected to %s\n", __func__, priv->info);
// Turn off active messages
char *cmd = "AI0;";
cmd = "AI0;";
retval = write_block(&rs->rigport, cmd, strlen(cmd));
if (retval < 0)
@ -404,14 +404,17 @@ static int trxmanager_cleanup(RIG *rig)
static int trxmanager_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
int n;
char vfoab;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -432,9 +435,7 @@ static int trxmanager_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
__func__, rig_strvfo(vfo));
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
char vfoab = vfo == RIG_VFO_A ? 'R' : 'T';
vfoab = vfo == RIG_VFO_A ? 'R' : 'T';
snprintf(cmd, sizeof(cmd), "X%c;", vfoab);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -451,7 +452,7 @@ static int trxmanager_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
}
*freq = 0;
int n = sscanf(&response[2], "%lg", freq);
n = sscanf(&response[2], "%lg", freq);
if (n != 1)
{
@ -474,14 +475,17 @@ static int trxmanager_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
static int trxmanager_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
rig_strvfo(vfo), freq);
char vfoab;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
rig_strvfo(vfo), freq);
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -501,9 +505,7 @@ static int trxmanager_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
vfo = RIG_VFO_B; // if split always TX on VFOB
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
char vfoab = vfo == RIG_VFO_A ? 'A' : 'B';
vfoab = vfo == RIG_VFO_A ? 'A' : 'B';
snprintf(cmd, sizeof(cmd), "F%c%011lu;", vfoab, (unsigned long)freq);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -530,11 +532,12 @@ static int trxmanager_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
static int trxmanager_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: ptt=%d\n", __func__, ptt);
struct rig_state *rs = &rig->state;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -542,9 +545,6 @@ static int trxmanager_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
return -RIG_EINVAL;
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "%s;", ptt == 1 ? "TX" : "RX");
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -576,14 +576,14 @@ static int trxmanager_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
static int trxmanager_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
int retval;
char cptt;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct rig_state *rs = &rig->state;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "IF;");
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -607,7 +607,7 @@ static int trxmanager_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
rig_debug(RIG_DEBUG_VERBOSE, "%s: IF response len=%d\n", __func__,
(int)strlen(response));
char cptt = response[28];
cptt = response[28];
*ptt = cptt == '0' ? 0 : 1;
return RIG_OK;
@ -635,12 +635,14 @@ static int trxmanager_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
pbwidth_t width)
{
int retval;
char ttmode;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
__func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
struct rig_state *rs = &rig->state;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -648,7 +650,7 @@ static int trxmanager_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
return -RIG_EINVAL;
}
char ttmode = FLRIG_MODE_USB;
ttmode = FLRIG_MODE_USB;
switch (mode)
{
@ -707,8 +709,6 @@ static int trxmanager_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "MD%c;", ttmode);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -740,14 +740,18 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
pbwidth_t *width)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
int n;
long iwidth = 0;
char tmode;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -768,8 +772,6 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
rig_debug(RIG_DEBUG_TRACE, "%s: using vfo=%s\n", __func__,
rig_strvfo(vfo));
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "MD;");
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -785,8 +787,7 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
rig_debug(RIG_DEBUG_ERR, "%s read_transaction failed\n", __func__);
}
char tmode;
int n = sscanf(response, "MD%c;", &tmode);
n = sscanf(response, "MD%c;", &tmode);
if (n != 1 || strlen(response) != 6)
{
@ -865,7 +866,6 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
return -RIG_EPROTO;
}
long iwidth = 0;
n = sscanf(response, "BW%ld;", &iwidth);
if (n != 1)
@ -883,14 +883,16 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
static int trxmanager_set_vfo(RIG *rig, vfo_t vfo)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -909,8 +911,6 @@ static int trxmanager_set_vfo(RIG *rig, vfo_t vfo)
vfo = priv->vfo_curr;
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "FN%d;", vfo == RIG_VFO_A ? 0 : 1);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -936,13 +936,14 @@ static int trxmanager_get_vfo(RIG *rig, vfo_t *vfo)
// TRXManager does not swap vfos
// So we maintain our own internal state during set_vfo
// This keeps the hamlib interface consistent with other rigs
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
char vfoab;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
char vfoab = priv->vfo_curr;
vfoab = priv->vfo_curr;
switch (vfoab)
{
@ -981,12 +982,13 @@ static int trxmanager_get_vfo(RIG *rig, vfo_t *vfo)
static int trxmanager_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
{
int retval;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
rig_strvfo(vfo), tx_freq);
struct rig_state *rs = &rig->state;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -994,8 +996,6 @@ static int trxmanager_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
return -RIG_EINVAL;
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "XT%011lu;", (unsigned long) tx_freq);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -1021,9 +1021,10 @@ static int trxmanager_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
*/
static int trxmanager_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
int retval = trxmanager_get_freq(rig, RIG_VFO_B, tx_freq);
retval = trxmanager_get_freq(rig, RIG_VFO_B, tx_freq);
return retval;
}
@ -1035,12 +1036,15 @@ static int trxmanager_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
vfo_t tx_vfo)
{
int retval;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
split_t tsplit;
vfo_t ttx_vfo;
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo=%s\n", __func__,
rig_strvfo(tx_vfo));
struct rig_state *rs = &rig->state;
if (tx_vfo == RIG_VFO_SUB || tx_vfo == RIG_VFO_TX)
{
tx_vfo = RIG_VFO_B;
@ -1056,8 +1060,6 @@ static int trxmanager_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
}
#endif
split_t tsplit;
vfo_t ttx_vfo;
retval = trxmanager_get_split_vfo(rig, vfo, &tsplit, &ttx_vfo);
if (retval < 0)
@ -1067,8 +1069,6 @@ static int trxmanager_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
if (tsplit == split) { return RIG_OK; } // don't need to change it
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "SP%c;", split ? '1' : '0');
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -1102,14 +1102,15 @@ static int trxmanager_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
vfo_t *tx_vfo)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
int tsplit = 0;
int n;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
snprintf(cmd, sizeof(cmd), "SP;");
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -1127,8 +1128,7 @@ static int trxmanager_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
}
*tx_vfo = RIG_VFO_B;
int tsplit = 0;
int n = sscanf(response, "SP%d", &tsplit);
n = sscanf(response, "SP%d", &tsplit);
if (n == 0)
{
@ -1149,13 +1149,14 @@ static int trxmanager_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
rmode_t mode, pbwidth_t width)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX)
{
return -RIG_ENTARGET;
@ -1163,8 +1164,6 @@ static int trxmanager_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
// assume split is on B
//
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "XT%011lu;", (unsigned long)freq);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -1182,8 +1181,9 @@ static int trxmanager_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
if (strlen(response) != 16 || strstr(response, cmd) == NULL)
{
FILE *fp;
rig_debug(RIG_DEBUG_ERR, "%s invalid response='%s'\n", __func__, response);
FILE *fp = fopen("debug.txt", "w+");
fp = fopen("debug.txt", "w+");
fprintf(fp, "XT response=%s\n", response);
fclose(fp);
return -RIG_EPROTO;

File diff suppressed because it is too large Load Diff

View File

@ -49,6 +49,7 @@ elad_fdm_duo_get_info(RIG *rig)
{
char firmbuf[50];
int retval;
size_t firm_len;
retval = elad_transaction(rig, "TY", firmbuf, sizeof(firmbuf));
@ -57,7 +58,7 @@ elad_fdm_duo_get_info(RIG *rig)
return NULL;
}
size_t firm_len = strlen(firmbuf);
firm_len = strlen(firmbuf);
if (firm_len != 5)
{

View File

@ -245,6 +245,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
char cmdbuf[BUFSZ + 1];
char respbuf[BUFSZ + 1];
char *p;
char *strip;
int cmd_len = 0;
unsigned csum = 0;
@ -321,7 +322,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
}
/* strip from *checksum and after */
char *strip = strrchr(respbuf, '*');
strip = strrchr(respbuf, '*');
if (strip)
{
@ -572,9 +573,11 @@ int icmarine_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
*/
int icmarine_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s:\n", __func__);
int retval = icmarine_transaction(rig, CMD_PTT,
retval = icmarine_transaction(rig, CMD_PTT,
ptt == RIG_PTT_ON ? "TX" : "RX", NULL);
if (retval != RIG_OK)

View File

@ -346,7 +346,7 @@ const struct rig_caps ic7300_caps =
.priv = (void *)& IC7300_priv_caps,
.rig_init = icom_init,
.rig_cleanup = icom_cleanup,
.rig_open = NULL,
.rig_open = icom_rig_open,
.rig_close = NULL,
.set_freq = icom_set_freq,

View File

@ -268,6 +268,7 @@ const struct rig_caps ic7410_caps =
.get_split_mode = icom_get_split_mode,
.set_split_vfo = icom_set_split_vfo,
.get_split_vfo = icom_mem_get_split_vfo,
.send_morse = icom_send_morse,
};

View File

@ -971,6 +971,9 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan)
/* do this only if not a blank channel */
if (chan_len != 1)
{
int band;
int sc;
unsigned char databuf[32];
membuf = (mem_buf_t *)(chanbuf + 4);
@ -991,14 +994,12 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan)
/* offset is default for the band & is not stored in channel memory.
The following retrieves the system default for the band */
int band = (int) chan->freq / 1000000; /* hf, 2m or 6 m */
band = (int) chan->freq / 1000000; /* hf, 2m or 6 m */
int sc;
if (band < 50) { sc = S_MEM_HF_DUP_OFST; }
else if (band < 108) { sc = S_MEM_6M_DUP_OFST; }
else { sc = S_MEM_2M_DUP_OFST; }
unsigned char databuf[32];
retval = icom_transaction(rig, C_CTL_MEM, sc,
NULL, 0, databuf, &data_len);

View File

@ -279,7 +279,7 @@ const struct rig_caps ic785x_caps =
.priv = (void *)& ic785x_priv_caps,
.rig_init = icom_init,
.rig_cleanup = icom_cleanup,
.rig_open = NULL,
.rig_open = icom_rig_open,
.rig_close = NULL,
.set_freq = icom_set_freq,

View File

@ -32,7 +32,7 @@
#define IC821H_MODES (RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_FM)
#define IC821H_VFO_ALL (RIG_VFO_A|RIG_VFO_C|RIG_VFO_MEM|RIG_VFO_MAIN|RIG_VFO_SUB)
#define IC821H_VFO_ALL (RIG_VFO_A|RIG_VFO_B|RIG_VFO_MEM|RIG_VFO_MAIN|RIG_VFO_SUB)
/* FIXME: What about MAIN/SUB mode? And satellite mode? */
#define IC821H_VFO_OPS (RIG_OP_FROM_VFO|RIG_OP_TO_VFO|RIG_OP_CPY|RIG_OP_MCL)
@ -59,9 +59,9 @@ const struct rig_caps ic821h_caps =
.rig_model = RIG_MODEL_IC821H,
.model_name = "IC-821H",
.mfg_name = "Icom",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_TRANSCEIVER,
.ptt_type = RIG_PTT_NONE,
.dcd_type = RIG_DCD_NONE,

View File

@ -280,6 +280,8 @@ const struct rig_caps ic9100_caps =
};
#ifdef XXREMOVEDXX
// Not referenced anywhere
int ic9100_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
unsigned char cmdbuf[MAXFRAMELEN];
@ -297,7 +299,10 @@ int ic9100_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
return icom_set_level(rig, vfo, level, val);
}
}
#endif
#ifdef XXREMOVEDXX
// Not referenced anywhere
int ic9100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
unsigned char cmdbuf[MAXFRAMELEN];
@ -315,3 +320,4 @@ int ic9100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return icom_get_level(rig, vfo, level, val);
}
}
#endif

View File

@ -538,10 +538,12 @@ int icom_init(RIG *rig)
struct icom_priv_data *priv;
const struct icom_priv_caps *priv_caps;
const struct rig_caps *caps;
int retval;
int satmode;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !rig->caps)
if (!rig->caps)
{
return -RIG_EINVAL;
}
@ -579,6 +581,15 @@ int icom_init(RIG *rig)
priv->tx_vfo = RIG_VFO_NONE;
priv->rx_vfo = RIG_VFO_NONE;
priv->curr_vfo = RIG_VFO_NONE;
retval = rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode);
rig_debug(RIG_DEBUG_VERBOSE, "%s: satmode=%d\n", __func__, satmode);
if (retval == RIG_OK && satmode)
{
priv->rx_vfo = RIG_VFO_MAIN;
priv->tx_vfo = RIG_VFO_SUB;
}
rig_debug(RIG_DEBUG_TRACE, "%s: done\n", __func__);
return RIG_OK;
@ -617,37 +628,57 @@ int icom_rig_open(RIG *rig)
unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf);
int retval = RIG_OK;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
freq_t freq;
struct rig_state *rs = &rig->state;
struct icom_priv_data *priv = (struct icom_priv_data *)rs->priv;
struct icom_priv_caps *priv_caps = (struct icom_priv_caps *) rig->caps->priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// if we can't get freq we may need to turn power on
retval = rig_get_freq(rig, RIG_VFO_CURR, &freq);
rig_debug(RIG_DEBUG_VERBOSE, "%s get_freq retval=%s\n", __func__,
rigerror(retval));
if (retval != RIG_OK) // maybe we need power on?
{
retval = rig_set_powerstat(rig, 1);
if (retval != RIG_OK) { rig_debug(RIG_DEBUG_WARN, "%s: unexpected retval here %s\n", __func__, rigerror(retval)); }
}
if (priv_caps->serial_USB_echo_check)
{
priv->serial_USB_echo_off = 0;
retval = icom_transaction(rig, C_RD_TRXID, 0x00, NULL, 0, ackbuf, &ack_len);
if (retval == RIG_OK)
{
priv->serial_USB_echo_off = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected\n", __func__);
return RIG_OK;
}
else
{
return retval;
}
priv->serial_USB_echo_off = 1;
retval = icom_transaction(rig, C_RD_TRXID, 0x00, NULL, 0, ackbuf, &ack_len);
if (retval == RIG_OK)
{
priv->serial_USB_echo_off = 1;
rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo off detected\n", __func__);
return RIG_OK;
}
else
{
return retval;
}
}
priv->serial_USB_echo_off = 0;
return retval;
return RIG_OK;
}
@ -661,6 +692,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
struct rig_state *rs;
unsigned char freqbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN];
int freq_len, ack_len = sizeof(ackbuf), retval;
int cmd, subcmd;
rig_debug(RIG_DEBUG_VERBOSE, "%s called %s=%"PRIfreq"\n", __func__,
rig_strvfo(vfo), freq);
@ -722,8 +754,8 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
*/
to_bcd(freqbuf, freq, freq_len * 2);
int cmd = C_SET_FREQ;
int subcmd = -1;
cmd = C_SET_FREQ;
subcmd = -1;
retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf,
&ack_len);
@ -753,14 +785,14 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
struct rig_state *rs;
unsigned char freqbuf[MAXFRAMELEN];
int freq_len, retval;
int cmd, subcmd;
rig_debug(RIG_DEBUG_VERBOSE, "%s called for %s\n", __func__, rig_strvfo(vfo));
rs = &rig->state;
priv = (struct icom_priv_data *)rs->priv;
// Newer Icoms can read main/sub frequency
int cmd = C_RD_FREQ;
int subcmd = -1;
cmd = C_RD_FREQ;
subcmd = -1;
// Pick the appropriate VFO when VFO_TX is requested
if (vfo == RIG_VFO_TX)
@ -779,6 +811,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
}
retval = set_vfo_curr(rig, vfo, priv->curr_vfo);
if (retval != RIG_OK) { return retval; }
// Pick the appropriate VFO when VFO_RX is requested
@ -1064,6 +1097,7 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width)
if (!rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_RF, &rfstatus) && (rfstatus))
{
int i;
for (i = 0; i < RTTY_FIL_NB; i++)
{
if (rtty_fil[i] == width)
@ -1485,6 +1519,8 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
{
unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf), icvfo, retval;
struct rig_state *rs = &rig->state;
struct icom_priv_data *priv = (struct icom_priv_data *)rs->priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -1493,10 +1529,6 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
return RIG_OK;
}
struct rig_state *rs = &rig->state;
struct icom_priv_data *priv = (struct icom_priv_data *)rs->priv;
if ((vfo == RIG_VFO_A || vfo == RIG_VFO_B) && !VFO_HAS_A_B)
{
rig_debug(RIG_DEBUG_ERR, "%s: Rig does not have VFO A/B?\n", __func__);
@ -1639,13 +1671,12 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
int lvl_cn, lvl_sc; /* Command Number, Subcommand */
int icom_val;
int i, retval;
const struct icom_priv_caps *priv_caps =
(const struct icom_priv_caps *) rig->caps->priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
const struct icom_priv_caps *priv_caps =
(const struct icom_priv_caps *) rig->caps->priv;
/*
* So far, levels of float type are in [0.0..1.0] range
*/
@ -1983,13 +2014,12 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
int icom_val;
int cmdhead;
int retval;
const struct icom_priv_caps *priv_caps =
(const struct icom_priv_caps *) rig->caps->priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
const struct icom_priv_caps *priv_caps =
(const struct icom_priv_caps *) rig->caps->priv;
lvl2_len = 0;
switch (level)
@ -2879,12 +2909,13 @@ int icom_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift)
*/
int icom_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
{
const struct icom_priv_caps *priv_caps;
priv_caps = (const struct icom_priv_caps *)rig->caps->priv;
int offs_len = (priv_caps->offs_len) ? priv_caps->offs_len : OFFS_LEN;
int offs_len;
unsigned char offsbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf), retval;
const struct icom_priv_caps *priv_caps;
priv_caps = (const struct icom_priv_caps *)rig->caps->priv;
offs_len = (priv_caps->offs_len) ? priv_caps->offs_len : OFFS_LEN;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/*
@ -2917,12 +2948,13 @@ int icom_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
*/
int icom_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
{
const struct icom_priv_caps *priv_caps;
priv_caps = (const struct icom_priv_caps *)rig->caps->priv;
int offs_len = (priv_caps->offs_len) ? priv_caps->offs_len : OFFS_LEN;
int offs_len;
unsigned char offsbuf[MAXFRAMELEN];
int buf_len, retval;
const struct icom_priv_caps *priv_caps;
priv_caps = (const struct icom_priv_caps *)rig->caps->priv;
offs_len = (priv_caps->offs_len) ? priv_caps->offs_len : OFFS_LEN;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = icom_transaction(rig, C_RD_OFFS, -1, NULL, 0,
@ -3326,9 +3358,13 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq,
}
}
rig_debug(RIG_DEBUG_VERBOSE,"%s: before get_split_vfos rx_vfo=%s tx_vfo=%s\n", __func__, rig_strvfo(priv->rx_vfo), rig_strvfo(priv->tx_vfo));
rig_debug(RIG_DEBUG_VERBOSE, "%s: before get_split_vfos rx_vfo=%s tx_vfo=%s\n",
__func__, rig_strvfo(priv->rx_vfo), rig_strvfo(priv->tx_vfo));
if (RIG_OK != (rc = icom_get_split_vfos(rig, &rx_vfo, &tx_vfo))) { return rc; }
rig_debug(RIG_DEBUG_VERBOSE,"%s: after get_split_vfos rx_vfo=%s tx_vfo=%s\n", __func__, rig_strvfo(priv->rx_vfo), rig_strvfo(priv->tx_vfo));
rig_debug(RIG_DEBUG_VERBOSE, "%s: after get_split_vfos rx_vfo=%s tx_vfo=%s\n",
__func__, rig_strvfo(priv->rx_vfo), rig_strvfo(priv->tx_vfo));
if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) { return rc; }
@ -3482,7 +3518,9 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
priv->rx_vfo = vfo;
priv->tx_vfo = tx_vfo;
priv->split_on = RIG_SPLIT_ON == split;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s rx_vfo=%s tx_vfo=%s split=%d\n", __func__, rig_strvfo(vfo), rig_strvfo(priv->rx_vfo), rig_strvfo(priv->tx_vfo), split);
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s rx_vfo=%s tx_vfo=%s split=%d\n",
__func__, rig_strvfo(vfo), rig_strvfo(priv->rx_vfo), rig_strvfo(priv->tx_vfo),
split);
return RIG_OK;
}
@ -3534,9 +3572,12 @@ int icom_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
rig_debug(RIG_DEBUG_ERR, "%s: unsupported split %d", __func__, splitbuf[1]);
return -RIG_EPROTO;
}
*tx_vfo = priv->tx_vfo;
priv->split_on = RIG_SPLIT_ON == *split;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s rx_vfo=%s tx_vfo=%s split=%d\n", __func__, rig_strvfo(vfo), rig_strvfo(priv->rx_vfo), rig_strvfo(priv->tx_vfo), *split);
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s rx_vfo=%s tx_vfo=%s split=%d\n",
__func__, rig_strvfo(vfo), rig_strvfo(priv->rx_vfo), rig_strvfo(priv->tx_vfo),
*split);
return RIG_OK;
}
@ -3817,11 +3858,16 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
case RIG_FUNC_DSQL:
fct_cn = C_CTL_FUNC;
fct_sc = S_FUNC_DSSQL;
if (status <= 2) {
if (status <= 2)
{
fctbuf[0] = status;
} else {
}
else
{
fctbuf[0] = 0;
}
break;
case RIG_FUNC_AFLT:
@ -4040,6 +4086,23 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
fct_sc = S_DUAL;
break;
case RIG_FUNC_SATMODE:
if (rig->caps->rig_model == RIG_MODEL_IC910)
{
// Is the 910 the only one that uses this command?
fct_cn = C_CTL_MEM;
fct_sc = S_MEM_SATMODE910;
}
else
{
fct_cn = C_CTL_FUNC;
fct_sc = S_MEM_SATMODE;
}
break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unsupported get_func %s\n", __func__,
rig_strfunc(func));
@ -4165,6 +4228,7 @@ int icom_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
if (caps->ctcss_list)
{
int i;
for (i = 0; caps->ctcss_list[i] != 0; i++)
{
if (caps->ctcss_list[i] == tone)
@ -4550,52 +4614,63 @@ int icom_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code)
int icom_set_powerstat(RIG *rig, powerstat_t status)
{
unsigned char ackbuf[200];
int ack_len = sizeof(ackbuf), retval;
int ack_len = sizeof(ackbuf), retval = RIG_OK;
int pwr_sc;
unsigned char fe_buf[200]; // for FE's to power up
int fe_len = 0;
// so we'll do up to 175 for 115,200
int fe_max = 175;
unsigned char fe_buf[fe_max]; // for FE's to power up
int i;
int retry;
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called status=%d\n", __func__, (int)status);
switch (status)
{
case RIG_POWER_ON:
pwr_sc = S_PWR_ON;
sleep(1); // let serial bus idle for a while
rig_debug(RIG_DEBUG_TRACE, "%s: PWR_ON failed, trying 0xfe's\n", __func__);
// ic7300 manual says ~150 for 115,200
// we'll just send 175 to be sure for all speeds
for (fe_len = 0; fe_len < 175; ++fe_len)
{
fe_buf[fe_len] = 0xfe;
}
// we'll just send a few more to be sure for all speeds
memset(fe_buf, 0xfe, fe_max);
// sending more than enough 0xfe's to wake up the rs232
retval = write_block(&rs->rigport, (char *) fe_buf, fe_max);
usleep(100 * 1000);
// we'll try 0x18 0x01 now -- should work on STBY rigs too
pwr_sc = S_PWR_ON;
fe_buf[0] = 0;
retry = rs->rigport.retry;
rs->rigport.retry = 0;
retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len);
rs->rigport.retry = retry;
break;
default:
pwr_sc = S_PWR_OFF;
fe_buf[0] = 0;
retry = rs->rigport.retry;
rs->rigport.retry = 0;
retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len);
rs->rigport.retry = retry;
}
// we can ignore this retval
// sending more than enough 0xfe's to wake up the rs232
icom_transaction(rig, 0xfe, 0xfe, fe_buf, fe_len, ackbuf, &ack_len);
retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len);
rig_debug(RIG_DEBUG_VERBOSE, "%s #2 called retval=%d\n", __func__, retval);
int i = 0;
int retry = 3 / rig->state.rigport.retry;
i = 0;
retry = 10;
if (status == RIG_POWER_ON) // wait for wakeup only
{
for (i = 0; i < retry; ++i) // up to 10 attempts
{
freq_t freq;
sleep(1);
freq_t freq = 0;
// Use get_freq as all rigs should repond to this
retval = rig_get_freq(rig, RIG_VFO_A, &freq);
retval = rig_get_freq(rig, RIG_VFO_CURR, &freq);
if (retval == RIG_OK) { return retval; }
else { rig_debug(RIG_DEBUG_TRACE, "%s: get_freq err=%s\n", __func__, rigerror(retval));}
rig_debug(RIG_DEBUG_TRACE, "%s: Wait %d of %d for get_powerstat\n", __func__,
i + 1, retry);
@ -4610,6 +4685,8 @@ int icom_set_powerstat(RIG *rig, powerstat_t status)
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_TRACE, "%s: retval != RIG_OK, =%s\n", __func__,
rigerror(retval));
return retval;
}
@ -4629,8 +4706,8 @@ int icom_set_powerstat(RIG *rig, powerstat_t status)
*/
int icom_get_powerstat(RIG *rig, powerstat_t *status)
{
unsigned char cmdbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN];
int cmd_len, ack_len = sizeof(ackbuf), retval;
unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -4639,7 +4716,8 @@ int icom_get_powerstat(RIG *rig, powerstat_t *status)
{
/* getting the mode doesn't work if a memory is blank */
/* so use one of the more innculous 'set mode' commands instead */
cmd_len = 1;
int cmd_len = 1;
unsigned char cmdbuf[MAXFRAMELEN];
cmdbuf[0] = S_PRM_TIME;
retval = icom_transaction(rig, C_CTL_MEM, S_MEM_MODE_SLCT,
cmdbuf, cmd_len, ackbuf, &ack_len);
@ -5028,9 +5106,10 @@ int icom_send_morse(RIG *rig, vfo_t vfo, const char *msg)
{
unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf), retval;
int len;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int len = strlen(msg);
len = strlen(msg);
if (len > 30) { len = 30; }
@ -5131,9 +5210,9 @@ int icom_decode_event(RIG *rig)
__func__);
}
if (frm_len < 0)
if (frm_len < 1)
{
return frm_len;
return 0;
}
switch (buf[frm_len - 1])
@ -5404,6 +5483,7 @@ int icom_get_custom_parm_time(RIG *rig, int parmbuflen, unsigned char *parmbuf,
unsigned char resbuf[MAXFRAMELEN];
int reslen = sizeof(resbuf);
int retval;
int hour, min;
retval = icom_get_raw_buf(rig, C_CTL_MEM, S_MEM_PARM, parmbuflen, parmbuf,
&reslen, resbuf);
@ -5413,8 +5493,8 @@ int icom_get_custom_parm_time(RIG *rig, int parmbuflen, unsigned char *parmbuf,
return retval;
}
int hour = from_bcd_be(resbuf, 2);
int min = from_bcd_be(resbuf + 1, 2);
hour = from_bcd_be(resbuf, 2);
min = from_bcd_be(resbuf + 1, 2);
*seconds = (hour * 3600) + (min * 60);
return RIG_OK;
@ -5423,8 +5503,8 @@ int icom_get_custom_parm_time(RIG *rig, int parmbuflen, unsigned char *parmbuf,
// Sets rig vfo && priv->curr_vfo to default VFOA, or current vfo, or the vfo requested
static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo)
{
struct icom_priv_data *priv = (struct icom_priv_data *)rig->state.priv;
int retval;
struct icom_priv_data *priv = (struct icom_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s, curr_vfo=%s\n", __func__,
rig_strvfo(vfo), rig_strvfo(curr_vfo));
@ -5461,9 +5541,10 @@ static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo)
rig_debug(RIG_DEBUG_TRACE, "%s: setting new vfo=%s\n", __func__,
rig_strvfo(vfo));
retval = rig_set_vfo(rig, vfo);
priv->curr_vfo = vfo;
if (retval != RIG_OK) { return retval; }
priv->curr_vfo = vfo;
}
return RIG_OK;

View File

@ -30,7 +30,7 @@
#include <sys/time.h>
#endif
#define BACKEND_VER "0.18"
#define BACKEND_VER "0.18a"
/*
* defines used by comp_cal_str in rig.c

View File

@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -28,7 +27,6 @@
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <math.h>
#include <sys/time.h>
#include "hamlib/rig.h"
#include "serial.h"
@ -502,6 +500,9 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
if (level != RIG_LEVEL_AF)
{
int lvl_cn, lvl_sc; /* Command Number, Subcommand */
unsigned char lvlbuf[MAXFRAMELEN];
int cmdhead;
switch (level)
{
case RIG_LEVEL_RAWSTR:
@ -514,7 +515,6 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return -RIG_EINVAL;
}
unsigned char lvlbuf[MAXFRAMELEN];
retval = icom_transaction(rig, lvl_cn, lvl_sc, NULL, 0,
lvlbuf, &lvl_len);
@ -526,7 +526,7 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
/*
* strbuf should contain Cn,Sc,Data area
*/
int cmdhead = (lvl_sc == -1) ? 1 : 2;
cmdhead = (lvl_sc == -1) ? 1 : 2;
lvl_len -= cmdhead;
if (lvlbuf[0] != ACK && lvlbuf[0] != lvl_cn)

View File

@ -1,4 +1,4 @@
noinst_HEADERS = config.h bandplan.h num_stdio.h hl_sleep.h
noinst_HEADERS = config.h bandplan.h num_stdio.h
nobase_include_HEADERS = hamlib/rig.h hamlib/riglist.h hamlib/rig_dll.h \
hamlib/rotator.h hamlib/rotlist.h hamlib/rigclass.h \

View File

@ -92,6 +92,26 @@
#define CONSTANT_64BIT_FLAG(BIT) (1ull << (BIT))
#endif
#include <time.h>
#undef sleep
#undef usleep
#define usleep(n)\
do {\
unsigned long sec = n/1000000ul;\
unsigned long nsec = n*1000ul - (sec * 1000000000ul);\
struct timespec t;\
t.tv_sec=sec;\
t.tv_nsec = nsec;\
nanosleep(&t,NULL);\
} while(0)
#define sleep(n)\
do {\
struct timespec t;\
t.tv_sec=n;\
t.tv_nsec = 0;\
nanosleep(&t,NULL);\
} while(0)
__BEGIN_DECLS
extern HAMLIB_EXPORT_VAR(const char) hamlib_version[];
@ -2431,6 +2451,7 @@ rig_probe HAMLIB_PARAMS((hamlib_port_t *p));
/* Misc calls */
extern HAMLIB_EXPORT(const char *) rig_strrmode(rmode_t mode);
extern HAMLIB_EXPORT(int) rig_strrmodes(rmode_t modes, char *buf, int buflen);
extern HAMLIB_EXPORT(const char *) rig_strvfo(vfo_t vfo);
extern HAMLIB_EXPORT(const char *) rig_strfunc(setting_t);
extern HAMLIB_EXPORT(const char *) rig_strlevel(setting_t);

View File

@ -1,41 +0,0 @@
/*
* Hamlib Interface - Replacement sleep() declaration for Windows
* Copyright (C) 2013 The Hamlib Group
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/* Define missing sleep() prototype */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_WINBASE_H
#include <windows.h>
#include <winbase.h>
#endif
/* TODO: what about SleepEx? */
static inline unsigned int sleep(unsigned int nb_sec)
{
Sleep(nb_sec * 1000);
return 0;
}
#ifdef __cplusplus
}
#endif

View File

@ -275,9 +275,9 @@ ioptron_get_info(ROT *rot)
{
static char info[16];
char str[6];
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
int retval;
retval = ioptron_transaction(rot, ":MountInfo#", str, sizeof(str));

View File

@ -1404,9 +1404,11 @@ int jrc_set_chan(RIG *rig, const channel_t *chan)
struct jrc_priv_caps *priv = (struct jrc_priv_caps *)rig->caps->priv;
char cmdbuf[BUFSZ];
int retval, cmd_len;
rmode_t mode;
pbwidth_t width;
channel_t current;
/* read first to get current values */
channel_t current;
current.channel_num = chan->channel_num;
if ((retval = jrc_get_chan(rig, &current)) != RIG_OK) { return retval; }
@ -1418,8 +1420,8 @@ int jrc_set_chan(RIG *rig, const channel_t *chan)
cmdbuf[4] = '1';
}
rmode_t mode = chan->mode;
pbwidth_t width = chan->width;
mode = chan->mode;
width = chan->width;
if (RIG_MODE_NONE == mode) { mode = current.mode; }
@ -1512,6 +1514,8 @@ int jrc_get_chan(RIG *rig, channel_t *chan)
if (mem_len != 6)
{
char freqbuf[BUFSZ];
if (membuf[4] == '1')
{
chan->levels[rig_setting2idx(RIG_LEVEL_ATT)].i = 20;
@ -1520,7 +1524,6 @@ int jrc_get_chan(RIG *rig, channel_t *chan)
jrc2rig_mode(rig, membuf[6], membuf[5],
&chan->mode, &chan->width);
char freqbuf[BUFSZ];
strncpy(freqbuf, membuf + 7, priv->max_freq_len);
freqbuf[priv->max_freq_len] = 0x00;
chan->freq = strtol(freqbuf, NULL, 10);

View File

@ -239,7 +239,7 @@ static int nrd525_set_mem(RIG *rig, vfo_t vfo, int ch)
{
char membuf[12];
sprintf(membuf, "C%03u", ch);
sprintf(membuf, "C%03d", ch);
return write_block(&rig->state.rigport, membuf, strlen(membuf));
}

View File

@ -93,16 +93,13 @@ int elecraft_get_firmware_revision_level(RIG *rig, const char *cmd,
int elecraft_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called, rig version=%s\n", __func__,
rig->caps->version);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
char id[KENWOOD_MAX_BUF_LEN];
struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called, rig version=%s\n", __func__,
rig->caps->version);
/* Actual read extension levels from radio.
*
@ -111,8 +108,6 @@ int elecraft_open(RIG *rig)
* elecraft_get_extension_level() private function during elecraft_open()
* and thereafter shall be treated as READ ONLY!
*/
struct kenwood_priv_data *priv = rig->state.priv;
/* As k3_fw_rev is declared static, it is persistent so the structure
* can point to it. This way was chosen to allow the compiler to
* calculate the size of the array to resolve a bug found by gcc 4.8.x
@ -250,16 +245,16 @@ int elecraft_open(RIG *rig)
int verify_kenwood_id(RIG *rig, char *id)
{
int err;
char *idptr;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !id)
if (!id)
{
return -RIG_EINVAL;
}
int err;
char *idptr;
/* Check for an Elecraft K2|K3 which returns "017" */
err = kenwood_get_id(rig, id);
@ -302,17 +297,17 @@ int verify_kenwood_id(RIG *rig, char *id)
int elecraft_get_extension_level(RIG *rig, const char *cmd, int *ext_level)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !ext_level)
{
return -RIG_EINVAL;
}
int err, i;
char buf[KENWOOD_MAX_BUF_LEN];
char *bufptr;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!ext_level)
{
return -RIG_EINVAL;
}
err = kenwood_safe_transaction(rig, cmd, buf, KENWOOD_MAX_BUF_LEN, 3);
if (err != RIG_OK)
@ -347,17 +342,17 @@ int elecraft_get_extension_level(RIG *rig, const char *cmd, int *ext_level)
int elecraft_get_firmware_revision_level(RIG *rig, const char *cmd,
char *fw_rev, size_t fw_rev_sz)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !fw_rev)
{
return -RIG_EINVAL;
}
int err;
char *bufptr;
char buf[KENWOOD_MAX_BUF_LEN];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!fw_rev)
{
return -RIG_EINVAL;
}
/* Get the actual firmware revision number. */
err = kenwood_transaction(rig, cmd, buf, sizeof(buf));
@ -378,7 +373,7 @@ int elecraft_get_firmware_revision_level(RIG *rig, const char *cmd,
bufptr += strlen(cmd);
/* Skip leading zero(s) as the revision number has the format of: "04.67" */
while (bufptr && *bufptr == '0') { bufptr++; }
while (*bufptr == '0') { bufptr++; }
/* Copy out */
strncpy(fw_rev, bufptr, fw_rev_sz - 1);

View File

@ -34,16 +34,16 @@
int verify_flexradio_id(RIG *rig, char *id)
{
int err;
char *idptr;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !id)
if (!id)
{
return -RIG_EINVAL;
}
int err;
char *idptr;
/* Check for a Flex 6700 which returns "904" */
err = kenwood_get_id(rig, id);
@ -110,19 +110,12 @@ int verify_flexradio_id(RIG *rig, char *id)
int flexradio_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
struct kenwood_priv_data *priv = rig->state.priv;
int err;
char id[FLEXRADIO_MAX_BUF_LEN];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
//struct flexradio_priv_data *priv = rig->state.priv;
/* Use check for "ID017;" to verify rig is reachable */

View File

@ -94,21 +94,18 @@ static int dsp_bw_dig[DSP_BW_NUM] =
static int flex6k_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char modebuf[10];
int index;
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !mode || !width)
if (!mode || !width)
{
return -RIG_EINVAL;
}
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char modebuf[10];
int index;
int retval;
retval = kenwood_safe_transaction(rig, "MD", modebuf, 6, 3);
if (retval != RIG_OK)
@ -243,23 +240,14 @@ static int flex6k_find_width(rmode_t mode, pbwidth_t width, int *ridx)
static int flex6k_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char buf[10];
char kmode;
int idx;
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
kmode = rmode2kenwood(mode, caps->mode_table);
if (kmode < 0)

View File

@ -500,6 +500,8 @@ int ic10_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
}
#ifdef XXREMOVEDXX
// Not referenced anywhere
/*
* ic10_set_ptt
* Assumes rig!=NULL
@ -527,6 +529,7 @@ int ic10_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
return retval;
}
#endif
/*

View File

@ -256,16 +256,11 @@ const struct rig_caps k2_caps =
*/
int k2_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = elecraft_open(rig);
if (err != RIG_OK)
@ -292,20 +287,15 @@ int k2_open(RIG *rig)
int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
char f;
char fcmd[16];
struct k2_filt_lst_s *flt;
struct kenwood_priv_data *priv = rig->state.priv;
shortfreq_t freq = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/* Select the filter array per mode. */
switch (mode)
{
@ -353,7 +343,7 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
width = rig_passband_normal(rig, mode);
}
if (width > flt->filt_list[0].width || ((flt->filt_list[0].width >= width)
if ((width > flt->filt_list[0].width) || ((flt->filt_list[0].width >= width)
&& (width > flt->filt_list[1].width)))
{
width = flt->filt_list[0].width;
@ -392,6 +382,8 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (width != RIG_PASSBAND_NOCHANGE)
{
char fcmd[16];
err = kenwood_transaction(rig, "K22", NULL, 0);
if (err != RIG_OK)
@ -430,19 +422,19 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
int k2_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !mode || !width)
{
return -RIG_EINVAL;
}
int err;
char buf[KENWOOD_MAX_BUF_LEN];
char tmp[16];
char *bufptr;
pbwidth_t temp_w;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!mode || !width)
{
return -RIG_EINVAL;
}
err = kenwood_get_mode(rig, vfo, mode, &temp_w);
if (err != RIG_OK)
@ -496,17 +488,17 @@ int k2_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
*/
int k2_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !val)
{
return -RIG_EINVAL;
}
char buf[KENWOOD_MAX_BUF_LEN];
int err;
const struct confparams *cfp;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!val)
{
return -RIG_EINVAL;
}
cfp = rig_ext_lookup_tok(rig, token);
switch (token)
@ -549,19 +541,19 @@ int k2_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
*/
int k2_probe_mdfw(RIG *rig, struct kenwood_priv_data *priv)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !priv)
{
return -RIG_EINVAL;
}
int err, i, c;
char buf[KENWOOD_MAX_BUF_LEN];
char mode[16];
char fw[16];
char cmd[16];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!priv)
{
return -RIG_EINVAL;
}
/* The K2 extension level has been stored by elecraft_open(). Now set rig
* to K22 for detailed query of mode and filter width values...
*/
@ -683,15 +675,15 @@ int k2_probe_mdfw(RIG *rig, struct kenwood_priv_data *priv)
/* Restore mode, filter, and ext_lvl to original values */
int k2_mdfw_rest(RIG *rig, const char *mode, const char *fw)
{
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !mode || !fw)
if (!mode || !fw)
{
return -RIG_EINVAL;
}
int err;
if (strlen(mode) != 3 || strlen(fw) != 7)
{
return -RIG_EINVAL;
@ -725,20 +717,19 @@ int k2_mdfw_rest(RIG *rig, const char *mode, const char *fw)
/* Populate k2_filt_lst_s structure for each mode */
int k2_pop_fw_lst(RIG *rig, const char *cmd)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !cmd)
{
return -RIG_EINVAL;
}
int err, f;
char fcmd[16];
char buf[KENWOOD_MAX_BUF_LEN];
char *bufptr;
char tmp[16];
struct k2_filt_lst_s *flt;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!cmd)
{
return -RIG_EINVAL;
}
/* Store filter data in the correct structure depending on mode */
if (strcmp(cmd, "MD1") == 0)
{
@ -767,6 +758,8 @@ int k2_pop_fw_lst(RIG *rig, const char *cmd)
for (f = 1; f < 5; f++)
{
char *bufptr = buf;
snprintf(fcmd, 8, "FW0000%d", f);
err = kenwood_transaction(rig, fcmd, NULL, 0);
@ -788,8 +781,6 @@ int k2_pop_fw_lst(RIG *rig, const char *cmd)
* f = crystal filter slot number--1-4
* a = audio filter slot number--0-2
*/
bufptr = buf;
strncpy(tmp, bufptr + 2, 4);
tmp[4] = '\0';
flt->filt_list[f - 1].width = atoi(tmp);

View File

@ -783,18 +783,18 @@ const struct rig_caps kx2_caps =
int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !mode || !width)
{
return -RIG_EINVAL;
}
char buf[KENWOOD_MAX_BUF_LEN];
int err;
rmode_t temp_m;
pbwidth_t temp_w;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!mode || !width)
{
return -RIG_EINVAL;
}
err = kenwood_get_mode(rig, vfo, &temp_m, &temp_w);
if (err != RIG_OK)
@ -903,16 +903,10 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
char cmd_m[4];
char cmd_s[64];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (mode)
{
@ -948,6 +942,7 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (width != RIG_PASSBAND_NOCHANGE)
{
char cmd_s[64];
/* and set the requested bandwidth. On my K3, the bandwidth is rounded
* down to the nearest 50 Hz, i.e. sending BW0239; will cause the bandwidth
* to be set to 2.350 kHz. As the width must be divided by 10, 10 Hz values
@ -1015,15 +1010,10 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
int k3_set_vfo(RIG *rig, vfo_t vfo)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (vfo)
{
case RIG_VFO_B:
@ -1058,15 +1048,10 @@ int k3_set_vfo(RIG *rig, vfo_t vfo)
*/
int k3_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char buf[10];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (token)
{
case TOK_RIT_CLR:
@ -1112,16 +1097,16 @@ int k3_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
*/
int k3_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
{
char buf[KENWOOD_MAX_BUF_LEN];
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !val)
if (!val)
{
return -RIG_EINVAL;
}
char buf[KENWOOD_MAX_BUF_LEN];
int err;
switch (token)
{
case TOK_IF_FREQ:
@ -1180,14 +1165,9 @@ int k3_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
*/
int k3_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int err;
if (!rig)
{
return -RIG_EINVAL;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = set_rit_xit(rig, rit);
@ -1206,14 +1186,9 @@ int k3_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
*/
int k3_set_xit(RIG *rig, vfo_t vfo, shortfreq_t rit)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int err;
if (!rig)
{
return -RIG_EINVAL;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = set_rit_xit(rig, rit);
@ -1231,16 +1206,13 @@ int k3_set_xit(RIG *rig, vfo_t vfo, shortfreq_t rit)
*/
int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char buf[32];
char kmode;
int err;
char cmd_m[4];
char cmd_s[32];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (tx_mode)
{
@ -1284,10 +1256,6 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
#endif
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char buf[32];
char kmode;
kmode = rmode2kenwood(tx_mode, caps->mode_table);
if (kmode < 0)
@ -1307,6 +1275,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
if (tx_width != RIG_PASSBAND_NOCHANGE)
{
char cmd_s[32];
/* and set the requested bandwidth. On my K3, the bandwidth is rounded
* down to the nearest 50 Hz, i.e. sending BW0239; will cause the bandwidth
* to be set to 2.350 kHz. As the width must be divided by 10, 10 Hz values
@ -1358,19 +1327,18 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
int k3_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
pbwidth_t *tx_width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !tx_mode || !tx_width)
{
return -RIG_EINVAL;
}
char buf[KENWOOD_MAX_BUF_LEN];
int err;
rmode_t temp_m;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!tx_mode || !tx_width)
{
return -RIG_EINVAL;
}
err = kenwood_safe_transaction(rig, "MD$", buf, KENWOOD_MAX_BUF_LEN, 4);
if (err != RIG_OK)
@ -1460,15 +1428,10 @@ int k3_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
int k3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char levelbuf[16];
int i, kenwood_val;
int kenwood_val;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (RIG_LEVEL_IS_FLOAT(level))
{
@ -1517,6 +1480,8 @@ int k3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
else
{
int i;
for (i = 0; i < MAXDBLSTSIZ && rig->state.attenuator[i]; i++)
{
if (val.i == rig->state.attenuator[i])
@ -1569,28 +1534,32 @@ int k3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
*/
int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
char lvlbuf[50];
int retval;
int lvl;
struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !val)
if (!val)
{
return -RIG_EINVAL;
}
char lvlbuf[50];
int retval, i;
int lvl;
struct kenwood_priv_data *priv = rig->state.priv;
switch (level)
{
float firmware_have;
float firmware_need;
case RIG_LEVEL_STRENGTH:
/* As of FW rev 4.37 the K3 supports an 'SMH' command that
* offers a higher resolution, 0-100 (mine went to 106),
* rawstr value for more precise S-meter reporting.
*/
retval = strncmp(priv->fw_rev, "4.37", 4);
firmware_have = 0;
if (priv->fw_rev != NULL) sscanf(priv->fw_rev,"%f",&firmware_have);
sscanf("4.37","%f",&firmware_need);
if (retval < 0)
if (firmware_have < firmware_need)
{
cal_table_t str_cal = K3_SM_CAL;
@ -1605,7 +1574,7 @@ int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
val->i = (int) rig_raw2val(val->i, &str_cal);
}
else if (retval >= 0)
else
{
cal_table_t str_cal = K3_SMH_CAL;
@ -1620,12 +1589,6 @@ int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
val->i = (int) rig_raw2val(val->i, &str_cal);
}
else
{
rig_debug(RIG_DEBUG_ERR, "%s: Firmware version comparison failed!\n",
__func__);
return -RIG_EINVAL;
}
break;
@ -1732,6 +1695,8 @@ int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
}
else
{
int i;
for (i = 0; i < lvl && i < MAXDBLSTSIZ; i++)
{
if (rig->state.attenuator[i] == 0)
@ -1823,8 +1788,6 @@ int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
int kx3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
int retval;
switch (level)
{
case RIG_LEVEL_RFPOWER_METER:
@ -1833,7 +1796,7 @@ int kx3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
float pwr;
// Return zero RF power when not in TX mode
retval = get_kenwood_func(rig, "TQ", &tx_status);
int retval = get_kenwood_func(rig, "TQ", &tx_status);
if (retval != RIG_OK)
{
@ -1867,15 +1830,10 @@ int kx3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
int k3_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char buf[10];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (func)
{
case RIG_FUNC_APF:
@ -1906,7 +1864,7 @@ int k3_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !status)
if (!status)
{
return -RIG_EINVAL;
}
@ -1942,16 +1900,9 @@ int k3_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
*/
int set_rit_xit(RIG *rig, shortfreq_t rit)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int err;
char offs;
char cmd[16];
if (!rig)
{
return -RIG_EINVAL;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (rit == 0)
{
@ -1969,6 +1920,8 @@ int set_rit_xit(RIG *rig, shortfreq_t rit)
/* Set offset */
if (rit <= 9999 && rit >= -9999)
{
char cmd[16];
char offs;
offs = (rit < 0) ? '-' : '+';
snprintf(cmd, 8, "RO%c%04d", offs, abs((int)rit));
@ -1990,19 +1943,12 @@ int set_rit_xit(RIG *rig, shortfreq_t rit)
int k3_set_nb_level(RIG *rig, float dsp_nb, float if_nb)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char lvlbuf[16];
int retval;
int dsp_nb_raw = 0;
int if_nb_raw = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (dsp_nb >= 0)
{
dsp_nb_raw = (int)(dsp_nb * 21.0f);
@ -2018,7 +1964,7 @@ int k3_set_nb_level(RIG *rig, float dsp_nb, float if_nb)
int current_dsp_nb_raw;
int current_if_nb_raw;
retval = kenwood_safe_transaction(rig, "NL", lvlbuf, sizeof(lvlbuf), 6);
int retval = kenwood_safe_transaction(rig, "NL", lvlbuf, sizeof(lvlbuf), 6);
if (retval != RIG_OK)
{
@ -2045,19 +1991,13 @@ int k3_set_nb_level(RIG *rig, float dsp_nb, float if_nb)
int k3_get_nb_level(RIG *rig, float *dsp_nb, float *if_nb)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char lvlbuf[16];
int retval;
int dsp_nb_raw;
int if_nb_raw;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = kenwood_safe_transaction(rig, "NL", lvlbuf, sizeof(lvlbuf), 6);
if (retval != RIG_OK)
@ -2083,20 +2023,14 @@ int k3_get_nb_level(RIG *rig, float *dsp_nb, float *if_nb)
int k3_get_bar_graph_level(RIG *rig, float *smeter, float *pwr, float *alc,
int *mode_tx)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char lvlbuf[16];
int retval;
int tm_raw;
int bg_raw;
char mode;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// Determine transmit metering mode: 0 = RF POWER, 1 = ALC
retval = get_kenwood_func(rig, "TM", &tm_raw);
@ -2186,18 +2120,12 @@ int k3_get_bar_graph_level(RIG *rig, float *smeter, float *pwr, float *alc,
int kx3_get_bar_graph_level(RIG *rig, float *level)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char lvlbuf[16];
int retval;
int bg_raw;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = kenwood_safe_transaction(rig, "BG", lvlbuf, sizeof(lvlbuf), 4);
if (retval != RIG_OK)

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@
#include <string.h>
#include "token.h"
#define BACKEND_VER "1.3"
#define BACKEND_VER "1.5"
#define EOM_KEN ';'
#define EOM_TH '\r'
@ -62,6 +62,22 @@ extern const struct confparams kenwood_cfg_params[];
#define MD_CWR '7'
#define MD_FSKR '9'
/* S-meter calibration tables */
/* This one for the TS590 no doubt applies elsewhere */
#define TS590_SM_CAL { 10, \
{ \
{ 0, -54 }, \
{ 3, -48 }, \
{ 6, -36 }, \
{ 9, -24 }, \
{ 12, -12 }, \
{ 15, 0 }, \
{ 20, 20 }, \
{ 25, 40 }, \
{ 30, 60 }, \
} }
struct kenwood_priv_caps
{
char cmdtrm; /* Command termination chars (ken=';' or th='\r') */

View File

@ -337,18 +337,20 @@ const struct rig_caps pihpsdr_caps =
int pihspdr_get_channel(RIG *rig, channel_t *chan)
{
int err;
int tmp;
char buf[52];
char cmd[8];
size_t length;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !chan || chan->vfo != RIG_VFO_MEM)
if (!chan || chan->vfo != RIG_VFO_MEM)
{
return -RIG_EINVAL;
}
int err;
char buf[52];
char cmd[8];
struct kenwood_priv_caps *caps = kenwood_caps(rig);
/* put channel num in the command string */
sprintf(cmd, "MR0%03d;", chan->channel_num);
@ -359,7 +361,7 @@ int pihspdr_get_channel(RIG *rig, channel_t *chan)
return err;
}
size_t length = strlen(buf);
length = strlen(buf);
memset(chan, 0x00, sizeof(channel_t));
chan->vfo = RIG_VFO_MEM;
@ -384,7 +386,6 @@ int pihspdr_get_channel(RIG *rig, channel_t *chan)
Tuning step depends on this number and the mode,
just save it for now */
buf[ 40 ] = '\0';
int tmp;
tmp = atoi(&buf[ 38]);
/* Offset frequency */
buf[ 38 ] = '\0';
@ -563,22 +564,20 @@ int pihspdr_get_channel(RIG *rig, channel_t *chan)
}
int pihspdr_set_channel(RIG *rig, const channel_t *chan)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !chan)
{
return -RIG_EINVAL;
}
{
char sqltype;
char shift;
char buf[128];
char mode, tx_mode = 0;
int err;
int tone = 0;
int tstep;
short code;
short dcscode;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
mode = rmode2kenwood(chan->mode, caps->mode_table);
if (mode < 0)
@ -601,7 +600,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
}
/* find tone */
char sqltype = '0';
sqltype = '0';
if (chan->ctcss_tone)
{
@ -622,7 +621,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
}
/* find CTCSS code */
short code = 0;
code = 0;
if (chan->ctcss_sql)
{
@ -643,7 +642,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
}
/* find DCS code */
short dcscode = 0;
dcscode = 0;
if (chan->dcs_code)
{
@ -663,7 +662,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
dcscode = 0;
}
char shift = '0';
shift = '0';
if (chan->rptr_shift == RIG_RPT_SHIFT_PLUS)
{
@ -675,7 +674,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
shift = '2';
}
int tstep = 0;
tstep = 0;
if ((chan->mode == RIG_MODE_AM) || (chan->mode == RIG_MODE_FM))
{
@ -770,16 +769,11 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
int pihpsdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char levelbuf[16];
int i, kenwood_val;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (RIG_LEVEL_IS_FLOAT(level))
{
kenwood_val = val.f * 255;
@ -1331,15 +1325,10 @@ int pihpsdr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
to not use the TS-2000 backend open function */
int pihpsdr_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char id[KENWOOD_MAX_BUF_LEN];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/* get id in buffer, will be null terminated */
kenwood_get_id(rig, id);

View File

@ -52,6 +52,7 @@ th_decode_event(RIG *rig)
{
char asyncbuf[128];
int retval;
int async_len;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -64,7 +65,7 @@ th_decode_event(RIG *rig)
rig_debug(RIG_DEBUG_TRACE, "%s: Decoding message\n", __func__);
size_t async_len = strlen(asyncbuf);
async_len = strlen(asyncbuf);
if (async_len > 3 && asyncbuf[0] == 'B' && asyncbuf[1] == 'U'
&& asyncbuf[2] == 'F')
@ -421,7 +422,6 @@ int
th_set_vfo(RIG *rig, vfo_t vfo)
{
const char *cmd;
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -436,6 +436,7 @@ th_set_vfo(RIG *rig, vfo_t vfo)
/* set band */
if (vfo != RIG_VFO_MEM)
{
int retval;
switch (vfo)
{
@ -508,6 +509,7 @@ th_get_vfo_char(RIG *rig, vfo_t *vfo, char *vfoch)
{
char cmdbuf[10], buf[10], vfoc;
int retval;
size_t length;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -520,7 +522,7 @@ th_get_vfo_char(RIG *rig, vfo_t *vfo, char *vfoch)
return retval;
}
size_t length = strlen(buf);
length = strlen(buf);
switch (length)
{
@ -1137,7 +1139,8 @@ int
th_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
char vch, buf[10], ackbuf[20];
int retval, v, l;
int retval, v;
unsigned int l;
vfo_t tvfo;
@ -1172,7 +1175,7 @@ th_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return retval;
}
retval = sscanf(ackbuf, "SM %d,%d", &v, &l);
retval = sscanf(ackbuf, "SM %d,%u", &v, &l);
if (retval != 2 || l < rig->caps->level_gran[LVL_RAWSTR].min.i
|| l > rig->caps->level_gran[LVL_RAWSTR].max.i)
@ -1241,9 +1244,9 @@ th_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return retval;
}
retval = sscanf(ackbuf, "PC %d,%d", &v, &l);
retval = sscanf(ackbuf, "PC %d,%u", &v, &l);
if (retval != 2 || l < 0 || l > 3)
if ((retval != 2) || l > 3)
{
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, ackbuf);
return -RIG_ERJCTED;
@ -1413,7 +1416,7 @@ th_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
caps = rig->caps;
for (i = 0; caps->ctcss_list[i] != 0 && i < RIG_TONEMAX; i++)
for (i = 0; caps->ctcss_list[i] != 0; i++)
{
if (caps->ctcss_list[i] == tone)
{
@ -1471,7 +1474,7 @@ th_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
}
/* verify tone index for TH-7DA rig */
if (tone_idx <= 0 || tone_idx == 2 || tone_idx > 39)
if (tone_idx == 0 || tone_idx == 2 || tone_idx > 39)
{
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected CTCSS tone no (%04d)\n",
__func__, tone_idx);
@ -1498,7 +1501,7 @@ th_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
caps = rig->caps;
for (i = 0; caps->ctcss_list[i] != 0 && i < RIG_TONEMAX; i++)
for (i = 0; caps->ctcss_list[i] != 0; i++)
{
if (caps->ctcss_list[i] == tone)
{
@ -1556,7 +1559,7 @@ th_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
}
/* verify tone index for TH-7DA rig */
if (tone_idx <= 0 || tone_idx == 2 || tone_idx > 39)
if (tone_idx == 0 || tone_idx == 2 || tone_idx > 39)
{
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected CTCSS no (%04d)\n",
__func__, tone_idx);
@ -1592,7 +1595,7 @@ th_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code)
return kenwood_transaction(rig, "DCS 0", NULL, 0);
}
for (i = 0; caps->dcs_list[i] != 0 && i < RIG_CODEMAX; i++)
for (i = 0; caps->dcs_list[i] != 0; i++)
{
if (caps->dcs_list[i] == code)
{
@ -1646,7 +1649,7 @@ th_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code)
return retval;
}
retval = sscanf(buf, "DCSN %u", (int *)&code_idx);
retval = sscanf(buf, "DCSN %d", (int *)&code_idx);
if (retval != 1)
{
@ -1668,7 +1671,7 @@ th_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code)
return retval;
}
retval = sscanf(buf, "DCSN %u", (int *)&code_idx);
retval = sscanf(buf, "DCSN %d", (int *)&code_idx);
if (retval != 1)
{
@ -1695,6 +1698,7 @@ th_get_info(RIG *rig)
{
static char firmbuf[50];
int retval;
size_t firm_len;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -1705,7 +1709,7 @@ th_get_info(RIG *rig)
return NULL;
}
size_t firm_len = strlen(firmbuf);
firm_len = strlen(firmbuf);
if (firm_len < 3)
{
@ -2191,6 +2195,7 @@ int th_get_channel(RIG *rig, channel_t *chan)
/* If not set already by special channels.. */
if (chan->channel_desc[0] == '\0')
{
size_t ack_len;
if (chan_caps[1].type == RIG_MTYPE_PRIO)
{
sprintf(membuf, "MNA %sI-%01d", mr_extra, channel_num);
@ -2208,7 +2213,7 @@ int th_get_channel(RIG *rig, channel_t *chan)
return retval;
}
size_t ack_len = strlen(ackbuf);
ack_len = strlen(ackbuf);
if (ack_len > rig->caps->chan_desc_sz)
{
@ -2226,7 +2231,7 @@ static int find_tone_index(const tone_t *tone_list, tone_t tone)
{
int i;
for (i = 0; tone_list[i] != 0 && i < RIG_TONEMAX; i++)
for (i = 0; tone_list[i] != 0; i++)
{
if (tone_list[i] == tone)
{
@ -2240,12 +2245,12 @@ static int find_tone_index(const tone_t *tone_list, tone_t tone)
/* --------------------------------------------------------------------- */
int th_set_channel(RIG *rig, const channel_t *chan)
{
char membuf[150];
char membuf[256];
int retval;
char req[64];
char lockoutstr[8];
int channel_num, step, shift, rev, tone, ctcss, tonefq, ctcssfq, dcs, dcscode,
mode, lockout;
lockout;
const char *mr_extra;
const struct kenwood_priv_caps *priv = (const struct kenwood_priv_caps *)
rig->caps->priv;
@ -2414,8 +2419,8 @@ int th_set_channel(RIG *rig, const channel_t *chan)
return -RIG_EINVAL;
}
rev = chan->funcs & RIG_FUNC_REV ? 1 : 0;
lockout = chan->flags & RIG_CHFLAG_SKIP ? 1 : 0;
rev = (chan->funcs & RIG_FUNC_REV) ? 1 : 0;
lockout = (chan->flags & RIG_CHFLAG_SKIP) ? 1 : 0;
if (chan_caps->mem_caps.flags)
{
@ -2428,6 +2433,7 @@ int th_set_channel(RIG *rig, const channel_t *chan)
if (chan_caps->mem_caps.flags && chan_caps->mem_caps.dcs_sql)
{
int mode;
if (!priv->mode_table)
{
@ -2446,8 +2452,8 @@ int th_set_channel(RIG *rig, const channel_t *chan)
}
/* Step can be hexa */
retval = snprintf(membuf, sizeof(membuf),
"%s,%011"PRIll",%X,%d,%d,%d,%d,%d,%02d,%02d,%03d,%09"PRIll",%d%s",
snprintf(membuf, sizeof(membuf),
"%8s,%011"PRIll",%X,%d,%d,%d,%d,%d,%02d,%02d,%03d,%09"PRIll",%d%10s",
req, (int64_t)chan->freq, step, shift, rev, tone,
ctcss, dcs, tonefq, ctcssfq, dcscode,
(int64_t)labs((long)(chan->rptr_offs)), mode, lockoutstr
@ -2457,8 +2463,7 @@ int th_set_channel(RIG *rig, const channel_t *chan)
{
/* Without DCS,mode */
retval = sprintf(membuf,
"%s,%011"PRIll",%X,%d,%d,%d,%d,,%02d,,%02d,%09"PRIll"%s",
sprintf(membuf, "%s,%011"PRIll",%X,%d,%d,%d,%d,,%02d,,%02d,%09"PRIll"%s",
req, (int64_t)chan->freq, step, shift, rev, tone,
ctcss, tonefq, ctcssfq,
(int64_t)labs((long)(chan->rptr_offs)), lockoutstr

View File

@ -196,19 +196,20 @@ static int thd72_set_vfo(RIG *rig, vfo_t vfo)
static int thd72_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char vfobuf[16];
struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
char vfonum = '0';
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
if (vfo == RIG_VFO_B || priv->split)
{
vfonum = '1';
}
sprintf(vfobuf, "BC %c", vfonum);
int retval = kenwood_transaction(rig, vfobuf, NULL, 0);
retval = kenwood_transaction(rig, vfobuf, NULL, 0);
if (retval != RIG_OK)
{
@ -222,6 +223,7 @@ static int thd72_get_vfo(RIG *rig, vfo_t *vfo)
{
int retval;
char c, buf[10];
size_t length;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -232,7 +234,7 @@ static int thd72_get_vfo(RIG *rig, vfo_t *vfo)
return retval;
}
size_t length = strlen(buf);
length = strlen(buf);
if (length == 4)
{
@ -378,7 +380,7 @@ static int thd72_get_freq_info(RIG *rig, vfo_t vfo, char *buf)
sprintf(cmd, "FO %c", c);
retval = kenwood_transaction(rig, cmd, buf, 53);
return RIG_OK;
return retval;
}
/* item is an offset into reply buf that is a single char */
@ -431,6 +433,8 @@ static int thd72_set_freq_item(RIG *rig, vfo_t vfo, int item, int val)
static int thd72_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int retval;
int tsindex;
shortfreq_t ts;
char buf[64], fbuf[11];
rig_debug(RIG_DEBUG_TRACE, "%s: called, vfo=%s, freq=%f\n", __func__,
@ -444,11 +448,11 @@ static int thd72_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
return retval;
}
int tsindex = buf[16] - '0';
tsindex = buf[16] - '0';
if (buf[16] >= 'A') { tsindex = buf[16] - 'A' + 10; }
shortfreq_t ts = thd72tuningstep[tsindex];
ts = thd72tuningstep[tsindex];
rig_debug(RIG_DEBUG_VERBOSE, "%s: tsindex=%d, stepsize=%d\n", __func__, tsindex,
(int)ts);
freq = roundl(freq / ts) * ts;
@ -461,6 +465,8 @@ static int thd72_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
static int thd72_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int retval;
int tsindex;
shortfreq_t ts;
char buf[64];
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -472,8 +478,8 @@ static int thd72_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
return retval;
}
int tsindex = buf[16] - '0';
shortfreq_t ts = thd72tuningstep[tsindex];
tsindex = buf[16] - '0';
ts = thd72tuningstep[tsindex];
rig_debug(RIG_DEBUG_VERBOSE, "%s: tsindex=%d, stepsize=%d\n", __func__, tsindex,
(int)ts);
sscanf(buf + 5, "%"SCNfreq, freq);
@ -1047,7 +1053,7 @@ static int thd72_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
retval = sscanf(buf, "SQ %d,%d", &v, &l);
if (retval != 2 || l < 0 || l > 6)
if (retval != 2 || l < 0 || l >= 6)
{
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf);
return -RIG_ERJCTED;
@ -1353,13 +1359,15 @@ static int thd72_parse_channel(int kind, const char *buf, channel_t *chan)
static int thd72_get_channel(RIG *rig, channel_t *chan)
{
int retval, len;
char cmd[8], buf[72];
int retval;
char buf[72];
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
if (chan->vfo == RIG_VFO_MEM) /* memory channel */
{
int len;
char cmd[16];
sprintf(cmd, "ME %03d", chan->channel_num);
retval = kenwood_transaction(rig, cmd, buf, sizeof(buf));
@ -1467,6 +1475,7 @@ static int thd72_get_block(RIG *rig, int block_num, char *block)
return RIG_OK;
}
#ifdef XXREMOVEDXX
int thd72_get_chan_all_cb(RIG *rig, chan_cb_t chan_cb, rig_ptr_t arg)
{
int i, j, ret;
@ -1599,6 +1608,7 @@ int thd72_get_chan_all_cb(RIG *rig, chan_cb_t chan_cb, rig_ptr_t arg)
return RIG_OK;
}
#endif
#endif /* none working stuff */
/*
* th-d72a rig capabilities.
@ -1608,7 +1618,7 @@ const struct rig_caps thd72a_caps =
.rig_model = RIG_MODEL_THD72A,
.model_name = "TH-D72A",
.mfg_name = "Kenwood",
.version = TH_VER ".3",
.version = TH_VER ".4",
.copyright = "LGPL",
.status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_HANDHELD | RIG_FLAG_APRS | RIG_FLAG_TNC | RIG_FLAG_DXCLUSTER,

View File

@ -202,6 +202,7 @@ static int thd74_get_vfo(RIG *rig, vfo_t *vfo)
{
int retval;
char c, buf[10];
size_t length;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -212,7 +213,7 @@ static int thd74_get_vfo(RIG *rig, vfo_t *vfo)
return retval;
}
size_t length = strlen(buf);
length = strlen(buf);
if (length == 4)
{
@ -458,6 +459,11 @@ int thd74_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
retval = thd74_vfoc(rig, vfo, &v);
if (retval != RIG_OK)
{
return retval;
}
if (priv->mode_table)
{
kmode = rmode2kenwood(mode, priv->mode_table);
@ -858,11 +864,6 @@ int thd74_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
switch (ptt)
{
case RIG_PTT_ON:
@ -1021,7 +1022,7 @@ static int thd74_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
retval = sscanf(buf, "SQ %d,%d", &v, &l);
if (retval != 2 || l < 0 || l > 6)
if (retval != 2 || l < 0 || l >= 6)
{
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf);
return -RIG_ERJCTED;
@ -1274,13 +1275,15 @@ static int thd74_parse_channel(int kind, const char *buf, channel_t *chan)
static int thd74_get_channel(RIG *rig, channel_t *chan)
{
int retval, len;
char cmd[8], buf[72];
int retval;
char buf[72];
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
if (chan->vfo == RIG_VFO_MEM) /* memory channel */
{
int len;
char cmd[16];
sprintf(cmd, "ME %03d", chan->channel_num);
retval = kenwood_transaction(rig, cmd, buf, sizeof(buf));
@ -1395,14 +1398,13 @@ otherwise return -RIG_EPROTO
int thd74_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
{
struct kenwood_priv_data *priv = rig->state.priv;
int retval;
char fbuf[12], buf[128];
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
if (priv->split == RIG_SPLIT_ON)
{
retval = thd74_get_freq_info(rig, RIG_VFO_A, buf);
char fbuf[12], buf[128];
int retval = thd74_get_freq_info(rig, RIG_VFO_A, buf);
if (retval != RIG_OK)
{
@ -1484,6 +1486,7 @@ static int thd74_get_block(RIG *rig, int block_num, char *block)
return RIG_OK;
}
#ifdef XXREMOVEDXX
int thd74_get_chan_all_cb(RIG *rig, chan_cb_t chan_cb, rig_ptr_t arg)
{
int i, j, ret;
@ -1616,6 +1619,7 @@ int thd74_get_chan_all_cb(RIG *rig, chan_cb_t chan_cb, rig_ptr_t arg)
return RIG_OK;
}
#endif
#endif /* none working stuff */
/*
* th-d74 rig capabilities.

View File

@ -455,8 +455,6 @@ int thg71_get_vfo(RIG *rig, vfo_t *vfo)
/* --------------------------------------------------------------------- */
int thg71_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
int retval;
if (func != RIG_FUNC_TBURST)
{
return -RIG_EINVAL;
@ -464,7 +462,7 @@ int thg71_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
if (status == 1)
{
retval = kenwood_transaction(rig, "TT", NULL, 0);
int retval = kenwood_transaction(rig, "TT", NULL, 0);
if (retval != RIG_OK)
{
@ -485,7 +483,7 @@ int thg71_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
/* --------------------------------------------------------------------- */
int thg71_open(RIG *rig)
{
char ackbuf[ACKBUF_LEN], *strl, *stru;
char ackbuf[ACKBUF_LEN], *strl;
int retval, i;
const freq_range_t frend = RIG_FRNG_END;
@ -510,6 +508,7 @@ int thg71_open(RIG *rig)
for (i = 0; i < FRQRANGESIZ; i++)
{
freq_range_t frng;
char *stru;
strl = strtok(NULL, ",");
stru = strtok(NULL, ",");

View File

@ -2114,7 +2114,8 @@ int tmd710_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
int tmd710_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
char buf[10], ackbuf[20];
int retval, v, l;
int retval, v;
unsigned int l;
int vfonum;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -2137,9 +2138,9 @@ int tmd710_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return retval;
}
retval = sscanf(ackbuf, "PC %d,%d", &v, &l);
retval = sscanf(ackbuf, "PC %d,%u", &v, &l);
if (retval != 2 || l < 0 || l > 2)
if (retval != 2 || l > 2)
{
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, ackbuf);
return -RIG_ERJCTED;
@ -2164,7 +2165,7 @@ int tmd710_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
retval = sscanf(ackbuf, "SQ %X", &l);
if (retval != 1 || l < TMD710_SQL_MIN || l > TMD710_SQL_MAX)
if (retval != 1 || l > TMD710_SQL_MAX)
{
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, ackbuf);
return -RIG_ERJCTED;

View File

@ -691,8 +691,7 @@ int tmv7_set_channel(RIG *rig, const channel_t *chan)
{
tone = 1;
for (tonefq = 0; rig->caps->ctcss_list[tonefq] != 0
&& tonefq < RIG_TONEMAX; tonefq++)
for (tonefq = 0; rig->caps->ctcss_list[tonefq] != 0; tonefq++)
{
if (rig->caps->ctcss_list[tonefq] == chan->ctcss_tone)
{
@ -711,8 +710,7 @@ int tmv7_set_channel(RIG *rig, const channel_t *chan)
{
ctcss = 1;
for (ctcssfq = 0; rig->caps->ctcss_list[ctcssfq] != 0
&& ctcssfq < RIG_TONEMAX; ctcssfq++)
for (ctcssfq = 0; rig->caps->ctcss_list[ctcssfq] != 0; ctcssfq++)
{
if (rig->caps->ctcss_list[ctcssfq] == chan->ctcss_sql)
{

View File

@ -370,6 +370,13 @@ const struct rig_caps ts2000_caps =
int ts2000_get_channel(RIG *rig, channel_t *chan)
{
int err;
int tmp;
size_t length;
char buf[52];
char cmd[8];
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !chan || chan->vfo != RIG_VFO_MEM)
@ -377,11 +384,6 @@ int ts2000_get_channel(RIG *rig, channel_t *chan)
return -RIG_EINVAL;
}
int err;
char buf[52];
char cmd[8];
struct kenwood_priv_caps *caps = kenwood_caps(rig);
/* put channel num in the command string */
sprintf(cmd, "MR0%03d;", chan->channel_num);
@ -392,7 +394,7 @@ int ts2000_get_channel(RIG *rig, channel_t *chan)
return err;
}
size_t length = strlen(buf);
length = strlen(buf);
memset(chan, 0x00, sizeof(channel_t));
chan->vfo = RIG_VFO_MEM;
@ -417,7 +419,6 @@ int ts2000_get_channel(RIG *rig, channel_t *chan)
Tuning step depends on this number and the mode,
just save it for now */
buf[ 40 ] = '\0';
int tmp;
tmp = atoi(&buf[ 38]);
/* Offset frequency */
buf[ 38 ] = '\0';
@ -597,21 +598,25 @@ int ts2000_get_channel(RIG *rig, channel_t *chan)
int ts2000_set_channel(RIG *rig, const channel_t *chan)
{
char sqltype = '0';
char buf[128];
char mode, tx_mode = 0;
char shift = '0';
short dcscode = 0;
short code = 0;
int tstep = 0;
int err;
int tone = 0;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !chan)
if (!chan)
{
return -RIG_EINVAL;
}
char buf[128];
char mode, tx_mode = 0;
int err;
int tone = 0;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
mode = rmode2kenwood(chan->mode, caps->mode_table);
if (mode < 0)
@ -634,7 +639,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
}
/* find tone */
char sqltype = '0';
if (chan->ctcss_tone)
{
@ -655,7 +659,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
}
/* find CTCSS code */
short code = 0;
if (chan->ctcss_sql)
{
@ -676,7 +679,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
}
/* find DCS code */
short dcscode = 0;
if (chan->dcs_code)
{
@ -696,8 +698,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
dcscode = 0;
}
char shift = '0';
if (chan->rptr_shift == RIG_RPT_SHIFT_PLUS)
{
shift = '1';
@ -708,7 +708,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
shift = '2';
}
int tstep = 0;
if ((chan->mode == RIG_MODE_AM) || (chan->mode == RIG_MODE_FM))
{

File diff suppressed because it is too large Load Diff

View File

@ -1,174 +0,0 @@
/*
* Hamlib TS2000 backend - main header
* Copyright (c) 2000-2002 by Stephane Fillod
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*
* created from kenwood.h --Dale kd7eni
*/
/*//+kd7eni*/
#ifndef _TS2K_H
#define _TS2K_H
#undef _USEVFO
// imported from ts2000.h --Dale kd7eni
/*
* 103 available DCS codes
*/
static const tone_t ts2k_dcs_list[] = {
23, 25, 26, 31, 32, 36, 43, 47, 51, 53, 54,
65, 71, 72, 73, 74, 114, 115, 116, 122, 125, 131,
132, 134, 143, 145, 152, 155, 156, 162, 165, 172, 174,
205, 212, 223, 225, 226, 243, 244, 245, 246, 251, 252,
255, 261, 263, 265, 266, 271, 274, 306, 311, 315, 325,
331, 332, 343, 346, 351, 356, 364, 365, 371, 411, 412,
413, 423, 431, 432, 445, 446, 452, 454, 455, 462, 464,
465, 466, 503, 506, 516, 523, 526, 532, 546, 565, 606,
612, 624, 627, 631, 632, 654, 662, 664, 703, 712, 723,
731, 732, 734, 743, 754,
0
};
#define TS2K_PTT_ON_MAIN 8
#define TS2K_CTRL_ON_MAIN 4
#define TS2K_PTT_ON_SUB 2
#define TS2K_CTRL_ON_SUB 1
// Needed to prevent ts2k_transaction (kenwood_transaction) from
// expecting a reply from the ts2000 in cases where there is none.
#define NOREPLY 0
// some commands reply "?;" if rig currently in requested mode
// usually, there is NOREPLY when mode is changed. This can be
// put in the acknowledge length to signify the error is no error.
#define BUGERR -1
//-kd7eni
#define EOM_KEN ";"
#define EOM_TH "\r"
struct ts2k_priv_caps {
/* read-only values */
const char *cmdtrm; /* Command termination chars (ken=';' or th='\r') */
/* changable values */
// nothing
};
#if 0 /* No private data for Kenwood backends. */
struct ts2k_priv_data {
int dummy; // placeholder for real entries.
};
#endif
extern int ts2k_init(RIG *rig);
extern int ts2k_cleanup(RIG *rig);
extern const int ts2k_ctcss_list[];
int ts2k_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
size_t *data_len);
int ts2k_set_vfo(RIG *rig, vfo_t vfo);
int ts2k_get_vfo(RIG *rig, vfo_t *vfo);
int ts2k_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
int ts2k_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
int ts2k_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
int ts2k_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
int ts2k_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
int ts2k_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
int ts2k_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
int ts2k_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status);
int ts2k_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone);
int ts2k_set_tone(RIG *rig, vfo_t vfo, tone_t tone);
int ts2k_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone);
int ts2k_get_tone(RIG *rig, vfo_t vfo, tone_t *tone);
int ts2k_set_Tones(RIG *rig, vfo_t vfo, tone_t tone, const char ct);
int ts2k_get_Tones(RIG *rig, vfo_t vfo, tone_t *tone, const char *ct);
int ts2k_set_powerstat(RIG *rig, powerstat_t status);
int ts2k_get_powerstat(RIG *rig, powerstat_t *status);
int ts2k_reset(RIG *rig, reset_t reset);
int ts2k_send_morse(RIG *rig, vfo_t vfo, const char *msg);
int ts2k_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt);
int ts2k_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
int ts2k_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd);
int ts2k_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
int ts2k_set_mem(RIG *rig, vfo_t vfo, int ch);
int ts2k_get_mem(RIG *rig, vfo_t vfo, int *ch);
const char* ts2k_get_info(RIG *rig);
int ts2k_get_trn(RIG *rig, int *trn);
int ts2k_set_trn(RIG *rig, int trn);
/*
* functions I've written -- Dale KD7ENI
*/
int ts2k_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch);
int ts2k_scan_on(RIG *rig, char ch);
int ts2k_scan_off(RIG *rig);
int ts2k_get_channel(RIG *rig, channel_t *chan);
int ts2k_set_channel(RIG *rig, const channel_t *chan);
char *ts2k_get_ctrl(RIG *rig);
int ts2k_set_ctrl(RIG *rig, int ptt, int ctrl);
int ts2k_vfo_ctrl(RIG *rig, vfo_t vfo);
int ts2k_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *tone);
int ts2k_set_dcs_code(RIG *rig, vfo_t vfo, tone_t tone);
int ts2k_get_int(char *c, int i);
int ts2k_sat_off(RIG *rig, vfo_t vfo);
int ts2k_sat_on(RIG *rig, vfo_t vfo);
int ts2k_get_parm(RIG *rig, setting_t parm, value_t *val);
int ts2k_set_parm(RIG *rig, setting_t parm, value_t val);
int ts2k_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit);
int ts2k_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit);
int ts2k_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *offs);
int ts2k_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs);
int ts2k_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *shift);
int ts2k_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift);
int ts2k_get_split(RIG *rig, vfo_t vfo, split_t *split);
int ts2k_set_split(RIG *rig, vfo_t vfo, split_t split);
int ts2k_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq);
int ts2k_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq);
int ts2k_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *txmode, pbwidth_t *txwidth);
int ts2k_set_split_mode(RIG *rig, vfo_t vfo, rmode_t txmode, pbwidth_t txwidth);
int ts2k_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts);
int ts2k_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts);
int ts2k_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *freq);
int ts2k_set_xit(RIG *rig, vfo_t vfo, shortfreq_t freq);
/* end kd7eni functions */
extern const struct rig_caps thd7a_caps;
extern const struct rig_caps thf7a_caps;
extern const struct rig_caps thf7e_caps;
extern const struct rig_caps ts450s_caps;
extern const struct rig_caps ts50s_caps;
extern const struct rig_caps ts570d_caps;
extern const struct rig_caps ts570s_caps;
extern const struct rig_caps ts790_caps;
extern const struct rig_caps ts850_caps;
extern const struct rig_caps ts870s_caps;
extern const struct rig_caps ts950sdx_caps;
extern const struct rig_caps ts2000_caps;
extern BACKEND_EXPORT(int) initrigs_ts2k(void *be_handle);
extern BACKEND_EXPORT(rig_model_t) proberigs_ts2k(port_t *port);
#endif /* _TS2000_H */

View File

@ -1,23 +0,0 @@
Rig: TS-2000, ts2k.c Thought this might help. --Dale kd73ni
n/i = not written, orig = original/rewritten, new = new, ok = works as written
F: ok (no limit check) orig f: ok, (vfo only) orig
M: ok orig m: ok (no vfo check) orig
V: ok (trivial only) orig v: ok (trivial only) orig
T: ok (even in CALL_C) orig t: ok orig
R: ok new r: ok (vfo only) new
O: bugs new o: ok new
C: ok (requires exact) orig c: ok orig
D: ok new d: ok new
I: broken new i: broken new
X: ok (TX only!) new x: replies new
S: ok (default only!) new s: on (not broken!) new
N: ok (default only) new n: ok new
L: ok (PREAMP at least) new l: bad new
U: bugs (VOX always on) new u: bugs orig
P: ok (BEEP 0.0 works!) new p: ok new
E: ok orig e: ok orig
G: ok (up/down at least) new g: broken new
H: n/i (rigctl too!) h: ok (needs work) new
A: ok (see a) orig a: ok (sigio remains on) orig
B: n/a _: ok (which Sea?) :) orig
2: bugs (don't understand) orig #: ok (rigctl comment) new

View File

@ -1,319 +0,0 @@
/*
* ts2k_menu.c (C) Copyright 2002 by Dale E. Edmons. All rights reserved.
*/
/*
* License: GNU
*/
/*
* status: Never been compiled!
*/
/*
* Functions to initialize, read, set, and list menus
* for the TS-2000. These functions will be added to
* src/rig.c as rig_*menu_*() as time permits.
*
* This is likely a can of worms nobody has wanted to
* deal with--until now. The ts2k is especially a
* pain as you'll soon seen (but cool nonetheless.)
*/
#include <rig.h>
#include "ts2k.h"
#include "ts2k_menu.h"
#include <ctype.h>
/*
* Set the menu number(s) and terminate with ";" (not ';')
*/
int ts2k_set_menu_no(RIG *rig, ts2k_menu_t *menu, int main, int sub)
{
int i;
menu->menu_no[0] = main;
menu->menu_no[1] = sub;
menu->menu_no[2] = menu->menu_no[3] = 0;
i = sprintf(&menu->cmd[0], "ex%03u%02u%01u%01u;", main, sub, 0, 0);
if (i != 10)
{
return -RIG_EINVAL;
}
return RIG_OK;
}
/*
* Get the menu number(s) from cmd[]
*/
int ts2k_get_menu_no(RIG *rig, ts2k_menu_t *menu, int *main, int *sub)
{
char tmp[30];
int m, s;
if (menu == NULL)
{
return -RIG_EINVAL;
}
m = int_n(tmp, &menu->cmd[2], 3);
s = int_n(tmp, &menu->cmd[7], 2);
menu->menu_no[0] = m;
menu->menu_no[1] = s;
menu->menu_no[2] = menu->menu_no[3] = 0;
if (main != NULL)
{
*main = m;
}
if (sub != NULL)
{
*sub = s;
}
return RIG_OK;
}
/*
* When called by ts2k_pm_init we read all of
* the rig's current menu options and set them
* in the current menu array. We don't do the
* memory allocation so you can init as many
* as you want. The reason for this is huge.
* First, after full reset the rig can access
* menuA or menuB and different values retained.
* Second, by sending "pm...;" we can select
* Programmable Memory 0-5, with 0 being the
* the default. Amazingly, each PM seems to
* have its own menuA and menuB. Thus, all
* told, we have up to twelve distinct menus
* each with (potentially) unique values. We
* do the allocation in the PM routines and
* leave this one much simpler and just call
* it up to twelve times with uniq ts2k_menu_t
* pointers. Third, the user may wish to use
* this to obtain a private copy for local use
* and only has to call this routine to make
* sure its current. (A ts2k_pm_t should be
* allocated as well!)
*/
int ts2k_menu_init(RIG *rig, ts2k_menu_t *menu[])
{
int retval, i;
ts2k_menu_t *m, *mref;
if (menu == NULL || menu == ts2k_menus)
{
rig_debug(rig, __func__": invalid menu pointer\n");
return -RIG_EINVAL;
}
// One set of defaults has been globally defined (mref)
for (i = 0, i < (sizeof(menu) / sizeof(ts2k_menu_t)); i++)
{
m = menu[i];
mref = ts2k_menus[i];
retval = ts2k_set_menu_no(rig, m, mref->menu[0], mref->menu[1]);
if (retval != RIG_OK)
{
return retval;
}
retval = ts2k_get_menu(rig, m);
if (retval != RIG_OK)
{
return retval;
}
// FIXME: set some debug traces here?
}
return RIG_OK;
}
/*
* read the rig and get the parameters for menu[n].
* convert them to a ts2k_menu_t, and eventually to
* a rig_menu_t. I do a lot of checking to ensure
* nothing breaks (hi!).
*/
int ts2k_get_menu(RIG *rig, ts2k_menu_t *menu,)
{
int retval, i, j, k, acklen;
char ack[30];
if (menu == NULL)
{
return -RIG_EINVAL;
}
else if ((toupper(menu->cmd[0]) != 'E')
|| (toupper(menu->cmd[1]) != 'X'))
{
return -RIG_EINVAL;
}
else if (menu->cmd[9] != ';')
{
retval = -RIG_EINVAL;
}
retval = ts2k_transaction(rig, menu->cmd, 10, ack, &acklen);
if (retval != RIG_OK)
{
return retval;
}
strncpy(menu->cmd, ack, 30);
retval = ts2k_menu_parse(rig, menu);
if (retval != RIG_OK)
{
return retval;
}
return retval;
}
/*
* Here, I expect everything to be setup for me.
* All we do is determe the value and param_txt
* for the menu item we are given.
*
* status: real ugly!
*/
int ts2k_menu_parse(RIG *rig, ts2k_menu_t *menu)
{
ts2k_menu_t *mref, *m;
char *vptr;
int on_off[] = { 01, 03, 04, 05, 07, 09, 17, 18, 23, 25, 26,
27, 30, 34, 35, 36, 37, 43, 44, 52, 53, 63, 54, 55,
-1
},
zero2nine =
{
m = menu; // to lazy to spell menu-> all the time
if (m->cmd[0] == '\0' || m->cmd[1] == '\0')
{
return -RIG_EINVAL; // Caller has blown it!
}
// find matching refence menu
i = 0;
do
{
mref = ts2k_menus[i];
if (mref == NULL) // Either Caller or I blew it!
{
return -RIG_EINTERNAL;
}
if (mref->menu_no[i] == NULL)
{
return -RIG_EINVAL; // It has to match one!
}
if (menu == ts2k_menus[i]) // Nobody changes our REF!
{
return -RIG_EINTERNAL;
}
if (mref->menu[0] == m->menu[0])
&& mref->menu[1] == m->menu[1]
&& mref->menu[2] == m->menu[2]
/*&& mref->menu[3] == m->menu[3]*/)
{
break;
}
}
while (++i)
/* Match the main menu and only look for sub-menus later */
// check for menus that are simple on/off first
// FIXME: this isn't fast, it just eliminates alot of cases!
for (i = 0; on_off == -1; i++)
{
if (m->menu[0] == m->menu[0])
{
m->val = m->cmd[9] - '0';
m->param_txt = (m->val == 1) ? m_on : m_off;
return RIG_OK;
}
}
// Use mref to do all we can
retval = -RIG_EINTERNAL;
for (i = 0; mref->param_txt != NULL; i++)
{
if (retval == RIG_OK)
{
return retval;
}
switch (mref->param_txt[i])
{
case m_tbd: // menu item under development!
m->param_txt = m_tbd;
vptr = malloc(17);
if (vptr == NULL)
{
return -RIG_NOMEM;
}
for (j = 0; vptr[i] != ';' && i < 17; i++)
{
vptr[i] == m->cmd[i];
}
vptr[i] = '\0';
return -RIG_NIMPL;
case m_off:
if (m->cmd[9] == '0')
{
m->param_txt = mref->param_txt[i];
m->val = 0;
retval = RIG_OK;
}
break;
case m_num:
default:
return -RIG_NIMPL;
}
}
switch (m->menu[0])
{
case 00:
case 00:
case 00:
case 00:
case 00:
case 00:
case 00:
case 00:
default:
return -RIG_EINTERNAL; // I'm requiring 100% match
}
return RIG_OK;
}
// End of ts2k_menu.c

View File

@ -1,240 +0,0 @@
/*
* ts2k_menu.h (C) Copyright 2002 by Dale E. Edmons. All rights reserved.
*/
/*
* License: GNU (same as what hamlib currently is using)
*/
/*
* status: uncompiled. Haven't finished factory defaults.
* anything with m_tbd is: to be developed
*/
/* Header to implement menus equivalent to those on the TS-2000. */
// sub-menu defines
#define MENU_A 1
#define MENU_B 2
#define MENU_C 3
#define MENU_D 4
#define MENU_E 5
#define MENU_F 6
// parameter value text. may be used in any menu.
const char m_on[]="On";
const char m_off[]="Off";
const char m_to[]="TO";
const char m_co[]="CO";
const char m_h_boost[]="High Boost";
const char m_b_boost[]="Bass Boost";
const char m_f_pass[]="F Pass";
const char m_conven[]="Conven";
const char m_user[]="User";
const char m_auto[]="Auto";
const char m_norm[]="Normal";
const char m_inv[]="Inverse";
const char m_low[]="Low";
const char m_mid[]="Mid";
const char m_hi[]="High";
const char m_burst[]="Burst";
const char m_cont[]="Cont";
const char m_slow[]="Slow";
const char m_fast[]="Fast";
const char m_main[]="Main";
const char m_sub[]="Sub";
const char m_tnc_band[]="TNC Band";
const char m_main_sub[]="Main & Sub";
const char m_man[]="Manual";
const char m_morse[]="Morse";
const char m_voice[]="Voice";
const char m_neg[]="Negative";
const char m_pos[]="Positive";
const char m_locked[]="Locked";
const char m_cross[]="Cross";
const char m_client[]="Client";
const char m_commander[]="Commander";
const char m_transporter[]="Transporter";
const char m_font1[]="font1";
const char m_font2[]="font2";
const char m_num[8+2]; // storage for numeric constants
const char m_text[8+2]; // storage for text constants
//const char m_[]="";
// array valued constants (mostly) or other undefined text
const char m_tbd[]="hamlib: t.b.d.";
// PF1 key assignments
#define KEY_MENU_MAX 62
#define KEY_KEY_MAX 90
#define KEY_UNASSIGNED 99
const char key_menu[]="Menu"; // menu # 0-62
const char key_none[]="None";
const char key_key[][KEY_KEY_MAX-KEY_MENU_MAX] = {
"Voice1", Voice2", "Voice3", "RX Moni", "DSP Moni",
"Quick Memo MR", "Quick Memo M.IN", "Split", "TF-SET",
"A/B", "VFO/M", "A=B", "Scan", "M>VFO", "M.IN", "CW TUNE",
"CH1", "CH2", "CH3", "Fine", "CLR", "Call", "CTRL",
"1MHz", "ANT1/2", "N.B.", "N.R.", "B.C.", "A.N.",
""
};
typedef struct {
const char menu_no[];
const char txt[];
const char *param_txt[];
char cmd[30];
const int menu[4];
int val; // same as P5
} ts2k_menu_t;
/*
* Defaults for menu_t.val were obtained via minicom
* on my rig after doing a full reset to factory defaults.
* (unfinished)
*/
const ts2k_menu_t ts2k_menus[] = {
{ "00", "Display Brightness", {m_off, m_num, NULL}, "", {00,0,0,0}, 3},
{ "01", "Key Illumination", {m_off, m_on, NULL}, "", {01,0,0,0}, 1},
{ "02", "Tuning Control Change Per Revolution", {m_num, NULL}, "", {02,0,0,0}, 1},
{ "03", "Tune using MULTI/CH Frequency Step", {m_off, m_on, NULL}, "", {03,0,0,0}, 1},
{ "04", "Round off VFO using MULTI/CH Control", {m_off, m_on, NULL}, "", {04,0,0,0}, 1},
{ "05", "9kHz step size for MULTI/CH in AM Broadcast Band", {m_off, m_on, NULL}, "", {05,0,0,0}, 0},
{ "06A", "Mem: Memory-VFO Split", {m_off, m_on, NULL}, "", {06,1,0,0}, 0},
{ "06B", "Mem: Temporary Frequency change after Memory Recall", {m_off, m_on, NULL}, "", {06,2,0,0}, 0},
{ "07", "Program scan partially slowed", {m_off, m_on, NULL}, "", {07,0,0,0}, 0},
{ "08", "Program Slow-Scan Range", {m_num, NULL}, "", {08,0,0,0}, 0},
{ "09", "Program scan hold", {m_off, m_on, NULL}, "", {09,0,0,0}, 0},
{ "10", "Scan Resume Method", {m_to, m_co, NULL}, "", {10,0,0,0}, 0},
{ "11", "Visual Scan Range", {m_tbd, NULL}, "", {11,0,0,0}, 0},
{ "12", "Beep Volume", {m_off, m_num, NULL}, "", {12,0,0,0}, 0},
{ "13", "Sidetone Volume", {m_off, m_num, NULL}, "", {13,0,0,0}, 0},
{ "14", "Message Playback Volume", {m_off, m_num, NULL}, "", {14,0,0,0}, 0},
{ "15", "Voice Volume", {m_off, m_num, NULL}, "", {15,0,0,0}, 0},
{ "16", "Output Configuration for sp2 or headphones", {m_tbd, NULL}, "", {16,0,0,0}, 0},
{ "17", "Reversed output configuration for sp2 or headphones", {m_off, m_on, NULL}, "", {17,0,0,0}, 0},
{ "18", "RX-Dedicated antenna", {m_off, m_on, NULL}, "", {18,0,0,0}, 0},
{ "19A", "S-Meter: SQ", {m_off, m_on, NULL}, "", {19,1,0,0}, 0},
{ "19B", "S-Meter: Hang Time", {m_off, m_tbd, NULL}, "", {19,2,0,0}, 0},
{ "20", "RX Equalizer", {m_off, m_h_boost, m_b_boost, m_conven, m_user, NULL}, "", {20,0,0,0}, 0},
{ "21", "TX Equalizer", {m_off, m_h_boost, m_b_boost, m_conven, m_user, NULL}, "", {21,0,0,0}, 0},
{ "22", "TX Filter Bandwidth for SSB or AM", {m_tbd, NULL}, "", {22,0,0,0}, 0},
{ "23", "Fine Transmit power change step", {m_off, m_on, NULL}, "", {23,0,0,0}, 0},
{ "24", "Time-out Timer", {m_off, m_tbd, NULL}, "", {24,0,0,0}, 0},
{ "25", "Transverter Frequency Display", {m_off, m_on, NULL}, "", {25,0,0,0}, 0},
{ "26", "TX Hold; Antenna tuner", {m_off, m_on, NULL}, "", {26,0,0,0}, 0},
{ "27", "Antenna tuner while receiving", {m_off, m_on, NULL}, "", {27,0,0,0}, 0},
{ "28A", "Linear Amp Control Relay: HF", {m_off, m_num, NULL}, "", {28,1,0,0}, 0},
{ "28B", "Linear Amp Control Relay: 50MHz", {m_off, m_num, NULL}, "", {28,2,0,0}, 0},
{ "28C", "Linear Amp Control Relay: 144MHz", {m_off, m_num, NULL}, "", {28,3,0,0}, 0},
{ "28D", "Linear Amp Control Relay: 430MHz", {m_off, m_num, NULL}, "", {28,4,0,0}, 0},
{ "28E", "Linear Amp Control Relay: 1.2GHz", {m_off, m_num, NULL}, "", {28,5,0,0}, 0},
{ "29A", "CW Message: Playback Repeat", {m_off, m_on, NULL}, "", {29,1,0,0}, 0},
{ "29B", "CW Message: Playback Interval", {m_num, NULL}, "", {29,2,0,0}, 0},
{ "30", "Keying Priority over playback", {m_off, m_on, NULL}, "", {30,0,0,0}, 0},
{ "31", "CW RX Pitch/TX sidetone frequency", {m_tbd, NULL}, "", {31,0,0,0}, 0},
{ "32", "CW rise time", {m_tbd, NULL}, "", {32,0,0,0}, 0},
{ "33", "CW weighting", {m_auto, m_tbd, NULL}, "", {33,0,0,0}, 0},
{ "34", "Reversed CW weighting", {m_off, m_on, NULL}, "", {34,0,0,0}, 0},
{ "35", "Bug key function", {m_off, m_on, NULL}, "", {35,0,0,0}, 0},
{ "36", "Auto CW TX when keying in SSB", {m_off, m_on, NULL}, "", {36,0,0,0}, 0},
{ "37", "Frequency correction for SSB-to-CW change", {m_off, m_on, NULL}, "", {37,0,0,0}, 0},
{ "38", "FSK shift", {m_tbd, NULL}, "", {38,0,0,0}, 0},
{ "39", "FSK key-down polarity", {m_norm, m_inv, NULL}, "", {39,0,0,0}, 0},
{ "40", "FSK tone frequency", {m_tbd, NULL}, "", {40,0,0,0}, 0},
{ "41", "FM mic gain", {m_low, m_mid, m_high, NULL}, "", {41,0,0,0}, 0},
{ "42", "FM sub-tone type", {m_burst, m_cont, NULL}, "", {42,0,0,0}, 0},
{ "43", "Auto repeater offset", {m_off, m_on, NULL}, "", {43,0,0,0}, 0},
{ "44", "TX hold; 1750Hz tone", {m_off, m_on, NULL}, "", {44,0,0,0}, 0},
{ "45A", "DTMF: Memory", {m_tbd, NULL}, "", {45,1,0,0}, 0},
{ "45B", "DTMF: TX speed", {m_fast, m_slow, NULL}, "", {45,2,0,0}, 0},
{ "45C", "DTMF: Pause duration", {m_tbd, NULL}, "", {45,3,0,0}, 0},
{ "45D", "DTMF: Mic control", {m_off, m_on, NULL}, "", {45,4,0,0}, 0},
{ "46", "TNC: Main/Sub", {m_main, m_sub, NULL}, "", {46,0,0,0}, 0},
{ "47", "Data transfer rate; Built-in TNC", {m_tbd, NULL}, "", {47,0,0,0}, 0},
{ "48", "DCD sense", {m_tnc, m_main_sub, NULL}, "", {48,0,0,0}, 0},
{ "49A", "Packet Cluster: Tune", {m_auto, m_man, NULL}, "", {49,1,0,0}, 0},
{ "49B", "Packet Cluster: RX confirmation tone", {m_off, m_morse, m_voice, NULL}, "", {49,2,0,0}, 0},
{ "50A", "TNC: filter bandwidth", {m_off, m_on, NULL}, "", {50,1,0,0}, 0},
{ "50B", "TNC: AF input level", {m_tbd, NULL}, "", {50,2,0,0}, 0},
{ "50C", "TNC: Main band AF output level", {m_tbd, NULL}, "", {50,3,0,0}, 0},
{ "50D", "TNC: Sub band AF output level", {m_tbd, NULL}, "", {50,4,0,0}, 0},
{ "50E", "TNC: External", {m_main, m_sub, NULL}, "", {50,5,0,0}, 0},
{ "50F", "TNC: Ext. Data transfer rate", {m_tbd, NULL}, "", {50,6,0,0}, 0},
{ "51A", "Front panel PF key program", {key_menu, key_key, NULL}, "", {51,1,0,0}, 0},
{ "51B", "Mic key program: PF1", {key_menu, key_key, NULL}, "", {51,2,0,0}, 0},
{ "51C", "Mic key program: PF2", {key_menu, key_key, NULL}, "", {51,3,0,0}, 0},
{ "51D", "Mic key program: PF3", {key_menu, key_key, NULL}, "", {51,4,0,0}, 0},
{ "51E", "Mic key program: PF4", {key_menu, key_key, NULL}, "", {51,5,0,0}, 0},
{ "52", "Settings copy to another transceiver", {m_off, m_on, NULL}, "", {52,0,0,0}, 0},
{ "53", "Settings Copy to VFO", {m_off, m_on, NULL}, "", {53,0,0,0}, 0},
{ "54", "TX inhibit", {m_off, m_on, NULL}, "", {54,0,0,0}, 0},
{ "55", "Packet operation", {m_off, m_on, NULL}, "", {0550,0,0}, 0},
{ "56", "COM connector parameters", {m_tbd, NULL}, "", {56,0,0,0}, 0},
{ "57", "Auto power off", {m_off, m_on, NULL}, "", {57,0,0,0}, 0},
{ "58", "Detachable-panel Display font in easy operation mode", {m_font1, m_font1, NULL}, "", {58,0,0,0}, 0},
{ "59", "Panel display contrast", {m_tbd, NULL}, "", {59,0,0,0}, 0},
{ "60", "Detachable-panel display reversal", {m_tbd, NULL}, "", {60,0,0,0}, 0},
{ "61A", "Repeater mode select", {m_off, m_locked, m_cross, NULL}, "", {61,1,0,0}, 0},
{ "61B", "TX hold; repeater", {m_off, m_on, NULL}, "", {61,2,0,0}, 0},
{ "61C", "Remote Control ID code", {m_num, NULL}, "", {61,3,0,0}, 0},
{ "61D", "Remote control acknowledge", {m_off, m_on, NULL}, "", {61,4,0,0}, 0},
{ "61E", "Remote control", {m_off, m_on, NULL}, "", {61,5,0,0}, 0},
{ "62A", "Commander callsign", {m_text, NULL}, "", {62,1,0,0}, 0},
{ "62B", "Transporter callsign", {m_text, NULL}, "", {62,2,0,0}, 0},
{ "62C", "Sky Command tone frequency", {m_tbd, NULL}, "", {62,3,0,0}, 0},
{ "62D", "Sky command communication speed", {m_tbd, NULL}, "", {62,4,0,0}, 0},
{ "62E", "Transceiver define", {m_off, m_client, m_command, m_transporter, NULL}, "", {62,5,0,0}, 0},
{ NULL, NULL, NULL, {00,0,0,0}, 0}
};
/*
* Items related to menu structure
*/
// Programmable memories
typedef struct {
int curr; // PM now in use
int orig; // what PM to restore on exit
int orig_menu; // orignal menu in effect
int menu; // menuA or menuB of current PM
// the following set which PM's are private or public
// they are set on init and enforced until exit
unsigned int pub;
unsigned int priv;
#ifdef TS2K_ENFORCE_PM
# define TS2K_PM_PUB ( (1<<2) | (1<<3) )
# define TS2K_PM_PRIV ( (1<<0) | (1<<1) | (1<<4) | (1<<5) )
#else
# define TS2K_PM_PUB ( (1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5) )
# define TS2K_PM_PRIV (0)
#endif
} ts2k_pm_t;
// Implemented/coded functions
int ts2k_menu_init(RIG *rig, ts2k_menu_t *menu[]);
int ts2k_menu_close(RIG *rig, ts2k_menu_t *menu[]);
int ts2k_get_menu_no(RIG *rig, ts2k_menu_t *menu, int *main, int *sub);
int ts2k_set_menu_no(RIG *rig, ts2k_menu_t *menu, int main, int sub);
// Unimplemented/uncoded functions
char * ts2k_list_menu_no(RIG *rig, ts2k_menu_t *menu, int main, int sub);
int ts2k_get_menu(RIG *rig, ts2k_menu_t *menu);
int ts2k_set_menu(RIG *rig, ts2k_menu_t *menu);
int ts2k_menu_parse(RIG *rig, ts2k_menu_t *menu);
/*
* Related functions specific to this rig
*/
// Programmable memories[0, ..., 5] + menu[A, ..., B]
int ts2k_get_menu_mode(RIG *rig, ts2k_menu_t *menu, ts2k_pm_t *pm);
int ts2k_set_menu_mode(RIG *rig, ts2k_menu_t *menu, ts2k_pm_t *pm);
int ts2k_pm_init(RIG *rig, ts2k_pm_t *pm);
int ts2k_pm_close(RIG *rig, ts2k_pm_t *pm);
// End ts2k_menu.c

View File

@ -77,7 +77,7 @@ static const struct confparams ts450_ext_parms[] =
{ RIG_CONF_END, NULL, }
};
static int ts450_open(RIG *rig)
int ts450_open(RIG *rig)
{
int err;
int maxtries;

View File

@ -52,6 +52,7 @@ kenwood_ts480_get_info(RIG *rig)
{
char firmbuf[50];
int retval;
size_t firm_len;
retval = kenwood_transaction(rig, "TY", firmbuf, sizeof(firmbuf));
@ -60,7 +61,7 @@ kenwood_ts480_get_info(RIG *rig)
return NULL;
}
size_t firm_len = strlen(firmbuf);
firm_len = strlen(firmbuf);
if (firm_len != 5)
{

View File

@ -337,7 +337,6 @@ ts570_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
char levelbuf[16];
int kenwood_val;
int i;
switch (level)
{
@ -349,7 +348,9 @@ ts570_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
sprintf(levelbuf, "PA0");
}
else
else {
int i;
for (i = 0; i < MAXDBLSTSIZ; i++)
if (kenwood_val == rig->state.preamp[i])
{
@ -360,6 +361,7 @@ ts570_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
return -RIG_EINVAL;
}
}
return kenwood_transaction(rig, levelbuf, NULL, 0);
@ -394,7 +396,6 @@ ts570_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
size_t ack_len;
int levelint;
int retval;
int i;
switch (level)
{
@ -471,6 +472,8 @@ ts570_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
}
else
{
int i;
for (i = 0; i < levelint && i < MAXDBLSTSIZ; i++)
{
if (rig->state.preamp[i] == 0)
@ -760,6 +763,7 @@ int ts570_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
{
char infobuf[50];
int retval;
size_t info_len;
retval = kenwood_transaction(rig, "IF", infobuf, sizeof(infobuf));
@ -768,7 +772,7 @@ int ts570_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
return retval;
}
size_t info_len = strlen(infobuf);
info_len = strlen(infobuf);
if (info_len != 37 || infobuf[1] != 'F')
{

View File

@ -29,6 +29,7 @@
#include "hamlib/rig.h"
#include "idx_builtin.h"
#include "kenwood.h"
#include "cal.h"
/* Function declarations */
@ -90,7 +91,7 @@ const struct rig_caps ts590_caps =
.rig_model = RIG_MODEL_TS590S,
.model_name = "TS-590S",
.mfg_name = "Kenwood",
.version = BACKEND_VER ".2",
.version = BACKEND_VER ".3",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -435,16 +436,11 @@ const struct rig_caps ts590sg_caps =
*/
const char *ts590_get_info(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return "*rig == NULL";
}
char firmbuf[10];
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = kenwood_safe_transaction(rig, "TY", firmbuf, 10, 6);
if (retval != RIG_OK)
@ -476,6 +472,14 @@ int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
switch (level)
{
case RIG_LEVEL_KEYSPD:
case RIG_LEVEL_AGC:
case RIG_LEVEL_SQL:
case RIG_LEVEL_CWPITCH:
case RIG_LEVEL_RFPOWER:
case RIG_LEVEL_RF:
return kenwood_get_level(rig, vfo, level, val);
case RIG_LEVEL_AF:
return get_kenwood_level(rig, "AG0", &val->f);
@ -563,6 +567,38 @@ int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
sscanf(lvlbuf + 3, "%d", &val->i);
return retval;
default: return rig_get_level(rig, vfo, level, val);
case RIG_LEVEL_RAWSTR:
case RIG_LEVEL_STRENGTH:
retval = kenwood_transaction(rig, "SM0", lvlbuf, sizeof(lvlbuf));
if (retval != RIG_OK)
{
return retval;
}
lvl_len = strlen(lvlbuf);
if (((lvl_len != 7)) || lvlbuf[1] != 'M')
{
/* TS-590 returns 8 bytes for S meter level */
rig_debug(RIG_DEBUG_ERR, "%s: wrong answer len=%d\n", __func__, (int)lvl_len);
return -RIG_ERJCTED;
}
/* Frontend expects: -54 = S0, 0 = S9 */
sscanf(lvlbuf + 3, "%d", &val->i);
/* TS-590 main receiver returns values from 0 - 30 */
/* Indicates # of dots on meter */
/* so first 15 are S0-S9 and last 15 are 20/40/60 */
if (level == RIG_LEVEL_STRENGTH)
{
cal_table_t str_cal = TS590_SM_CAL;
val->i = (int) rig_raw2val(val->i, &str_cal);
}
return retval;
default: return -RIG_EINVAL;
}
}

View File

@ -29,6 +29,7 @@
#include "bandplan.h"
#include "kenwood.h"
extern int ts450_open(RIG *rig);
#define TS690_ALL_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_CW|RIG_MODE_RTTYR|RIG_MODE_CWR|RIG_MODE_SSB)
#define TS690_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_CWR)
@ -37,7 +38,7 @@
/* FIXME: TBC */
#define TS690_FUNC_ALL (RIG_FUNC_LOCK|RIG_FUNC_AIP|RIG_FUNC_TONE)
#define TS690_LEVEL_ALL (RIG_LEVEL_STRENGTH|RIG_LEVEL_AGC|RIG_LEVEL_METER|RIG_LEVEL_SWR|RIG_LEVEL_ALC)
#define TS690_LEVEL_ALL (RIG_LEVEL_STRENGTH|RIG_LEVEL_METER|RIG_LEVEL_SWR|RIG_LEVEL_ALC)
#define TS690_PARMS (RIG_PARM_ANN) /* optional */
@ -76,7 +77,7 @@ const struct rig_caps ts690s_caps =
.rig_model = RIG_MODEL_TS690S,
.model_name = "TS-690S",
.mfg_name = "Kenwood",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -96,7 +97,7 @@ const struct rig_caps ts690s_caps =
.has_get_func = TS690_FUNC_ALL,
.has_set_func = TS690_FUNC_ALL,
.has_get_level = TS690_LEVEL_ALL | RIG_LEVEL_RFPOWER,
.has_get_level = TS690_LEVEL_ALL,
.has_set_level = RIG_LEVEL_SET(TS690_LEVEL_ALL),
.has_get_parm = TS690_PARMS,
.has_set_parm = RIG_LEVEL_SET(TS690_PARMS), /* FIXME: parms */
@ -166,7 +167,7 @@ const struct rig_caps ts690s_caps =
.rig_init = kenwood_init,
.rig_cleanup = kenwood_cleanup,
.rig_open = kenwood_open,
.rig_open = ts450_open,
.rig_close = kenwood_close,
.set_freq = kenwood_set_freq,
.get_freq = kenwood_get_freq,

View File

@ -108,7 +108,6 @@ static int ts870s_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
size_t buf_len;
int retval;
buf_len = 50;
retval = kenwood_transaction(rig, "MD", buf, sizeof(buf));
if (retval != RIG_OK)

View File

@ -162,6 +162,7 @@ const struct rig_caps ts950sdx_caps =
.priv = (void *)& ts950_priv_caps,
.rig_init = kenwood_init,
.rig_open = kenwood_open,
.rig_cleanup = kenwood_cleanup,
.set_freq = kenwood_set_freq,
.get_freq = kenwood_get_freq,

View File

@ -107,7 +107,7 @@ const struct rig_caps xg3_caps =
.rig_model = RIG_MODEL_XG3,
.model_name = "XG3",
.mfg_name = "Elecraft",
.version = "20150101",
.version = "20191218",
.copyright = "LGPL",
.status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -171,11 +171,11 @@ const struct rig_caps xg3_caps =
*/
int xg3_init(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv;
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
priv = (struct xg3_priv_data *)malloc(sizeof(struct xg3_priv_data));
if (!priv)
@ -212,14 +212,10 @@ int xg3_init(RIG *rig)
*/
int xg3_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
ptt_t ptt;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = elecraft_open(rig);
@ -228,7 +224,6 @@ int xg3_open(RIG *rig)
return err;
}
ptt_t ptt;
xg3_get_ptt(rig, RIG_VFO_A, &ptt); // set our PTT status
return RIG_OK;
@ -237,15 +232,10 @@ int xg3_open(RIG *rig)
int xg3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char levelbuf[16];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (level)
{
case RIG_LEVEL_RFPOWER:
@ -272,18 +262,13 @@ int xg3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
*/
int xg3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !val)
{
return -RIG_EINVAL;
}
char cmdbuf[32], replybuf[32];
int retval;
size_t replysize = sizeof(replybuf);
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (level)
{
case RIG_LEVEL_RFPOWER:
@ -344,11 +329,11 @@ int xg3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
*/
int xg3_get_vfo(RIG *rig, vfo_t *vfo)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
if (!rig || !vfo)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!vfo)
{
return -RIG_EINVAL;
}
@ -362,11 +347,11 @@ int xg3_get_vfo(RIG *rig, vfo_t *vfo)
*/
int xg3_set_vfo(RIG *rig, vfo_t vfo)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
if (!rig || !vfo)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!vfo)
{
return -RIG_EINVAL;
}
@ -384,17 +369,12 @@ int xg3_set_vfo(RIG *rig, vfo_t vfo)
*/
int xg3_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int err;
vfo_t tvfo;
char cmdbuf[20];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char cmdbuf[20];
tvfo = (vfo == RIG_VFO_CURR ||
vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo;
@ -422,7 +402,7 @@ int xg3_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
sprintf(cmdbuf, "F,%011ld", (long)freq);
}
int err = kenwood_transaction(rig, cmdbuf, NULL, 0);
err = kenwood_transaction(rig, cmdbuf, NULL, 0);
return err;
}
@ -432,21 +412,21 @@ int xg3_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
*/
int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct rig_state *rs;
if (!rig || !freq)
{
return -RIG_EINVAL;
}
char freqbuf[50];
int freqsize = sizeof(freqbuf);
char cmdbuf[16];
int retval;
int offset;
vfo_t tvfo;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!freq)
{
return -RIG_EINVAL;
}
tvfo = (vfo == RIG_VFO_CURR ||
vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo;
rs = &rig->state;
@ -491,7 +471,7 @@ int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
return retval;
}
int offset = tvfo == RIG_VFO_A ? 2 : 5;
offset = tvfo == RIG_VFO_A ? 2 : 5;
sscanf(freqbuf + offset, "%" SCNfreq, freq);
@ -503,13 +483,14 @@ int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
*/
int xg3_set_powerstat(RIG *rig, powerstat_t status)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
const char *cmd = "X";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (status == RIG_POWER_OFF)
{
const char *cmd = "X";
priv->powerstat = RIG_POWER_OFF;
return kenwood_transaction(rig, cmd, NULL, 0);
}
@ -524,23 +505,14 @@ int xg3_set_powerstat(RIG *rig, powerstat_t status)
*/
int xg3_get_powerstat(RIG *rig, powerstat_t *status)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
const char *cmd = "G"; // any command to test will do
char reply[32];
int retval = kenwood_transaction(rig, cmd, NULL, 0);
if (retval != RIG_OK)
{
return retval;
}
struct rig_state *rs = &rig->state;
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
char reply[32];
retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (retval != RIG_OK)
{
@ -562,11 +534,11 @@ int xg3_get_powerstat(RIG *rig, powerstat_t *status)
*/
int xg3_set_mem(RIG *rig, vfo_t vfo, int ch)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char cmdbuf[32];
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (ch < 0 || ch > 11)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s invalid channel#%02d\n", __func__, ch);
@ -591,13 +563,13 @@ int xg3_set_mem(RIG *rig, vfo_t vfo, int ch)
*/
int xg3_get_mem(RIG *rig, vfo_t vfo, int *ch)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char cmdbuf[32];
char reply[32];
int retval;
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
sprintf(cmdbuf, "C;");
retval = kenwood_transaction(rig, cmdbuf, NULL, 0);
@ -623,17 +595,11 @@ int xg3_get_mem(RIG *rig, vfo_t vfo, int *ch)
*/
int xg3_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
if (!rig)
{
return -RIG_EINVAL;
}
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = kenwood_simple_transaction(rig,
(ptt == RIG_PTT_ON) ? "O,01" : "O,00", 0);
@ -650,18 +616,17 @@ int xg3_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
*/
int xg3_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char pttbuf[6];
int retval;
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
if (!rig || !ptt)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!ptt)
{
return -RIG_EINVAL;
}
char pttbuf[6];
int retval;
retval = kenwood_safe_transaction(rig, "O", pttbuf, 6, 4);
if (retval != RIG_OK)
@ -680,12 +645,12 @@ int xg3_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
*/
int xg3_set_parm(RIG *rig, setting_t parm, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int ival;
char cmdbuf[16];
int retval = -RIG_EINVAL;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (parm)
{
case RIG_PARM_BACKLIGHT:
@ -709,12 +674,12 @@ int xg3_set_parm(RIG *rig, setting_t parm, value_t val)
*/
int xg3_get_parm(RIG *rig, setting_t parm, value_t *val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int ival;
char replybuf[6];
int retval = -RIG_EINVAL;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (parm)
{
case RIG_PARM_BACKLIGHT:

View File

@ -224,7 +224,7 @@ int drt1_set_conf(RIG *rig, token_t token, const char *val)
break;
case TOK_REFMULT:
sscanf(val, "%d", &priv->ref_mult);
sscanf(val, "%u", &priv->ref_mult);
break;
case TOK_IFMIXFREQ:
@ -232,7 +232,7 @@ int drt1_set_conf(RIG *rig, token_t token, const char *val)
break;
case TOK_PUMPCRNT:
sscanf(val, "%d", &priv->pump_crrnt);
sscanf(val, "%u", &priv->pump_crrnt);
break;
default:
@ -260,7 +260,7 @@ int drt1_get_conf(RIG *rig, token_t token, char *val)
break;
case TOK_REFMULT:
sprintf(val, "%d", priv->ref_mult);
sprintf(val, "%u", priv->ref_mult);
break;
case TOK_IFMIXFREQ:
@ -268,7 +268,7 @@ int drt1_get_conf(RIG *rig, token_t token, char *val)
break;
case TOK_PUMPCRNT:
sprintf(val, "%d", priv->pump_crrnt);
sprintf(val, "%u", priv->pump_crrnt);
break;
default:
@ -377,7 +377,7 @@ static int ad_write_reg(hamlib_port_t *port, unsigned addr, unsigned nb_bytes,
for (i = 7; i >= 0; i--)
{
ad_sdio(port, addr & (1U << i) ? 0 : 1); /* RTS 0 or 1 */
ad_sdio(port, (addr & (1U << i)) ? 0 : 1); /* RTS 0 or 1 */
ad_sclk(port, 1); /* TXD 1, clock */
ad_sclk(port, 0); /* TXD 0 */
}
@ -386,7 +386,7 @@ static int ad_write_reg(hamlib_port_t *port, unsigned addr, unsigned nb_bytes,
for (i = nb_bytes * 8 - 1; i >= 0; i--)
{
ad_sdio(port, data & (1U << i) ? 0 : 1); /* RTS 0 or 1 */
ad_sdio(port, (data & (1U << i)) ? 0 : 1); /* RTS 0 or 1 */
ad_sclk(port, 1); /* TXD 1, clock */
ad_sclk(port, 0); /* TXD 0 */
}

View File

@ -323,7 +323,7 @@ static int ad_write(hamlib_port_t *port, unsigned data)
for (i = 0; i < 16; i++)
{
ad_sdata(port, data & mask ? 0 : 1); /* RTS 0 or 1 */
ad_sdata(port, (data & mask) ? 0 : 1); /* RTS 0 or 1 */
ad_sclk(port, 1); /* TXD 1, clock */
ad_sclk(port, 0); /* TXD 0 */
mask >>= 1; /* Next bit for masking */

View File

@ -967,10 +967,10 @@ static void find_P_Q_DIV1N(
{
#define VCO_MIN 100000000
#define VCO_MAX 400000000
int Ptotal, Pmin, Pmax;
int Ptotal;
int Qtotal, Qmax = 40;
int Div1N;
double REFdivQ, PmulREFdivQ;
double PmulREFdivQ;
double Ref = priv->osc_freq * 1000.0;
double freq4 = freq * 4;
double newdelta, delta = fabs((priv->P * (Ref / priv->Q) / priv->Div1N) -
@ -980,11 +980,11 @@ static void find_P_Q_DIV1N(
/* Qmax = (int) ( Ref / 250000); */
for (Qtotal = 2; Qtotal <= Qmax; Qtotal++)
{
REFdivQ = (Ref / Qtotal);
double REFdivQ = (Ref / Qtotal);
/* For stable operation: Ptotal*(Ref/Qtotal) must be ... */
Pmin = (int)(VCO_MIN / REFdivQ); /* ... >= 100mHz */
Pmax = (int)(VCO_MAX / REFdivQ); /* ... <= 400mHz */
int Pmin = (int)(VCO_MIN / REFdivQ); /* ... >= 100mHz */
int Pmax = (int)(VCO_MAX / REFdivQ); /* ... <= 400mHz */
for (Ptotal = Pmin; Ptotal <= Pmax; Ptotal++)
{
@ -1023,10 +1023,11 @@ int elektor507_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rig->state.priv;
freq_t final_freq;
int ret = 0;
int Mux;
if (priv->ant == ANT_AUTO)
{
int Mux;
/* Automatically select appropriate filter */
if (freq <= kHz(1600))
{

View File

@ -418,7 +418,7 @@ const char *fifisdr_get_info(RIG *rig)
return NULL;
}
snprintf(buf, sizeof(buf), "Firmware version: %d", svn_version);
snprintf(buf, sizeof(buf), "Firmware version: %u", svn_version);
return buf;
}
@ -639,11 +639,6 @@ static int fifisdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
/* Transform Hamlib value (float: 0...1) to an integer range (0...100) */
fifi_squelch = (uint8_t)(val.f * 100.0f);
if (fifi_squelch < 0)
{
fifi_squelch = 0;
}
if (fifi_squelch > 100)
{
fifi_squelch = 100;

View File

@ -149,11 +149,12 @@ static int rshfiq_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
char cmdstr[15];
char stopset[2];
stopset[0] = '\r';
stopset[1] = '\n';
int retval;
serial_flush(&rig->state.rigport);
stopset[0] = '\r';
stopset[1] = '\n';
snprintf(cmdstr, sizeof(cmdstr), "*f?\r");
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, cmdstr);
@ -186,11 +187,12 @@ static int rshfiq_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
static int rshfiq_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
char cmdstr[5];
int retval;
cmdstr[0] = '*';
cmdstr[1] = 'x';
cmdstr[3] = '\r';
cmdstr[4] = 0;
int retval;
if (ptt == RIG_PTT_ON)
{

View File

@ -869,7 +869,7 @@ int si570xxxusb_set_conf(RIG *rig, token_t token, const char *val)
struct si570xxxusb_priv_data *priv;
freq_t freq;
double multiplier;
int i2c_addr;
unsigned int i2c_addr;
priv = (struct si570xxxusb_priv_data *)rig->state.priv;
@ -904,7 +904,7 @@ int si570xxxusb_set_conf(RIG *rig, token_t token, const char *val)
return -RIG_EINVAL;
}
if (i2c_addr < 0 || i2c_addr >= (1 << 9))
if (i2c_addr >= (1 << 9))
{
return -RIG_EINVAL;
}
@ -964,7 +964,7 @@ static int setBPF(RIG *rig, int enable)
libusb_device_handle *udh = rig->state.rigport.handle;
/* allocate enough space for up to 16 filters */
unsigned short FilterCrossOver[16];
int nBytes, i;
int nBytes;
// Does FilterCrossOver needs endianess ordering ?
@ -981,16 +981,17 @@ static int setBPF(RIG *rig, int enable)
if (nBytes > 2)
{
nBytes = libusb_control_transfer(udh, REQUEST_TYPE_IN,
int i;
int retval = libusb_control_transfer(udh, REQUEST_TYPE_IN,
REQUEST_FILTERS, enable, (nBytes / 2) - 1,
(unsigned char *) FilterCrossOver, sizeof(FilterCrossOver),
rig->state.rigport.timeout);
if (nBytes < 0)
if (retval < 1)
{
return -RIG_EIO;
}
nBytes = retval;
rig_debug(RIG_DEBUG_TRACE, "%s: Filter Bank 1:\n", __func__);

View File

@ -22,26 +22,10 @@
*/
/* NOTE!!! AIX requires this to be the first thing in the file.
Do not put ANYTHING before it! */
#if !defined (__GNUC__) && defined (_AIX)
#pragma alloca
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not __GNUC__ */
#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
#include <alloca.h>
#else
#ifndef _AIX
char *alloca();
#endif
#endif /* alloca.h */
#endif /* not __GNUC__ */
#if !__STDC__ && !defined(const) && IN_GCC
#define const
#endif
@ -67,12 +51,9 @@ char *alloca();
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#undef alloca
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
#include <stdlib.h>
#else /* Not GNU C library. */
#define __alloca alloca
#endif /* GNU C library. */
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
@ -244,7 +225,7 @@ exchange(argv)
char **argv;
{
int nonopts_size = (last_nonopt - first_nonopt) * sizeof(char *);
char **temp = (char **) __alloca(nonopts_size);
char **temp = (char **) malloc(nonopts_size);
/* Interchange the two blocks of data in ARGV. */
@ -259,6 +240,7 @@ char **argv;
first_nonopt += (optind - last_nonopt);
last_nonopt = optind;
free(temp);
}
/* Scan elements of ARGV (whose length is ARGC) for option characters
@ -326,8 +308,6 @@ const struct option *longopts;
int *longind;
int long_only;
{
int option_index;
optarg = 0;
/* Initialize the internal data when the first call is made.
@ -474,6 +454,7 @@ int long_only;
int ambig = 0;
const struct option *pfound = NULL;
int indfound;
int option_index;
while (*s && *s != '=')
{
@ -740,11 +721,11 @@ main(argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int c;
int digit_optind = 0;
int this_option_optind = optind ? optind : 1;
c = getopt(argc, argv, "abc:d:0123456789");

View File

@ -91,11 +91,11 @@ main(argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int c;
int digit_optind = 0;
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =

View File

@ -292,6 +292,18 @@ const char *lowe_get_info(RIG *rig)
/* hack: no idea what INF is for */
retval = lowe_transaction(rig, "INF?" EOM, 5, idbuf, &id_len);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_VERBOSE,"%s: INF didn't work\n", __func__);
// non-fatal
}
if (retval != RIG_OK)
{
return NULL;
}
/* this is the real one */
retval = lowe_transaction(rig, "TYP?" EOM, 5, idbuf, &id_len);

View File

@ -68,12 +68,12 @@
static int rc2800_parse(char *s, char *device, float *value)
{
int i, msgtype = 0, errcode = 0;
int msgtype = 0, errcode = 0;
int len;
rig_debug(RIG_DEBUG_TRACE, "%s: device return->%s", __func__, s);
int len = strlen(s);
len = strlen(s);
if (len == 0)
{
return -RIG_EPROTO;
@ -83,6 +83,7 @@ static int rc2800_parse(char *s, char *device, float *value)
{
if (*s == 'A' || *s == 'E')
{
int i;
*device = *s;
if (!strncmp(s + 2, "ERR=", 4))
@ -324,15 +325,25 @@ rc2800_rot_stop(ROT *rot)
/* Stop AZ*/
retval = rc2800_transaction(rot, "A" CR, NULL, 0); /* select AZ */
if (retval != RIG_OK) { rig_debug(RIG_DEBUG_VERBOSE, "%s: A command failed?\n", __func__); }
retval = rc2800_transaction(rot, "S" CR, NULL, 0); /* STOP */
if (retval != RIG_OK) { rig_debug(RIG_DEBUG_VERBOSE, "%s: az S command failed?\n", __func__); }
/* do not overwhelm the MCU? */
usleep(200 * 1000);
/* Stop EL*/
retval = rc2800_transaction(rot, "E" CR, NULL, 0); /* select EL */
if (retval != RIG_OK) { rig_debug(RIG_DEBUG_VERBOSE, "%s: E command failed?\n", __func__); }
retval = rc2800_transaction(rot, "S" CR, NULL, 0); /* STOP */
if (retval != RIG_OK) { rig_debug(RIG_DEBUG_VERBOSE, "%s: el S command failed?\n", __func__); }
return retval;
}

View File

@ -320,6 +320,7 @@ static int meade_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
char eom;
size_t return_str_size;
int az_degrees, az_minutes, az_seconds, el_degrees, el_minutes, el_seconds;
int n;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -327,7 +328,7 @@ static int meade_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
rig_debug(RIG_DEBUG_VERBOSE, "%s: returned '%s'\n", __func__, return_str);
// GZ returns DDD*MM# or DDD*MM'SS#
// GA returns sDD*MM# or sDD*MM'SS#
int n = sscanf(return_str, "%d%*c%d:%d#%d%*c%d:%d%c", &az_degrees, &az_minutes,
n = sscanf(return_str, "%d%*c%d:%d#%d%*c%d:%d%c", &az_degrees, &az_minutes,
&az_seconds, &el_degrees, &el_minutes, &el_seconds, &eom);
if (n != 7 || eom != '#')
@ -432,10 +433,10 @@ static int meade_move(ROT *rot, int direction, int speed)
static const char *meade_get_info(ROT *rot)
{
static char buf[256]; // this is not thread-safe but not important either
struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
static char buf[256]; // this is not thread-safe but not important either
sprintf(buf, "Meade telescope rotator with LX200 protocol.\nModel: %s",
priv->product_name);
return buf;

View File

@ -64,12 +64,14 @@ static int miniVNA_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
}
#ifdef XXREMOVEDXX
static const char *miniVNA_get_info(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
return "miniVNA";
}
#endif
const struct rig_caps miniVNA_caps =
{

View File

@ -28,7 +28,6 @@
* (403) PCR1500 fw 2.0, proto 2.0 (usb) by KM3T
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -167,7 +166,6 @@ static int is_sub_rcvr(RIG *rig, vfo_t vfo);
static int
pcr_read_block(RIG *rig, char *rxbuffer, size_t count)
{
int err;
int read = 0, tries = 4;
struct rig_state *rs = &rig->state;
@ -188,7 +186,7 @@ pcr_read_block(RIG *rig, char *rxbuffer, size_t count)
char *p = &rxbuffer[0];
/* read first char */
err = read_block(&rs->rigport, p, 1);
int err = read_block(&rs->rigport, p, 1);
if (err < 0)
{
@ -813,7 +811,7 @@ pcr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
unsigned char buf[20];
int buf_len, err;
int pcrmode, pcrfilter;
int pcrmode;
rig_debug(RIG_DEBUG_VERBOSE, "%s: mode = %s, width = %d\n",
__func__, rig_strrmode(mode), (int)width);
@ -862,6 +860,7 @@ pcr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (width != RIG_PASSBAND_NOCHANGE)
{
int pcrfilter;
if (width == RIG_PASSBAND_NORMAL)
{
width = rig_passband_normal(rig, mode);
@ -1076,8 +1075,8 @@ pcr_get_info(RIG *rig)
"Optional devices:%s%s%s, Country: %s",
priv->firmware / 10, priv->firmware % 10,
priv->protocol / 10, priv->protocol % 10,
priv->options & OPT_UT106 ? " DSP" : "",
priv->options & OPT_UT107 ? " DARC" : "",
(priv->options & OPT_UT106) ? " DSP" : "",
(priv->options & OPT_UT107) ? " DARC" : "",
priv->options ? "" : " none",
country);
@ -1086,8 +1085,8 @@ pcr_get_info(RIG *rig)
__func__,
priv->firmware / 10, priv->firmware % 10,
priv->protocol / 10, priv->protocol % 10,
priv->options & OPT_UT106 ? " DSP" : "",
priv->options & OPT_UT107 ? " DARC" : "",
(priv->options & OPT_UT106) ? " DSP" : "",
(priv->options & OPT_UT107) ? " DARC" : "",
priv->options ? "" : " none",
country);
@ -1974,11 +1973,10 @@ int pcr_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
struct pcr_rcvr *rcvr = is_sub_rcvr(rig,
vfo) ? &priv->sub_rcvr : &priv->main_rcvr;
int err;
if (priv->auto_update == 0)
{
err = pcr_transaction(rig, is_sub_rcvr(rig, vfo) ? "I4?" : "I0?");
int err = pcr_transaction(rig, is_sub_rcvr(rig, vfo) ? "I4?" : "I0?");
if (err != RIG_OK)
{
@ -1993,7 +1991,7 @@ int pcr_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
* Bit 2: VSC open
* Bit 3: RX error (not ready to receive)
*/
*dcd = rcvr->squelch_status & 0x02 ? RIG_DCD_ON : RIG_DCD_OFF;
*dcd = (rcvr->squelch_status & 0x02) ? RIG_DCD_ON : RIG_DCD_OFF;
return RIG_OK;
}

View File

@ -49,8 +49,8 @@ struct pcr_priv_data
float volume;
float squelch;
int raw_level;
int squelch_status;
unsigned int raw_level;
unsigned int squelch_status;
} main_rcvr, sub_rcvr;

View File

@ -99,7 +99,6 @@ static int prm80_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
return retval;
}
retbuf[retval] = '\0';
#if 0
/*
@ -230,7 +229,7 @@ int prm80_set_mem(RIG *rig, vfo_t vfo, int ch)
return -RIG_EINVAL;
}
cmd_len = sprintf(cmdbuf, "N%02u", ch);
cmd_len = sprintf(cmdbuf, "N%02d", ch);
return prm80_transaction(rig, cmdbuf, cmd_len, NULL, NULL);
}
@ -318,9 +317,9 @@ int prm80_get_channel(RIG *rig, channel_t *chan)
chanstate = hhtoi(statebuf + 4) & 0x0f;
/* is it rptr_shift or split mode ? */
chan->rptr_shift = (chanstate & 0x01) == 0 ? RIG_RPT_SHIFT_NONE :
chanstate & 0x02 ? RIG_RPT_SHIFT_MINUS :
chanstate & 0x04 ? RIG_RPT_SHIFT_PLUS : RIG_RPT_SHIFT_NONE;
chan->flags = chanstate & 0x08 ? RIG_CHFLAG_SKIP : 0;
(chanstate & 0x02) ? RIG_RPT_SHIFT_MINUS :
(chanstate & 0x04) ? RIG_RPT_SHIFT_PLUS : RIG_RPT_SHIFT_NONE;
chan->flags = (chanstate & 0x08) ? RIG_CHFLAG_SKIP : 0;
chan->levels[LVL_SQL].f = ((float)(hhtoi(statebuf + 6) >> 4)) / 15.;
chan->levels[LVL_AF].f = ((float)(hhtoi(statebuf + 8) >> 4)) / 15.;
@ -356,12 +355,12 @@ int prm80_set_channel(RIG *rig, const channel_t *chan)
/* [T] = Set current channel state. (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq) ? */
/* Example: 1240080AFF0033F02D40 ? */
statebuf_len = sprintf(statebuf, "T%02X%02X%02X%02X%02X%02X%04X%04X",
chan->mode == RIG_MODE_FM ? 0x12 : 0x12,
0x12,
chan->channel_num,
chan->flags & RIG_CHFLAG_SKIP ? 0x08 : 0, /* TODO: tx shift */
(chan->flags & RIG_CHFLAG_SKIP) ? 0x08 : 0, /* TODO: tx shift */
(unsigned)(chan->levels[LVL_SQL].f * 15),
(unsigned)(chan->levels[LVL_AF].f * 15),
chan->flags & RIG_CHFLAG_SKIP ? 0x01 : 0x00, /* Lock */
(chan->flags & RIG_CHFLAG_SKIP) ? 0x01 : 0x00, /* Lock */
(unsigned)(chan->freq / 12500.),
(unsigned)(chan->tx_freq / 12500.)
);

View File

@ -49,7 +49,6 @@ struct prosistel_rot_priv_data
azimuth_t az;
elevation_t el;
struct timeval tv; /* time last az/el update */
azimuth_t target_az;
elevation_t target_el;
};
@ -119,13 +118,13 @@ transaction_write:
}
//check if reply match issued command
if (data[0] == 0x02 && data[3] == cmdstr[2])
if ( cmdstr && data[0] == 0x02 && data[3] == cmdstr[2])
{
rig_debug(RIG_DEBUG_VERBOSE, "%s Command %c reply received\n", __func__,
data[3]);
retval = RIG_OK;
}
else
else if (cmdstr)
{
rig_debug(RIG_DEBUG_VERBOSE,
"%s Error Command issued: %c doesn't match reply %c\n", __func__, cmdstr[2],
@ -198,6 +197,7 @@ static int prosistel_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
char data[20];
float posval;
int retval;
int n;
num_sprintf(cmdstr, STX"A?"CR);
retval = prosistel_transaction(rot, cmdstr, data, sizeof(data));
@ -209,7 +209,7 @@ static int prosistel_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
// Example response of 100 azimuth
// 02 41 2c 3f 2c 31 30 30 30 2c 52 0d .A,?,1000,R.
int n = sscanf(data, "%*cA,?,%f,%*c.", &posval);
n = sscanf(data, "%*cA,?,%f,%*c.", &posval);
if (n != 1)
{

View File

@ -341,7 +341,7 @@ int ra37xx_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
char freqbuf[BUFSZ];
int freq_len;
freq_len = sprintf(freqbuf, "F%ld", (unsigned long)freq);
freq_len = sprintf(freqbuf, "F%lu", (unsigned long)freq);
if (freq_len < 0)
{
@ -377,7 +377,7 @@ int ra37xx_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
int ra37xx_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
//struct ra37xx_priv_data *priv = (struct ra37xx_priv_data*)rig->state.priv;
int ra_mode, widthtype, widthnum;
int ra_mode, widthtype, widthnum=0;
char buf[BUFSZ];
switch (mode)
@ -407,19 +407,19 @@ int ra37xx_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
width = rig_passband_normal(rig, mode);
}
rig_debug(RIG_DEBUG_TRACE, "%s: widthtype = %i, widthnum = %i not implemented\n", __func__, widthtype, widthnum);
#ifdef XXREMOVEDXX
widthtype = 0; /* FIXME: no bandwidth for now */
widthnum = 0;
/* width set using 'B', QBCON must be queried firsthand */
#endif
#if 0
#ifdef XXREMOVEDXX
sprintf(buf, "M%d;B%d,%d", ra_mode, widthtype, widthnum);
#else
sprintf(buf, "M%d", ra_mode);
#endif
rig_debug(RIG_DEBUG_TRACE, "%s: widthtype = %i, widthnum = %i\n", __func__,
widthtype, widthnum);
return ra37xx_transaction(rig, buf, NULL, NULL);
}

View File

@ -82,7 +82,7 @@ static int racal_transaction(RIG *rig, const char *cmd, char *data,
int cmd_len;
int retval;
cmd_len = sprintf(cmdbuf, SOM "%d%s" EOM, priv->receiver_id, cmd);
cmd_len = sprintf(cmdbuf, SOM "%u%s" EOM, priv->receiver_id, cmd);
serial_flush(&rs->rigport);
@ -198,7 +198,7 @@ int racal_get_conf(RIG *rig, token_t token, char *val)
switch (token)
{
case TOK_RIGID:
sprintf(val, "%d", priv->receiver_id);
sprintf(val, "%u", priv->receiver_id);
break;
default:

View File

@ -233,6 +233,10 @@ gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
char buf[RESPSZ];
int buf_len, retval;
int nmode;
char *pmode = "UNKNOWN";
int n = sscanf(buf, "%*cI%d", &nmode);
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
@ -246,10 +250,6 @@ gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
return retval;
}
int nmode;
char *pmode = "UNKNOWN";
int n = sscanf(buf, "%*cI%d", &nmode);
if (n != 1)
{
return -RIG_EPROTO;
@ -289,6 +289,8 @@ gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
}
#ifdef XXREMOVEDXX
// Not referenced anywhere
int
gp2000_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
@ -312,7 +314,10 @@ gp2000_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
return retval;
}
#endif
#ifdef XXREMOVEDXX
// Not referenced anywhere
int
gp2000_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
{
@ -343,6 +348,7 @@ gp2000_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
return retval;
}
#endif
int
gp2000_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
@ -444,6 +450,12 @@ gp2000_get_info(RIG *rig)
{
static char infobuf[128];
int info_len, retval;
int addr = -1;
char type[32] = "unk type";
char rigid[32] = "unk rigid";
char sernum[32] = "unk sernum";
char *p;
rig_debug(RIG_DEBUG_VERBOSE, "%s\n", __func__);
@ -457,27 +469,21 @@ gp2000_get_info(RIG *rig)
return NULL;
}
int addr = -1;
char type[32] = "unk type";
char rigid[32] = "unk rigid";
char sernum[32] = "unk sernum";
char *p = strtok(infobuf, ",");
p = strtok(infobuf, ",");
while (p)
{
switch (p[0])
{
case 0x0a:
sscanf(p, "%*cIDENT%s", type);
sscanf(p, "%*cIDENT%31s", type);
break;
case 'i':
sscanf(p, "id%s", rigid);
sscanf(p, "id%31s", rigid);
break;
case 's':
sscanf(p, "sn%s", sernum);
sscanf(p, "sn%31s", sernum);
break;
default:

View File

@ -68,7 +68,6 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
{
int retval;
struct rig_state *rs;
char retbuf[BUFSZ + 1];
rs = &rig->state;
@ -88,6 +87,7 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
/*
* Transceiver sends back ">"
*/
char retbuf[BUFSZ + 1];
retval = read_string(&rs->rigport, retbuf, BUFSZ, PROMPT, strlen(PROMPT));
if (retval < 0)

View File

@ -183,13 +183,13 @@ const struct rig_caps trp8255_caps =
/* TODO: retry */
static int cu_transaction(RIG *rig, const char *cmd, int cmd_len)
{
int i, ret;
int i;
char retchar;
for (i = 0; i < cmd_len; i++)
{
ret = write_block(&rig->state.rigport, &cmd[i], 1);
int ret = write_block(&rig->state.rigport, &cmd[i], 1);
if (ret != RIG_OK)
{
@ -396,8 +396,7 @@ int cu_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
cmdbuf[0] = 'S'; /* low */
}
if (val.f < 0.6)
else if (val.f < 0.6)
{
cmdbuf[0] = 'U'; /* medium */
}

View File

@ -47,8 +47,6 @@ struct spid_rot2prog_priv_data
static int spid_rot_init(ROT *rot)
{
struct spid_rot2prog_priv_data *priv;
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
if (!rot || !rot->caps)
@ -59,6 +57,8 @@ static int spid_rot_init(ROT *rot)
if (rot->caps->rot_model == ROT_MODEL_SPID_ROT2PROG ||
rot->caps->rot_model == ROT_MODEL_SPID_MD01_ROT2PROG)
{
struct spid_rot2prog_priv_data *priv;
priv = (struct spid_rot2prog_priv_data *)malloc(sizeof(struct
spid_rot2prog_priv_data));

View File

@ -432,6 +432,8 @@ int frontamp_get_conf(AMP *amp, token_t token, char *val)
}
#ifdef XXREMOVEDXXC
// Not referenced anywhere
/**
* \brief Executes cfunc on all the elements stored in the conf table
* \param amp non-null
@ -483,6 +485,7 @@ int HAMLIB_API amp_token_foreach(AMP *amp,
return RIG_OK;
}
#endif
/**

View File

@ -125,6 +125,7 @@ static int remove_opened_amp(AMP *amp)
}
#ifdef XXREMOVEDXX
/**
* \brief execs cfunc() on each opened amp
* \param cfunc The function to be executed on each amp
@ -157,6 +158,7 @@ int foreach_opened_amp(int (*cfunc)(AMP *, rig_ptr_t), rig_ptr_t data)
return RIG_OK;
}
#endif
/**
@ -176,7 +178,6 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model)
AMP *amp;
const struct amp_caps *caps;
struct amp_state *rs;
int retcode;
amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -253,7 +254,7 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model)
*/
if (caps->amp_init != NULL)
{
retcode = caps->amp_init(amp);
int retcode = caps->amp_init(amp);
if (retcode != RIG_OK)
{

View File

@ -77,38 +77,38 @@
* \param port
* \return file descriptor
*/
int cm108_open(hamlib_port_t *port)
int cm108_open(hamlib_port_t *p)
{
int fd;
#ifdef HAVE_LINUX_HIDRAW_H
struct hidraw_devinfo hiddevinfo;
#endif
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!port->pathname[0])
if (!p->pathname[0])
{
return -RIG_EINVAL;
}
fd = open(port->pathname, O_RDWR);
fd = open(p->pathname, O_RDWR);
if (fd < 0)
{
rig_debug(RIG_DEBUG_ERR,
"%s: opening device \"%s\": %s\n",
__func__,
port->pathname,
p->pathname,
strerror(errno));
return -RIG_EIO;
}
#ifdef HAVE_LINUX_HIDRAW_H
// CM108 detection copied from Thomas Sailer's soundmodem code
rig_debug(RIG_DEBUG_VERBOSE,
"%s: checking for cm108 (or compatible) device\n",
__func__);
struct hidraw_devinfo hiddevinfo;
if (!ioctl(fd, HIDIOCGRAWINFO, &hiddevinfo)
&& ((hiddevinfo.vendor == 0x0d8c
// CM108/108B/109/119/119A
@ -138,7 +138,7 @@ int cm108_open(hamlib_port_t *port)
#endif
port->fd = fd;
p->fd = fd;
return fd;
}
@ -147,11 +147,11 @@ int cm108_open(hamlib_port_t *port)
* \brief Close CM108 HID port
* \param port
*/
int cm108_close(hamlib_port_t *port)
int cm108_close(hamlib_port_t *p)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
return close(port->fd);
return close(p->fd);
}
@ -163,6 +163,17 @@ int cm108_close(hamlib_port_t *port)
*/
int cm108_ptt_set(hamlib_port_t *p, ptt_t pttx)
{
ssize_t nw;
char out_rep[] =
{
0x00, // report number
// HID output report
0x00,
(pttx == RIG_PTT_ON) ? (1 << p->parm.cm108.ptt_bitnum) : 0, // set GPIO
1 << p->parm.cm108.ptt_bitnum, // Data direction register (1=output)
0x00
};
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// For a CM108 USB audio device PTT is wired up to one of the GPIO
@ -174,6 +185,7 @@ int cm108_ptt_set(hamlib_port_t *p, ptt_t pttx)
switch (p->type.ptt)
{
case RIG_PTT_CM108:
{
@ -192,18 +204,6 @@ int cm108_ptt_set(hamlib_port_t *p, ptt_t pttx)
p->parm.cm108.ptt_bitnum,
(pttx == RIG_PTT_ON) ? 1 : 0);
char out_rep[] =
{
0x00, // report number
// HID output report
0x00,
(pttx == RIG_PTT_ON) ? (1 << p->parm.cm108.ptt_bitnum) : 0, // set GPIO
1 << p->parm.cm108.ptt_bitnum, // Data direction register (1=output)
0x00
};
ssize_t nw;
if (p->fd == -1)
{
return -RIG_EINVAL;
@ -246,9 +246,7 @@ int cm108_ptt_get(hamlib_port_t *p, ptt_t *pttx)
{
case RIG_PTT_CM108:
{
int status;
return -RIG_ENIMPL;
return status;
}
default:
@ -262,6 +260,8 @@ int cm108_ptt_get(hamlib_port_t *p, ptt_t *pttx)
return RIG_OK;
}
#ifdef XXREMOVEXX
// Not referenced anywhere
/**
* \brief get Data Carrier Detect (squelch) from CM108 GPIO
* \param p
@ -281,9 +281,7 @@ int cm108_dcd_get(hamlib_port_t *p, dcd_t *dcdx)
{
case RIG_DCD_CM108:
{
int status;
return -RIG_ENIMPL;
return status;
}
default:
@ -296,5 +294,6 @@ int cm108_dcd_get(hamlib_port_t *p, dcd_t *dcdx)
return RIG_OK;
}
#endif
/** @} */

View File

@ -73,7 +73,6 @@ void dump_hex(const unsigned char ptr[], size_t size)
* 0010 30 30 0d 0a 00..
*/
char line[4 + 4 + 3 * DUMP_HEX_WIDTH + 4 + DUMP_HEX_WIDTH + 1];
unsigned char c;
int i;
if (!rig_need_debug(RIG_DEBUG_TRACE))
@ -85,6 +84,7 @@ void dump_hex(const unsigned char ptr[], size_t size)
for (i = 0; i < size; ++i)
{
unsigned char c;
if (i % DUMP_HEX_WIDTH == 0)
{
/* new line */
@ -142,6 +142,7 @@ void HAMLIB_API rig_set_debug_time_stamp(int flag)
char *date_strget(char *buf, int buflen)
{
char tmp[16];
time_t mytime;
struct tm *mytm;
struct timeval tv;
@ -149,7 +150,6 @@ char *date_strget(char *buf, int buflen)
mytm = gmtime(&mytime);
gettimeofday(&tv, NULL);
strftime(buf, buflen, "%Y-%m-%d:%H:%M:%S.", mytm);
char tmp[16];
sprintf(tmp, "%06ld", (long)tv.tv_usec);
strcat(buf, tmp);
return buf;

View File

@ -790,7 +790,8 @@ int HAMLIB_API rig_set_trn(RIG *rig, int trn)
{
#ifdef HAVE_SETITIMER
retcode = remove_trn_poll_rig(rig);
// don't care about the return code here
remove_trn_poll_rig(rig);
value.it_value.tv_sec = 0;
value.it_value.tv_usec = 0;

View File

@ -67,7 +67,6 @@ int HAMLIB_API rig_ext_level_foreach(RIG *rig,
rig_ptr_t data)
{
const struct confparams *cfp;
int ret;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -78,7 +77,7 @@ int HAMLIB_API rig_ext_level_foreach(RIG *rig,
for (cfp = rig->caps->extlevels; cfp && cfp->name; cfp++)
{
ret = (*cfunc)(rig, cfp, data);
int ret = (*cfunc)(rig, cfp, data);
if (ret == 0)
{
@ -113,7 +112,6 @@ int HAMLIB_API rig_ext_parm_foreach(RIG *rig,
rig_ptr_t data)
{
const struct confparams *cfp;
int ret;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -124,7 +122,7 @@ int HAMLIB_API rig_ext_parm_foreach(RIG *rig,
for (cfp = rig->caps->extparms; cfp && cfp->name; cfp++)
{
ret = (*cfunc)(rig, cfp, data);
int ret = (*cfunc)(rig, cfp, data);
if (ret == 0)
{

View File

@ -69,7 +69,6 @@ int HAMLIB_API amp_ext_level_foreach(AMP *amp,
amp_ptr_t data)
{
const struct confparams *cfp;
int ret;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -80,7 +79,7 @@ int HAMLIB_API amp_ext_level_foreach(AMP *amp,
for (cfp = amp->caps->extlevels; cfp && cfp->name; cfp++)
{
ret = (*cfunc)(amp, cfp, data);
int ret = (*cfunc)(amp, cfp, data);
if (ret == 0)
{
@ -115,7 +114,6 @@ int HAMLIB_API amp_ext_parm_foreach(AMP *amp,
amp_ptr_t data)
{
const struct confparams *cfp;
int ret;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -126,7 +124,7 @@ int HAMLIB_API amp_ext_parm_foreach(AMP *amp,
for (cfp = amp->caps->extparms; cfp && cfp->name; cfp++)
{
ret = (*cfunc)(amp, cfp, data);
int ret = (*cfunc)(amp, cfp, data);
if (ret == 0)
{

View File

@ -34,6 +34,7 @@ int gpio_open(hamlib_port_t *port, int output, int on_value)
char pathname[FILPATHLEN * 2];
FILE *fexp, *fdir;
int fd;
char *dir;
port->parm.gpio.on_value = on_value;
@ -69,7 +70,7 @@ int gpio_open(hamlib_port_t *port, int output, int on_value)
return -RIG_EIO;
}
char *dir = output ? "out" : "in";
dir = output ? "out" : "in";
rig_debug(RIG_DEBUG_VERBOSE, "Setting direction of GPIO%s to %s\n",
port->pathname, dir);
fprintf(fdir, "%s\n", dir);

View File

@ -369,16 +369,15 @@ static int port_select(hamlib_port_t *p,
static ssize_t port_read(hamlib_port_t *p, void *buf, size_t count)
{
int i;
ssize_t ret;
if (p->type.rig == RIG_PORT_SERIAL && p->parm.serial.data_bits == 7)
{
unsigned char *pbuf = buf;
ret = read(p->fd, buf, count);
int ret = read(p->fd, buf, count);
/* clear MSB */
int i;
for (i = 0; i < ret; i++)
{
pbuf[i] &= ~0x80;
@ -428,7 +427,7 @@ static ssize_t port_read(hamlib_port_t *p, void *buf, size_t count)
int HAMLIB_API write_block(hamlib_port_t *p, const char *txbuffer, size_t count)
{
int i, ret;
int ret;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -460,6 +459,8 @@ int HAMLIB_API write_block(hamlib_port_t *p, const char *txbuffer, size_t count)
if (p->write_delay > 0)
{
int i;
for (i = 0; i < count; i++)
{
ret = port_write(p, txbuffer + i, 1);
@ -545,8 +546,7 @@ int HAMLIB_API read_block(hamlib_port_t *p, char *rxbuffer, size_t count)
{
fd_set rfds, efds;
struct timeval tv, tv_timeout, start_time, end_time, elapsed_time;
int rd_count, total_count = 0;
int retval;
int total_count = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -561,6 +561,8 @@ int HAMLIB_API read_block(hamlib_port_t *p, char *rxbuffer, size_t count)
while (count > 0)
{
int retval;
int rd_count;
tv = tv_timeout; /* select may have updated it */
FD_ZERO(&rfds);
@ -668,8 +670,7 @@ int HAMLIB_API read_string(hamlib_port_t *p,
{
fd_set rfds, efds;
struct timeval tv, tv_timeout, start_time, end_time, elapsed_time;
int rd_count, total_count = 0;
int retval;
int total_count = 0;
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
@ -696,6 +697,8 @@ int HAMLIB_API read_string(hamlib_port_t *p,
while (total_count < rxmax - 1)
{
int rd_count;
int retval;
tv = tv_timeout; /* select may have updated it */
FD_ZERO(&rfds);

View File

@ -400,8 +400,7 @@ int HAMLIB_API locator2longlat(double *longitude,
{
int x_or_y, paircount;
int locvalue, pair;
int divisions;
double xy[2], ordinate;
double xy[2];
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -426,8 +425,8 @@ int HAMLIB_API locator2longlat(double *longitude,
/* For x(=longitude) and y(=latitude) */
for (x_or_y = 0; x_or_y < 2; ++x_or_y)
{
ordinate = -90.0;
divisions = 1;
double ordinate = -90.0;
int divisions = 1;
for (pair = 0; pair < paircount; ++pair)
{
@ -488,8 +487,8 @@ int HAMLIB_API longlat2locator(double longitude,
char *locator,
int pair_count)
{
int x_or_y, pair, locvalue, divisions;
double square_size, ordinate;
int x_or_y, pair, locvalue;
double square_size;
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -505,8 +504,8 @@ int HAMLIB_API longlat2locator(double longitude,
for (x_or_y = 0; x_or_y < 2; ++x_or_y)
{
ordinate = (x_or_y == 0) ? longitude / 2.0 : latitude;
divisions = 1;
double ordinate = (x_or_y == 0) ? longitude / 2.0 : latitude;
int divisions = 1;
/* The 1e-6 here guards against floating point rounding errors */
ordinate = fmod(ordinate + 270.000001, 180.0);

Some files were not shown because too many files have changed in this diff Show More