Add SF command for TS-590S/SG

Still need to add bandwidth get/set
https://github.com/Hamlib/Hamlib/issues/1293
pull/1294/head
Mike Black W9MDB 2023-05-14 11:06:22 -05:00
rodzic 10f1f3a7cd
commit 6651345065
4 zmienionych plików z 586 dodań i 41 usunięć

Wyświetl plik

@ -201,6 +201,85 @@ const char *ts590_get_info(RIG *rig)
}
}
// keep track of SF command ability
static int sf_fails;
static int ts590_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char kmode = rmode2kenwood(mode, caps->mode_table);
char cmd[32], c;
int retval = -RIG_EINTERNAL;
if (kmode < 0)
{
rig_debug(RIG_DEBUG_WARN, "%s: unsupported mode '%s'\n",
__func__, rig_strrmode(mode));
RETURNFUNC2(-RIG_EINVAL);
}
if (kmode <= 9)
{
c = '0' + kmode;
}
else
{
c = 'A' + kmode - 10;
}
if (!sf_fails)
{
SNPRINTF(cmd, sizeof(cmd), "SF%d%011.0f%c", vfo == RIG_VFO_A ? 0 : 1,
vfo == RIG_VFO_A ? rig->state.cache.freqMainA : rig->state.cache.freqMainB,
c);
retval = kenwood_transaction(rig, cmd, NULL, 0);
}
if (retval != RIG_OK || sf_fails)
{
return kenwood_set_mode(rig, vfo, mode, width);
}
return retval;
}
static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char cmd[32], ackbuf[32];
int retval;
if (!sf_fails)
{
SNPRINTF(cmd, sizeof(cmd), "SF%d", vfo == RIG_VFO_A ? 0 : 1);
retval = kenwood_safe_transaction(rig, cmd, ackbuf, sizeof(ackbuf), 15);
}
// if this fails fall back to old method
if (retval != RIG_OK || sf_fails)
{
sf_fails = 1;
return kenwood_get_mode(rig, vfo, mode, width);
}
*mode = ackbuf[14];
if (*mode >= 'A') { *mode = *mode - 'A' + 10; }
else { *mode -= '0'; }
*mode = kenwood2rmode(*mode, caps->mode_table);
if (*mode == RIG_MODE_PKTUSB || *mode == RIG_MODE_PKTLSB)
{
}
else if (*mode == RIG_MODE_AM || *mode == RIG_MODE_PKTAM)
{
}
return RIG_OK;
}
static int ts590_set_ex_menu(RIG *rig, int number, int value_len, int value)
{
char buf[20];
@ -1431,7 +1510,7 @@ const struct rig_caps ts590_caps =
RIG_MODEL(RIG_MODEL_TS590S),
.model_name = "TS-590S",
.mfg_name = "Kenwood",
.version = BACKEND_VER ".4",
.version = BACKEND_VER ".5",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -1453,7 +1532,7 @@ const struct rig_caps ts590_caps =
.max_rit = kHz(9.99),
.max_xit = kHz(9.99),
.max_ifshift = Hz(0),
.targetable_vfo = RIG_TARGETABLE_FREQ,
.targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
.transceive = RIG_TRN_RIG,
.agc_level_count = 6,
.agc_levels = { RIG_AGC_OFF, RIG_AGC_SLOW, RIG_AGC_MEDIUM, RIG_AGC_FAST, RIG_AGC_SUPERFAST, RIG_AGC_ON },
@ -1577,8 +1656,8 @@ const struct rig_caps ts590_caps =
.get_rit = ts590_get_rit,
.set_xit = ts590_set_rit,
.get_xit = ts590_get_rit,
.set_mode = kenwood_set_mode,
.get_mode = kenwood_get_mode,
.set_mode = ts590_set_mode,
.get_mode = ts590_get_mode,
.set_vfo = kenwood_set_vfo,
.get_vfo = kenwood_get_vfo_if,
.set_split_vfo = kenwood_set_split_vfo,
@ -1629,7 +1708,7 @@ const struct rig_caps ts590sg_caps =
RIG_MODEL(RIG_MODEL_TS590SG),
.model_name = "TS-590SG",
.mfg_name = "Kenwood",
.version = BACKEND_VER ".2",
.version = BACKEND_VER ".3",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -1651,7 +1730,7 @@ const struct rig_caps ts590sg_caps =
.max_rit = kHz(9.99),
.max_xit = kHz(9.99),
.max_ifshift = Hz(0),
.targetable_vfo = RIG_TARGETABLE_FREQ,
.targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
.transceive = RIG_TRN_RIG,
.agc_level_count = 6,
.agc_levels = { RIG_AGC_OFF, RIG_AGC_SLOW, RIG_AGC_MEDIUM, RIG_AGC_FAST, RIG_AGC_SUPERFAST, RIG_AGC_ON },
@ -1774,8 +1853,8 @@ const struct rig_caps ts590sg_caps =
.get_rit = ts590_get_rit,
.set_xit = ts590_set_rit,
.get_xit = ts590_get_rit,
.set_mode = kenwood_set_mode,
.get_mode = kenwood_get_mode,
.set_mode = ts590_set_mode,
.get_mode = ts590_get_mode,
.set_vfo = kenwood_set_vfo,
.get_vfo = kenwood_get_vfo_if,
.set_split_vfo = kenwood_set_split_vfo,

Wyświetl plik

@ -8,7 +8,7 @@ DISTCLEANFILES =
bin_PROGRAMS =
check_PROGRAMS = simelecraft simicom simkenwood simyaesu simicom9100 simicom9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817
check_PROGRAMS = simelecraft simicom simkenwood simyaesu simicom9100 simicom9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590
simelecraft_SOURCES = simelecraft.c
simicom_SOURCES = simicom.c

Wyświetl plik

@ -0,0 +1,445 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <hamlib/rig.h>
#define BUFSIZE 256
int mysleep = 20;
float freqA = 14074000;
float freqB = 14074500;
int filternum = 7;
int datamode = 0;
int vfo, vfo_tx, ptt, ptt_data, ptt_mic, ptt_tune;
// ID 0310 == 310, Must drop leading zero
typedef enum nc_rigid_e
{
NC_RIGID_NONE = 0,
NC_RIGID_FT450 = 241,
NC_RIGID_FT450D = 244,
NC_RIGID_FT950 = 310,
NC_RIGID_FT891 = 135,
NC_RIGID_FT991 = 135,
NC_RIGID_FT2000 = 251,
NC_RIGID_FT2000D = 252,
NC_RIGID_FTDX1200 = 583,
NC_RIGID_FTDX9000D = 101,
NC_RIGID_FTDX9000Contest = 102,
NC_RIGID_FTDX9000MP = 103,
NC_RIGID_FTDX5000 = 362,
NC_RIGID_FTDX3000 = 460,
NC_RIGID_FTDX101D = 681,
NC_RIGID_FTDX101MP = 682
} nc_rigid_t;
int
getmyline(int fd, char *buf)
{
char c;
int i = 0;
memset(buf, 0, BUFSIZE);
while (read(fd, &c, 1) > 0)
{
buf[i++] = c;
if (c == ';') { return strlen(buf); }
}
return strlen(buf);
}
#if defined(WIN32) || defined(_WIN32)
int openPort(char *comport) // doesn't matter for using pts devices
{
int fd;
fd = open(comport, O_RDWR);
if (fd < 0)
{
perror(comport);
}
return fd;
}
#else
int openPort(char *comport) // doesn't matter for using pts devices
{
int fd = posix_openpt(O_RDWR);
char *name = ptsname(fd);
if (name == NULL)
{
perror("pstname");
return -1;
}
printf("name=%s\n", name);
if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1)
{
perror("posix_openpt");
return -1;
}
return fd;
}
#endif
int main(int argc, char *argv[])
{
char buf[256];
char *pbuf;
int n;
int fd = openPort(argv[1]);
int freqa = 14074000, freqb = 140735000;
int modeA = 1, modeB = 2;
while (1)
{
buf[0] = 0;
if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); }
// else { return 0; }
if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("RM5"); }
}
else if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("AN"); }
}
else if (strcmp(buf, "IF;") == 0)
{
char ifbuf[256];
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
pbuf = "IF000503130001000+0000000000030000000;";
sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa);
//pbuf = "IF00010138698 +00000000002000000 ;
n = write(fd, ifbuf, strlen(ifbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("IF"); }
continue;
}
else if (strcmp(buf, "NB;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "NB0;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "RA;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "RA01;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "RG;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "RG055;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "MG;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "MG050;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "AG;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "AG100;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "FV;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "FV1.2;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strncmp(buf, "IS;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "IS+0000;");
n = write(fd, buf, strlen(buf));
printf("%s\n", buf);
continue;
}
else if (strncmp(buf, "IS", 2) == 0)
{
continue;
}
else if (strncmp(buf, "SM;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "SM0035;");
n = write(fd, buf, strlen(buf));
printf("%s\n", buf);
continue;
}
else if (strncmp(buf, "PC;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "PC100;");
n = write(fd, buf, strlen(buf));
printf("%s\n", buf);
continue;
}
else if (strcmp(buf, "FW;") == 0)
{
//usleep(mysleep * 1000);
pbuf = "FW240";
n = write(fd, pbuf, strlen(pbuf));
hl_usleep(20 * 1000);
pbuf = "0;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strncmp(buf, "FW", 2) == 0)
{
continue;
}
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
int id = 24;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n <= 0) { perror("ID"); }
continue;
}
#if 0
else if (strncmp(buf, "AI", 2) == 0)
{
if (strcmp(buf, "AI;"))
{
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
if (n <= 0) { perror("AI"); }
}
}
#endif
else if (strcmp(buf, "VS;") == 0)
{
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n < 0) { perror("VS"); }
continue;
}
else if (strcmp(buf, "EX032;") == 0)
{
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n < 0) { perror("EX032"); }
continue;
}
else if (strncmp(buf, "EX", 2) == 0)
{
continue;
}
else if (strcmp(buf, "FA;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
n = write(fd, buf, strlen(buf));
continue;
}
else if (strcmp(buf, "FB;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb);
n = write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "FA", 2) == 0)
{
sscanf(buf, "FA%d", &freqa);
continue;
}
else if (strncmp(buf, "FB", 2) == 0)
{
sscanf(buf, "FB%d", &freqb);
continue;
}
else if (strncmp(buf, "AI;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf));
continue;
}
if (strncmp(buf, "PS;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "PS1;");
n = write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "SA;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "SA0;");
n = write(fd, buf, strlen(buf));
}
else if (buf[3] == ';' && strncmp(buf, "SF", 2)==0)
{
SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2], buf[2] == '0' ? freqA : freqB,
buf[2] == '0' ? modeA + '0' : modeB + '0');
n = write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "SF", 2) == 0)
{
mode_t tmpmode= buf[14];
if (buf[2] == '0') { modeA = tmpmode - '0'; }
else { modeB = tmpmode - '0'; }
printf("modeA=%c, modeB=%c\n", modeA, modeB);
continue;
}
else if (strncmp(buf, "MD;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "MD%d;",
modeA); // not worried about modeB yet for simulator
n = write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "MD", 2) == 0)
{
sscanf(buf, "MD%d", &modeA); // not worried about modeB yet for simulator
continue;
}
else if (strncmp(buf, "FL;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum);
n = write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "FL", 2) == 0)
{
sscanf(buf, "FL%d", &filternum);
continue;
}
else if (strcmp(buf, "FR;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo);
n = write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "FR", 2) == 0)
{
sscanf(buf, "FR%d", &vfo);
}
else if (strcmp(buf, "FT;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx);
n = write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "FT", 2) == 0)
{
sscanf(buf, "FT%d", &vfo_tx);
}
else if (strncmp(buf, "DA;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "DA%d;", datamode);
n = write(fd, buf, strlen(buf));
printf("%s\n", buf);
continue;
}
else if (strncmp(buf, "DA", 2) == 0)
{
sscanf(buf, "DA%d", &datamode);
printf("%s\n", buf);
continue;
}
else if (strncmp(buf, "BD;", 3) == 0)
{
continue;
}
else if (strncmp(buf, "BU;", 3) == 0)
{
continue;
}
else if (strncmp(buf, "TX", 2) == 0)
{
ptt = ptt_mic = ptt_data = ptt_tune = 0;
switch (buf[2])
{
case ';': ptt = 1;
case '0': ptt_mic = 1;
case '1': ptt_data = 1;
case '2': ptt_tune = 1;
}
continue;
}
else if (strlen(buf) > 0)
{
fprintf(stderr, "Unknown command: %s\n", buf);
}
}
return 0;
}

