kopia lustrzana https://github.com/Hamlib/Hamlib
Merge master and fix conflicts
commit
9e1adcfdb8
10
configure.ac
10
configure.ac
|
@ -229,6 +229,16 @@ AC_CHECK_FUNC([gethostbyname],
|
|||
[])
|
||||
])
|
||||
|
||||
# Winsock2 32 bit
|
||||
AC_CHECK_FUNC([timeBeginPeriod],
|
||||
[],
|
||||
[AC_CHECK_LIB([winmm],
|
||||
[main],
|
||||
[NET_LIBS="$NET_LIBS -lwinmm"],
|
||||
[],
|
||||
[])
|
||||
])
|
||||
|
||||
LIBS="$LIBS $NET_LIBS"
|
||||
|
||||
# macros/hl_getaddrinfo.m4
|
||||
|
|
|
@ -14,6 +14,7 @@ SUPPRESS="\
|
|||
-i bindings \
|
||||
-i lib/getopt.c \
|
||||
-i lib/getopt_long.c \
|
||||
-i lib/cJSON.c \
|
||||
--suppress=*:extra/gnuradio/demod.h \
|
||||
--suppress=*:extra/gnuradio/HrAGC.h \
|
||||
--suppress=*:extra/gnuradio/nfm.h \
|
||||
|
|
|
@ -1035,7 +1035,7 @@ typedef uint64_t rig_level_e;
|
|||
//! @cond Doxygen_Suppress
|
||||
#define RIG_LEVEL_FLOAT_LIST (RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_APF|RIG_LEVEL_NR|RIG_LEVEL_PBT_IN|RIG_LEVEL_PBT_OUT|RIG_LEVEL_RFPOWER|RIG_LEVEL_MICGAIN|RIG_LEVEL_COMP|RIG_LEVEL_BALANCE|RIG_LEVEL_SWR|RIG_LEVEL_ALC|RIG_LEVEL_VOXGAIN|RIG_LEVEL_ANTIVOX|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_RFPOWER_METER_WATTS|RIG_LEVEL_COMP_METER|RIG_LEVEL_VD_METER|RIG_LEVEL_ID_METER|RIG_LEVEL_NOTCHF_RAW|RIG_LEVEL_MONITOR_GAIN|RIG_LEVEL_NB|RIG_LEVEL_SPECTRUM_REF|RIG_LEVEL_TEMP_METER|RIG_LEVEL_USB_AF|RIG_LEVEL_AGC_TIME)
|
||||
|
||||
#define RIG_LEVEL_READONLY_LIST (RIG_LEVEL_SWR|RIG_LEVEL_ALC|RIG_LEVEL_STRENGTH|RIG_LEVEL_RAWSTR|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_COMP_METER|RIG_LEVEL_VD_METER|RIG_LEVEL_ID_METER|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_RFPOWER_METER_WATTS)
|
||||
#define RIG_LEVEL_READONLY_LIST (RIG_LEVEL_SWR|RIG_LEVEL_ALC|RIG_LEVEL_STRENGTH|RIG_LEVEL_RAWSTR|RIG_LEVEL_COMP_METER|RIG_LEVEL_VD_METER|RIG_LEVEL_ID_METER|RIG_LEVEL_TEMP_METER|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_RFPOWER_METER_WATTS)
|
||||
|
||||
#define RIG_LEVEL_IS_FLOAT(l) ((l)&RIG_LEVEL_FLOAT_LIST)
|
||||
#define RIG_LEVEL_SET(l) ((l)&~RIG_LEVEL_READONLY_LIST)
|
||||
|
@ -1619,7 +1619,7 @@ typedef struct chan_list chan_t;
|
|||
*
|
||||
* The granularity is undefined if min = 0, max = 0, and step = 0.
|
||||
*
|
||||
* For float settings, if min.f = 0 and max.f = 0 (and step.f! = 0), max.f is
|
||||
* For float settings, if min.f = 0 and max.f = 0 (and step.f != 0), max.f is
|
||||
* assumed to be actually equal to 1.0.
|
||||
*
|
||||
* If step = 0 (and min and/or max are not null), then this means step can
|
||||
|
@ -2084,7 +2084,6 @@ struct rig_caps {
|
|||
int (*password)(RIG *rig, const char *key1); /*< Send encrypted password if rigctld is secured with -A/--password */
|
||||
int (*set_lock_mode)(RIG *rig, int mode);
|
||||
int (*get_lock_mode)(RIG *rig, int *mode);
|
||||
short timeout_retry; /*!< number of retries to make in case of read timeout errors, some serial interfaces may require this, 0 to use default value, -1 to disable */
|
||||
};
|
||||
//! @endcond
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
EXTRA_DIST = getopt.c getopt.h getopt_long.c usleep.c \
|
||||
EXTRA_DIST = getopt.c getopt.h getopt_long.c usleep.c \
|
||||
termios.c win32termios.h gettimeofday.c getaddrinfo.c
|
||||
|
||||
noinst_LTLIBRARIES = libmisc.la
|
||||
|
||||
libmisc_la_SOURCES = cJSON.c cJSON.h asyncpipe.c asyncpipe.h
|
||||
libmisc_la_SOURCES = cJSON.c cJSON.h asyncpipe.c asyncpipe.h precise_time.c
|
||||
libmisc_la_LIBADD = $(LTLIBOBJS) $(NET_LIBS)
|
||||
|
|
|
@ -0,0 +1,164 @@
|
|||
// ---------------------------------------------------------------------
|
||||
// precise_time.cxx
|
||||
//
|
||||
// Copyright (C) 2023
|
||||
// Dave Freese, W1HKJ
|
||||
//
|
||||
// This file is part of flrig
|
||||
//
|
||||
// flrig is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// flrig 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with fldigi. If not, see <http://www.gnu.org/licenses/>.
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if 0
|
||||
// return current tick time in seconds
|
||||
double monotonic_seconds()
|
||||
{
|
||||
static struct timeval t1;
|
||||
gettimeofday(&t1, NULL);
|
||||
return t1.tv_sec + t1.tv_usec / 1e6;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//======================================================================
|
||||
//
|
||||
// A cross platform monotonic timer.
|
||||
// Copyright 2013 Alex Reece.
|
||||
//
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define NANOS_PER_SECF 1000000000.0
|
||||
#define USECS_PER_SEC 1000000
|
||||
|
||||
static int showme = 0;
|
||||
|
||||
#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
// If we have it, use clock_gettime and CLOCK_MONOTONIC.
|
||||
|
||||
#include <time.h>
|
||||
|
||||
double monotonic_seconds() {
|
||||
if (showme) {
|
||||
showme = 0;
|
||||
}
|
||||
struct timespec time;
|
||||
// Note: Make sure to link with -lrt to define clock_gettime.
|
||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
return ((double) time.tv_sec) + ((double) time.tv_nsec / (NANOS_PER_SECF));
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
// If we don't have CLOCK_MONOTONIC, we might be on a Mac. There we instead
|
||||
// use mach_absolute_time().
|
||||
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
static mach_timebase_info_data_t info;
|
||||
static void __attribute__((constructor)) init_info() {
|
||||
mach_timebase_info(&info);
|
||||
}
|
||||
|
||||
double monotonic_seconds() {
|
||||
uint64_t time = mach_absolute_time();
|
||||
double dtime = (double) time;
|
||||
dtime *= (double) info.numer;
|
||||
dtime /= (double) info.denom;
|
||||
return dtime / NANOS_PER_SECF;
|
||||
}
|
||||
|
||||
#elif defined(__WIN32__)
|
||||
// On Windows, use QueryPerformanceCounter and QueryPerformanceFrequency.
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
static double PCFreq = 0.0;
|
||||
|
||||
// According to http://stackoverflow.com/q/1113409/447288, this will
|
||||
// make this function a constructor.
|
||||
// TODO(awreece) Actually attempt to compile on windows.
|
||||
// w1hkj - builds OK on mingw32
|
||||
|
||||
static void __cdecl init_pcfreq();
|
||||
__declspec(allocate(".CRT$XCU")) void (__cdecl*init_pcfreq_)() = init_pcfreq;
|
||||
static void __cdecl init_pcfreq() {
|
||||
// Accoring to http://stackoverflow.com/a/1739265/447288, this will
|
||||
// properly initialize the QueryPerformanceCounter.
|
||||
LARGE_INTEGER li;
|
||||
int has_qpc = QueryPerformanceFrequency(&li);
|
||||
assert(has_qpc);
|
||||
|
||||
PCFreq = ((double) li.QuadPart) / 1000.0;
|
||||
}
|
||||
|
||||
double monotonic_seconds() {
|
||||
LARGE_INTEGER li;
|
||||
QueryPerformanceCounter(&li);
|
||||
return ((double) li.QuadPart) / PCFreq;
|
||||
}
|
||||
|
||||
#else
|
||||
// Fall back to rdtsc. The reason we don't use clock() is this scary message
|
||||
// from the man page:
|
||||
// "On several other implementations, the value returned by clock() also
|
||||
// includes the times of any children whose status has been collected via
|
||||
// wait(2) (or another wait-type call)."
|
||||
//
|
||||
// Also, clock() only has microsecond accuracy.
|
||||
//
|
||||
// This whitepaper offered excellent advice on how to use rdtscp for
|
||||
// profiling: http://download.intel.com/embedded/software/IA/324264.pdf
|
||||
//
|
||||
// Unfortunately, we can't follow its advice exactly with our semantics,
|
||||
// so we're just going to use rdtscp with cpuid.
|
||||
//
|
||||
// Note that rdtscp will only be available on new processors.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static inline uint64_t rdtsc() {
|
||||
uint32_t hi, lo;
|
||||
asm volatile("rdtscp\n"
|
||||
"movl %%edx, %0\n"
|
||||
"movl %%eax, %1\n"
|
||||
"cpuid"
|
||||
: "=r" (hi), "=r" (lo) : : "%rax", "%rbx", "%rcx", "%rdx");
|
||||
return (((uint64_t)hi) << 32) | (uint64_t)lo;
|
||||
}
|
||||
|
||||
static uint64_t rdtsc_per_sec = 0;
|
||||
static void __attribute__((constructor)) init_rdtsc_per_sec() {
|
||||
uint64_t before, after;
|
||||
|
||||
before = rdtsc();
|
||||
usleep(USECS_PER_SEC);
|
||||
after = rdtsc();
|
||||
|
||||
rdtsc_per_sec = after - before;
|
||||
}
|
||||
|
||||
double monotonic_seconds() {
|
||||
if (showme) {
|
||||
showme = false;
|
||||
}
|
||||
return (double) rdtsc() / (double) rdtsc_per_sec;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -3798,9 +3798,9 @@ int win32_serial_select(int n, fd_set *readfds, fd_set *writefds,
|
|||
goto end;
|
||||
}
|
||||
|
||||
hl_usleep(10000);
|
||||
hl_usleep(1000);
|
||||
/* FIXME: not very accurate wrt process time */
|
||||
timeout_usec -= 10000;
|
||||
timeout_usec -= 1000;
|
||||
|
||||
report("sleep...\n");
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ const struct rig_caps ic7000_caps =
|
|||
.get_freq = icom_get_freq,
|
||||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.set_ant = NULL, /*automatically set by rig depending band */
|
||||
.get_ant = NULL,
|
||||
|
|
|
@ -201,7 +201,7 @@ const struct rig_caps ic703_caps =
|
|||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
|
||||
.decode_event = icom_decode_event,
|
||||
.set_level = icom_set_level,
|
||||
|
|
|
@ -262,7 +262,7 @@ const struct rig_caps ic706_caps =
|
|||
.get_freq = icom_get_freq,
|
||||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_vfo = icom_set_vfo,
|
||||
|
||||
.decode_event = icom_decode_event,
|
||||
|
@ -413,7 +413,7 @@ const struct rig_caps ic706mkii_caps =
|
|||
.get_freq = icom_get_freq,
|
||||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_vfo = icom_set_vfo,
|
||||
|
||||
.decode_event = icom_decode_event,
|
||||
|
@ -610,7 +610,7 @@ const struct rig_caps ic706mkiig_caps =
|
|||
.get_freq = icom_get_freq,
|
||||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_vfo = icom_set_vfo,
|
||||
|
||||
.decode_event = icom_decode_event,
|
||||
|
|
|
@ -461,7 +461,7 @@ const struct rig_caps ic7100_caps =
|
|||
.get_mode = icom_get_mode_with_data,
|
||||
.set_mode = icom_set_mode_with_data,
|
||||
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
|
|
@ -184,7 +184,7 @@ const struct rig_caps ic718_caps =
|
|||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
|
||||
.decode_event = icom_decode_event,
|
||||
.set_level = icom_set_level,
|
||||
|
|
|
@ -242,7 +242,7 @@ const struct rig_caps ic7200_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = NULL, /*automatically set by rig depending band */
|
||||
.get_ant = NULL,
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ int ic7300_get_clock(RIG *rig, int *year, int *month, int *day,
|
|||
int *hour,
|
||||
int *min, int *sec, double *msec, int *utc_offset);
|
||||
|
||||
int ic9700_set_vfo(RIG *rig, vfo_t vfo);
|
||||
|
||||
|
||||
#define IC7300_ALL_RX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM|RIG_MODE_PKTAM)
|
||||
#define IC7300_1HZ_TS_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM|RIG_MODE_PKTAM)
|
||||
|
@ -369,6 +371,7 @@ static const struct icom_priv_caps IC7300_priv_caps =
|
|||
},
|
||||
},
|
||||
.extcmds = ic7300_extcmds, /* Custom op parameters */
|
||||
.x25_always = 1
|
||||
};
|
||||
|
||||
static const struct icom_priv_caps IC9700_priv_caps =
|
||||
|
@ -417,6 +420,7 @@ static const struct icom_priv_caps IC9700_priv_caps =
|
|||
},
|
||||
},
|
||||
.extcmds = ic9700_extcmds, /* Custom op parameters */
|
||||
.x25_always = 1
|
||||
};
|
||||
|
||||
static const struct icom_priv_caps IC705_priv_caps =
|
||||
|
@ -571,6 +575,7 @@ const struct rig_caps ic7300_caps =
|
|||
.has_get_parm = IC7300_PARMS,
|
||||
.has_set_parm = RIG_PARM_SET(IC7300_PARMS),
|
||||
.level_gran = {
|
||||
#include "level_gran_icom.h"
|
||||
// cppcheck-suppress *
|
||||
[LVL_RAWSTR] = {.min = {.i = 0}, .max = {.i = 255}},
|
||||
[LVL_VOXDELAY] = {.min = {.i = 0}, .max = {.i = 20}, .step = {.i = 1}},
|
||||
|
@ -724,7 +729,7 @@ const struct rig_caps ic7300_caps =
|
|||
.get_freq = icom_get_freq,
|
||||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.set_ant = NULL,
|
||||
.get_ant = NULL,
|
||||
|
@ -783,7 +788,7 @@ struct rig_caps ic9700_caps =
|
|||
RIG_MODEL(RIG_MODEL_IC9700),
|
||||
.model_name = "IC-9700",
|
||||
.mfg_name = "Icom",
|
||||
.version = BACKEND_VER ".12",
|
||||
.version = BACKEND_VER ".13",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
|
@ -807,6 +812,7 @@ struct rig_caps ic9700_caps =
|
|||
.has_get_parm = IC9700_PARMS,
|
||||
.has_set_parm = RIG_PARM_SET(IC9700_PARMS),
|
||||
.level_gran = {
|
||||
#include "level_gran_icom.h"
|
||||
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
|
||||
[LVL_VOXDELAY] = { .min = { .i = 0 }, .max = { .i = 20 }, .step = { .i = 1 } },
|
||||
[LVL_KEYSPD] = {.min = {.i = 6}, .max = {.i = 48}, .step = {.i = 1}},
|
||||
|
@ -1042,7 +1048,7 @@ struct rig_caps ic9700_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.get_vfo = icom_get_vfo,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.set_vfo = ic9700_set_vfo,
|
||||
.set_ant = NULL,
|
||||
.get_ant = NULL,
|
||||
|
||||
|
@ -1119,6 +1125,7 @@ const struct rig_caps ic705_caps =
|
|||
.has_get_parm = IC7300_PARMS,
|
||||
.has_set_parm = RIG_PARM_SET(IC7300_PARMS),
|
||||
.level_gran = {
|
||||
#include "level_gran_icom.h"
|
||||
[LVL_RAWSTR] = {.min = {.i = 0}, .max = {.i = 255}},
|
||||
[LVL_VOXDELAY] = {.min = {.i = 0}, .max = {.i = 20}, .step = {.i = 1}},
|
||||
[LVL_KEYSPD] = {.min = {.i = 6}, .max = {.i = 48}, .step = {.i = 1}},
|
||||
|
@ -1304,7 +1311,7 @@ const struct rig_caps ic705_caps =
|
|||
.get_freq = icom_get_freq,
|
||||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.set_ant = NULL,
|
||||
.get_ant = NULL,
|
||||
|
@ -1693,3 +1700,27 @@ int ic9700_get_clock(RIG *rig, int *year, int *month, int *day, int *hour,
|
|||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int ic9700_set_vfo(RIG *rig, vfo_t vfo)
|
||||
{
|
||||
ENTERFUNC;
|
||||
unsigned char ackbuf[MAXFRAMELEN];
|
||||
int ack_len = sizeof(ackbuf), retval;
|
||||
|
||||
if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN)
|
||||
{
|
||||
retval = icom_transaction(rig, 0x07, 0xd0, NULL, 0, ackbuf, &ack_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = icom_transaction(rig, 0x07, 0xd1, NULL, 0, ackbuf, &ack_len);
|
||||
}
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: %s\n", __func__, rigerror(retval));
|
||||
return -retval;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ const struct rig_caps ic7410_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ const struct rig_caps ic746_caps =
|
|||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
@ -557,7 +557,7 @@ const struct rig_caps ic746pro_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ const struct rig_caps ic756_caps =
|
|||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
@ -416,7 +416,7 @@ const struct rig_caps ic756pro_caps =
|
|||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
@ -658,7 +658,7 @@ const struct rig_caps ic756pro2_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
@ -1105,7 +1105,7 @@ const struct rig_caps ic756pro3_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
|
|
@ -407,7 +407,7 @@ const struct rig_caps ic7600_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
|
|
@ -241,6 +241,7 @@ static const struct icom_priv_caps ic7610_priv_caps =
|
|||
},
|
||||
},
|
||||
.extcmds = ic7610_extcmds,
|
||||
.x25_always = 1,
|
||||
};
|
||||
|
||||
|
||||
|
@ -349,7 +350,7 @@ const struct rig_caps ic7610_caps =
|
|||
RIG_MODEL(RIG_MODEL_IC7610),
|
||||
.model_name = "IC-7610",
|
||||
.mfg_name = "Icom",
|
||||
.version = BACKEND_VER ".11",
|
||||
.version = BACKEND_VER ".14",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
|
@ -581,8 +582,7 @@ const struct rig_caps ic7610_caps =
|
|||
.set_split_vfo = icom_set_split_vfo,
|
||||
.get_split_vfo = icom_get_split_vfo,
|
||||
.set_powerstat = icom_set_powerstat,
|
||||
// 7610 cannot read power status apparently
|
||||
// .get_powerstat = icom_get_powerstat,
|
||||
.get_powerstat = icom_get_powerstat,
|
||||
.send_morse = icom_send_morse,
|
||||
.stop_morse = icom_stop_morse,
|
||||
.wait_morse = rig_wait_morse,
|
||||
|
|
|
@ -386,7 +386,7 @@ const struct rig_caps ic7700_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ const struct rig_caps ic7800_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ const struct rig_caps ic781_caps =
|
|||
.set_mode = icom_set_mode,
|
||||
.get_mode = icom_get_mode,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_split_vfo = icom_set_split_vfo,
|
||||
.set_split_freq = icom_set_split_freq,
|
||||
.get_split_freq = icom_get_split_freq,
|
||||
|
|
|
@ -234,6 +234,7 @@ static struct icom_priv_caps ic785x_priv_caps =
|
|||
},
|
||||
},
|
||||
.extcmds = ic785x_extcmds,
|
||||
.x25_always = 1,
|
||||
};
|
||||
|
||||
const struct rig_caps ic785x_caps =
|
||||
|
@ -241,7 +242,7 @@ const struct rig_caps ic785x_caps =
|
|||
RIG_MODEL(RIG_MODEL_IC785x),
|
||||
.model_name = "IC-7850/7851",
|
||||
.mfg_name = "Icom",
|
||||
.version = BACKEND_VER ".5",
|
||||
.version = BACKEND_VER ".7",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
|
|
|
@ -327,7 +327,7 @@ const struct rig_caps ic910_caps =
|
|||
.set_ptt = icom_set_ptt,
|
||||
.get_ptt = icom_get_ptt,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.get_ts = icom_get_ts,
|
||||
.set_ts = icom_set_ts,
|
||||
.get_func = ic910_get_func,
|
||||
|
|
|
@ -241,7 +241,7 @@ const struct rig_caps ic9100_caps =
|
|||
.set_mode = icom_set_mode_with_data,
|
||||
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_ant = icom_set_ant,
|
||||
.get_ant = icom_get_ant,
|
||||
.get_ts = icom_get_ts,
|
||||
|
|
|
@ -467,7 +467,7 @@ const struct rig_caps icf8101_caps =
|
|||
.set_ptt = icf8101_set_ptt,
|
||||
.get_ptt = icf8101_get_ptt,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.get_vfo = icom_get_vfo,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.get_ts = icom_get_ts,
|
||||
.set_ts = icom_set_ts,
|
||||
.get_func = icf8101_get_func,
|
||||
|
|
|
@ -869,8 +869,9 @@ static vfo_t icom_current_vfo(RIG *rig)
|
|||
vfo_t chkVFO = RIG_VFO_A;
|
||||
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;
|
||||
|
||||
if (priv->x25cmdfails <= 0) // these newer rigs get special treatment
|
||||
if (priv->x25cmdfails <= 0 || priv_caps->x25_always) // these newer rigs get special treatment
|
||||
{
|
||||
return icom_current_vfo_x25(rig);
|
||||
}
|
||||
|
@ -1512,6 +1513,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
int ack_len = sizeof(ackbuf);
|
||||
int civ_731_mode = 0; // even these rigs have 5-byte channels
|
||||
vfo_t vfo_save = rig->state.current_vfo;
|
||||
const struct icom_priv_caps *priv_caps = rig->caps->priv;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called for %s, curr_vfo=%s\n", __func__,
|
||||
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
|
||||
|
@ -1631,7 +1633,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
// we'll use 0x25 command to get unselected frequency
|
||||
// we have to assume current_vfo is accurate to determine what "other" means
|
||||
if (priv->x25cmdfails <= 0)
|
||||
if (priv->x25cmdfails <= 0 || priv_caps->x25_always)
|
||||
{
|
||||
int cmd2 = 0x25;
|
||||
int subcmd2 = 0x00;
|
||||
|
@ -2764,22 +2766,28 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
RETURNFUNC2(RIG_OK);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// this seems to work but not for cqrlog and user twiddling VFO knob.
|
||||
// may be able to use twiddle but will disable for now
|
||||
/*
|
||||
* icom_get_vfo
|
||||
* Assumes rig!=NULL, rig->state.priv!=NULL
|
||||
* Only works on IC9700 so far
|
||||
*/
|
||||
int icom_get_vfo(RIG *rig, vfo_t *vfo)
|
||||
{
|
||||
*vfo = icom_current_vfo(rig);
|
||||
ENTERFUNC;
|
||||
unsigned char ackbuf[MAXFRAMELEN];
|
||||
int ack_len = sizeof(ackbuf), retval;
|
||||
retval = icom_transaction(rig, 0x07, 0xd2, NULL, 0, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: %s\n", __func__, rigerror(retval));
|
||||
return -retval;
|
||||
}
|
||||
dump_hex(ackbuf, ack_len);
|
||||
if (ackbuf[2] == 0) *vfo = RIG_VFO_MAIN;
|
||||
else *vfo = RIG_VFO_SUB;
|
||||
|
||||
if (vfo == NULL) { RETURNFUNC(-RIG_EINTERNAL); }
|
||||
|
||||
RETURNFUNC2(RIG_OK);
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* icom_set_vfo
|
||||
|
@ -2791,6 +2799,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
|
|||
int ack_len = sizeof(ackbuf), icvfo, retval;
|
||||
struct rig_state *rs = &rig->state;
|
||||
struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
|
||||
const struct icom_priv_caps *priv_caps = rig->caps->priv;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo));
|
||||
|
||||
|
@ -3044,6 +3053,8 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
|
|||
case RIG_VFO_OTHER:
|
||||
switch (rig->state.current_vfo)
|
||||
{
|
||||
case RIG_VFO_CURR:
|
||||
break; // no change needed
|
||||
case RIG_VFO_A:
|
||||
icvfo = vfo = RIG_VFO_B;
|
||||
break;
|
||||
|
@ -3082,7 +3093,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
|
|||
}
|
||||
|
||||
default:
|
||||
if (priv->x25cmdfails == 0)
|
||||
if (priv->x25cmdfails == 0 || priv_caps->x25_always)
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__,
|
||||
rig_strvfo(vfo));
|
||||
|
||||
|
@ -8068,6 +8079,7 @@ int icom_set_powerstat(RIG *rig, powerstat_t status)
|
|||
|
||||
if (retval != RIG_OK) { sleep(1); }
|
||||
}
|
||||
if (retval == RIG_OK) priv->poweron = 1;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -8186,7 +8198,13 @@ int icom_get_powerstat(RIG *rig, powerstat_t *status)
|
|||
RIG_POWER_ON : RIG_POWER_OFF;
|
||||
}
|
||||
|
||||
if (rig->caps->rig_model == RIG_MODEL_IC7300)
|
||||
if (rig->caps->rig_model == RIG_MODEL_IC2730
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7100
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7300
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7600
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7610
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7700
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7800)
|
||||
{
|
||||
freq_t freq;
|
||||
int retrysave = rig->caps->retry;
|
||||
|
@ -9052,12 +9070,14 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
|
|||
freq_t freq = (freq_t) from_bcd(frame + 5, (priv->civ_731_mode ? 4 : 5) * 2);
|
||||
rig_fire_freq_event(rig, RIG_VFO_CURR, freq);
|
||||
|
||||
#if 0
|
||||
if (rs->use_cached_freq != 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): use_cached_freq turning on\n", __func__,
|
||||
__LINE__);
|
||||
rs->use_cached_freq = 1;
|
||||
rs->use_cached_freq = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -9072,7 +9092,7 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
|
|||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): use_cached_mode turning on\n", __func__,
|
||||
__LINE__);
|
||||
rs->use_cached_mode = 1;
|
||||
rs->use_cached_mode = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#define BACKEND_VER "20230512"
|
||||
#define BACKEND_VER "20230520"
|
||||
|
||||
#define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31)
|
||||
#define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51)
|
||||
|
@ -244,6 +244,7 @@ struct icom_priv_caps
|
|||
struct icom_spectrum_edge_frequency_range spectrum_edge_frequency_ranges[ICOM_MAX_SPECTRUM_FREQ_RANGES]; /*!< Icom spectrum scope edge frequencies, if supported by the rig. Last entry should have zeros in all fields. */
|
||||
struct cmdparams *extcmds; /*!< Pointer to extended operations array */
|
||||
int dualwatch_split; /*!< Rig supports dual watch for split ops -- e.g. ID-5100 */
|
||||
int x25_always; /*!< Means the rig should use 0x25 and 0x26 commands always */
|
||||
};
|
||||
|
||||
struct icom_priv_data
|
||||
|
@ -319,7 +320,7 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
|||
int icom_get_mode_with_data(RIG *rig, vfo_t vfo, rmode_t *mode,
|
||||
pbwidth_t *width);
|
||||
int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
|
||||
#if 0 // see icom_get_vfo in icom.c
|
||||
#if 1 // see icom_get_vfo in icom.c
|
||||
int icom_get_vfo(RIG *rig, vfo_t *vfo);
|
||||
#else
|
||||
#define icom_get_vfo NULL
|
||||
|
|
|
@ -16,8 +16,8 @@ LVL_KEYSPD
|
|||
/* raw data */
|
||||
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
|
||||
/* levels with dB units */
|
||||
[LVL_PREAMP] = { .min = { .i = 10 }, .max = { .i = 20 }, .step = { .i = 10 } },
|
||||
[LVL_ATT] = { .min = { .i = 12 }, .max = { .i = 12 }, .step = { .i = 0 } },
|
||||
[LVL_PREAMP] = { .min = { .i = 0 }, .max = { .i = 20 }, .step = { .i = 10 } },
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 12 }, .step = { .i = 0 } },
|
||||
[LVL_STRENGTH] = { .min = { .i = 0 }, .max = { .i = 60 }, .step = { .i = 0 } },
|
||||
[LVL_NB] = { .min = { .f = 0 }, .max = { .f = 10 }, .step = { .f = 1 } },
|
||||
/* levels with WPM units */
|
||||
|
|
|
@ -9,7 +9,7 @@ IC10SRC = ts440.c ts940.c ts711.c ts811.c r5000.c
|
|||
THSRC = thd7.c thf7.c thg71.c tmd700.c tmv7.c thf6a.c thd72.c tmd710.c thd74.c
|
||||
|
||||
KENWOODSRC = kenwood.c kenwood.h th.c th.h ic10.c ic10.h elecraft.c elecraft.h \
|
||||
transfox.c flex.c flex.h level_gran_kenwood.h
|
||||
transfox.c flex.c flex.h level_gran_kenwood.h level_gran_elecraft.h
|
||||
|
||||
noinst_LTLIBRARIES = libhamlib-kenwood.la
|
||||
libhamlib_kenwood_la_SOURCES = $(TSSRC) $(THSRC) $(IC10SRC) $(KENWOODSRC)
|
||||
|
|
|
@ -1122,7 +1122,9 @@ const struct rig_caps f6k_caps =
|
|||
.has_set_level = F6K_LEVEL_ALL,
|
||||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
|
||||
.level_gran = {}, /* FIXME: granularity */
|
||||
.level_gran = {
|
||||
[LVL_KEYSPD] = { .min = { .i = 5 }, .max = { .i = 60 }, .step = { .i = 1 } },
|
||||
}, /* FIXME: granularity */
|
||||
.parm_gran = {},
|
||||
//.extlevels = elecraft_ext_levels,
|
||||
//.extparms = kenwood_cfg_params,
|
||||
|
@ -1260,7 +1262,9 @@ const struct rig_caps powersdr_caps =
|
|||
.has_set_level = POWERSDR_LEVEL_SET,
|
||||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
|
||||
.level_gran = {}, /* FIXME: granularity */
|
||||
.level_gran = {
|
||||
[LVL_KEYSPD] = { .min = { .i = 5 }, .max = { .i = 60 }, .step = { .i = 1 } },
|
||||
}, /* FIXME: granularity */
|
||||
.parm_gran = {},
|
||||
//.extlevels = elecraft_ext_levels,
|
||||
//.extparms = kenwood_cfg_params,
|
||||
|
|
|
@ -143,7 +143,9 @@ const struct rig_caps k2_caps =
|
|||
.has_set_level = RIG_LEVEL_SET(K2_LEVEL_ALL),
|
||||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
|
||||
.level_gran = {}, /* FIXME: granularity */
|
||||
.level_gran = {
|
||||
#include "level_gran_elecraft.h"
|
||||
}, /* FIXME: granularity */
|
||||
.parm_gran = {},
|
||||
.extlevels = elecraft_ext_levels,
|
||||
.extparms = kenwood_cfg_params,
|
||||
|
|
|
@ -216,8 +216,7 @@ const struct rig_caps k3_caps =
|
|||
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
|
||||
.level_gran = {
|
||||
// cppcheck-suppress *
|
||||
[LVL_KEYSPD] = { .min = { .i = 8 }, .max = { .i = 50 }, .step = { .i = 1 } },
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 10 }, .step = { .i = 10 } },
|
||||
#include "level_gran_elecraft.h"
|
||||
},
|
||||
.parm_gran = {},
|
||||
.extlevels = k3_ext_levels,
|
||||
|
@ -369,7 +368,7 @@ const struct rig_caps k3s_caps =
|
|||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
|
||||
.level_gran = {
|
||||
[LVL_KEYSPD] = { .min = { .i = 8 }, .max = { .i = 50 }, .step = { .i = 1 } },
|
||||
#include "level_gran_elecraft.h"
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 15 }, .step = { .i = 5 } },
|
||||
},
|
||||
.parm_gran = {},
|
||||
|
@ -522,13 +521,16 @@ const struct rig_caps k4_caps =
|
|||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
|
||||
.level_gran = {
|
||||
[LVL_KEYSPD] = { .min = { .i = 8 }, .max = { .i = 50 }, .step = { .i = 1 } },
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 15 }, .step = { .i = 5 } },
|
||||
#include "level_gran_elecraft.h"
|
||||
[LVL_CWPITCH] = { .min = { .i = 250 }, .max = { .i = 950 }, .step = { .i = 10 } },
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 15 }, .step = { .i = 5 } },
|
||||
[LVL_VOXDELAY] = { .min = { .i = 0 }, .max = { .i = 255 }, .step = { .i = 10 } },
|
||||
[LVL_PREAMP] = { .min = { .i = 0 }, .max = { .i = 30}, .step = { .i = 10 } },
|
||||
},
|
||||
.parm_gran = {},
|
||||
.extlevels = k3_ext_levels,
|
||||
.extparms = kenwood_cfg_params,
|
||||
.preamp = { 1, RIG_DBLST_END, },
|
||||
.preamp = { 10, 20, 30, RIG_DBLST_END, },
|
||||
.attenuator = { 5, 10, 15, RIG_DBLST_END, },
|
||||
.max_rit = Hz(9990),
|
||||
.max_xit = Hz(9990),
|
||||
|
@ -536,6 +538,8 @@ const struct rig_caps k4_caps =
|
|||
.vfo_ops = K3_VFO_OP,
|
||||
.targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
|
||||
.transceive = RIG_TRN_RIG,
|
||||
.agc_level_count = 3,
|
||||
.agc_levels = { RIG_AGC_OFF, RIG_AGC_SLOW, RIG_AGC_FAST },
|
||||
.bank_qty = 0,
|
||||
.chan_desc_sz = 0,
|
||||
|
||||
|
@ -674,8 +678,7 @@ const struct rig_caps kx3_caps =
|
|||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
|
||||
.level_gran = {
|
||||
[LVL_KEYSPD] = { .min = { .i = 8 }, .max = { .i = 50 }, .step = { .i = 1 } },
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 10 }, .step = { .i = 10 } },
|
||||
#include "level_gran_elecraft.h"
|
||||
},
|
||||
.parm_gran = {},
|
||||
.extlevels = kx3_ext_levels,
|
||||
|
@ -826,8 +829,7 @@ const struct rig_caps kx2_caps =
|
|||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
|
||||
.level_gran = {
|
||||
[LVL_KEYSPD] = { .min = { .i = 8 }, .max = { .i = 50 }, .step = { .i = 1 } },
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 10 }, .step = { .i = 10 } },
|
||||
#include "level_gran_elecraft.h"
|
||||
},
|
||||
.parm_gran = {},
|
||||
.extlevels = kx3_ext_levels,
|
||||
|
|
|
@ -246,9 +246,16 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data,
|
|||
struct kenwood_priv_caps *caps = kenwood_caps(rig);
|
||||
struct rig_state *rs;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called cmd=%s datasize=%d\n", __func__,
|
||||
if (datasize > 0 && datasize < strlen(cmdstr)) {
|
||||
rig_debug(RIG_DEBUG_WARN, "%s called cmd=%s datasize=%d, datasize < cmd length?\n", __func__,
|
||||
cmdstr ? cmdstr : "(NULL)",
|
||||
(int)datasize);
|
||||
}
|
||||
else
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called cmd=%s\n", __func__,
|
||||
cmdstr ? cmdstr : "(NULL)");
|
||||
}
|
||||
|
||||
if ((!cmdstr && !datasize) || (datasize && !data))
|
||||
{
|
||||
|
@ -376,13 +383,15 @@ transaction_write:
|
|||
|
||||
transaction_read:
|
||||
/* allow room for most any response */
|
||||
// this len/expected stuff is confusing -- logic in some places includes the semicolon
|
||||
// so we add 1 to our read_string length to cover these cases
|
||||
// eventually we should be able to get rid of this but requires testing all Kenwood rigs
|
||||
len = min(datasize ? datasize + 1 : strlen(priv->verify_cmd) + 48,
|
||||
KENWOOD_MAX_BUF_LEN);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) buffer, len,
|
||||
cmdtrm_str, strlen(cmdtrm_str), 0, 1);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read_string(expected=%d, len=%d)='%s'\n",
|
||||
__func__,
|
||||
len, (int)strlen(buffer), buffer);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read_string len=%d '%s'\n", __func__,
|
||||
(int)strlen(buffer), buffer);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -1233,7 +1242,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo)
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "%s: checking satellite mode status\n", __func__);
|
||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "SA");
|
||||
|
||||
retval = kenwood_transaction(rig, cmdbuf, retbuf, 20);
|
||||
retval = kenwood_transaction(rig, cmdbuf, retbuf, 4);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -5329,6 +5338,20 @@ int kenwood_stop_morse(RIG *rig, vfo_t vfo)
|
|||
RETURNFUNC(kenwood_transaction(rig, "KY0", NULL, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* kenwood_send_voice
|
||||
*/
|
||||
int kenwood_send_voice_mem(RIG *rig, vfo_t vfo, int bank)
|
||||
{
|
||||
char cmd[16];
|
||||
ENTERFUNC;
|
||||
|
||||
SNPRINTF(cmd, sizeof(cmd), "PB01");
|
||||
kenwood_transaction(rig, cmd, NULL, 0);
|
||||
SNPRINTF(cmd, sizeof(cmd), "PB1%d", bank);
|
||||
RETURNFUNC(kenwood_transaction(rig, cmd, NULL, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* kenwood_vfo_op
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "token.h"
|
||||
#include "idx_builtin.h"
|
||||
|
||||
#define BACKEND_VER "20230430"
|
||||
#define BACKEND_VER "20230517"
|
||||
|
||||
#define EOM_KEN ';'
|
||||
#define EOM_TH '\r'
|
||||
|
@ -253,6 +253,7 @@ int kenwood_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch);
|
|||
const char *kenwood_get_info(RIG *rig);
|
||||
int kenwood_get_id(RIG *rig, char *buf);
|
||||
int kenwood_get_if(RIG *rig);
|
||||
int kenwood_send_voice_mem(RIG *rig, vfo_t vfo, int bank);
|
||||
|
||||
int kenwood_set_trn(RIG *rig, int trn);
|
||||
int kenwood_get_trn(RIG *rig, int *trn);
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// Once included these values can be overidden in the back-end
|
||||
// Known variants are PREAMP, ATT, NB, CWPITCH, IF, NOTCHF, VOXDELAY, BKINDL, BKIN_DLYMS, RFPOWER_METER(255 or 100), RFPOWER_METER_WATTS(255 or 100)
|
||||
// cppcheck-suppress *
|
||||
/* raw data */
|
||||
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
|
||||
/* levels with dB units */
|
||||
[LVL_PREAMP] = { .min = { .i = 0 }, .max = { .i = 20 }, .step = { .i = 10 } },
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 10 }, .step = { .i = 10 } },
|
||||
[LVL_STRENGTH] = { .min = { .i = 0 }, .max = { .i = 60 }, .step = { .i = 0 } },
|
||||
[LVL_NB] = { .min = { .f = 0 }, .max = { .f = 10 }, .step = { .f = 1 } },
|
||||
/* levels with WPM units */
|
||||
[LVL_KEYSPD] = { .min = { .i = 8 }, .max = { .i = 50 }, .step = { .i = 1 } },
|
||||
/* levels with Hz units */
|
||||
[LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 800 }, .step = { .i = 10 } },
|
||||
/* levels with time units */
|
||||
[LVL_VOXDELAY] = { .min = { .i = 0 }, .max = { .i = 255 }, .step = { .i = 50 } },
|
||||
/* levels with 0-1 values -- increment based on rig's range */
|
||||
[LVL_NR] = { .min = { .f = 0 }, .max = { .f = 1 }, .step = { .f = 1.0f/10.0f } },
|
||||
[LVL_AF] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/255.0f } },
|
||||
[LVL_RF] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/255.0f } },
|
||||
[LVL_RFPOWER] = { .min = { .f = .05 }, .max = { .f = 1 }, .step = { .f = 1.0f/100.0f } },
|
||||
[LVL_RFPOWER_METER] = { .min = { .f = .0 }, .max = { .f = 1 }, .step = { .f = 1.0f/255.0f } },
|
||||
[LVL_RFPOWER_METER_WATTS] = { .min = { .f = .0 }, .max = { .f = 100 }, .step = { .f = 1.0f/255.0f } },
|
||||
[LVL_SQL] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } },
|
||||
[LVL_MICGAIN] = { .min = { .f = .0 }, .max = { .f = 1 }, .step = { .f = 1.0f/100.0f } },
|
||||
[LVL_MONITOR_GAIN] = { .min = { .f = .0 }, .max = { .f = 1 }, .step = { .f = 1.0f/100.0f } },
|
||||
[LVL_COMP] = { .min = { .f = .0 }, .max = { .f = 1 }, .step = { .f = 1.0f/100.0f } },
|
||||
[LVL_VOXGAIN] = { .min = { .f = .0 }, .max = { .f = 1 }, .step = { .f = 1.0f/100.0f } },
|
||||
[LVL_ALC] = { .min = { .f = .0 }, .max = { .f = 1 }, .step = { .f = 1.0f/100.0f } },
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
/* raw data */
|
||||
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
|
||||
/* levels with dB units */
|
||||
[LVL_PREAMP] = { .min = { .i = 10 }, .max = { .i = 20 }, .step = { .i = 10 } },
|
||||
[LVL_PREAMP] = { .min = { .i = 0 }, .max = { .i = 20 }, .step = { .i = 10 } },
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 12 }, .step = { .i = 0 } },
|
||||
[LVL_STRENGTH] = { .min = { .i = 0 }, .max = { .i = 60 }, .step = { .i = 0 } },
|
||||
/* levels with WPM units */
|
||||
|
@ -18,10 +18,10 @@
|
|||
/* levels with time units */
|
||||
[LVL_VOXDELAY] = { .min = { .i = 3 }, .max = { .i = 300 }, .step = { .i = 1 } },
|
||||
[LVL_BKINDL] = { .min = { .i = 30 }, .max = { .i = 3000 }, .step = { .i = 1 } },
|
||||
[LVL_BKIN_DLYMS] = { .min = { .i = 30 }, .max = { .i = 3000 }, .step = { .i = 1 } },
|
||||
[LVL_BKIN_DLYMS] = { .min = { .i = 30 }, .max = { .i = 3000 }, .step = { .i = 1 } },
|
||||
/* level with misc units */
|
||||
[LVL_SWR] = { .min = { .f = 0 }, .max = { .f = 5.0 }, .step = { .f = 1.0f/255.0f } },
|
||||
[LVL_BAND_SELECT] = { .min = { .i = 0 }, .max = { .i = 16 }, .step = { .i = 1 } },
|
||||
[LVL_BAND_SELECT] = { .min = { .i = 0 }, .max = { .i = 16 }, .step = { .i = 1 } },
|
||||
/* levels with 0-1 values -- increment based on rig's range */
|
||||
[LVL_NR] = { .min = { .f = 0 }, .max = { .f = 1 }, .step = { .f = 1.0f/10.0f } },
|
||||
[LVL_NB] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/10.0f } },
|
||||
|
|
|
@ -249,6 +249,10 @@ static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
char cmd[32], ackbuf[32];
|
||||
int retval;
|
||||
|
||||
if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; }
|
||||
|
||||
if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, rig->state.cache.split); }
|
||||
|
||||
if (!sf_fails)
|
||||
{
|
||||
SNPRINTF(cmd, sizeof(cmd), "SF%d", vfo == RIG_VFO_A ? 0 : 1);
|
||||
|
@ -271,14 +275,14 @@ static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
|
||||
// now let's get our widths
|
||||
SNPRINTF(cmd, sizeof(cmd), "SH");
|
||||
retval = kenwood_safe_transaction(rig, cmd, ackbuf, sizeof(ackbuf), 15);
|
||||
retval = kenwood_safe_transaction(rig, cmd, ackbuf, sizeof(ackbuf), 4);
|
||||
int hwidth;
|
||||
sscanf(cmd, "SH%d", &hwidth);
|
||||
int lwidth;
|
||||
int shift = 0;
|
||||
SNPRINTF(cmd, sizeof(cmd), "SL");
|
||||
sscanf(cmd, "SH%d", &lwidth);
|
||||
retval = kenwood_safe_transaction(rig, cmd, ackbuf, sizeof(ackbuf), 15);
|
||||
retval = kenwood_safe_transaction(rig, cmd, ackbuf, sizeof(ackbuf), 4);
|
||||
|
||||
if (*mode == RIG_MODE_PKTUSB || *mode == RIG_MODE_PKTLSB
|
||||
|| *mode == RIG_MODE_FM || *mode == RIG_MODE_PKTFM || *mode == RIG_MODE_USB
|
||||
|
@ -1542,7 +1546,7 @@ const struct rig_caps ts590_caps =
|
|||
RIG_MODEL(RIG_MODEL_TS590S),
|
||||
.model_name = "TS-590S",
|
||||
.mfg_name = "Kenwood",
|
||||
.version = BACKEND_VER ".5",
|
||||
.version = BACKEND_VER ".7",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
|
@ -1661,10 +1665,8 @@ const struct rig_caps ts590_caps =
|
|||
#include "level_gran_kenwood.h"
|
||||
[LVL_RF] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f / 100.0f } },
|
||||
[LVL_AF] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f / 100.0f } },
|
||||
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
|
||||
[LVL_VOXDELAY] = { .min = { .i = 0 }, .max = { .i = 30 }, .step = { .i = 1 } },
|
||||
[LVL_KEYSPD] = {.min = {.i = 4}, .max = {.i = 60}, .step = {.i = 1}},
|
||||
[LVL_CWPITCH] = {.min = {.i = 400}, .max = {.i = 1000}, .step = {.i = 50}},
|
||||
[LVL_CWPITCH] = {.min = {.i = 300}, .max = {.i = 1000}, .step = {.i = 50}},
|
||||
[LVL_BKIN_DLYMS] = {.min = {.i = 0}, .max = {.i = 1000}, .step = {.i = 50}},
|
||||
[LVL_SLOPE_LOW] = {.min = {.i = 0}, .max = {.i = 2400}, .step = {.i = 10}},
|
||||
[LVL_SLOPE_HIGH] = {.min = {.i = 0}, .max = {.i = 5000}, .step = {.i = 10}},
|
||||
|
@ -1740,7 +1742,7 @@ const struct rig_caps ts590sg_caps =
|
|||
RIG_MODEL(RIG_MODEL_TS590SG),
|
||||
.model_name = "TS-590SG",
|
||||
.mfg_name = "Kenwood",
|
||||
.version = BACKEND_VER ".3",
|
||||
.version = BACKEND_VER ".5",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
|
@ -1858,10 +1860,8 @@ const struct rig_caps ts590sg_caps =
|
|||
#include "level_gran_kenwood.h"
|
||||
[LVL_RF] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f / 100.0f } },
|
||||
[LVL_AF] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f / 100.0f } },
|
||||
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
|
||||
[LVL_VOXDELAY] = { .min = { .i = 0 }, .max = { .i = 30 }, .step = { .i = 1 } },
|
||||
[LVL_KEYSPD] = {.min = {.i = 4}, .max = {.i = 60}, .step = {.i = 1}},
|
||||
[LVL_CWPITCH] = {.min = {.i = 400}, .max = {.i = 1000}, .step = {.i = 50}},
|
||||
[LVL_CWPITCH] = {.min = {.i = 300}, .max = {.i = 1000}, .step = {.i = 50}},
|
||||
[LVL_BKIN_DLYMS] = {.min = {.i = 0}, .max = {.i = 1000}, .step = {.i = 50}},
|
||||
[LVL_SLOPE_LOW] = {.min = {.i = 0}, .max = {.i = 2400}, .step = {.i = 10}},
|
||||
[LVL_SLOPE_HIGH] = {.min = {.i = 0}, .max = {.i = 5000}, .step = {.i = 10}},
|
||||
|
|
|
@ -565,6 +565,7 @@ const struct rig_caps ts870s_caps =
|
|||
.level_gran =
|
||||
{
|
||||
#include "level_gran_kenwood.h"
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 18 }, .step = { .i = 6 } },
|
||||
},
|
||||
.parm_gran = {},
|
||||
.ctcss_list = kenwood38_ctcss_list,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <hamlib/rig.h>
|
||||
#include "kenwood.h"
|
||||
#include "cal.h"
|
||||
#include "misc.h"
|
||||
|
||||
// TODO: Copied from TS-480, to be verified
|
||||
#define TS890_VFO (RIG_VFO_A|RIG_VFO_B)
|
||||
|
@ -47,10 +48,16 @@
|
|||
int kenwood_ts890_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
{
|
||||
char levelbuf[16];
|
||||
int kenwood_val;
|
||||
int kenwood_val, retval;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
||||
|
||||
retval = check_level_param(rig, level, val, NULL);
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
|
||||
switch (level)
|
||||
{
|
||||
case RIG_LEVEL_RF:
|
||||
|
@ -68,32 +75,20 @@ int kenwood_ts890_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
/* possible values for TS890 0(=off), 1(=slow), 2(=mid), 3(=fast), 4(=off/Last) */
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s TS890S RIG_LEVEL_AGC\n", __func__);
|
||||
|
||||
switch (val.i)
|
||||
{
|
||||
case RIG_AGC_OFF:
|
||||
kenwood_val = 0;
|
||||
break;
|
||||
|
||||
case RIG_AGC_SLOW:
|
||||
kenwood_val = 1;
|
||||
break;
|
||||
|
||||
case RIG_AGC_MEDIUM:
|
||||
kenwood_val = 2;
|
||||
break;
|
||||
|
||||
case RIG_AGC_FAST:
|
||||
kenwood_val = 3;
|
||||
break;
|
||||
|
||||
case RIG_AGC_AUTO:
|
||||
kenwood_val = 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported agc value", __func__);
|
||||
kenwood_val = -1; /* Flag invalid value */
|
||||
for (int j = 0; j < rig->caps->agc_level_count; j++)
|
||||
{
|
||||
if (val.i == rig->caps->agc_levels[j])
|
||||
{
|
||||
kenwood_val = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( kenwood_val < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported agc value:%d\n", __func__, val.i);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
SNPRINTF(levelbuf, sizeof(levelbuf), "GC%d", kenwood_val);
|
||||
break;
|
||||
|
@ -228,47 +223,23 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
return RIG_OK;
|
||||
|
||||
case RIG_LEVEL_AGC:
|
||||
retval = kenwood_transaction(rig, "GC", ackbuf, sizeof(ackbuf));
|
||||
ack_len_expected = 3;
|
||||
retval = kenwood_safe_transaction(rig, "GC", ackbuf, sizeof(ackbuf), 3);
|
||||
|
||||
if (RIG_OK != retval)
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
|
||||
ack_len = strlen(ackbuf);
|
||||
|
||||
if (ack_len != ack_len_expected)
|
||||
{
|
||||
levelint = ackbuf[2] - '0'; /* atoi */
|
||||
if (levelint >= 0 && levelint < rig->caps->agc_level_count)
|
||||
{
|
||||
val->i = rig->caps->agc_levels[levelint];
|
||||
}
|
||||
else
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unknown agc value: %s\n", __func__, ackbuf);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
switch (ackbuf[ack_len_expected - 1])
|
||||
{
|
||||
case '0':
|
||||
val->i = RIG_AGC_OFF;
|
||||
break;
|
||||
|
||||
case '1':
|
||||
val->i = RIG_AGC_SLOW;
|
||||
|
||||
break;
|
||||
|
||||
case '2':
|
||||
val->i = RIG_AGC_MEDIUM;
|
||||
break;
|
||||
|
||||
case '3':
|
||||
val->i = RIG_AGC_FAST;
|
||||
break;
|
||||
|
||||
case '4':
|
||||
val->i = RIG_AGC_AUTO;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
|
||||
|
@ -585,6 +556,7 @@ const struct rig_caps ts890s_caps =
|
|||
.get_ant = kenwood_get_ant,
|
||||
.send_morse = kenwood_send_morse,
|
||||
.stop_morse = kenwood_stop_morse,
|
||||
.send_voice_mem = kenwood_send_voice_mem,
|
||||
.wait_morse = rig_wait_morse,
|
||||
.scan = kenwood_scan, /* not working, invalid arguments using rigctl; kenwood_scan does only support on/off and not tone and CTCSS scan */
|
||||
.has_set_level = TS890_LEVEL_SET,
|
||||
|
|
|
@ -80,6 +80,7 @@ const struct rig_caps ts930_caps =
|
|||
.level_gran =
|
||||
{
|
||||
#include "level_gran_kenwood.h"
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 18 }, .step = { .i = 6 } },
|
||||
},
|
||||
.parm_gran = {},
|
||||
.preamp = { RIG_DBLST_END, }, /* FIXME: preamp list */
|
||||
|
|
|
@ -127,7 +127,9 @@ const struct rig_caps xg3_caps =
|
|||
.has_set_level = RIG_LEVEL_SET(XG3_LEVEL_ALL),
|
||||
.has_get_parm = XG3_PARM_ALL,
|
||||
.has_set_parm = XG3_PARM_ALL,
|
||||
.level_gran = {}, /* FIXME: granularity */
|
||||
.level_gran = {
|
||||
#include "level_gran_elecraft.h"
|
||||
}, /* FIXME: granularity */
|
||||
.parm_gran = {},
|
||||
.extparms = kenwood_cfg_params,
|
||||
.max_ifshift = Hz(0),
|
||||
|
|
|
@ -97,6 +97,7 @@ const struct rig_caps ftdx101mp_caps =
|
|||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_NONE,
|
||||
.level_gran = {
|
||||
#include "level_gran_yaesu.h"
|
||||
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
|
||||
[LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 1050 }, .step = { .i = 10 } },
|
||||
[LVL_KEYSPD] = { .min = { .i = 4 }, .max = { .i = 60 }, .step = { .i = 1 } },
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
/* raw data */
|
||||
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
|
||||
/* levels with dB units */
|
||||
[LVL_PREAMP] = { .min = { .i = 10 }, .max = { .i = 20 }, .step = { .i = 10 } },
|
||||
[LVL_ATT] = { .min = { .i = 12 }, .max = { .i = 12 }, .step = { .i = 0 } },
|
||||
[LVL_PREAMP] = { .min = { .i = 0 }, .max = { .i = 20 }, .step = { .i = 10 } },
|
||||
[LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 12 }, .step = { .i = 0 } },
|
||||
[LVL_STRENGTH] = { .min = { .i = 0 }, .max = { .i = 60 }, .step = { .i = 0 } },
|
||||
[LVL_NB] = { .min = { .f = 0 }, .max = { .f = 10 }, .step = { .f = 1 } },
|
||||
/* levels with WPM units */
|
||||
[LVL_KEYSPD] = { .min = { .i = 4 }, .max = { .i = 60 }, .step = { .i = 1 } },
|
||||
/* levels with Hz units */
|
||||
[LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 1050 }, .step = { .i = 50 } },
|
||||
[LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 1050 }, .step = { .i = 10 } },
|
||||
[LVL_IF] = { .min = { .i = -1200 }, .max = { .i = 1200 }, .step = { .i = 20 } },
|
||||
[LVL_NOTCHF] = { .min = { .i = 1 }, .max = { .i = 3200 }, .step = { .i = 10 } },
|
||||
/* levels with time units */
|
||||
|
|
|
@ -693,7 +693,7 @@ int newcat_close(RIG *rig)
|
|||
|
||||
ENTERFUNC;
|
||||
|
||||
if (!no_restore_ai && priv->trn_state >= 0 && rig_s->comm_state)
|
||||
if (!no_restore_ai && priv->trn_state >= 0 && rig_s->comm_state && rig_s->powerstat != RIG_POWER_OFF)
|
||||
{
|
||||
/* restore AI state */
|
||||
newcat_set_trn(rig, priv->trn_state); /* ignore status in
|
||||
|
@ -1073,7 +1073,6 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
|
||||
if (priv->ret_data[2] != target_vfo)
|
||||
{
|
||||
HAMLIB_TRACE;
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "VS%c%c", target_vfo, cat_term);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str);
|
||||
|
||||
|
@ -1144,7 +1143,6 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
&& rig->caps->get_vfo != NULL
|
||||
&& rig->caps->set_vfo != NULL) // gotta' have get_vfo too
|
||||
{
|
||||
HAMLIB_TRACE;
|
||||
|
||||
if (rig->state.current_vfo != vfo)
|
||||
{
|
||||
|
@ -7849,7 +7847,6 @@ int newcat_set_tx_vfo(RIG *rig, vfo_t tx_vfo)
|
|||
newcat_is_rig(rig, RIG_MODEL_FTDX10) ||
|
||||
newcat_is_rig(rig, RIG_MODEL_FTDX3000))
|
||||
{
|
||||
HAMLIB_TRACE;
|
||||
p1 = p1 + 2; /* use non-Toggle commands */
|
||||
|
||||
// If VFOB is active then we change VFOB with FT3 instead of VFOA
|
||||
|
@ -10540,6 +10537,12 @@ int newcat_get_cmd(RIG *rig)
|
|||
|
||||
ENTERFUNC;
|
||||
|
||||
if (state->powerstat == 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: Cannot get from rig when power is off\n", __func__);
|
||||
return RIG_OK; // to prevent repeats
|
||||
}
|
||||
|
||||
// try to cache rapid repeats of the IF command
|
||||
// this is for WSJT-X/JTDX sequence of v/f/m/t
|
||||
// should allow rapid repeat of any call using the IF; cmd
|
||||
|
@ -10622,12 +10625,13 @@ int newcat_get_cmd(RIG *rig)
|
|||
while (rc != RIG_OK && retry_count++ <= state->rigport.retry)
|
||||
{
|
||||
rig_flush(&state->rigport); /* discard any unsolicited data */
|
||||
|
||||
if (rc != -RIG_BUSBUSY)
|
||||
{
|
||||
/* send the command */
|
||||
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
|
||||
|
||||
|
||||
if (strncmp(priv->cmd_str,"PS",2)==0) state->rigport.timeout_retry = 0;
|
||||
if (RIG_OK != (rc = write_block(&state->rigport,
|
||||
(unsigned char *) priv->cmd_str,
|
||||
strlen(priv->cmd_str))))
|
||||
|
@ -10641,6 +10645,11 @@ int newcat_get_cmd(RIG *rig)
|
|||
sizeof(priv->ret_data),
|
||||
&cat_term, sizeof(cat_term), 0, 1)) <= 0)
|
||||
{
|
||||
// if we get a timeout from PS probably means power is off
|
||||
if (strncmp(priv->cmd_str,"PS",2)==0) {
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: rig power is off?\n", __func__);
|
||||
return -RIG_ETIMEOUT;
|
||||
}
|
||||
continue; /* usually a timeout - retry */
|
||||
}
|
||||
|
||||
|
@ -10896,23 +10905,6 @@ int newcat_set_cmd_validate(RIG *rig)
|
|||
|
||||
if (strlen(valcmd) == 0) { RETURNFUNC(RIG_OK); }
|
||||
|
||||
// we can use a single ; to get a response of ?; for some rigs
|
||||
// this list can be expanded as we get more testing
|
||||
// seems newer rigs have this older ones time out
|
||||
switch (rig->caps->rig_model)
|
||||
{
|
||||
case RIG_MODEL_FT991:
|
||||
case RIG_MODEL_FTDX101MP:
|
||||
case RIG_MODEL_FTDX3000:
|
||||
strcpy(valcmd, ";");
|
||||
break;
|
||||
|
||||
// these models do not work with a single ;
|
||||
case RIG_MODEL_FT897:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SNPRINTF(cmd, sizeof(cmd), "%s", valcmd);
|
||||
rc = write_block(&state->rigport, (unsigned char *) cmd, strlen(cmd));
|
||||
|
||||
|
@ -10924,7 +10916,7 @@ int newcat_set_cmd_validate(RIG *rig)
|
|||
|
||||
// FA and FB success is now verified in rig.c with a followup query
|
||||
// so no validation is needed
|
||||
if (strncmp(priv->cmd_str, "FA", 2) == 0 || strncmp(priv->cmd_str, "FB", 2))
|
||||
if (strncmp(priv->cmd_str, "FA", 2) == 0 || strncmp(priv->cmd_str, "FB", 2) == 0)
|
||||
{
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -10954,6 +10946,7 @@ int newcat_set_cmd_validate(RIG *rig)
|
|||
if (strncmp(priv->cmd_str, "VS", 2) == 0
|
||||
&& strncmp(priv->cmd_str, priv->ret_data, 2) == 0) { RETURNFUNC(RIG_OK); }
|
||||
else if (strcmp(priv->cmd_str, priv->ret_data) == 0) { RETURNFUNC(RIG_OK); }
|
||||
else if (priv->cmd_str[0] == ';' && priv->ret_data[0]=='?') { hl_usleep(50*1000);RETURNFUNC(RIG_OK); }
|
||||
else { rc = -RIG_EPROTO; }
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
typedef char ncboolean;
|
||||
|
||||
/* shared function version */
|
||||
#define NEWCAT_VER "20230513"
|
||||
#define NEWCAT_VER "20230517"
|
||||
|
||||
/* Hopefully large enough for future use, 128 chars plus '\0' */
|
||||
#define NEWCAT_DATA_LEN 129
|
||||
|
|
|
@ -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 simts590 simft847
|
||||
check_PROGRAMS = simelecraft simicom simkenwood simyaesu simicom9100 simicom9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simicom7300
|
||||
|
||||
simelecraft_SOURCES = simelecraft.c
|
||||
simicom_SOURCES = simicom.c
|
||||
|
|
|
@ -204,8 +204,8 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
int val = ft;
|
||||
|
||||
if (ft == 2) { val == 0; }
|
||||
else if (ft == 3) { val == 1; }
|
||||
if (ft == 2) { val = 0; }
|
||||
else if (ft == 3) { val = 1; }
|
||||
|
||||
SNPRINTF(buf, sizeof(buf), "FT%d;", val);
|
||||
n = write(fd, buf, strlen(buf));
|
||||
|
|
|
@ -0,0 +1,617 @@
|
|||
// simicom will show the pts port to use for rigctl on Unix
|
||||
// using virtual serial ports on Windows is to be developed yet
|
||||
// Needs a lot of improvement to work on all Icoms
|
||||
// gcc -g -Wall -o simicom simicom.c -lhamlib
|
||||
// On mingw in the hamlib src directory
|
||||
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
|
||||
#define _XOPEN_SOURCE 700
|
||||
// since we are POSIX here we need this
|
||||
struct ip_mreq
|
||||
{
|
||||
int dummy;
|
||||
};
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <hamlib/rig.h>
|
||||
#include "../src/misc.h"
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#define BUFSIZE 256
|
||||
#define X25
|
||||
|
||||
int civ_731_mode = 0;
|
||||
vfo_t current_vfo = RIG_VFO_A;
|
||||
int split = 0;
|
||||
|
||||
// we make B different from A to ensure we see a difference at startup
|
||||
float freqA = 14074000;
|
||||
float freqB = 14074500;
|
||||
mode_t modeA = RIG_MODE_PKTUSB;
|
||||
mode_t modeB = RIG_MODE_PKTUSB;
|
||||
int datamodeA = 0;
|
||||
int datamodeB = 0;
|
||||
pbwidth_t widthA = 0;
|
||||
pbwidth_t widthB = 1;
|
||||
ant_t ant_curr = 0;
|
||||
int ant_option = 0;
|
||||
int ptt = 0;
|
||||
int satmode = 0;
|
||||
int agc_time = 1;
|
||||
int ovf_status = 0;
|
||||
int powerstat = 1;
|
||||
|
||||
void dumphex(unsigned char *buf, int n)
|
||||
{
|
||||
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int
|
||||
frameGet(int fd, unsigned char *buf)
|
||||
{
|
||||
int i = 0;
|
||||
memset(buf, 0, BUFSIZE);
|
||||
unsigned char c;
|
||||
|
||||
again:
|
||||
|
||||
while (read(fd, &c, 1) > 0)
|
||||
{
|
||||
buf[i++] = c;
|
||||
//printf("i=%d, c=0x%02x\n",i,c);
|
||||
|
||||
if (c == 0xfd)
|
||||
{
|
||||
dumphex(buf, i);
|
||||
return i;
|
||||
}
|
||||
|
||||
if (i > 2 && c == 0xfe)
|
||||
{
|
||||
printf("Turning power on due to 0xfe string\n");
|
||||
powerstat = 1;
|
||||
int j;
|
||||
|
||||
for (j = i; j < 175; ++j)
|
||||
{
|
||||
if (read(fd, &c, 1) < 0) { break; }
|
||||
}
|
||||
|
||||
i = 0;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Error??? c=x%02x\n", c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void frameParse(int fd, unsigned char *frame, int len)
|
||||
{
|
||||
double freq;
|
||||
int n = 0;
|
||||
|
||||
dumphex(frame, len);
|
||||
|
||||
if (frame[0] != 0xfe && frame[1] != 0xfe)
|
||||
{
|
||||
printf("expected fe fe, got ");
|
||||
dumphex(frame, len);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (frame[4])
|
||||
{
|
||||
case 0x03:
|
||||
|
||||
//from_bcd(frameackbuf[2], (civ_731_mode ? 4 : 5) * 2);
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
|
||||
{
|
||||
printf("get_freqA\n");
|
||||
to_bcd(&frame[5], (long long)freqA, (civ_731_mode ? 4 : 5) * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("get_freqB\n");
|
||||
to_bcd(&frame[5], (long long)freqB, (civ_731_mode ? 4 : 5) * 2);
|
||||
}
|
||||
|
||||
frame[10] = 0xfd;
|
||||
|
||||
if (powerstat)
|
||||
{
|
||||
n = write(fd, frame, 11);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
|
||||
{
|
||||
printf("get_modeA\n");
|
||||
frame[5] = modeA;
|
||||
frame[6] = widthA;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("get_modeB\n");
|
||||
frame[5] = modeB;
|
||||
frame[6] = widthB;
|
||||
}
|
||||
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
break;
|
||||
|
||||
case 0x05:
|
||||
freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("set_freq to %.0f\n", freq);
|
||||
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { freqA = freq; }
|
||||
else { freqB = freq; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x06:
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { modeA = frame[6]; }
|
||||
else { modeB = frame[6]; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x07:
|
||||
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0x00: current_vfo = RIG_VFO_A; break;
|
||||
|
||||
case 0x01: current_vfo = RIG_VFO_B; break;
|
||||
|
||||
case 0xd0: current_vfo = RIG_VFO_MAIN; break;
|
||||
|
||||
case 0xd1: current_vfo = RIG_VFO_SUB; break;
|
||||
}
|
||||
|
||||
printf("set_vfo to %s\n", rig_strvfo(current_vfo));
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x0f:
|
||||
if (frame[5] == 0) { split = 0; }
|
||||
else if (frame[5] == 1) { split = 1; }
|
||||
else { frame[6] = split; }
|
||||
|
||||
if (frame[5] == 0xfd)
|
||||
{
|
||||
printf("get split %d\n", 1);
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("set split %d\n", 1);
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x12: // we're simulating the 3-byte version -- not the 2-byte
|
||||
if (frame[5] != 0xfd)
|
||||
{
|
||||
printf("Set ant %d\n", -1);
|
||||
ant_curr = frame[5];
|
||||
ant_option = frame[6];
|
||||
dump_hex(frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Get ant\n");
|
||||
}
|
||||
|
||||
frame[5] = ant_curr;
|
||||
frame[6] = ant_option;
|
||||
frame[7] = 0xfd;
|
||||
printf("write 8 bytes\n");
|
||||
dump_hex(frame, 8);
|
||||
n = write(fd, frame, 8);
|
||||
break;
|
||||
|
||||
case 0x14:
|
||||
switch (frame[5])
|
||||
{
|
||||
static int power_level = 0;
|
||||
|
||||
case 0x07:
|
||||
case 0x08:
|
||||
if (frame[6] != 0xfd)
|
||||
{
|
||||
frame[6] = 0xfb;
|
||||
dumphex(frame, 7);
|
||||
n = write(fd, frame, 7);
|
||||
printf("ACK x14 x08\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
to_bcd(&frame[6], (long long)128, 2);
|
||||
frame[8] = 0xfb;
|
||||
dumphex(frame, 9);
|
||||
n = write(fd, frame, 9);
|
||||
printf("SEND x14 x08\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x0a:
|
||||
printf("Using power level %d\n", power_level);
|
||||
power_level += 10;
|
||||
|
||||
if (power_level > 250) { power_level = 0; }
|
||||
|
||||
to_bcd(&frame[6], (long long)power_level, 2);
|
||||
frame[8] = 0xfd;
|
||||
n = write(fd, frame, 9);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x15:
|
||||
switch (frame[5])
|
||||
{
|
||||
static int meter_level = 0;
|
||||
|
||||
case 0x07:
|
||||
frame[6] = ovf_status;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
ovf_status = ovf_status == 0 ? 1 : 0;
|
||||
break;
|
||||
|
||||
case 0x11:
|
||||
printf("Using meter level %d\n", meter_level);
|
||||
meter_level += 10;
|
||||
|
||||
if (meter_level > 250) { meter_level = 0; }
|
||||
|
||||
to_bcd(&frame[6], (long long)meter_level, 2);
|
||||
frame[8] = 0xfd;
|
||||
n = write(fd, frame, 9);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x16:
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0x5a:
|
||||
if (frame[6] == 0xfe)
|
||||
{
|
||||
satmode = frame[6];
|
||||
}
|
||||
else
|
||||
{
|
||||
frame[6] = satmode;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x18: // miscellaneous things
|
||||
frame[5] = 1;
|
||||
frame[6] = 0xfd;
|
||||
n = write(fd, frame, 7);
|
||||
break;
|
||||
|
||||
case 0x19: // miscellaneous things
|
||||
frame[5] = 0x94;
|
||||
frame[6] = 0xfd;
|
||||
n = write(fd, frame, 7);
|
||||
break;
|
||||
|
||||
case 0x1a: // miscellaneous things
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0x03: // width
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { frame[6] = widthA; }
|
||||
else { frame[6] = widthB; }
|
||||
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
break;
|
||||
|
||||
case 0x04: // AGC TIME
|
||||
printf("frame[6]==x%02x, frame[7]=0%02x\n", frame[6], frame[7]);
|
||||
|
||||
if (frame[6] == 0xfd) // the we are reading
|
||||
{
|
||||
frame[6] = agc_time;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("AGC_TIME RESPONSE******************************");
|
||||
agc_time = frame[6];
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x07: // satmode
|
||||
frame[4] = 0;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x1c:
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0:
|
||||
if (frame[6] == 0xfd)
|
||||
{
|
||||
frame[6] = ptt;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptt = frame[6];
|
||||
frame[7] = 0xfb;
|
||||
frame[8] = 0xfd;
|
||||
n = write(fd, frame, 9);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
#ifdef X25
|
||||
|
||||
case 0x25:
|
||||
if (frame[6] == 0xfd)
|
||||
{
|
||||
if (frame[5] == 0x00)
|
||||
{
|
||||
to_bcd(&frame[6], (long long)freqA, (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("X25 get_freqA=%.0f\n", freqA);
|
||||
}
|
||||
else
|
||||
{
|
||||
to_bcd(&frame[6], (long long)freqB, (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("X25 get_freqB=%.0f\n", freqB);
|
||||
}
|
||||
|
||||
frame[11] = 0xfd;
|
||||
unsigned char frame2[11];
|
||||
|
||||
frame2[0] = 0xfe;
|
||||
frame2[1] = 0xfe;
|
||||
frame2[2] = 0x00; // send transceive frame
|
||||
frame2[3] = frame[3]; // send transceive frame
|
||||
frame2[4] = 0x00;
|
||||
frame2[5] = 0x70;
|
||||
frame2[6] = 0x28;
|
||||
frame2[7] = 0x57;
|
||||
frame2[8] = 0x03;
|
||||
frame2[9] = 0x00;
|
||||
frame2[10] = 0xfd;
|
||||
n = write(fd, frame2, 11);
|
||||
n = write(fd, frame, 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
freq = from_bcd(&frame[6], (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("set_freq to %.0f\n", freq);
|
||||
|
||||
if (frame[5] == 0x00) { freqA = freq; }
|
||||
else { freqB = freq; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
// send async frame
|
||||
frame[2] = 0x00; // async freq
|
||||
frame[3] = 0xa2;
|
||||
frame[4] = 0x00;
|
||||
frame[5] = 0x00;
|
||||
frame[6] = 0x10;
|
||||
frame[7] = 0x01;
|
||||
frame[8] = 0x96;
|
||||
frame[9] = 0x12;
|
||||
frame[10] = 0xfd;
|
||||
n = write(fd, frame, 11);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x26:
|
||||
for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); }
|
||||
|
||||
if (frame[6] == 0xfd) // then a query
|
||||
{
|
||||
for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); }
|
||||
|
||||
frame[6] = frame[5] == 0 ? modeA : modeB;
|
||||
frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
|
||||
frame[8] = 0xfb;
|
||||
frame[9] = 0xfd;
|
||||
n = write(fd, frame, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 12; ++i) { printf("%02x:", frame[i]); }
|
||||
|
||||
if (frame[6] == 0)
|
||||
{
|
||||
modeA = frame[7];
|
||||
datamodeA = frame[8];
|
||||
}
|
||||
else
|
||||
{
|
||||
modeB = frame[7];
|
||||
datamodeB = frame[8];
|
||||
}
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
break;
|
||||
#else
|
||||
|
||||
case 0x25:
|
||||
printf("x25 send nak\n");
|
||||
frame[4] = 0xfa;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x26:
|
||||
printf("x26 send nak\n");
|
||||
frame[4] = 0xfa;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: printf("cmd 0x%02x unknown\n", frame[4]);
|
||||
}
|
||||
|
||||
if (n == 0) { printf("Write failed=%s\n", strerror(errno)); }
|
||||
|
||||
// don't care about the rig type yet
|
||||
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
void rigStatus()
|
||||
{
|
||||
char vfoa = current_vfo == RIG_VFO_A ? '*' : ' ';
|
||||
char vfob = current_vfo == RIG_VFO_B ? '*' : ' ';
|
||||
printf("%cVFOA: mode=%d datamode=%d width=%ld freq=%.0f\n", vfoa, modeA,
|
||||
datamodeA,
|
||||
widthA,
|
||||
freqA);
|
||||
printf("%cVFOB: mode=%d datamode=%d width=%ld freq=%.0f\n", vfob, modeB,
|
||||
datamodeB,
|
||||
widthB,
|
||||
freqB);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned char buf[256];
|
||||
int fd = openPort(argv[1]);
|
||||
|
||||
printf("%s: %s\n", argv[0], rig_version());
|
||||
#ifdef X25
|
||||
printf("x25/x26 command recognized\n");
|
||||
#else
|
||||
printf("x25/x26 command rejected\n");
|
||||
#endif
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("Missing comport argument\n");
|
||||
printf("%s [comport]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
int len = frameGet(fd, buf);
|
||||
|
||||
if (len <= 0)
|
||||
{
|
||||
close(fd);
|
||||
fd = openPort(argv[1]);
|
||||
}
|
||||
|
||||
if (powerstat)
|
||||
{
|
||||
frameParse(fd, buf, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
hl_usleep(1000 * 1000);
|
||||
}
|
||||
|
||||
rigStatus();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -287,6 +287,9 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
|
|||
{
|
||||
switch (rig->state.current_vfo)
|
||||
{
|
||||
case RIG_VFO_CURR:
|
||||
break; // no change
|
||||
|
||||
case RIG_VFO_OTHER:
|
||||
vfo = RIG_VFO_OTHER;
|
||||
break;
|
||||
|
|
18
src/conf.c
18
src/conf.c
|
@ -69,11 +69,6 @@ static const struct confparams frontend_cfg_params[] =
|
|||
TOK_RETRY, "retry", "Retry", "Max number of retry",
|
||||
"0", RIG_CONF_NUMERIC, { .n = { 0, 10, 1 } }
|
||||
},
|
||||
{
|
||||
TOK_TIMEOUT_RETRY, "timeout_retry", "Number of retries for read timeouts",
|
||||
"Set the number of retries for data read timeouts that may occur especially with some serial interfaces",
|
||||
"1", RIG_CONF_NUMERIC, { .n = { 0, 100, 1 } }
|
||||
},
|
||||
{
|
||||
TOK_RANGE_SELECTED, "Selected range list", "Range list#",
|
||||
"The tx/rx range list in use",
|
||||
|
@ -743,15 +738,6 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
rs->tuner_control_pathname = strdup(val); // yeah -- need to free it
|
||||
break;
|
||||
|
||||
case TOK_TIMEOUT_RETRY:
|
||||
if (1 != sscanf(val, "%ld", &val_i))
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs->rigport.timeout_retry = val_i;
|
||||
break;
|
||||
|
||||
case TOK_OFFSET_VFOA:
|
||||
if (1 != sscanf(val, "%ld", &val_i))
|
||||
{
|
||||
|
@ -1125,10 +1111,6 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
SNPRINTF(val, val_len, "%d", rs->async_data_enabled);
|
||||
break;
|
||||
|
||||
case TOK_TIMEOUT_RETRY:
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.timeout_retry);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
|
15
src/iofunc.c
15
src/iofunc.c
|
@ -731,9 +731,9 @@ static int port_wait_for_data_direct(hamlib_port_t *p)
|
|||
int fd = p->fd;
|
||||
struct timeval tv, tv_timeout;
|
||||
int result;
|
||||
|
||||
tv_timeout.tv_sec = p->timeout / 1000;
|
||||
tv_timeout.tv_usec = (p->timeout % 1000) * 1000;
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s(%d): timeout=%ld,%ld\n", __func__, __LINE__, tv_timeout.tv_sec, tv_timeout.tv_usec);
|
||||
|
||||
tv = tv_timeout; /* select may have updated it */
|
||||
|
||||
|
@ -742,6 +742,7 @@ static int port_wait_for_data_direct(hamlib_port_t *p)
|
|||
efds = rfds;
|
||||
|
||||
result = port_select(p, fd + 1, &rfds, NULL, &efds, &tv, 1);
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s(%d): timeout=%ld,%ld\n", __func__, __LINE__, tv_timeout.tv_sec, tv_timeout.tv_usec);
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
|
@ -1126,6 +1127,7 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
|
|||
if (p->post_write_delay > 0)
|
||||
{
|
||||
method |= 4;
|
||||
#if 0
|
||||
#ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY
|
||||
#define POST_WRITE_DELAY_TRSHLD 10
|
||||
|
||||
|
@ -1137,6 +1139,7 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
|
|||
p->post_write_date.tv_usec = tv.tv_usec;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
hl_usleep(p->post_write_delay * 1000); /* optional delay after last write */
|
||||
|
||||
|
@ -1177,8 +1180,8 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer,
|
|||
if (timeout_retries > 0)
|
||||
{
|
||||
timeout_retries--;
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s: retrying read timeout %d/%d\n", __func__,
|
||||
p->timeout_retry - timeout_retries, p->timeout_retry);
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s(%d): retrying read timeout %d/%d timeout=%dms\n", __func__, __LINE__,
|
||||
p->timeout_retry - timeout_retries, p->timeout_retry, p->timeout);
|
||||
hl_usleep(10 * 1000);
|
||||
continue;
|
||||
}
|
||||
|
@ -1333,12 +1336,10 @@ static int read_string_generic(hamlib_port_t *p,
|
|||
memset(rxbuffer, 0, rxmax);
|
||||
|
||||
short timeout_retries = p->timeout_retry;
|
||||
|
||||
while (total_count < rxmax - 1) // allow 1 byte for end-of-string
|
||||
{
|
||||
ssize_t rd_count = 0;
|
||||
int result;
|
||||
|
||||
result = port_wait_for_data(p, direct);
|
||||
|
||||
if (result == -RIG_ETIMEOUT)
|
||||
|
@ -1346,8 +1347,8 @@ static int read_string_generic(hamlib_port_t *p,
|
|||
if (timeout_retries > 0)
|
||||
{
|
||||
timeout_retries--;
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s: retrying read timeout %d/%d\n", __func__,
|
||||
p->timeout_retry - timeout_retries, p->timeout_retry);
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s(%d): retrying read timeout %d/%d timeout=%d\n", __func__, __LINE__,
|
||||
p->timeout_retry - timeout_retries, p->timeout_retry, p->timeout);
|
||||
hl_usleep(10 * 1000);
|
||||
continue;
|
||||
}
|
||||
|
|
23
src/misc.c
23
src/misc.c
|
@ -972,6 +972,7 @@ static const struct
|
|||
int check_level_param(RIG *rig, setting_t level, value_t val, gran_t **gran)
|
||||
{
|
||||
gran_t *this_gran;
|
||||
float maxval;
|
||||
|
||||
this_gran = &rig->caps->level_gran[rig_setting2idx(level)];
|
||||
|
||||
|
@ -982,13 +983,21 @@ int check_level_param(RIG *rig, setting_t level, value_t val, gran_t **gran)
|
|||
|
||||
if (RIG_LEVEL_IS_FLOAT(level))
|
||||
{
|
||||
/* If min==max==0, all values are OK here but may be checked later */
|
||||
if (this_gran->min.f == 0.0f && this_gran->max.f == 0.0f)
|
||||
|
||||
/* If min==max==step==0, all values are OK here */
|
||||
maxval = this_gran->max.f;
|
||||
if (this_gran->min.f == 0.0f && maxval == 0.0f)
|
||||
{
|
||||
return RIG_OK;
|
||||
/* if step==0 also, we're good */
|
||||
if (this_gran->step.f == 0.0f)
|
||||
{
|
||||
return RIG_OK;
|
||||
}
|
||||
/* non-zero step, check for max of 1.0 */
|
||||
maxval = 1.0f;
|
||||
}
|
||||
|
||||
if (val.f < this_gran->min.f || val.f > this_gran->max.f)
|
||||
if (val.f < this_gran->min.f || val.f > maxval)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
@ -2551,7 +2560,7 @@ long long HAMLIB_API rig_get_caps_int(rig_model_t rig_model,
|
|||
enum rig_caps_int_e rig_caps)
|
||||
{
|
||||
const struct rig_caps *caps = rig_get_caps(rig_model);
|
||||
//rig_debug(RIG_DEBUG_TRACE, "%s: getting rig_caps=%u\n", __func__, rig_caps);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: getting rig_caps for model=%d, rig_caps=%d\n", __func__, rig_model, rig_caps);
|
||||
|
||||
switch (rig_caps)
|
||||
{
|
||||
|
@ -2562,7 +2571,7 @@ long long HAMLIB_API rig_get_caps_int(rig_model_t rig_model,
|
|||
return caps->rig_model;
|
||||
|
||||
case RIG_CAPS_PTT_TYPE:
|
||||
//rig_debug(RIG_DEBUG_TRACE, "%s: return %u\n", __func__, caps->ptt_type);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: return %u\n", __func__, caps->ptt_type);
|
||||
return caps->ptt_type;
|
||||
|
||||
case RIG_CAPS_PORT_TYPE:
|
||||
|
@ -2572,7 +2581,7 @@ long long HAMLIB_API rig_get_caps_int(rig_model_t rig_model,
|
|||
return caps->has_get_level;
|
||||
|
||||
default:
|
||||
//rig_debug(RIG_DEBUG_ERR, "%s: Unknown rig_caps value=%lld\n", __func__, rig_caps);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Unknown rig_caps value=%d\n", __func__, rig_caps);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
}
|
||||
|
|
76
src/rig.c
76
src/rig.c
|
@ -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 == 1) { rig_debug(RIG_DEBUG_ERR, "%s: %s\n", n?"lock":"unlock", __func__); rig_lock(rig,n); }
|
||||
#define LOCK(n) if (rig->state.depth == 1) { rig_debug(RIG_DEBUG_CACHE, "%s: %s\n", n?"lock":"unlock", __func__); rig_lock(rig,n); }
|
||||
|
||||
#ifdef PTHREAD
|
||||
#define MUTEX(var) static pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER
|
||||
|
@ -623,28 +623,13 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
|
|||
rs->rigport.post_write_delay = caps->post_write_delay;
|
||||
|
||||
// since we do two timeouts now we can cut the timeout in half for serial
|
||||
if (caps->port_type == RIG_PORT_SERIAL && caps->timeout_retry >= 0)
|
||||
if (caps->port_type == RIG_PORT_SERIAL)
|
||||
{
|
||||
rs->rigport.timeout = caps->timeout / 2;
|
||||
}
|
||||
|
||||
rs->rigport.retry = caps->retry;
|
||||
|
||||
if (caps->timeout_retry < 0)
|
||||
{
|
||||
// Rigs may disable read timeout retries
|
||||
rs->rigport.timeout_retry = 0;
|
||||
}
|
||||
else if (caps->timeout_retry == 0)
|
||||
{
|
||||
// Default to 1 retry for read timeouts
|
||||
rs->rigport.timeout_retry = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rs->rigport.timeout_retry = caps->timeout_retry;
|
||||
}
|
||||
|
||||
rs->pttport.type.ptt = caps->ptt_type;
|
||||
rs->dcdport.type.dcd = caps->dcd_type;
|
||||
|
||||
|
@ -1289,6 +1274,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "%s: %p rs->comm_state==1?=%d\n", __func__,
|
||||
&rs->comm_state,
|
||||
rs->comm_state);
|
||||
hl_usleep(100 * 1000); // wait a bit after opening to give some serial ports time
|
||||
|
||||
/*
|
||||
* Maybe the backend has something to initialize
|
||||
|
@ -2113,10 +2099,11 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
rig_cache_show(rig, __func__, __LINE__);
|
||||
LOCK(1);
|
||||
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: depth=%d\n", __func__, rig->state.depth);
|
||||
rig_debug(RIG_DEBUG_CACHE, "%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_debug(RIG_DEBUG_CACHE, "%s: %s\n", 1 ? "lock" : "unlock", __func__);
|
||||
// rig_lock(rig, 1);
|
||||
}
|
||||
|
||||
|
@ -2370,7 +2357,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
if (locked_mode)
|
||||
{
|
||||
ELAPSED2;
|
||||
RETURNFUNC (RIG_OK);
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
// do not mess with mode while PTT is on
|
||||
|
@ -2931,6 +2918,8 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
|||
HAMLIB_TRACE;
|
||||
vfo_t vfo_save = rig->state.current_vfo;
|
||||
|
||||
LOCK(1);
|
||||
|
||||
if (vfo != RIG_VFO_CURR) { rig->state.current_vfo = vfo; }
|
||||
|
||||
retcode = caps->set_vfo(rig, vfo);
|
||||
|
@ -2979,6 +2968,7 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
|||
retcode,
|
||||
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -3047,6 +3037,7 @@ int HAMLIB_API rig_get_vfo(RIG *rig, vfo_t *vfo)
|
|||
}
|
||||
|
||||
HAMLIB_TRACE;
|
||||
LOCK(1);
|
||||
retcode = caps->get_vfo(rig, vfo);
|
||||
|
||||
if (retcode == RIG_OK)
|
||||
|
@ -3067,6 +3058,7 @@ int HAMLIB_API rig_get_vfo(RIG *rig, vfo_t *vfo)
|
|||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -3102,6 +3094,8 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
|
||||
caps = rig->caps;
|
||||
|
||||
LOCK(1);
|
||||
|
||||
switch (rig->state.pttport.type.ptt)
|
||||
{
|
||||
case RIG_PTT_RIG:
|
||||
|
@ -3115,6 +3109,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
if (caps->set_ptt == NULL)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(-RIG_ENIMPL);
|
||||
}
|
||||
|
||||
|
@ -3133,6 +3128,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
if (retcode != RIG_OK)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -3169,6 +3165,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
|
||||
if (!caps->set_vfo)
|
||||
{
|
||||
LOCK(0);
|
||||
ELAPSED2;
|
||||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
@ -3206,6 +3203,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
if (retcode != RIG_OK)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -3438,6 +3436,8 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
|
||||
caps = rig->caps;
|
||||
|
||||
LOCK(1);
|
||||
|
||||
switch (rig->state.pttport.type.ptt)
|
||||
{
|
||||
case RIG_PTT_RIG:
|
||||
|
@ -3446,6 +3446,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
{
|
||||
*ptt = rs->transmit ? RIG_PTT_ON : RIG_PTT_OFF;
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
|
@ -3463,12 +3464,14 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
if (!caps->set_vfo)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
|
@ -3494,6 +3497,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
if (retcode != RIG_OK)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -3515,6 +3519,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_PTT_SERIAL_RTS:
|
||||
|
@ -3530,6 +3535,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
rig->state.cache.ptt = *ptt;
|
||||
}
|
||||
|
||||
LOCK(0);
|
||||
ELAPSED2;
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
@ -3551,6 +3557,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
rig->state.cache.ptt = *ptt;
|
||||
elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_SET);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_PTT_SERIAL_DTR:
|
||||
|
@ -3567,6 +3574,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -3587,6 +3595,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
rig->state.cache.ptt = *ptt;
|
||||
elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_SET);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_PTT_PARALLEL:
|
||||
|
@ -3602,6 +3611,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -3614,6 +3624,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_PTT_CM108:
|
||||
|
@ -3629,6 +3640,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -3641,6 +3653,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_PTT_GPIO:
|
||||
|
@ -3657,25 +3670,30 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_SET);
|
||||
retcode = gpio_ptt_get(&rig->state.pttport, ptt);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_PTT_NONE:
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(-RIG_ENAVAIL); /* not available */
|
||||
|
||||
default:
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_SET);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
|
@ -7663,6 +7681,9 @@ static int async_data_handler_stop(RIG *rig)
|
|||
{
|
||||
if (async_data_handler_priv->thread_id != 0)
|
||||
{
|
||||
// all cleanup is done in this function so we can kill thread
|
||||
// Windows was taking 30 seconds to stop without this
|
||||
pthread_cancel(async_data_handler_priv->thread_id);
|
||||
int err = pthread_join(async_data_handler_priv->thread_id, NULL);
|
||||
|
||||
if (err)
|
||||
|
@ -7764,6 +7785,7 @@ void *async_data_handler(void *arg)
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Stopping async data handler thread\n",
|
||||
__func__);
|
||||
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -7797,8 +7819,8 @@ HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
|
|||
int nbytes;
|
||||
int retval;
|
||||
int simulate = rig->caps->rig_model == RIG_MODEL_DUMMY ||
|
||||
rig->caps->rig_model == RIG_MODEL_NONE ||
|
||||
rs->rigport.rig == RIG_PORT_NONE;
|
||||
rig->caps->rig_model == RIG_MODEL_NONE ||
|
||||
rs->rigport.rig == RIG_PORT_NONE;
|
||||
ENTERFUNC;
|
||||
|
||||
ELAPSED1;
|
||||
|
@ -7810,7 +7832,7 @@ HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
|
|||
if (simulate)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: simulating response for model %s\n",
|
||||
__func__, rig->caps->model_name);
|
||||
__func__, rig->caps->model_name);
|
||||
retval = send_len;
|
||||
}
|
||||
else
|
||||
|
@ -7820,7 +7842,8 @@ HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
|
|||
if (retval < 0)
|
||||
{
|
||||
// TODO: error handling? can writing to a pipe really fail in ways we can recover from?
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: write_block_sync() failed, result=%d\n", __func__, retval);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: write_block_sync() failed, result=%d\n", __func__,
|
||||
retval);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7846,9 +7869,10 @@ HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
|
|||
}
|
||||
else // we'll assume the provided terminator works
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: reading frame terminated by 0x%x\n", __func__, *term);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: reading frame terminated by 0x%x\n", __func__,
|
||||
*term);
|
||||
retval = read_string(&rs->rigport, buf, sizeof(buf), (const char *)term,
|
||||
1, 0, 1);
|
||||
1, 0, 1);
|
||||
}
|
||||
|
||||
if (retval < RIG_OK)
|
||||
|
|
88
src/sleep.c
88
src/sleep.c
|
@ -38,22 +38,66 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include "config.h"
|
||||
#include "hamlib/config.h"
|
||||
#include "sleep.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern double monotonic_seconds();
|
||||
|
||||
int hl_usleep(rig_useconds_t usec)
|
||||
{
|
||||
double sleep_time = usec / 1e6;
|
||||
struct timespec tv1, tv2;
|
||||
double start_at = monotonic_seconds();
|
||||
double end_at = start_at + sleep_time;
|
||||
double delay = sleep_time;
|
||||
double lasterr = 0;
|
||||
|
||||
if (sleep_time > .001) { sleep_time -= .001; }
|
||||
else if (sleep_time > .0001) { sleep_time -= .0005; }
|
||||
|
||||
tv1.tv_sec = (time_t) delay;
|
||||
tv1.tv_nsec = (long)((delay - tv1.tv_sec) * 1e+9);
|
||||
tv2.tv_sec = 0;
|
||||
tv2.tv_nsec = 10;
|
||||
rig_debug(RIG_DEBUG_CACHE,"usec=%ld, sleep_time=%f, tv1=%ld,%ld\n", usec, sleep_time, (long)tv1.tv_sec,
|
||||
(long)tv1.tv_nsec);
|
||||
|
||||
#ifdef __WIN32__
|
||||
timeBeginPeriod(1);
|
||||
nanosleep(&tv1, NULL);
|
||||
|
||||
while ((lasterr = end_at - monotonic_seconds()) > 0)
|
||||
{
|
||||
nanosleep(&tv2, NULL);
|
||||
}
|
||||
|
||||
timeEndPeriod(1);
|
||||
#else
|
||||
nanosleep(&tv1, NULL);
|
||||
|
||||
while (((lasterr = end_at - monotonic_seconds()) > 0))
|
||||
{
|
||||
nanosleep(&tv2, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// In order to stop the usleep warnings in cppcheck we provide our own interface
|
||||
// So this will use system usleep or our usleep depending on availability of nanosleep
|
||||
// This version of usleep can handle > 1000000 usec values
|
||||
int hl_usleep(rig_useconds_t usec)
|
||||
{
|
||||
int retval = 0;
|
||||
//rig_debug(RIG_DEBUG_ERR, "%s: usec=%ld\n", __func__, usec);
|
||||
if (usec <= 1000) return 0; // dont' sleep if only 1ms is requested -- speeds things up on Windows
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: usec=%ld\n", __func__, usec);
|
||||
|
||||
if (usec <= 1000) { return 0; } // dont' sleep if only 1ms is requested -- speeds things up on Windows
|
||||
|
||||
while (usec > 1000000)
|
||||
{
|
||||
|
@ -62,15 +106,18 @@ int hl_usleep(rig_useconds_t usec)
|
|||
retval = usleep(1000000);
|
||||
usec -= 1000000;
|
||||
}
|
||||
|
||||
#ifdef HAVE_NANOSLEEP
|
||||
struct timespec t, tleft;
|
||||
t.tv_sec = usec/1e6;
|
||||
t.tv_nsec = (usec - (t.tv_sec*1e6)) * 1e3;
|
||||
t.tv_sec = usec / 1e6;
|
||||
t.tv_nsec = (usec - (t.tv_sec * 1e6)) * 1e3;
|
||||
return nanosleep(&t, &tleft);
|
||||
#else
|
||||
return usleep(usec);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_NANOSLEEP
|
||||
#ifndef HAVE_SLEEP
|
||||
|
@ -123,3 +170,34 @@ int usleep(rig_useconds_t usec)
|
|||
}
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#ifdef TEST
|
||||
#include "misc.h"
|
||||
double get_elapsed_time(struct tm start, struct tm end) {
|
||||
// Convert struct tm to time_t
|
||||
time_t start_seconds = mktime(&start);
|
||||
time_t end_seconds = mktime(&end);
|
||||
|
||||
double elapsed_time = difftime(end_seconds, start_seconds);
|
||||
return elapsed_time;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
struct tm start_time, end_time;
|
||||
time_t rawtime;
|
||||
|
||||
for (int i = 0; i < 11; ++i)
|
||||
{
|
||||
char buf[256];
|
||||
time(&rawtime);
|
||||
hl_usleep(1000000 * 1000); // test 1s sleep
|
||||
date_strget(buf, sizeof(buf), 0);
|
||||
printf("%s\n", buf);
|
||||
time(&rawtime);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue