Merge upstream changes and fix conflicts

pull/892/head
Mikael Nousiainen 2021-12-18 23:53:42 +02:00
commit cd9a24b72e
27 zmienionych plików z 742 dodań i 85 usunięć

3
NEWS
Wyświetl plik

@ -6,8 +6,9 @@ Copyright (C) 2000-2021 Michael Black W9MDB, and others
Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net
Version 4.5
Version 4.x
* 202?-??-??
* Added JRC JST-145 and JST-245
Version 4.4
* 2021-12-02

Wyświetl plik

@ -80,7 +80,7 @@ CHECK="\
if test $# -eq 0 ; then
echo "See cppcheck.log when done"
echo "This takes a while to run"
strace -f cppcheck --inline-suppr \
cppcheck --inline-suppr \
-I src \
-I include \
--include=include/config.h \

Wyświetl plik

@ -3191,6 +3191,7 @@ extern HAMLIB_EXPORT(const char *) rig_strparm(setting_t);
extern HAMLIB_EXPORT(const char *) rig_stragclevel(enum agc_level_e level);
extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcstr (char *agcString);
extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcvalue (int agcValue);
extern HAMLIB_EXPORT(value_t) rig_valueagclevel (enum agc_level_e agcLevel);
extern HAMLIB_EXPORT(const char *) rig_strptrshift(rptr_shift_t);
extern HAMLIB_EXPORT(const char *) rig_strvfop(vfo_op_t op);
extern HAMLIB_EXPORT(const char *) rig_strscan(scan_t scan);

Wyświetl plik

@ -2244,12 +2244,12 @@ struct rig_caps dummy_caps =
RIG_MODEL(RIG_MODEL_DUMMY),
.model_name = "Dummy",
.mfg_name = "Hamlib",
.version = "20211130.0",
.version = "20211213.0",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_OTHER,
.targetable_vfo = RIG_TARGETABLE_PTT | RIG_TARGETABLE_RITXIT | RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE | RIG_TARGETABLE_SPECTRUM,
.ptt_type = RIG_PTT_RIG,
.ptt_type = RIG_PTT_NONE,
.dcd_type = RIG_DCD_RIG,
.port_type = RIG_PORT_NONE,
.has_get_func = DUMMY_FUNC,

Wyświetl plik

@ -733,20 +733,14 @@ int icom_get_usb_echo_off(RIG *rig)
unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf);
struct rig_state *rs = &rig->state;
int retry_save = rs->rigport.retry;
struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// reduce the retry here so it's quicker
rs->rigport.retry = 0;
// Check for echo on first by assuming echo is off and checking the answer
priv->serial_USB_echo_off = 1;
rig_debug(RIG_DEBUG_VERBOSE, "%s: retry temp set to %d\n", __func__,
rs->rigport.retry);
retval = icom_transaction(rig, C_RD_FREQ, -1, NULL, 0, ackbuf, &ack_len);
// if rig is not powered on we get no data and TIMEOUT
@ -758,17 +752,17 @@ int icom_get_usb_echo_off(RIG *rig)
{
unsigned char buf[16];
priv->serial_USB_echo_off = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected\n", __func__);
// we should have a freq response so we'll read it and don't really care
// flushing doesn't always work as it depends on timing
read_icom_frame(&rs->rigport, buf, sizeof(buf));
retval = read_icom_frame(&rs->rigport, buf, sizeof(buf));
rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected, get freq retval=%d\n", __func__, retval);
if (retval <= 0) RETURNFUNC(-RIG_ETIMEOUT);
}
else
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo off detected\n", __func__);
}
rs->rigport.retry = retry_save;
RETURNFUNC(priv->serial_USB_echo_off);
}
@ -929,30 +923,43 @@ static vfo_t icom_current_vfo(RIG *rig)
int
icom_rig_open(RIG *rig)
{
int retval = RIG_OK;
int retval, retval_echo;
int satmode = 0;
struct rig_state *rs = &rig->state;
struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
int retry_flag = 1;
int echo_off;
int retry_save = rs->rigport.retry;
ENTERFUNC;
rs->rigport.retry = 0;
priv->no_1a_03_cmd = ENUM_1A_03_UNK;
rig_debug(RIG_DEBUG_VERBOSE, "%s: %s v%s\n", __func__, rig->caps->model_name,
rig->caps->version);
retry_open:
echo_off = icom_get_usb_echo_off(rig);
retval_echo = icom_get_usb_echo_off(rig);
if (echo_off == 0) // then echo is on so let's try freq now
rig_debug(RIG_DEBUG_TRACE, "%s: retval_echo=%d\n", __func__, retval_echo);
if (retval_echo == 0 || retval_echo == 1) { retval = RIG_OK; }
else { retval = retval_echo; }
if (retval == RIG_OK) // then we know our echo status
{
rig_debug(RIG_DEBUG_TRACE, "%s: echo status known, getting freq\n", __func__);
rs->rigport.retry = 0;
rig->state.current_vfo = icom_current_vfo(rig);
// some rigs like the IC7100 still echo when in standby
// so asking for freq now should timeout if such a rig
freq_t tfreq;
retval = rig_get_freq(rig, RIG_VFO_CURR, &tfreq);
}
else
{
rig_debug(RIG_DEBUG_TRACE, "%s: echo status unknown\n", __func__);
}
if (retval != RIG_OK && priv->poweron == 0 && rs->auto_power_on)
{
@ -969,15 +976,17 @@ retry_open:
rig_debug(RIG_DEBUG_WARN, "%s: rig_set_powerstat failed: =%s\n", __func__,
rigerror(retval));
rs->rigport.retry = retry_save;
RETURNFUNC(retval);
}
// Now that we're powered up let's try again
echo_off = icom_get_usb_echo_off(rig);
retval_echo = icom_get_usb_echo_off(rig);
if (echo_off < 0)
if (retval_echo != 0 && retval_echo != 1)
{
rig_debug(RIG_DEBUG_ERR, "%s: Unable to determine USB echo status\n", __func__);
rs->rigport.retry = retry_save;
RETURNFUNC(retval);
}
}
@ -994,6 +1003,7 @@ retry_open:
goto retry_open;
}
rs->rigport.retry = retry_save;
RETURNFUNC(retval);
}
@ -1025,6 +1035,7 @@ retry_open:
icom_get_freq_range(rig); // try get to get rig range capability dyamically
#endif
rs->rigport.retry = retry_save;
RETURNFUNC(RIG_OK);
}
@ -2155,10 +2166,19 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode,
rig_debug(RIG_DEBUG_TRACE, "%s(%d) mode_icom=%d, datamode[0]=%d, filter=%d\n",
__func__, __LINE__, mode_icom, datamode[0], datamode[1]);
retval = icom_set_mode_x26(rig, vfo, mode_icom, datamode[0], datamode[1]);
if (!priv->x26cmdfails)
{
retval = icom_set_mode_x26(rig, vfo, mode_icom, datamode[0], datamode[1]);
}
else
{
retval = -RIG_EPROTO;
}
if (retval != RIG_OK)
{
TRACE;
retval =
icom_transaction(rig, C_CTL_MEM, dm_sub_cmd, datamode, 2, ackbuf, &ack_len);
}
@ -2316,7 +2336,7 @@ int icom_get_mode_with_data(RIG *rig, vfo_t vfo, rmode_t *mode,
struct rig_state *rs;
struct icom_priv_data *priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo));
rs = &rig->state;
priv = (struct icom_priv_data *) rs->priv;

Wyświetl plik

@ -30,7 +30,7 @@
#include <sys/time.h>
#endif
#define BACKEND_VER "20211120"
#define BACKEND_VER "20211214"
#define ICOM_IS_SECONDARY_VFO(vfo) ((vfo) & (RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B))
#define ICOM_GET_VFO_NUMBER(vfo) (ICOM_IS_SECONDARY_VFO(vfo) ? 0x01 : 0x00)

Wyświetl plik

@ -1,4 +1,4 @@
JRCSRC = nrd535.c nrd545.c nrd525.c jrc.c jrc.h
JRCSRC = nrd535.c nrd545.c nrd525.c jrc.c jrc.h jst145.c
noinst_LTLIBRARIES = libhamlib-jrc.la
libhamlib_jrc_la_SOURCES = $(JRCSRC)

Wyświetl plik

@ -67,7 +67,7 @@
* Otherwise, you'll get a nice seg fault. You've been warned!
* TODO: error case handling
*/
static int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
int *data_len)
{
int retval;
@ -1683,6 +1683,8 @@ DECLARE_INITRIG_BACKEND(jrc)
rig_register(&nrd535_caps);
rig_register(&nrd545_caps);
rig_register(&nrd525_caps);
rig_register(&jst145_caps);
rig_register(&jst245_caps);
return RIG_OK;
}

Wyświetl plik

@ -37,6 +37,7 @@ struct jrc_priv_caps {
const char * cw_pitch;
};
int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *data_len);
int jrc_open(RIG *rig);
int jrc_close(RIG *rig);
int jrc_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
@ -66,6 +67,8 @@ int jrc_decode_event(RIG *rig);
extern const struct rig_caps nrd535_caps;
extern const struct rig_caps nrd545_caps;
extern const struct rig_caps nrd525_caps;
extern const struct rig_caps jst145_caps;
extern const struct rig_caps jst245_caps;
#endif /* _JRC_H */

577
rigs/jrc/jst145.c 100644
Wyświetl plik

@ -0,0 +1,577 @@
/*
* Hamlib JRC backend - JST-145 description
* Copyright (c) 2001-2009 by Stephane Fillod
* Copyright (c) 2021 by Michael Black W9MDB
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "hamlib/rig.h"
#include "iofunc.h"
#include "jrc.h"
static int jst145_init(RIG *rig);
static int jst145_open(RIG *rig);
static int jst145_close(RIG *rig);
static int jst145_set_vfo(RIG *rig, vfo_t vfo);
static int jst145_get_vfo(RIG *rig, vfo_t *vfo);
static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
static int jst145_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
pbwidth_t *width);
static int jst145_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch);
static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt);
#define MAX_LEN 24
#define JST145_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_FAX)
#define JST145_LEVEL (RIG_LEVEL_AGC)
// Rig has VFOB but for now we won't do much with it except set freq
#define JST145_VFO (RIG_VFO_VFO)
#define JST145_MEM_CAP { \
.freq = 1, \
.mode = 1, \
.width = 1, \
.levels = RIG_LEVEL_AGC, \
}
struct jst145_priv_data
{
ptt_t ptt;
freq_t freqA, freqB;
mode_t mode;
};
/*
* JST-145 rig capabilities.
*
*/
const struct rig_caps jst145_caps =
{
RIG_MODEL(RIG_MODEL_JST145),
.model_name = "JST-145",
.mfg_name = "JRC",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_NONE,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800,
.serial_rate_max = 4800,
.serial_data_bits = 8,
.serial_stop_bits = 1,
.serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0,
.post_write_delay = 0,
.timeout = 1000,
.retry = 1,
.has_get_func = RIG_FUNC_NONE,
.has_set_func = RIG_FUNC_NONE,
.has_get_level = RIG_LEVEL_NONE,
.has_set_level = JST145_LEVEL,
.has_get_parm = RIG_PARM_NONE,
.has_set_parm = RIG_PARM_NONE,
.level_gran = {},
.parm_gran = {},
.ctcss_list = NULL,
.dcs_list = NULL,
.preamp = { RIG_DBLST_END },
.attenuator = { 20, RIG_DBLST_END },
.max_rit = Hz(0),
.max_xit = Hz(0),
.max_ifshift = Hz(0),
.targetable_vfo = RIG_TARGETABLE_FREQ,
.transceive = RIG_TRN_OFF,
.vfo_ops = RIG_OP_FROM_VFO,
.scan_ops = RIG_SCAN_NONE,
.bank_qty = 0,
.chan_desc_sz = 0,
.chan_list = {
{ 0, 199, RIG_MTYPE_MEM, JST145_MEM_CAP },
RIG_CHAN_END
},
.rx_range_list1 = {
{kHz(100), MHz(30), JST145_MODES, -1, -1, JST145_VFO},
RIG_FRNG_END,
},
.tx_range_list1 = { RIG_FRNG_END, },
.rx_range_list2 = {
{kHz(100), MHz(30), JST145_MODES, -1, -1, JST145_VFO},
RIG_FRNG_END,
},
.tx_range_list2 = { RIG_FRNG_END, },
.tuning_steps = {
{JST145_MODES, 10},
RIG_TS_END,
},
/* mode/filter list, .remember = order matters! */
.filters = {
{RIG_MODE_FM, kHz(12)},
{RIG_MODE_FM, kHz(6)},
{RIG_MODE_AM, kHz(6)},
{RIG_MODE_AM, kHz(2)},
{RIG_MODE_AM, kHz(12)},
{RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(2)},
{RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(1)},
{RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(6)},
{RIG_MODE_CW, kHz(1)},
{RIG_MODE_CW, kHz(2)},
RIG_FLT_END,
},
.rig_open = jst145_open,
.rig_close = jst145_close,
.set_vfo = jst145_set_vfo,
.get_vfo = jst145_get_vfo,
.set_freq = jst145_set_freq,
.get_freq = jst145_get_freq,
.set_mode = jst145_set_mode,
.get_mode = jst145_get_mode,
.set_func = jst145_set_func,
.set_level = jst145_set_level,
.set_mem = jst145_set_mem,
.vfo_op = jst145_vfo_op,
.set_ptt = jst145_set_ptt,
.get_ptt = jst145_get_ptt
};
/*
* JST-245 rig capabilities.
*
*/
const struct rig_caps jst245_caps =
{
RIG_MODEL(RIG_MODEL_JST245),
.model_name = "JST-245",
.mfg_name = "JRC",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_NONE,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800,
.serial_rate_max = 4800,
.serial_data_bits = 8,
.serial_stop_bits = 1,
.serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0,
.post_write_delay = 20,
.timeout = 1000,
.retry = 0,
.has_get_func = RIG_FUNC_NONE,
.has_set_func = RIG_FUNC_NONE,
.has_get_level = RIG_LEVEL_NONE,
.has_set_level = JST145_LEVEL,
.has_get_parm = RIG_PARM_NONE,
.has_set_parm = RIG_PARM_NONE,
.level_gran = {},
.parm_gran = {},
.ctcss_list = NULL,
.dcs_list = NULL,
.preamp = { RIG_DBLST_END },
.attenuator = { 20, RIG_DBLST_END },
.max_rit = Hz(0),
.max_xit = Hz(0),
.max_ifshift = Hz(0),
.targetable_vfo = RIG_TARGETABLE_FREQ,
.transceive = RIG_TRN_OFF,
.vfo_ops = RIG_OP_FROM_VFO,
.scan_ops = RIG_SCAN_NONE,
.bank_qty = 0,
.chan_desc_sz = 0,
.chan_list = {
{ 0, 199, RIG_MTYPE_MEM, JST145_MEM_CAP },
RIG_CHAN_END
},
.rx_range_list1 = {
{kHz(100), MHz(54), JST145_MODES, -1, -1, JST145_VFO},
RIG_FRNG_END,
},
.tx_range_list1 = { RIG_FRNG_END, },
.rx_range_list2 = {
{kHz(100), MHz(54), JST145_MODES, -1, -1, JST145_VFO},
RIG_FRNG_END,
},
.tx_range_list2 = { RIG_FRNG_END, },
.tuning_steps = {
{JST145_MODES, 10},
RIG_TS_END,
},
/* mode/filter list, .remember = order matters! */
.filters = {
{RIG_MODE_FM, kHz(12)},
{RIG_MODE_FM, kHz(6)},
{RIG_MODE_AM, kHz(6)},
{RIG_MODE_AM, kHz(2)},
{RIG_MODE_AM, kHz(12)},
{RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(2)},
{RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(1)},
{RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(6)},
{RIG_MODE_CW, kHz(1)},
{RIG_MODE_CW, kHz(2)},
RIG_FLT_END,
},
.rig_init = jst145_init,
.rig_open = jst145_open,
.rig_close = jst145_close,
.set_vfo = jst145_set_vfo,
.get_vfo = jst145_get_vfo,
.set_freq = jst145_set_freq,
.get_freq = jst145_get_freq,
.set_mode = jst145_set_mode,
.get_mode = jst145_get_mode,
.set_func = jst145_set_func,
.set_level = jst145_set_level,
.set_mem = jst145_set_mem,
.vfo_op = jst145_vfo_op,
.set_ptt = jst145_set_ptt,
.get_ptt = jst145_get_ptt
};
/*
* Function definitions below
*/
static int jst145_init(RIG *rig)
{
struct jst145_priv_data *priv;
priv = (struct jst145_priv_data *)malloc(sizeof(struct jst145_priv_data));
if (!priv)
{
return -RIG_ENOMEM;
}
rig->state.priv = (void *)priv;
return RIG_OK;
}
static int jst145_open(RIG *rig)
{
int retval;
freq_t freq;
rmode_t mode;
pbwidth_t width;
struct jst145_priv_data *priv = rig->state.priv;
retval = write_block(&rig->state.rigport, "H1\r", 3);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: H1 failed: %s\n", __func__, rigerror(retval));
return retval;
}
jst145_get_freq(rig, RIG_VFO_A, &freq);
priv->freqA = freq;
jst145_get_freq(rig, RIG_VFO_B, &freq);
priv->freqB = freq;
jst145_get_mode(rig, RIG_VFO_A, &mode, &width);
priv->mode = mode;
return retval;
}
static int jst145_close(RIG *rig)
{
return write_block(&rig->state.rigport, "H0\r", 3);
}
static int jst145_set_vfo(RIG *rig, vfo_t vfo)
{
char cmd[MAX_LEN];
snprintf(cmd, sizeof(cmd), "F%c\r", vfo == RIG_VFO_A ? 'A' : 'B');
return write_block(&rig->state.rigport, cmd, strlen(cmd));
}
static int jst145_get_vfo(RIG *rig, vfo_t *vfo)
{
char cmd[MAX_LEN];
char channel[MAX_LEN];
int channel_size = sizeof(channel);
int retval;
ptt_t ptt;
jst145_get_ptt(rig, RIG_VFO_A, &ptt); // set priv->ptt to current transmit status
if (ptt) // can't get vfo while transmitting
{
*vfo = RIG_VFO_A;
return RIG_OK;
}
snprintf(cmd, sizeof(cmd), "L\r");
retval = jrc_transaction(rig, cmd, strlen(cmd), channel, &channel_size);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: jrc_transaction error: %s\n", __func__,
rigerror(retval));
return retval;
}
*vfo = channel[1] == 'A' ? RIG_VFO_A : RIG_VFO_B;
return RIG_OK;
}
static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
char freqbuf[MAX_LEN];
struct jst145_priv_data *priv = rig->state.priv;
snprintf(freqbuf, sizeof(freqbuf), "F%08u%c\r", (unsigned)(freq),
vfo == RIG_VFO_A ? 'A' : 'B');
if (vfo == RIG_VFO_B)
{
priv->freqB = freq;
}
else
{
priv->freqA = freq;
}
return write_block(&rig->state.rigport, freqbuf, strlen(freqbuf));
}
static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
char freqbuf[MAX_LEN];
char cmd[MAX_LEN];
int freqbuf_size = sizeof(freqbuf);
int retval;
int n;
struct jst145_priv_data *priv = rig->state.priv;
if (!priv->ptt) // can't get freq while transmitting
{
jst145_set_vfo(rig, vfo);
//*freq = vfo == RIG_VFO_B ? priv->freqB : priv->freqA;
//return RIG_OK;
}
snprintf(cmd, sizeof(cmd), "I\r");
retval = jrc_transaction(rig, cmd, strlen(cmd), freqbuf, &freqbuf_size);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: jrc_transaction error: %s\n", __func__,
rigerror(retval));
return retval;
}
n = sscanf(freqbuf, "I%*c%*c%*c%8lf", freq);
if (n != 1) { retval = -RIG_EPROTO; }
return retval;
}
static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
int retval;
char *modestr;
struct jst145_priv_data *priv = rig->state.priv;
switch (mode)
{
case RIG_MODE_RTTY: modestr = "D0\r"; break;
case RIG_MODE_CW: modestr = "D1\r"; break;
case RIG_MODE_USB: modestr = "D2\r"; break;
case RIG_MODE_LSB: modestr = "D3\r"; break;
case RIG_MODE_AM: modestr = "D4\r"; break;
case RIG_MODE_FM: modestr = "D5\r"; break;
default:
return -RIG_EINVAL;
}
retval = write_block(&rig->state.rigport, modestr, strlen(modestr));
if (retval != RIG_OK)
{
return retval;
}
priv->mode = mode;
if (RIG_PASSBAND_NOCHANGE == width) { return retval; }
// TODO: width -- could use B command but let user handle it for now
return retval;
}
static int jst145_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
char cmd[MAX_LEN];
char modebuf[MAX_LEN];
int modebuf_len = sizeof(modebuf);
int retval;
snprintf(cmd, sizeof(cmd), "I\r");
retval = jrc_transaction(rig, cmd, strlen(cmd), modebuf, &modebuf_len);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: jrc_transcation failed: %s\n", __func__,
rigerror(retval));
}
switch (modebuf[3])
{
case '0': *mode = RIG_MODE_RTTY; break;
case '1': *mode = RIG_MODE_CW; break;
case '2': *mode = RIG_MODE_USB; break;
case '3': *mode = RIG_MODE_LSB; break;
case '4': *mode = RIG_MODE_AM; break;
case '5': *mode = RIG_MODE_FM; break;
}
return retval;
}
static int jst145_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
return -RIG_ENIMPL;
}
static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
switch (level)
{
case RIG_LEVEL_AGC:
return write_block(&rig->state.rigport,
val.i == RIG_AGC_SLOW ? "G0\r" :
(val.i == RIG_AGC_FAST ? "G1\r" : "G2\r"), 3);
default:
return -RIG_EINVAL;
}
return -RIG_EINVAL;
}
static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch)
{
char membuf[MAX_LEN];
sprintf(membuf, "C%03d\r", ch);
return write_block(&rig->state.rigport, membuf, strlen(membuf));
}
static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
{
switch (op)
{
case RIG_OP_FROM_VFO:
return write_block(&rig->state.rigport, "E1\r", 3);
default:
return -RIG_EINVAL;
}
return -RIG_EINVAL;
}
static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
char cmd[MAX_LEN];
struct jst145_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__);
snprintf(cmd, sizeof(cmd), "X%c\r", ptt ? '1' : '0');
priv->ptt = ptt;
return write_block(&rig->state.rigport, cmd, strlen(cmd));
}
static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
char cmd[MAX_LEN];
char pttstatus[MAX_LEN];
int pttstatus_size = sizeof(pttstatus);
int retval;
struct jst145_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__);
snprintf(cmd, sizeof(cmd), "X\r");
retval = jrc_transaction(rig, cmd, strlen(cmd), pttstatus, &pttstatus_size);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: jrc_transaction error: %s\n", __func__,
rigerror(retval));
return retval;
}
if (pttstatus[1] == '1') { *ptt = RIG_PTT_ON; }
else { *ptt = RIG_PTT_OFF; }
priv->ptt = *ptt;
return RIG_OK;
}

Wyświetl plik

@ -247,7 +247,6 @@ static const yaesu_cmd_set_t ncmd[] =
struct ft1000d_priv_data
{
unsigned char pacing; /* pacing value */
unsigned int read_update_delay; /* depends on pacing value */
vfo_t current_vfo; /* active VFO from last cmd */
vfo_t split_vfo; /* TX VFO in split mode Added on 16 Dec 2016 to include FT1000D function */
split_t split; /* split active or not Added on 16 Dec 2016 to include FT1000D function */
@ -444,9 +443,6 @@ static int ft1000d_init(RIG *rig)
// Set default pacing value
priv->pacing = FT1000D_PACING_DEFAULT_VALUE;
// Set update timeout
priv->read_update_delay = FT1000D_DEFAULT_READ_TIMEOUT;
// Set operating vfo mode to current VFO changed from RIG_VFO_MAIN to RIG_VFO_A December 2016
priv->current_vfo = RIG_VFO_A;

Wyświetl plik

@ -296,7 +296,6 @@ static tone_t ft1000mp_ctcss_list[] =
struct ft1000mp_priv_data
{
unsigned char pacing; /* pacing value */
unsigned int read_update_delay; /* depends on pacing value */
unsigned char
p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */
unsigned char update_data[2 *
@ -740,8 +739,6 @@ static int ft1000mp_init(RIG *rig)
/* TODO: read pacing from preferences */
priv->pacing =
FT1000MP_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
priv->read_update_delay =
FT1000MP_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
RETURNFUNC(RIG_OK);
}

Wyświetl plik

@ -142,7 +142,7 @@ const struct rig_caps ftdx5000_caps =
RIG_MODEL(RIG_MODEL_FTDX5000),
.model_name = "FTDX-5000",
.mfg_name = "Yaesu",
.version = NEWCAT_VER ".1",
.version = NEWCAT_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -184,6 +184,7 @@ const struct rig_caps ftdx5000_caps =
.transceive = RIG_TRN_OFF, /* May enable later as the 5000 has an Auto Info command */
.bank_qty = 0,
.chan_desc_sz = 0,
.rfpower_meter_cal = FT5000_RFPOWER_METER_CAL,
.str_cal = FTDX5000_STR_CAL,
.chan_list = {
{ 1, 99, RIG_MTYPE_MEM, NEWCAT_MEM_CAP },

Wyświetl plik

@ -92,7 +92,30 @@
{ 220, 40 }, /* +40 */ \
{ 240, 50 }, /* +50 */ \
{ 255, 60 }, /* +60 */ \
} }
}\
}
// Values stolen from FLRig -- thanks to Dave W1HKJ
#define FT5000_RFPOWER_METER_CAL \
{ \
14, \
{ \
{55, 10.0f}, \
{75, 20.0f}, \
{101, 40.0f}, \
{125, 60.0f}, \
{144, 80.0f}, \
{161, 100.0f}, \
{177, 120.0f}, \
{190, 140.0f}, \
{202, 160.0f}, \
{215, 180.0f}, \
{225, 200.0f}, \
{237, 220.0f}, \
{242, 240.0f}, \
{255, 250.0f}, \
} \
}
/*

Wyświetl plik

@ -88,7 +88,6 @@ static int rig2mode(RIG *rig, int md, rmode_t *mode, pbwidth_t *width);
struct ft757_priv_data
{
unsigned char pacing; /* pacing value */
unsigned int read_update_delay; /* depends on pacing value */
unsigned char
current_vfo; /* active VFO from last cmd , can be either RIG_VFO_A or RIG_VFO_B only */
unsigned char
@ -375,8 +374,6 @@ static int ft757_init(RIG *rig)
priv->pacing =
FT757GX_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
priv->read_update_delay =
FT757GX_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
priv->current_vfo = RIG_VFO_A; /* default to VFO_A ? */
return RIG_OK;