Wyświetl plik

@ -168,7 +168,7 @@ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */
#define CHECK_RIG_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state)
#define CHECK_RIG_CAPS(r) (!(r) || !(r)->caps)
#define LOCK(n) if (rig->state.depth == 0) { rig_debug(RIG_DEBUG_ERR, "%s: lock!! *******************************************\n", __func__); rig_lock(rig,n); }
#define LOCK(n) if (rig->state.depth == 1) { rig_debug(RIG_DEBUG_ERR, "%s: %s\n", n?"lock":"unlock", __func__); rig_lock(rig,n); }
#ifdef PTHREAD
#define MUTEX(var) static pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER
@ -1784,6 +1784,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
vfo_t vfo_save;
ELAPSED1;
ENTERFUNC;
LOCK(1);
#if BUILTINFUNC
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f, called from %s\n",
@ -1801,7 +1802,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
ELAPSED2;
LOCK(0);
RETURNFUNC2(-RIG_EINVAL);
RETURNFUNC(-RIG_EINVAL);
}
if (rig->state.twiddle_state == TWIDDLE_ON)
@ -1845,7 +1846,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
ELAPSED2;
LOCK(0);
RETURNFUNC2(-RIG_ENAVAIL);
RETURNFUNC(-RIG_ENAVAIL);
}
vfo_save = rig->state.current_vfo;
@ -1867,7 +1868,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
ELAPSED2;
LOCK(0);
RETURNFUNC2(
RETURNFUNC(
RIG_OK); // would be better as error but other software won't handle errors
}
@ -1936,7 +1937,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
ELAPSED2;
LOCK(0);
RETURNFUNC2(-RIG_ENAVAIL);
RETURNFUNC(-RIG_ENAVAIL);
}
retcode = rig_set_vfo(rig, vfo);
@ -1961,7 +1962,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
ELAPSED2;
LOCK(0);
RETURNFUNC2(
RETURNFUNC(
RIG_OK); // would be better as error but other software won't handle errors
}
@ -2023,7 +2024,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
ELAPSED2;
LOCK(0);
RETURNFUNC2(retcode);
RETURNFUNC(retcode);
}
@ -2051,12 +2052,11 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rmode_t mode;
pbwidth_t width;
LOCK(1);
ENTERFUNC;
if (CHECK_RIG_ARG(rig))
{
LOCK(0);
RETURNFUNC2(-RIG_EINVAL);
RETURNFUNC(-RIG_EINVAL);
}
ELAPSED1;
@ -2064,8 +2064,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (!freq)
{
rig_debug(RIG_DEBUG_TRACE, "%s: freq ptr invalid\n", __func__);
LOCK(0);
RETURNFUNC2(-RIG_EINVAL);
RETURNFUNC(-RIG_EINVAL);
}
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) called vfo=%s\n", __func__, __LINE__,
@ -2097,11 +2096,20 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode, &width,
&cache_ms_width);
ELAPSED2;
LOCK(0);
return (RIG_OK);
RETURNFUNC(RIG_OK);
}
rig_cache_show(rig, __func__, __LINE__);
LOCK(1);
rig_debug(RIG_DEBUG_ERR, "%s: depth=%d\n", __func__, rig->state.depth);
if (rig->state.depth == 1)
{
rig_debug(RIG_DEBUG_ERR, "%s: %s\n", 1 ? "lock" : "unlock", __func__);
// rig_lock(rig, 1);
}
// there are some rigs that can't get VFOA freq while VFOB is transmitting
// so we'll return the cached VFOA freq for them
@ -2119,7 +2127,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
ELAPSED2;
LOCK(0);
RETURNFUNC2(retcode);
RETURNFUNC(retcode);
}
if (ptt)
@ -2130,7 +2138,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
*freq = rig->state.cache.freqMainA;
ELAPSED2;
LOCK(0);
return (RIG_OK);
RETURNFUNC(RIG_OK);
}
}
@ -2150,7 +2158,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_strvfo(vfo), cache_ms_freq, *freq, rig->state.use_cached_freq);
ELAPSED2;
LOCK(0);
return (RIG_OK);
RETURNFUNC(RIG_OK);
}
else
{
@ -2167,7 +2175,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
ELAPSED2;
LOCK(0);
RETURNFUNC2(-RIG_ENAVAIL);
RETURNFUNC(-RIG_ENAVAIL);
}
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo_opt=%d, model=%d\n", __func__,
@ -2212,7 +2220,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
ELAPSED2;
LOCK(0);
RETURNFUNC2(-RIG_ENAVAIL);
RETURNFUNC(-RIG_ENAVAIL);
}
HAMLIB_TRACE;
@ -2222,7 +2230,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
ELAPSED2;
LOCK(0);
RETURNFUNC2(retcode);
RETURNFUNC(retcode);
}
rig_cache_show(rig, __func__, __LINE__);
@ -2278,7 +2286,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
ELAPSED2;
LOCK(0);
return (retcode);
RETURNFUNC(retcode);
}
/**
@ -2331,7 +2339,9 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
int retcode;
int locked_mode;
ENTERFUNC;
ELAPSED1;
LOCK(1);
rig_debug(RIG_DEBUG_VERBOSE,
"%s called, vfo=%s, mode=%s, width=%d, curr_vfo=%s\n", __func__,
@ -2341,7 +2351,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (CHECK_RIG_ARG(rig))
{
ELAPSED2;
RETURNFUNC2(-RIG_EINVAL);
RETURNFUNC(-RIG_EINVAL);
}
rig_get_lock_mode(rig, &locked_mode);
@ -2349,7 +2359,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (locked_mode)
{
ELAPSED2;
return (RIG_OK);
RETURNFUNC (RIG_OK);
}
// do not mess with mode while PTT is on
@ -2357,7 +2367,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s PTT on so set_mode ignored\n", __func__);
ELAPSED2;
return RIG_OK;
RETURNFUNC(RIG_OK);
}
caps = rig->caps;
@ -2365,7 +2375,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (caps->set_mode == NULL)
{
ELAPSED2;
RETURNFUNC2(-RIG_ENAVAIL);
RETURNFUNC(-RIG_ENAVAIL);
}
if (vfo == RIG_VFO_CURR)
@ -2395,7 +2405,8 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
"%s: mode already %s and bw change not requested\n", __func__,
rig_strrmode(mode));
ELAPSED2;
RETURNFUNC2(RIG_OK);
LOCK(0);
RETURNFUNC(RIG_OK);
}
}
@ -2418,7 +2429,8 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
rig_debug(RIG_DEBUG_TRACE, "%s: VFOB mode not changing so ignoring\n",
__func__);
ELAPSED2;
RETURNFUNC2(RIG_OK);
LOCK(0);
RETURNFUNC(RIG_OK);
}
rig_debug(RIG_DEBUG_TRACE, "%s: not targetable need vfo swap\n", __func__);
@ -2426,7 +2438,8 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (!caps->set_vfo)
{
ELAPSED2;
RETURNFUNC2(-RIG_ENAVAIL);
LOCK(0);
RETURNFUNC(-RIG_ENAVAIL);
}
curr_vfo = rig->state.current_vfo;
@ -2438,7 +2451,8 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (retcode != RIG_OK)
{
ELAPSED2;
RETURNFUNC2(retcode);
LOCK(0);
RETURNFUNC(retcode);
}
retcode = caps->set_mode(rig, vfo, mode, width);
@ -2457,13 +2471,15 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
rig_debug(RIG_DEBUG_TRACE, "%s: failed set_mode(%s)=%s\n",
__func__, rig_strrmode(mode), rigerror(retcode));
ELAPSED2;
LOCK(0);
RETURNFUNC(retcode);
}
rig_set_cache_mode(rig, vfo, mode, width);
ELAPSED2;
RETURNFUNC2(retcode);
LOCK(0);
RETURNFUNC(retcode);
}
/*
@ -2497,8 +2513,8 @@ int HAMLIB_API rig_get_mode(RIG *rig,
int retcode;
freq_t freq;
ENTERFUNC;
ELAPSED1;
ENTERFUNC;
if (CHECK_RIG_ARG(rig))
{
@ -2564,6 +2580,8 @@ int HAMLIB_API rig_get_mode(RIG *rig,
__func__, cache_ms_mode, cache_ms_width);
}
LOCK(1); // we let the caching work before we lock things
if ((caps->targetable_vfo & RIG_TARGETABLE_MODE)
|| vfo == RIG_VFO_CURR
|| vfo == rig->state.current_vfo)
@ -2582,6 +2600,7 @@ int HAMLIB_API rig_get_mode(RIG *rig,
if (!caps->set_vfo)
{
ELAPSED2;
LOCK(0);
RETURNFUNC(-RIG_ENAVAIL);
}
@ -2596,6 +2615,7 @@ int HAMLIB_API rig_get_mode(RIG *rig,
if (retcode != RIG_OK)
{
ELAPSED2;
LOCK(0);
RETURNFUNC(retcode);
}
@ -2629,6 +2649,7 @@ int HAMLIB_API rig_get_mode(RIG *rig,
rig_set_cache_mode(rig, vfo, *mode, *width);
rig_cache_show(rig, __func__, __LINE__);
LOCK(0);
ELAPSED2;
RETURNFUNC(retcode);
}
@ -7545,7 +7566,7 @@ void rig_lock(RIG *rig, int lock)
{
#ifdef HAVE_PTHREAD
if (rig->state.multicast == NULL) return; // not initialized yet
if (rig->state.multicast == NULL) { return; } // not initialized yet
if (!rig->state.multicast->mutex_initialized)
{