merged upstream/master into master

pull/519/head
Joshua Lynch 2021-01-27 12:44:07 -06:00
commit b5a18c1732
12 zmienionych plików z 193 dodań i 38 usunięć

1
NEWS
Wyświetl plik

@ -7,6 +7,7 @@ Copyright (C) 2000-2020 Michael Black W9MDB, and others
Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net
Version 4.1 Version 4.1
* rigctld and rigs should be more robust for disconnect problemsy
* Several fixes for Icom and Yaesu rigs * Several fixes for Icom and Yaesu rigs
* Nobody should need to use rig->caps or rig->state anymore * Nobody should need to use rig->caps or rig->state anymore
If you need a variable added please contact us. If you need a variable added please contact us.

Wyświetl plik

@ -541,6 +541,11 @@ static int flrig_transaction(RIG *rig, char *cmd, char *cmd_arg, char *value,
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
rig_debug(RIG_DEBUG_ERR, "%s: write_transaction error=%d\n", __func__, retval); rig_debug(RIG_DEBUG_ERR, "%s: write_transaction error=%d\n", __func__, retval);
// if we get RIG_EIO the socket has probably disappeared
// so bubble up the error so port can re re-opened
if (retval == -RIG_EIO) { return retval; }
hl_usleep(50 * 1000); // 50ms sleep if error hl_usleep(50 * 1000); // 50ms sleep if error
} }

Wyświetl plik

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

Wyświetl plik

@ -181,7 +181,7 @@ const struct rig_caps k3_caps =
RIG_MODEL(RIG_MODEL_K3), RIG_MODEL(RIG_MODEL_K3),
.model_name = "K3", .model_name = "K3",
.mfg_name = "Elecraft", .mfg_name = "Elecraft",
.version = BACKEND_VER ".2", .version = BACKEND_VER ".3",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_STABLE, .status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER, .rig_type = RIG_TYPE_TRANSCEIVER,
@ -1584,7 +1584,7 @@ static int k3_get_maxpower(RIG *rig)
{ {
int retval; int retval;
int maxpower = 12; // K3 default power level int maxpower = 12; // K3 default power level
char levelbuf[16]; char levelbuf[KENWOOD_MAX_BUF_LEN];
struct kenwood_priv_data *priv = rig->state.priv; struct kenwood_priv_data *priv = rig->state.priv;
// default range is 0-12 if there is no KPA3 installed // default range is 0-12 if there is no KPA3 installed
@ -2129,6 +2129,24 @@ int kx3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
val->f = pwr; val->f = pwr;
return retval; return retval;
} }
case RIG_LEVEL_RFPOWER_METER_WATTS:
{
struct kenwood_priv_data *priv = rig->state.priv;
char levelbuf[KENWOOD_MAX_BUF_LEN];
int pwr;
retval = kenwood_safe_transaction(rig, "PO", levelbuf, sizeof(levelbuf), 5);
if (retval != RIG_OK)
{
return retval;
}
sscanf(levelbuf + 2, "%d", &pwr);
val->f = priv->has_kpa100 ? pwr : pwr / 10.0;
return retval;
}
} }
return k3_get_level(rig, vfo, level, val); return k3_get_level(rig, vfo, level, val);

Wyświetl plik

@ -76,7 +76,7 @@ const struct rig_caps ftdx101d_caps =
RIG_MODEL(RIG_MODEL_FTDX101D), RIG_MODEL(RIG_MODEL_FTDX101D),
.model_name = "FTDX-101D", .model_name = "FTDX-101D",
.mfg_name = "Yaesu", .mfg_name = "Yaesu",
.version = NEWCAT_VER ".7", .version = NEWCAT_VER ".8z",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_STABLE, .status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER, .rig_type = RIG_TYPE_TRANSCEIVER,
@ -86,7 +86,7 @@ const struct rig_caps ftdx101d_caps =
.serial_rate_min = 4800, .serial_rate_min = 4800,
.serial_rate_max = 38400, .serial_rate_max = 38400,
.serial_data_bits = 8, .serial_data_bits = 8,
.serial_stop_bits = 1, .serial_stop_bits = 2,
.serial_parity = RIG_PARITY_NONE, .serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_HARDWARE, .serial_handshake = RIG_HANDSHAKE_HARDWARE,
.write_delay = FTDX101_WRITE_DELAY, .write_delay = FTDX101_WRITE_DELAY,