Wyświetl plik

@ -240,7 +240,6 @@ static int rig2ctcss(RIG *rig, unsigned char tn, tone_t *tone);
struct ft767_priv_data
{
unsigned char pacing; /* pacing value */
unsigned int read_update_delay; /* depends on pacing value */
unsigned char
current_vfo; /* active VFO from last cmd , can be either RIG_VFO_A or RIG_VFO_B only */
unsigned char
@ -413,8 +412,6 @@ int ft767_init(RIG *rig)
/* TODO: read pacing from preferences */
priv->pacing = FT767GX_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
priv->read_update_delay =
FT767GX_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
priv->current_vfo = RIG_VFO_A; /* default to VFO_A ? */
priv->ack_cmd[0] = 00;
priv->ack_cmd[1] = 00;

Wyświetl plik

@ -230,7 +230,6 @@ static const yaesu_cmd_set_t ncmd[] =
struct ft840_priv_data
{
unsigned char pacing; /* pacing value */
unsigned int read_update_delay; /* depends on pacing value */
vfo_t current_vfo; /* active VFO from last cmd */
unsigned char
p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */
@ -400,8 +399,6 @@ static int ft840_init(RIG *rig)
/* TODO: read pacing from preferences */
priv->pacing = FT840_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
priv->read_update_delay =
FT840_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */
return RIG_OK;

Wyświetl plik

@ -382,7 +382,6 @@ static const yaesu_cmd_set_t ncmd[] =
struct ft890_priv_data
{
unsigned char pacing; /* pacing value */
unsigned int read_update_delay; /* depends on pacing value */
vfo_t current_vfo; /* active VFO from last cmd */
unsigned char
p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */
@ -550,8 +549,6 @@ static int ft890_init(RIG *rig)
/* TODO: read pacing from preferences */
priv->pacing = FT890_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
priv->read_update_delay =
FT890_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */
return RIG_OK;

Wyświetl plik

@ -403,7 +403,6 @@ static const yaesu_cmd_set_t ncmd[] =
struct ft900_priv_data
{
unsigned char pacing; /* pacing value */
unsigned int read_update_delay; /* depends on pacing value */
vfo_t current_vfo; /* active VFO from last cmd */
unsigned char
p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */
@ -572,8 +571,6 @@ static int ft900_init(RIG *rig)
/* TODO: read pacing from preferences */
priv->pacing = FT900_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
priv->read_update_delay =
FT900_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */
return RIG_OK;

Wyświetl plik

@ -392,7 +392,6 @@ static const yaesu_cmd_set_t ncmd[] =
struct ft920_priv_data
{
unsigned char pacing; /* pacing value */
unsigned int read_update_delay; /* depends on pacing value */
vfo_t current_vfo; /* active VFO from last cmd */
vfo_t split_vfo; /* TX VFO in split mode */
split_t split; /* split active or not */
@ -647,8 +646,6 @@ static int ft920_init(RIG *rig)
/* TODO: read pacing from preferences */
priv->pacing =
FT920_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
priv->read_update_delay =
FT920_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
priv->current_vfo = RIG_VFO_A; /* default to VFO_A */
return RIG_OK;

Wyświetl plik

@ -218,7 +218,6 @@ static const yaesu_cmd_set_t ncmd[] =
struct ft990_priv_data
{
unsigned char pacing; /* pacing value */
unsigned int read_update_delay; /* depends on pacing value */
vfo_t current_vfo; /* active VFO from last cmd */
unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of CAT cmd */
ft990_update_data_t update_data; /* returned data */
@ -408,9 +407,6 @@ int ft990_init(RIG *rig)
// Set default pacing value
priv->pacing = FT990_PACING_DEFAULT_VALUE;
// Set update timeout
priv->read_update_delay = FT990_DEFAULT_READ_TIMEOUT;
// Set operating vfo mode to current VFO
priv->current_vfo = RIG_VFO_MAIN;

Wyświetl plik

@ -116,19 +116,20 @@
}
#define FTDX101MP_RFPOWER_METER_WATTS_CAL \
{ \
11, \
15, \
{ \
{0, 0.0f}, \
{69, 10.0f}, \
{111, 20.0f}, \
{129, 30.0f}, \
{143, 40.0f}, \
{158, 50.0f}, \
{184, 70.0f}, \
{200, 80.0f}, \
{211, 90.0f}, \
{222, 100.0f}, \
{255, 200.0f}, \
{0, 0.0f}, \
{32, 20.0f}, \
{97, 40.0f}, \
{119, 60.0f}, \
{137, 80.0f}, \
{154, 100.0f}, \
{170, 120.0f}, \
{180, 140.0f}, \
{209, 160.0f}, \
{227, 180.0f}, \
{240, 200.0f}, \
{255, 210.0f}, \
} \
}

Wyświetl plik

@ -469,11 +469,6 @@ int newcat_init(RIG *rig)
priv = rig->state.priv;
/* TODO: read pacing from preferences */
// priv->pacing = NEWCAT_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
priv->read_update_delay =
NEWCAT_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
// priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */
// priv->current_vfo = RIG_VFO_A;
@ -4590,7 +4585,34 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
RETURNFUNC(-RIG_ENAVAIL);
}
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term);
if (is_ftdx9000)
{
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM09%c", cat_term);
}
else if (is_ftdx3000 || is_ftdx5000)
{
// The 3000 has to use the meter read for SWR when the tuner is on
// We'll assume the 5000 is the same way for now
// Also need to ensure SWR is selected for the meter
int tuner;
value_t meter;
newcat_get_func(rig, RIG_VFO_A, RIG_FUNC_TUNER, &tuner);
newcat_get_level(rig, RIG_VFO_A, RIG_LEVEL_METER, &meter);
if (tuner && meter.i != RIG_METER_SWR)
{
RETURNFUNC(-RIG_ENAVAIL); // if meter not SWR can't read SWR
}
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM%c%c", (tuner
&& meter.i == RIG_METER_SWR) ? '2' : '6',
cat_term);
}
else
{
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term);
}
break;
case RIG_LEVEL_ALC:
@ -4599,7 +4621,15 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
RETURNFUNC(-RIG_ENAVAIL);
}
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM4%c", cat_term);
if (is_ftdx9000)
{
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM07%c", cat_term);
}
else
{
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM4%c", cat_term);
}
break;
case RIG_LEVEL_RFPOWER_METER:
@ -9868,8 +9898,7 @@ int newcat_get_cmd(RIG *rig)
|| strcmp(priv->cmd_str, "RF1;") == 0
|| strcmp(priv->cmd_str, "RL0;") == 0
|| strcmp(priv->cmd_str, "RL1;") == 0
|| strcmp(priv->cmd_str, "RM0;") == 0
|| strcmp(priv->cmd_str, "RM1;") == 0
|| strncmp(priv->cmd_str, "RM", 2) == 0
|| strcmp(priv->cmd_str, "SM0;") == 0
|| strcmp(priv->cmd_str, "SM1;") == 0
|| strcmp(priv->cmd_str, "SQ0;") == 0
@ -11049,7 +11078,8 @@ int newcat_set_clock(RIG *rig, int year, int month, int day, int hour, int min,
RETURNFUNC(err);
}
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT1%02d%02d%02d%c", hour, min, sec, cat_term);
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT1%02d%02d%02d%c", hour, min,
sec, cat_term);
if (RIG_OK != (err = newcat_set_cmd(rig)))
{
@ -11058,7 +11088,8 @@ int newcat_set_clock(RIG *rig, int year, int month, int day, int hour, int min,
RETURNFUNC(err);
}
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT2%c%04d%c", utc_offset>=0?'+':'-', utc_offset, cat_term);
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT2%c%04d%c",
utc_offset >= 0 ? '+' : '-', utc_offset, cat_term);
if (RIG_OK != (err = newcat_set_cmd(rig)))
{

Wyświetl plik

@ -50,7 +50,7 @@
typedef char ncboolean;
/* shared function version */
#define NEWCAT_VER "20211202"
#define NEWCAT_VER "20211216"
/* Hopefully large enough for future use, 128 chars plus '\0' */
#define NEWCAT_DATA_LEN 129
@ -102,9 +102,6 @@ struct newcat_priv_caps
*/
struct newcat_priv_data
{
unsigned int
read_update_delay; /* depends on pacing value */
// vfo_t current_vfo; /* active VFO from last cmd */
char cmd_str[NEWCAT_DATA_LEN]; /* command string buffer */
char
ret_data[NEWCAT_DATA_LEN]; /* returned data--max value, most are less */

Wyświetl plik

@ -195,6 +195,13 @@ void frameParse(int fd, unsigned char *frame, int len)
write(fd, frame, 8);
break;
case 0x04: // IC7200 data mode
frame[6] = 0;
frame[7] = 0;
frame[8] = 0xfd;
write(fd, frame, 9);
break;
case 0x07: // satmode
frame[6] = 0;
frame[7] = 0xfd;
@ -205,7 +212,7 @@ void frameParse(int fd, unsigned char *frame, int len)
break;
#if 0
#if 1
case 0x25:
if (frame[6] == 0xfd)

Wyświetl plik

@ -1293,12 +1293,32 @@ const char *HAMLIB_API rig_stragclevel(enum agc_level_e level)
return "";
}
/**
* \brief Convert a enum agc_level_e to value
* \param integer...
* \return agc_level_e value
*/
value_t rig_valueagclevel (enum agc_level_e agcLevel)
{
value_t value;
if (agcLevel == RIG_AGC_OFF) value.i = 0;
else if (agcLevel == RIG_AGC_SUPERFAST) value.i = 1;
else if (agcLevel == RIG_AGC_FAST) value.i = 2;
else if (agcLevel == RIG_AGC_SLOW) value.i = 3;
else if (agcLevel == RIG_AGC_USER) value.i = 4;
else if (agcLevel == RIG_AGC_MEDIUM) value.i = 5;
else value.i = 6; //RIG_AGC_AUTO
return value;
}
/**
* \brief Convert a value to agc_level_e -- constrains the range
* \param integer...
* \return agc_level_e
*/
enum agc_level_e levelagcvalue(int agcValue)
enum agc_level_e rig_levelagcvalue(int agcValue)
{
enum agc_level_e agcLevel;
@ -1329,7 +1349,7 @@ enum agc_level_e levelagcvalue(int agcValue)
* \param mode AGC string...
* \return agc_level_e
*/
enum agc_level_e levelagcstr(char *agcString)
enum agc_level_e rig_levelagcstr(char *agcString)
{
enum agc_level_e agcLevel;

Wyświetl plik

@ -130,6 +130,7 @@ int main(int argc, char *argv[])
if (widthC != 3000) { printf("widthC = %d\n", (int)widthC); exit(1); }
#if 0 // PTT does not work for dummy device
printf("PTT ON\n");
rig_set_ptt(my_rig, RIG_VFO_CURR, RIG_PTT_ON);
ptt_t ptt;
@ -151,6 +152,7 @@ int main(int argc, char *argv[])
rig_get_ptt(my_rig, RIG_VFO_CURR, &ptt);
printf("PTT get ptt OFF\n");
#endif
vfo_t tx_vfo;
split_t split;