mirror of
https://github.com/Hamlib/Hamlib.git
synced 2024-09-21 10:27:18 +00:00
Merge master
This commit is contained in:
commit
eea12aff0a
@ -19,23 +19,6 @@
|
||||
|
||||
#ifndef MULTICAST_H
|
||||
#define MULTICAST_H
|
||||
#if 0 // moved to rig.h
|
||||
struct multicast_s
|
||||
{
|
||||
int multicast_running;
|
||||
int sock;
|
||||
int seqnumber;
|
||||
int runflag; // = 0;
|
||||
pthread_t threadid;
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#warn HAVE_ARPA_INET
|
||||
struct ip_mreq mreq; // = {0};
|
||||
struct sockaddr_in dest_addr; // = {0};
|
||||
#else
|
||||
#warn DO NOT HAVE ARPA_INET_H
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
struct multicast_vfo
|
||||
{
|
||||
|
@ -2489,6 +2489,11 @@ struct multicast_s
|
||||
int seqnumber;
|
||||
int runflag; // = 0;
|
||||
pthread_t threadid;
|
||||
// this mutex is needed to control serial access
|
||||
// as of 2023-05-13 we have main thread and multicast thread needing it
|
||||
// eventually we should be able to use cached info only in the main thread to avoid contention
|
||||
pthread_mutex_t mutex;
|
||||
int mutex_initialized;
|
||||
//#ifdef HAVE_ARPA_INET_H
|
||||
struct ip_mreq mreq; // = {0};
|
||||
struct sockaddr_in dest_addr; // = {0};
|
||||
@ -2720,6 +2725,9 @@ rig_flush_force(hamlib_port_t *port, int flush_async_data);
|
||||
extern HAMLIB_EXPORT(int)
|
||||
rig_flush(hamlib_port_t *port);
|
||||
|
||||
extern HAMLIB_EXPORT(void)
|
||||
rig_lock(RIG *rig, int lock);
|
||||
|
||||
#if BUILTINFUNC
|
||||
#define rig_set_freq(r,v, f) rig_set_vfo(r,v,f,__builtin_FUNCTION())
|
||||
#else
|
||||
|
@ -706,6 +706,7 @@ int icom_init(RIG *rig)
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7000
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7100
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7200
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7700
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC821H
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC910
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC2730
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#define BACKEND_VER "20230508"
|
||||
#define BACKEND_VER "20230512"
|
||||
|
||||
#define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31)
|
||||
#define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51)
|
||||
|
@ -384,7 +384,7 @@ const struct rig_caps ft847_caps =
|
||||
RIG_MODEL(RIG_MODEL_FT847),
|
||||
.model_name = "FT-847",
|
||||
.mfg_name = "Yaesu",
|
||||
.version = "20220525.0",
|
||||
.version = "20230512.0",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
@ -542,7 +542,7 @@ const struct rig_caps ft650_caps =
|
||||
RIG_MODEL(RIG_MODEL_FT650),
|
||||
.model_name = "FT-650",
|
||||
.mfg_name = "Yaesu",
|
||||
.version = "20220525.0",
|
||||
.version = "20230512.0",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
@ -680,7 +680,7 @@ const struct rig_caps mchfqrp_caps =
|
||||
RIG_MODEL(RIG_MODEL_MCHFQRP),
|
||||
.model_name = "mcHF QRP",
|
||||
.mfg_name = "M0NKA",
|
||||
.version = "20220525.0",
|
||||
.version = "20230512.0",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
@ -853,7 +853,7 @@ const struct rig_caps ft847uni_caps =
|
||||
RIG_MODEL(RIG_MODEL_FT847UNI),
|
||||
.model_name = "FT-847UNI",
|
||||
.mfg_name = "Yaesu",
|
||||
.version = "20210221.0",
|
||||
.version = "20230511.0",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
@ -1137,7 +1137,7 @@ static int opcode_vfo(RIG *rig, unsigned char *cmd, int cmd_index, vfo_t vfo)
|
||||
/* If the sat_mode is not enabled,
|
||||
* then leave the OpCode untouched (MAIN VFO) */
|
||||
|
||||
if (p->sat_mode == RIG_SPLIT_ON)
|
||||
if (p->sat_mode == RIG_SPLIT_ON || vfo == RIG_VFO_SUB)
|
||||
{
|
||||
switch (vfo)
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ const struct rig_caps ftdx10_caps =
|
||||
RIG_MODEL(RIG_MODEL_FTDX10),
|
||||
.model_name = "FTDX-10",
|
||||
.mfg_name = "Yaesu",
|
||||
.version = NEWCAT_VER ".6",
|
||||
.version = NEWCAT_VER ".7",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
|
@ -59,6 +59,7 @@ typedef enum nc_rigid_e
|
||||
NC_RIGID_FT2000 = 251,
|
||||
NC_RIGID_FT2000D = 252,
|
||||
NC_RIGID_FTDX1200 = 583,
|
||||
NC_RIGID_FTDX10 = 761,
|
||||
NC_RIGID_FTDX9000D = 101,
|
||||
NC_RIGID_FTDX9000Contest = 102,
|
||||
NC_RIGID_FTDX9000MP = 103,
|
||||
@ -598,6 +599,7 @@ int newcat_open(RIG *rig)
|
||||
|| priv->rig_id == NC_RIGID_FT991
|
||||
|| priv->rig_id == NC_RIGID_FT991A
|
||||
|| priv->rig_id == NC_RIGID_FT950
|
||||
|| priv->rig_id == NC_RIGID_FTDX10
|
||||
|| priv->rig_id == NC_RIGID_FTDX3000
|
||||
|| priv->rig_id == NC_RIGID_FTDX3000DM)
|
||||
{
|
||||
@ -616,6 +618,8 @@ int newcat_open(RIG *rig)
|
||||
|| rig->caps->rig_model == RIG_MODEL_FTDX3000) { cmd = "EX0391;"; set_only = 1; }
|
||||
else if (priv->rig_id == NC_RIGID_FTDX5000
|
||||
|| rig->caps->rig_model == RIG_MODEL_FTDX5000) { cmd = "EX0331;EX033"; }
|
||||
else if (priv->rig_id == NC_RIGID_FTDX10
|
||||
|| rig->caps->rig_model == RIG_MODEL_FTDX10) { cmd = "EX03010901;EX030109;"; }
|
||||
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "%s", cmd);
|
||||
|
||||
@ -689,7 +693,7 @@ int newcat_close(RIG *rig)
|
||||
|
||||
ENTERFUNC;
|
||||
|
||||
if (!no_restore_ai && priv->trn_state >= 0)
|
||||
if (!no_restore_ai && priv->trn_state >= 0 && rig_s->comm_state)
|
||||
{
|
||||
/* restore AI state */
|
||||
newcat_set_trn(rig, priv->trn_state); /* ignore status in
|
||||
@ -697,7 +701,7 @@ int newcat_close(RIG *rig)
|
||||
supported */
|
||||
}
|
||||
|
||||
if (priv->poweron != 0 && rig_s->auto_power_off)
|
||||
if (priv->poweron != 0 && rig_s->auto_power_off && rig_s->comm_state)
|
||||
{
|
||||
rig_set_powerstat(rig, 0);
|
||||
priv->poweron = 0;
|
||||
@ -3617,7 +3621,7 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
|
||||
int newcat_get_powerstat(RIG *rig, powerstat_t *status)
|
||||
{
|
||||
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
|
||||
struct rig_state *state = &rig->state;
|
||||
//struct rig_state *state = &rig->state;
|
||||
int err;
|
||||
char ps;
|
||||
char command[] = "PS";
|
||||
@ -3633,11 +3637,18 @@ int newcat_get_powerstat(RIG *rig, powerstat_t *status)
|
||||
|
||||
// when not powered on need a dummy byte to wake it up
|
||||
// then sleep from 1 to 2 seconds so we'll do 1.5 secs
|
||||
write_block(&state->rigport, (unsigned char *) "PS;", 3);
|
||||
hl_usleep(1200000);
|
||||
// write_block(&state->rigport, (unsigned char *) "PS;", 3);
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term);
|
||||
newcat_get_cmd(rig); // don't care about the return
|
||||
if (priv->ret_data[2] == '1')
|
||||
{
|
||||
*status = 1;
|
||||
RETURNFUNC(RIG_OK);
|
||||
|
||||
}
|
||||
hl_usleep(1200000); // then we must be waking up
|
||||
rig_flush(&rig->state.rigport); /* discard any unsolicited data */
|
||||
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term);
|
||||
|
||||
/* Get Power status */
|
||||
if (RIG_OK != (err = newcat_get_cmd(rig)))
|
||||
@ -11168,7 +11179,7 @@ rmode_t newcat_rmode_width(RIG *rig, vfo_t vfo, char mode, pbwidth_t *width)
|
||||
ncboolean narrow;
|
||||
int i;
|
||||
|
||||
ENTERFUNC;
|
||||
ENTERFUNC2;
|
||||
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
|
||||
@ -11197,7 +11208,7 @@ rmode_t newcat_rmode_width(RIG *rig, vfo_t vfo, char mode, pbwidth_t *width)
|
||||
{
|
||||
if (newcat_get_narrow(rig, vfo, &narrow) != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(newcat_mode_conv[i].mode);
|
||||
RETURNFUNC2(newcat_mode_conv[i].mode);
|
||||
}
|
||||
|
||||
if (narrow == TRUE)
|
||||
@ -11212,14 +11223,14 @@ rmode_t newcat_rmode_width(RIG *rig, vfo_t vfo, char mode, pbwidth_t *width)
|
||||
}
|
||||
|
||||
// don't use RETURNFUNC here as that macros expects an int for the return code
|
||||
return (newcat_mode_conv[i].mode);
|
||||
RETURNFUNC2 (newcat_mode_conv[i].mode);
|
||||
}
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s fell out the bottom %c %s\n", __func__,
|
||||
mode, rig_strrmode(mode));
|
||||
|
||||
RETURNFUNC('0');
|
||||
RETURNFUNC2('0');
|
||||
}
|
||||
|
||||
int newcat_send_voice_mem(RIG *rig, vfo_t vfo, int ch)
|
||||
|
@ -50,7 +50,7 @@
|
||||
typedef char ncboolean;
|
||||
|
||||
/* shared function version */
|
||||
#define NEWCAT_VER "20230509"
|
||||
#define NEWCAT_VER "20230513"
|
||||
|
||||
/* Hopefully large enough for future use, 128 chars plus '\0' */
|
||||
#define NEWCAT_DATA_LEN 129
|
||||
|
@ -257,7 +257,7 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
|
||||
if (CHECK_RIG_ARG(rig) || !freq || !cache_ms_freq ||
|
||||
!mode || !cache_ms_mode || !width || !cache_ms_width)
|
||||
{
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
if (rig_need_debug(RIG_DEBUG_CACHE))
|
||||
@ -448,7 +448,7 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): unknown vfo?, vfo=%s\n", __func__, __LINE__,
|
||||
rig_strvfo(vfo));
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
RETURNFUNC2(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s(%d): vfo=%s, freq=%.0f, mode=%s, width=%d\n",
|
||||
@ -457,7 +457,7 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
|
||||
|
||||
if (rig_need_debug(RIG_DEBUG_CACHE))
|
||||
{
|
||||
RETURNFUNC(RIG_OK);
|
||||
RETURNFUNC2(RIG_OK);
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -167,6 +167,7 @@ void errmsg(int err, char *s, const char *func, const char *file, int line);
|
||||
#define RETURNFUNC(rc) {do { \
|
||||
int rctmp = rc; \
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%.*s%d:%s(%d):%s returning(%ld) %s\n", rig->state.depth, spaces(), rig->state.depth, __FILENAME__, __LINE__, __func__, (long int) (rctmp), rctmp<0?rigerror2(rctmp):""); \
|
||||
if (rig->state.depth == 0) rig_debug(RIG_DEBUG_ERR, "%s(%d) depth=0 ******************\n", __func__, __LINE__); \
|
||||
--rig->state.depth; \
|
||||
return (rctmp); \
|
||||
} while(0);}
|
||||
|
100
src/rig.c
100
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 \
|
||||
#define LOCK(n) if (rig->state.depth == 0) { rig_debug(RIG_DEBUG_ERR, "%s: lock!! *******************************************\n", __func__); rig_lock(rig,n); }
|
||||
|
||||
#ifdef PTHREAD
|
||||
#define MUTEX(var) static pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER
|
||||
@ -621,7 +621,13 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
|
||||
|
||||
rs->rigport.write_delay = caps->write_delay;
|
||||
rs->rigport.post_write_delay = caps->post_write_delay;
|
||||
rs->rigport.timeout = caps->timeout;
|
||||
|
||||
// since we do two timeouts now we can cut the timeout in half for serial
|
||||
if (caps->port_type == RIG_PORT_SERIAL)
|
||||
{
|
||||
rs->rigport.timeout = caps->timeout / 2;
|
||||
}
|
||||
|
||||
rs->rigport.retry = caps->retry;
|
||||
rs->pttport.type.ptt = caps->ptt_type;
|
||||
rs->dcdport.type.dcd = caps->dcd_type;
|
||||
@ -825,11 +831,11 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
//unsigned int net1, net2, net3, net4, net5, net6, net7, net8, port;
|
||||
int is_network = 0;
|
||||
|
||||
ENTERFUNC;
|
||||
ENTERFUNC2;
|
||||
|
||||
if (!rig || !rig->caps)
|
||||
{
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
RETURNFUNC2(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
caps = rig->caps;
|
||||
@ -841,7 +847,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: 'USB' is not a valid COM port name\n", __func__);
|
||||
errno = 2;
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
RETURNFUNC2(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
// rigctl/rigctld may have deprecated values -- backwards compatibility
|
||||
@ -981,7 +987,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
rs->comm_state);
|
||||
port_close(&rs->rigport, rs->rigport.type.rig);
|
||||
rs->comm_state = 0;
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
RETURNFUNC2(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
rs->rigport.fd = -1;
|
||||
@ -995,7 +1001,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
"%s: cannot set RTS with hardware handshake \"%s\"\n",
|
||||
__func__,
|
||||
rs->rigport.pathname);
|
||||
RETURNFUNC(-RIG_ECONF);
|
||||
RETURNFUNC2(-RIG_ECONF);
|
||||
}
|
||||
|
||||
if ('\0' == rs->pttport.pathname[0]
|
||||
@ -1009,7 +1015,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
"%s: cannot set RTS with PTT by RTS \"%s\"\n",
|
||||
__func__,
|
||||
rs->rigport.pathname);
|
||||
RETURNFUNC(-RIG_ECONF);
|
||||
RETURNFUNC2(-RIG_ECONF);
|
||||
}
|
||||
|
||||
if (rs->rigport.parm.serial.dtr_state != RIG_SIGNAL_UNSET
|
||||
@ -1019,11 +1025,12 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
"%s: cannot set DTR with PTT by DTR \"%s\"\n",
|
||||
__func__,
|
||||
rs->rigport.pathname);
|
||||
RETURNFUNC(-RIG_ECONF);
|
||||
RETURNFUNC2(-RIG_ECONF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rs->rigport.timeout = caps->timeout;
|
||||
status = port_open(&rs->rigport);
|
||||
|
||||
if (status < 0)
|
||||
@ -1031,7 +1038,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: rs->comm_state==0?=%d\n", __func__,
|
||||
rs->comm_state);
|
||||
rs->comm_state = 0;
|
||||
RETURNFUNC(status);
|
||||
RETURNFUNC2(status);
|
||||
}
|
||||
|
||||
switch (rs->pttport.type.ptt)
|
||||
@ -1249,7 +1256,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
if (status < 0)
|
||||
{
|
||||
port_close(&rs->rigport, rs->rigport.type.rig);
|
||||
RETURNFUNC(status);
|
||||
RETURNFUNC2(status);
|
||||
}
|
||||
|
||||
status = async_data_handler_start(rig);
|
||||
@ -1257,7 +1264,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
if (status < 0)
|
||||
{
|
||||
port_close(&rs->rigport, rs->rigport.type.rig);
|
||||
RETURNFUNC(status);
|
||||
RETURNFUNC2(status);
|
||||
}
|
||||
|
||||
add_opened_rig(rig);
|
||||
@ -1272,7 +1279,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
* In case of failure, just close down and report error code.
|
||||
*/
|
||||
int retry_save = rs->rigport.retry;
|
||||
rs->rigport.retry = 1;
|
||||
rs->rigport.retry = 0;
|
||||
|
||||
if (caps->rig_open != NULL)
|
||||
{
|
||||
@ -1288,7 +1295,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
"%s: rig power is off, use --set-conf=auto_power_on=1 if power on is wanted\n",
|
||||
__func__);
|
||||
|
||||
return (-RIG_EPOWER);
|
||||
RETURNFUNC2(-RIG_EPOWER);
|
||||
}
|
||||
|
||||
// don't need auto_power_on if power is already on
|
||||
@ -1303,7 +1310,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
__func__);
|
||||
// A TS-480 user was showing ;;;;PS; not working so we'll just show the error message for now
|
||||
// https://github.com/Hamlib/Hamlib/issues/1226
|
||||
//return (-RIG_EPOWER);
|
||||
//RETURNFUNC2 (-RIG_EPOWER);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1316,7 +1323,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
port_close(&rs->rigport, rs->rigport.type.rig);
|
||||
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
|
||||
rs->comm_state = 0;
|
||||
RETURNFUNC(status);
|
||||
RETURNFUNC2(status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1418,7 +1425,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->pttport_deprecated, &rs->pttport, sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->dcdport_deprecated, &rs->dcdport, sizeof(hamlib_port_t_deprecated));
|
||||
RETURNFUNC(RIG_OK);
|
||||
RETURNFUNC2(RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
@ -1777,6 +1784,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
vfo_t vfo_save;
|
||||
|
||||
ELAPSED1;
|
||||
LOCK(1);
|
||||
#if BUILTINFUNC
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f, called from %s\n",
|
||||
__func__,
|
||||
@ -1792,6 +1800,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
if (CHECK_RIG_ARG(rig))
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
@ -1835,6 +1844,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
if (caps->set_freq == NULL)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
@ -1856,6 +1866,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(
|
||||
RIG_OK); // would be better as error but other software won't handle errors
|
||||
}
|
||||
@ -1872,9 +1883,9 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
|
||||
// some rig will return -RIG_ENTARGET if cannot set ptt while transmitting
|
||||
// we will just return RIG_OK and the frequency set will be ignored
|
||||
if (retcode == -RIG_ENTARGET) { RETURNFUNC(RIG_OK); }
|
||||
if (retcode == -RIG_ENTARGET) { LOCK(0); RETURNFUNC(RIG_OK); }
|
||||
|
||||
if (retcode != RIG_OK) { RETURNFUNC(retcode); }
|
||||
if (retcode != RIG_OK) { LOCK(0); RETURNFUNC(retcode); }
|
||||
|
||||
// Unidirectional rigs do not reset cache
|
||||
if (rig->caps->rig_model != RIG_MODEL_FT736R)
|
||||
@ -1891,7 +1902,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
// WSJT-X does a 55Hz check so we can stop early if that's the case
|
||||
if ((long long)freq % 100 == 55) { retry = 0; }
|
||||
|
||||
if (retcode != RIG_OK) { RETURNFUNC(retcode); }
|
||||
if (retcode != RIG_OK) { LOCK(0); RETURNFUNC(retcode); }
|
||||
|
||||
if (tfreq != freq)
|
||||
{
|
||||
@ -1924,6 +1935,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
if (!caps->set_vfo)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
@ -1948,6 +1960,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(
|
||||
RIG_OK); // would be better as error but other software won't handle errors
|
||||
}
|
||||
@ -1983,6 +1996,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
}
|
||||
@ -2008,6 +2022,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(retcode);
|
||||
}
|
||||
|
||||
@ -2036,8 +2051,11 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
rmode_t mode;
|
||||
pbwidth_t width;
|
||||
|
||||
LOCK(1);
|
||||
|
||||
if (CHECK_RIG_ARG(rig))
|
||||
{
|
||||
LOCK(0);
|
||||
RETURNFUNC2(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
@ -2046,6 +2064,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
if (!freq)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: freq ptr invalid\n", __func__);
|
||||
LOCK(0);
|
||||
RETURNFUNC2(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
@ -2078,6 +2097,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode, &width,
|
||||
&cache_ms_width);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
@ -2098,6 +2118,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(retcode);
|
||||
}
|
||||
|
||||
@ -2108,6 +2129,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
__func__);
|
||||
*freq = rig->state.cache.freqMainA;
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
return (RIG_OK);
|
||||
}
|
||||
}
|
||||
@ -2127,6 +2149,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
"%s: %s cache hit age=%dms, freq=%.0f, use_cached_freq=%d\n", __func__,
|
||||
rig_strvfo(vfo), cache_ms_freq, *freq, rig->state.use_cached_freq);
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
return (RIG_OK);
|
||||
}
|
||||
else
|
||||
@ -2143,6 +2166,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
if (caps->get_freq == NULL)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
@ -2187,6 +2211,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
if (!caps->set_vfo)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
@ -2196,6 +2221,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
RETURNFUNC2(retcode);
|
||||
}
|
||||
|
||||
@ -2251,6 +2277,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
}
|
||||
|
||||
ELAPSED2;
|
||||
LOCK(0);
|
||||
return (retcode);
|
||||
}
|
||||
|
||||
@ -2519,7 +2546,7 @@ int HAMLIB_API rig_get_mode(RIG *rig,
|
||||
{
|
||||
*mode = rig->state.cache.modeMainA;
|
||||
*width = rig->state.cache.widthMainA;
|
||||
return RIG_OK;
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
if ((*mode != RIG_MODE_NONE && cache_ms_mode < rig->state.cache.timeout_ms)
|
||||
@ -7493,10 +7520,12 @@ int HAMLIB_API rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static pthread_mutex_t initializer = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
HAMLIB_EXPORT(void) sync_callback(int lock)
|
||||
{
|
||||
#ifdef HAVE_PTHREAD
|
||||
static pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_t client_lock = initializer;
|
||||
|
||||
if (lock)
|
||||
{
|
||||
@ -7512,6 +7541,33 @@ HAMLIB_EXPORT(void) sync_callback(int lock)
|
||||
#endif
|
||||
}
|
||||
|
||||
void rig_lock(RIG *rig, int lock)
|
||||
{
|
||||
#ifdef HAVE_PTHREAD
|
||||
|
||||
if (rig->state.multicast == NULL) return; // not initialized yet
|
||||
|
||||
if (!rig->state.multicast->mutex_initialized)
|
||||
{
|
||||
rig->state.multicast->mutex = initializer;
|
||||
rig->state.multicast->mutex_initialized = 1;
|
||||
}
|
||||
|
||||
if (lock)
|
||||
{
|
||||
pthread_mutex_lock(&rig->state.multicast->mutex);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: client lock engaged\n", __func__);
|
||||
}
|
||||
else
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: client lock disengaged\n", __func__);
|
||||
pthread_mutex_unlock(&rig->state.multicast->mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*! @} */
|
||||
|
||||
|
@ -255,8 +255,8 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
|
||||
return (err);
|
||||
}
|
||||
|
||||
serial_flush(rp); // ensure nothing is there when we open
|
||||
hl_usleep(50 * 1000); // give a little time for MicroKeyer to finish
|
||||
serial_flush(rp); // ensure nothing is there when we open
|
||||
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user