Wyświetl plik

@ -775,6 +775,18 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
target_vfo = 'A' == c ? '0' : '1'; target_vfo = 'A' == c ? '0' : '1';
// some rigs like FTDX101D cannot change non-TX vfo freq
// but they can change the TX vfo
if (is_ftdx101 && rig->state.cache.ptt == RIG_PTT_ON)
{
rig_debug(RIG_DEBUG_TRACE, "%s: ftdx101 check vfo OK, vfo=%s, tx_vfo=%s\n", __func__, rig_strvfo(vfo), rig_strvfo(rig->state.tx_vfo));
// when in split we can change VFOB but not VFOA
if (rig->state.cache.split == RIG_SPLIT_ON && target_vfo == '0') return -RIG_ENTARGET;
// when not in split we can't change VFOA at all
if (rig->state.cache.split == RIG_SPLIT_OFF && target_vfo == '0') return -RIG_ENTARGET;
if (vfo != rig->state.tx_vfo) return -RIG_ENTARGET;
}
if (rig->state.cache.ptt == if (rig->state.cache.ptt ==
RIG_PTT_ON) // we have a few rigs that can't set TX VFO while PTT_ON RIG_PTT_ON) // we have a few rigs that can't set TX VFO while PTT_ON
{ {
@ -6687,6 +6699,7 @@ ncboolean newcat_is_rig(RIG *rig, rig_model_t model)
/* /*
* newcat_set_tx_vfo does not set priv->curr_vfo * newcat_set_tx_vfo does not set priv->curr_vfo
* does set rig->state.tx_vfo
*/ */
int newcat_set_tx_vfo(RIG *rig, vfo_t tx_vfo) int newcat_set_tx_vfo(RIG *rig, vfo_t tx_vfo)
{ {
@ -6762,9 +6775,10 @@ int newcat_set_tx_vfo(RIG *rig, vfo_t tx_vfo)
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c%c", command, p1, cat_term); snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c%c", command, p1, cat_term);
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str); rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s, vfo=%s\n", priv->cmd_str, rig_strvfo(tx_vfo));
rig->state.tx_vfo = tx_vfo;
/* Set TX VFO */
RETURNFUNC(newcat_set_cmd(rig)); RETURNFUNC(newcat_set_cmd(rig));
} }

Wyświetl plik

@ -50,7 +50,7 @@
typedef char ncboolean; typedef char ncboolean;
/* shared function version */ /* shared function version */
#define NEWCAT_VER "20210123" #define NEWCAT_VER "20210124"
/* Hopefully large enough for future use, 128 chars plus '\0' */ /* Hopefully large enough for future use, 128 chars plus '\0' */
#define NEWCAT_DATA_LEN 129 #define NEWCAT_DATA_LEN 129

Wyświetl plik

@ -0,0 +1,12 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := satel.c
LOCAL_MODULE := satel
LOCAL_CFLAGS := -DHAVE_CONFIG_H
LOCAL_C_INCLUDES := android include src
LOCAL_LDLIBS := -lhamlib -Lobj/local/armeabi
include $(BUILD_STATIC_LIBRARY)

Wyświetl plik

@ -58,6 +58,63 @@
#include "serial.h" #include "serial.h"
#include "network.h" #include "network.h"
#ifdef __APPLE__
#include <time.h>
#if !defined(CLOCK_REALTIME) && !defined(CLOCK_MONOTONIC)
//
// MacOS < 10.12 does not have clock_gettime
//
// Contribution from github user "ra1nb0w"
//
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 6
typedef int clockid_t;
#include <sys/time.h>
#include <mach/mach_time.h>
static int clock_gettime(clockid_t clock_id, struct timespec *tp)
{
if (clock_id == CLOCK_REALTIME)
{
struct timeval t;
if (gettimeofday(&t, NULL) != 0)
{
return -1;
}
tp->tv_sec = t.tv_sec;
tp->tv_nsec = t.tv_usec * 1000;
}
else if (clock_id == CLOCK_MONOTONIC)
{
static mach_timebase_info_data_t info = { 0, 0 };
if (info.denom == 0)
{
mach_timebase_info(&info);
}
uint64_t t = mach_absolute_time() * info.numer / info.denom;
tp->tv_sec = t / 1000000000;
tp->tv_nsec = t % 1000000000;
}
else
{
errno = EINVAL;
return -1;
}
return 0;
}
#endif // !HAVE_CLOCK_GETTIME
#endif // __APPLE__
/** /**
* \brief Convert from binary to 4-bit BCD digits, little-endian * \brief Convert from binary to 4-bit BCD digits, little-endian

Wyświetl plik

@ -1653,12 +1653,16 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo)); rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo));
#if 0 // don't think we really need this check
if (CHECK_RIG_ARG(rig) || !freq) if (CHECK_RIG_ARG(rig) || !freq)
{ {
rig_debug(RIG_DEBUG_TRACE, "%s: rig or freq ptr invalid\n", __func__); rig_debug(RIG_DEBUG_TRACE, "%s: rig or freq ptr invalid\n", __func__);
RETURNFUNC(-RIG_EINVAL); RETURNFUNC(-RIG_EINVAL);
} }
#endif
curr_vfo = rig->state.current_vfo; // save vfo for restore later curr_vfo = rig->state.current_vfo; // save vfo for restore later
vfo = vfo_fixup(rig, vfo); vfo = vfo_fixup(rig, vfo);

Wyświetl plik

@ -177,7 +177,7 @@ int main(int argc, char *argv[])
exit(0); exit(0);
case 'V': case 'V':
version(); printf("rigctl %s\nLast commit was %s\n", hamlib_version, HAMLIBDATETIME);
exit(0); exit(0);
case 'm': case 'm':
@ -433,8 +433,7 @@ int main(int argc, char *argv[])
rig_set_debug(verbose); rig_set_debug(verbose);
rig_debug(RIG_DEBUG_VERBOSE, "rigctl %s\nLast commit was %s\n", hamlib_version, rig_debug(RIG_DEBUG_VERBOSE, "rigctl %s\nLast commit was %s\n", hamlib_version,HAMLIBDATETIME);
HAMLIBDATETIME);
rig_debug(RIG_DEBUG_VERBOSE, "%s", rig_debug(RIG_DEBUG_VERBOSE, "%s",
"Report bugs to <hamlib-developer@lists.sourceforge.net>\n\n"); "Report bugs to <hamlib-developer@lists.sourceforge.net>\n\n");
@ -615,6 +614,23 @@ int main(int argc, char *argv[])
{ {
exitcode = 2; exitcode = 2;
} }
rig_debug(RIG_DEBUG_ERR, "%s: XXXXXXXXX#1 retcode=%d\n", __func__, retcode);
if (retcode == -RIG_EIO || retcode == 2)
{
rig_debug(RIG_DEBUG_ERR, "%s: i/o error\n", __func__)
do
{
retcode = rig_close(my_rig);
hl_usleep(1000 * 1000);
rig_debug(RIG_DEBUG_ERR, "%s: rig_close retcode=%d\n", __func__, retcode);
retcode = rig_open(my_rig);
rig_debug(RIG_DEBUG_ERR, "%s: rig_open retcode=%d\n", __func__, retcode);
}
while (retcode != RIG_OK);
}
} }
while (retcode == 0 || retcode == 2 || retcode == -RIG_ENAVAIL); while (retcode == 0 || retcode == 2 || retcode == -RIG_ENAVAIL);

Wyświetl plik

@ -287,7 +287,7 @@ int main(int argc, char *argv[])
exit(0); exit(0);
case 'V': case 'V':
version(); printf("rigctl %s\nLast commit was %s\n", hamlib_version, HAMLIBDATETIME);
exit(0); exit(0);
case 'm': case 'm':
@ -969,6 +969,32 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
static FILE*get_fsockout(struct handle_data *handle_data_arg)
{
#ifdef __MINGW32__
int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY);
return _fdopen(sock_osfhandle, "wb");
#else
return fdopen(handle_data_arg->sock, "wb");
#endif
}
static FILE* get_fsockin(struct handle_data *handle_data_arg)
{
#ifdef __MINGW32__
int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY);
if (sock_osfhandle == -1)
{
rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno));
return NULL;
}
return _fdopen(sock_osfhandle, "rb");
#else
return fdopen(handle_data_arg->sock, "rb");
#endif
}
/* /*
* This is the function run by the threads * This is the function run by the threads
@ -985,19 +1011,7 @@ void *handle_socket(void *arg)
int ext_resp = 0; int ext_resp = 0;
char resp_sep = '\n'; char resp_sep = '\n';
#ifdef __MINGW32__ fsockin = get_fsockin(handle_data_arg);
int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY);
if (sock_osfhandle == -1)
{
rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno));
goto handle_exit;
}
fsockin = _fdopen(sock_osfhandle, "rb");
#else
fsockin = fdopen(handle_data_arg->sock, "rb");
#endif
if (!fsockin) if (!fsockin)
{ {
@ -1006,11 +1020,7 @@ void *handle_socket(void *arg)
goto handle_exit; goto handle_exit;
} }
#ifdef __MINGW32__ fsockout = get_fsockout(handle_data_arg);
fsockout = _fdopen(sock_osfhandle, "wb");
#else
fsockout = fdopen(handle_data_arg->sock, "wb");
#endif
if (!fsockout) if (!fsockout)
{ {
@ -1055,7 +1065,7 @@ void *handle_socket(void *arg)
do do
{ {
rig_debug(RIG_DEBUG_TRACE, "%s: vfo_mode=%d\n", __func__, rig_debug(RIG_DEBUG_TRACE, "%s: doing rigctl_parse vfo_mode=%d\n", __func__,
handle_data_arg->vfo_mode); handle_data_arg->vfo_mode);
retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0, retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0,
sync_callback, sync_callback,
@ -1063,24 +1073,42 @@ void *handle_socket(void *arg)
if (retcode != 0) { rig_debug(RIG_DEBUG_ERR, "%s: rigctl_parse retcode=%d\n", __func__, retcode); } if (retcode != 0) { rig_debug(RIG_DEBUG_ERR, "%s: rigctl_parse retcode=%d\n", __func__, retcode); }
#if 0 // disabled -- don't think we need this
// see https://github.com/Hamlib/Hamlib/issues/516
if (retcode == -1) if (retcode == -1)
{ {
//sleep(1); // probably don't need this delay //sleep(1); // probably don't need this delay
continue; //continue;
} }
if (ferror(fsockin) || ferror(fsockout)) #endif
// if socket error or rigctld gets RIG_EIO we'll try to reopen
if (ferror(fsockin))
{ {
rig_debug(RIG_DEBUG_ERR, "%s: sockin err=%s\n", __func__, strerror(errno));
RETURNFUNC(NULL);
}
if (ferror(fsockin) || ferror(fsockout) || retcode == 2)
{
if (ferror(fsockout)) fsockout = get_fsockout(handle_data_arg);
rig_debug(RIG_DEBUG_ERR, "%s: socket error in=%d, out=%d\n", __func__, rig_debug(RIG_DEBUG_ERR, "%s: socket error in=%d, out=%d\n", __func__,
ferror(fsockin), ferror(fsockout)); ferror(fsockin), ferror(fsockout));
do
{
retcode = rig_close(my_rig); retcode = rig_close(my_rig);
hl_usleep(1000 * 1000);
rig_debug(RIG_DEBUG_ERR, "%s: rig_close retcode=%d\n", __func__, retcode); rig_debug(RIG_DEBUG_ERR, "%s: rig_close retcode=%d\n", __func__, retcode);
retcode = rig_open(my_rig); retcode = rig_open(my_rig);
rig_debug(RIG_DEBUG_ERR, "%s: rig_open retcode=%d\n", __func__, retcode); rig_debug(RIG_DEBUG_ERR, "%s: rig_open retcode=%d\n", __func__, retcode);
} }
while (retcode != RIG_OK);
}
} }
while (retcode == 0 || retcode == 2 || retcode == -RIG_ENAVAIL); while (retcode == 0 || retcode == 2 || retcode == -RIG_ENAVAIL);
#ifdef HAVE_PTHREAD #ifdef HAVE_PTHREAD