Added x108g backend

astyle-formatting
Michael D Black 2017-02-14 15:39:31 -06:00
rodzic f17ddfc676
commit ea6f4e7115
5 zmienionych plików z 559 dodań i 13 usunięć

Wyświetl plik

@ -9,7 +9,7 @@ ICOMSRC = ic706.c icr8500.c ic735.c ic775.c ic756.c \
ic707.c ic728.c ic751.c ic761.c \
ic78.c ic7800.c ic785x.c \
ic7000.c ic7100.c ic7200.c ic7300.c ic7600.c ic7700.c \
icom.c icom.h icom_defs.h frame.c frame.h optoscan.c optoscan.h
icom.c icom.h icom_defs.h frame.c frame.h optoscan.c optoscan.h x108g.c
noinst_LTLIBRARIES = libhamlib-icom.la
libhamlib_icom_la_SOURCES = $(ICOMSRC)

Wyświetl plik

@ -354,6 +354,7 @@ static const struct icom_addr icom_addr_list[] = {
{ RIG_MODEL_IC7200, 0x76 },
{ RIG_MODEL_IC7700, 0x74 },
{ RIG_MODEL_PERSEUS, 0xE1 },
{ RIG_MODEL_X108G, 0x70 },
{ RIG_MODEL_NONE, 0 },
};
@ -370,6 +371,7 @@ int icom_init(RIG *rig)
const struct icom_priv_caps *priv_caps;
const struct rig_caps *caps;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !rig->caps)
return -RIG_EINVAL;
@ -411,6 +413,7 @@ int icom_init(RIG *rig)
*/
int icom_cleanup(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
return -RIG_EINVAL;
@ -433,6 +436,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
unsigned char freqbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN];
int freq_len, ack_len=sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -469,6 +473,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
unsigned char freqbuf[MAXFRAMELEN];
int freq_len, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -517,6 +522,7 @@ int icom_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
int freq_len, ack_len=sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
freq_len = 2;
/*
* to_bcd requires nibble len
@ -555,6 +561,7 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode) {
unsigned char fw_sub_cmd = RIG_MODEL_IC7200 == rig->caps->rig_model ? 0x02 : S_MEM_FILT_WDTH;
struct icom_priv_data * priv = (struct icom_priv_data*)rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (rig_has_get_func(rig, RIG_FUNC_RF) && (mode & (RIG_MODE_RTTY | RIG_MODE_RTTYR))) {
if(!rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_RF, &rfstatus) && (rfstatus)) {
retval = rig_get_ext_parm (rig, TOK_RTTY_FLTR, &rfwidth);
@ -564,6 +571,7 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode) {
return rtty_fil[rfwidth.i];
}
}
if (RIG_MODEL_X108G == rig->caps->rig_model) priv->no_1a_03_cmd = 1;
if (priv->no_1a_03_cmd) return 0;
retval = icom_transaction (rig, C_CTL_MEM, fw_sub_cmd, 0, 0,
resbuf, &res_len);
@ -653,6 +661,7 @@ int icom_set_mode_with_data (RIG * rig, vfo_t vfo, rmode_t mode, pbwidth_t width
rmode_t icom_mode;
unsigned char dm_sub_cmd = RIG_MODEL_IC7200 == rig->caps->rig_model ? 0x04 : S_MEM_DATA_MODE;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (mode)
{
case RIG_MODE_PKTUSB: icom_mode = RIG_MODE_USB; break;
@ -709,7 +718,8 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
unsigned char icmode;
signed char icmode_ext;
int ack_len=sizeof(ackbuf), retval, err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -770,6 +780,7 @@ int icom_get_mode_with_data(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width
int data_len, retval;
unsigned char dm_sub_cmd = RIG_MODEL_IC7200 == rig->caps->rig_model ? 0x04 : S_MEM_DATA_MODE;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = icom_get_mode (rig, vfo, mode, width);
if (RIG_OK == retval && (RIG_MODE_USB == *mode || RIG_MODE_LSB == *mode || RIG_MODE_FM == *mode))
@ -831,6 +842,7 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
const struct icom_priv_caps *priv_caps;
int mode_len, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
priv_caps = (const struct icom_priv_caps *) rig->caps->priv;
retval = icom_transaction (rig, C_RD_MODE, -1, NULL, 0,
@ -884,6 +896,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf), icvfo, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (vfo == RIG_VFO_CURR)
return RIG_OK;
@ -946,10 +959,10 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
int icom_val;
int i, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
/*
* So far, levels of float type are in [0.0..1.0] range
*/
@ -1178,6 +1191,7 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
int cmdhead;
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -1466,6 +1480,7 @@ int icom_set_conf(RIG *rig, token_t token, const char *val)
struct icom_priv_data *priv;
struct rig_state *rs;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -1498,6 +1513,7 @@ int icom_get_conf(RIG *rig, token_t token, char *val)
struct icom_priv_data *priv;
struct rig_state *rs;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -1527,6 +1543,7 @@ int icom_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
unsigned char ackbuf[MAXFRAMELEN], pttbuf[1];
int ack_len=sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
pttbuf[0] = ptt == RIG_PTT_ON ? 1 : 0;
retval = icom_transaction (rig, C_CTL_PTT, S_PTT, pttbuf, 1,
@ -1552,6 +1569,7 @@ int icom_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
unsigned char pttbuf[MAXFRAMELEN];
int ptt_len, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = icom_transaction (rig, C_CTL_PTT, S_PTT, NULL, 0,
pttbuf, &ptt_len);
@ -1582,6 +1600,7 @@ int icom_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
unsigned char dcdbuf[MAXFRAMELEN];
int dcd_len, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = icom_transaction (rig, C_RD_SQSM, S_SQL, NULL, 0,
dcdbuf, &dcd_len);
if (retval != RIG_OK)
@ -1615,6 +1634,7 @@ int icom_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift)
int ack_len=sizeof(ackbuf), retval;
int rptr_sc;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (rptr_shift) {
case RIG_RPT_SHIFT_NONE:
rptr_sc = S_DUP_OFF; /* Simplex mode */
@ -1656,6 +1676,7 @@ int icom_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift)
unsigned char rptrbuf[MAXFRAMELEN];
int rptr_len, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = icom_transaction (rig, C_CTL_SPLT, -1, NULL, 0,
rptrbuf, &rptr_len);
if (retval != RIG_OK)
@ -1698,6 +1719,7 @@ int icom_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
unsigned char offsbuf[MAXFRAMELEN],ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/*
* Icoms are using a 100Hz unit (at least on 706MKIIg) -- SF
*/
@ -1727,7 +1749,7 @@ int icom_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
unsigned char offsbuf[MAXFRAMELEN];
int offs_len, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = icom_transaction (rig, C_RD_OFFS, -1, NULL, 0,
offsbuf, &offs_len);
if (retval != RIG_OK)
@ -1754,8 +1776,9 @@ int icom_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
/*
* Helper function to go back and forth split VFO
*/
static int get_split_vfos(const RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo)
int icom_get_split_vfos(const RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if ((rig->state.vfo_list & (RIG_VFO_A|RIG_VFO_B)) == (RIG_VFO_A|RIG_VFO_B)) {
*rx_vfo = RIG_VFO_A;
*tx_vfo = RIG_VFO_B; /* rig doesn't enforce this but
@ -1785,6 +1808,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -1811,7 +1835,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
return -RIG_ERJCTED;
}
}
if (RIG_OK != (rc = get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) return rc;
if (RIG_OK != (rc = rig_set_freq(rig, RIG_VFO_CURR, tx_freq))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, rx_vfo))) return rc;
@ -1837,6 +1861,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -1863,7 +1888,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
return -RIG_ERJCTED;
}
}
if (RIG_OK != (rc = get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) return rc;
if (RIG_OK != (rc = icom_get_freq(rig, RIG_VFO_CURR, tx_freq))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, rx_vfo))) return rc;
@ -1889,6 +1914,7 @@ int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -1915,7 +1941,7 @@ int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width
return -RIG_ERJCTED;
}
}
if (RIG_OK != (rc = get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) return rc;
if (RIG_OK != (rc = rig->caps->set_mode(rig, RIG_VFO_CURR, tx_mode, tx_width))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, rx_vfo))) return rc;
@ -1942,6 +1968,7 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_wid
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -1968,7 +1995,7 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_wid
return -RIG_ERJCTED;
}
}
if (RIG_OK != (rc = get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) return rc;
if (RIG_OK != (rc = rig->caps->get_mode(rig, RIG_VFO_CURR, tx_mode, tx_width))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, rx_vfo))) return rc;
@ -1993,6 +2020,7 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, rmode_t tx_mod
int ack_len=sizeof(ackbuf);
vfo_t rx_vfo, tx_vfo;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/* This method works also in memory mode(RIG_VFO_MEM) */
if (!priv->no_xchg && rig_has_vfo_op(rig, RIG_OP_XCHG)) {
if (RIG_OK != (rc = icom_vfo_op(rig, vfo, RIG_OP_XCHG))) return rc;
@ -2017,7 +2045,7 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, rmode_t tx_mod
return -RIG_ERJCTED;
}
}
if (RIG_OK != (rc = get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) return rc;
if (RIG_OK != (rc = rig_set_freq(rig, RIG_VFO_CURR, tx_freq))) return rc;
if (RIG_OK != (rc = rig->caps->set_mode(rig, RIG_VFO_CURR, tx_mode, tx_width))) return rc;
@ -2045,6 +2073,7 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, rmode_t *tx_m
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -2072,7 +2101,7 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, rmode_t *tx_m
return -RIG_ERJCTED;
}
}
if (RIG_OK != (rc = get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) return rc;
if (RIG_OK != (rc = icom_get_freq(rig, RIG_VFO_CURR, tx_freq))) return rc;
if (RIG_OK != (rc = rig->caps->get_mode(rig, RIG_VFO_CURR, tx_mode, tx_width))) return rc;
@ -2097,6 +2126,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
int ack_len=sizeof(ackbuf), rc;
int split_sc;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (split) {
case RIG_SPLIT_OFF:
split_sc = S_SPLT_OFF;
@ -2139,6 +2169,7 @@ int icom_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
unsigned char splitbuf[MAXFRAMELEN];
int split_len, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = icom_transaction (rig, C_CTL_SPLT, -1, NULL, 0,
splitbuf, &split_len);
if (retval != RIG_OK)
@ -2178,6 +2209,7 @@ int icom_mem_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
{
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/* this hacks works only when in memory mode
* I have no clue how to detect split in regular VFO mode
*/
@ -2211,6 +2243,7 @@ int icom_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
int i, ack_len=sizeof(ackbuf), retval;
int ts_sc = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
priv_caps = (const struct icom_priv_caps*)rig->caps->priv;
for (i=0; i<TSLSTSIZ; i++) {
@ -2247,6 +2280,7 @@ int icom_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts)
unsigned char tsbuf[MAXFRAMELEN];
int ts_len, i, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
priv_caps = (const struct icom_priv_caps*)rig->caps->priv;
retval = icom_transaction (rig, C_SET_TS, -1, NULL, 0, tsbuf, &ts_len);
@ -2444,6 +2478,7 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
int ack_len=sizeof(ackbuf), retval;
int fct_cn, fct_sc; /* Command Number, Subcommand */
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (func) {
case RIG_FUNC_FAGC:
fct_cn = C_CTL_FUNC;
@ -2557,6 +2592,7 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val)
int retval;
int min,hr,sec;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -2681,6 +2717,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val)
int retval;
int min,hr,sec;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -2810,6 +2847,7 @@ int icom_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
int tone_len, ack_len=sizeof(ackbuf), retval;
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
caps = rig->caps;
if (caps->ctcss_list) {
@ -2851,6 +2889,7 @@ int icom_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
int tone_len, retval;
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
caps = rig->caps;
retval = icom_transaction(rig, C_SET_TONE, S_TONE_RPTR, NULL, 0,
@ -2892,6 +2931,7 @@ int icom_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
int tone_len, ack_len=sizeof(ackbuf), retval;
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
caps = rig->caps;
for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) {
@ -2931,6 +2971,7 @@ int icom_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
int tone_len, retval;
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
caps = rig->caps;
retval = icom_transaction(rig, C_SET_TONE, S_TONE_SQL, NULL, 0,
@ -2969,6 +3010,7 @@ int icom_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
int code_len, ack_len=sizeof(ackbuf), retval;
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
caps = rig->caps;
for (i = 0; caps->dcs_list[i] != 0 && i<104; i++) {
@ -3006,6 +3048,7 @@ int icom_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
int code_len, retval;
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
caps = rig->caps;
retval = icom_transaction(rig, C_SET_TONE, S_TONE_DTCS, NULL, 0,
@ -3046,6 +3089,7 @@ int icom_set_powerstat(RIG *rig, powerstat_t status)
unsigned char fe_buf[200]; // for FE's to power up
int fe_len = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (status) {
case RIG_POWER_ON:
pwr_sc = RIG_POWER_ON;
@ -3087,6 +3131,7 @@ int icom_get_powerstat(RIG *rig, powerstat_t *status)
unsigned char cmdbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN];
int cmd_len, ack_len=sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/* r75 has no way to get power status, so fake it */
if (rig->caps->rig_model == RIG_MODEL_ICR75) {
/* getting the mode doesn't work if a memory is blank */
@ -3129,6 +3174,7 @@ int icom_set_mem(RIG *rig, vfo_t vfo, int ch)
int ack_len=sizeof(ackbuf), retval;
int chan_len;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
chan_len = ch < 100 ? 1 : 2;
to_bcd_be(membuf, ch, chan_len*2);
@ -3156,6 +3202,7 @@ int icom_set_bank(RIG *rig, vfo_t vfo, int bank)
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
to_bcd_be(bankbuf, bank, BANK_NB_LEN*2);
retval = icom_transaction (rig, C_SET_MEM, S_BANK,
bankbuf, CHAN_NB_LEN, ackbuf, &ack_len);
@ -3182,6 +3229,7 @@ int icom_set_ant(RIG * rig, vfo_t vfo, ant_t ant)
int ack_len=sizeof(ackbuf), retval, i_ant=0;
int ant_len;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/*
* TODO: IC-756* and [RX ANT]
*/
@ -3222,6 +3270,7 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t *ant)
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = icom_transaction(rig, C_CTL_ANT, -1, NULL, 0,
ackbuf, &ack_len);
if (retval != RIG_OK)
@ -3256,6 +3305,7 @@ int icom_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
int mv_cn, mv_sc;
int vfo_list;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -3335,7 +3385,7 @@ int icom_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
int scan_len, ack_len=sizeof(ackbuf), retval;
int scan_cn, scan_sc;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
scan_len = 0;
scan_cn = C_CTL_SCAN;
@ -3405,6 +3455,7 @@ int icom_send_morse (RIG * rig, vfo_t vfo, const char *msg)
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int len = strlen(msg);
if (len > 30) len=30;
@ -3428,6 +3479,7 @@ int icom_power2mW(RIG * rig, unsigned int *mwpower, float power, freq_t freq, rm
{
int rig_id;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rig_id = rig->caps->rig_model;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -3445,6 +3497,7 @@ int icom_mW2power(RIG * rig, float *power, unsigned int mwpower, freq_t freq, rm
{
int rig_id;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rig_id = rig->caps->rig_model;
rig_debug(RIG_DEBUG_TRACE, "%s: passed mwpower = %i\n", __func__, mwpower);
@ -3479,7 +3532,7 @@ int icom_decode_event(RIG *rig)
rmode_t mode;
pbwidth_t width;
rig_debug(RIG_DEBUG_VERBOSE, "icom: icom_decode called\n");
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
@ -3567,6 +3620,7 @@ DECLARE_PROBERIG_BACKEND(icom)
int rates[] = { 19200, 9600, 300, 0 };
int rates_idx;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!port)
return RIG_MODEL_NONE;
@ -3789,5 +3843,7 @@ DECLARE_INITRIG_BACKEND(icom)
rig_register(&perseus_caps);
rig_register(&x108g_caps);
return RIG_OK;
}

Wyświetl plik

@ -140,6 +140,7 @@ extern const struct ts_sc_list ic7200_ts_sc_list[];
extern const struct ts_sc_list ic7300_ts_sc_list[];
extern const struct ts_sc_list ic910_ts_sc_list[];
extern const struct ts_sc_list ic718_ts_sc_list[];
extern const struct ts_sc_list x108g_ts_sc_list[];
extern const pbwidth_t rtty_fil[]; /* rtty filter passband width; available on 746pro and 756pro rigs */
@ -201,6 +202,8 @@ int icom_decode_event(RIG *rig);
int icom_power2mW(RIG * rig, unsigned int *mwpower, float power, freq_t freq, rmode_t mode);
int icom_mW2power(RIG * rig, float *power, unsigned int mwpower, freq_t freq, rmode_t mode);
int icom_send_morse (RIG * rig, vfo_t vfo, const char *msg);
/* Exposed routines */
int icom_get_split_vfos(const RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo);
extern const struct confparams icom_cfg_params[];
@ -273,4 +276,7 @@ extern const struct rig_caps ic2730_caps;
extern const struct rig_caps perseus_caps;
extern const struct rig_caps x108g_caps;
#endif /* _ICOM_H */

483
icom/x108g.c 100644
Wyświetl plik

@ -0,0 +1,483 @@
/*
* Hamlib CI-V backend - description of Xeigu X108G and variations
* Adapted from IC-7000 code 2017 by Michael Black W9MDB
* As of this date there is no CAT manual for this rig
* The X108G is supposed to emulate the IC-7000 but there are a few
* differences as of 2017-02-11 in the return data from the rig
* It's quite possible they may fix all these eventually
* If they do the functions below can go back to the icom routines
* #1 the response to PTT
* #2 the inability to set_dsp_mode
* #3 setting splie which impacts 3 routines
*
* Copyright (c) 2004-2010 by Stephane Fillod
*
*
* 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> /* String function definitions */
#include <hamlib/rig.h>
#include "token.h"
#include "idx_builtin.h"
#include "icom.h"
#include "icom_defs.h"
#include "frame.h"
#include "misc.h"
#include "bandplan.h"
#define X108G_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_WFM)
#define X108G_1HZ_TS_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR)
#define X108G_NOT_TS_MODES (X108G_ALL_RX_MODES &~X108G_1HZ_TS_MODES)
#define X108G_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM)
#define X108G_AM_TX_MODES (RIG_MODE_AM)
#define X108G_FUNCS (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN|RIG_FUNC_NR|RIG_FUNC_MON|RIG_FUNC_MN|RIG_FUNC_ANF|RIG_FUNC_VSC|RIG_FUNC_LOCK|RIG_FUNC_ARO)
#define X108G_LEVELS (RIG_LEVEL_PREAMP|RIG_LEVEL_ATT|RIG_LEVEL_AGC|RIG_LEVEL_COMP|RIG_LEVEL_BKINDL|RIG_LEVEL_NR|RIG_LEVEL_PBT_IN|RIG_LEVEL_PBT_OUT|RIG_LEVEL_CWPITCH|RIG_LEVEL_RFPOWER|RIG_LEVEL_MICGAIN|RIG_LEVEL_KEYSPD|RIG_LEVEL_NOTCHF|RIG_LEVEL_SQL|RIG_LEVEL_RAWSTR|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_VOXGAIN|RIG_LEVEL_VOXDELAY|RIG_LEVEL_SWR|RIG_LEVEL_ALC)
#define X108G_VFOS (RIG_VFO_A|RIG_VFO_B|RIG_VFO_MEM)
#define X108G_PARMS (RIG_PARM_ANN|RIG_PARM_BACKLIGHT|RIG_PARM_APO|RIG_PARM_TIME|RIG_PARM_BEEP)
#define X108G_VFO_OPS (RIG_OP_CPY|RIG_OP_XCHG|RIG_OP_FROM_VFO|RIG_OP_TO_VFO|RIG_OP_MCL|RIG_OP_TUNE)
#define X108G_SCAN_OPS (RIG_SCAN_MEM|RIG_SCAN_PROG|RIG_SCAN_SLCT|RIG_SCAN_PRIO)
#define X108G_ANTS (RIG_ANT_1|RIG_ANT_2) /* ant-1 is Hf-6m, ant-2 is 2m-70cm */
/*
* Measurement by Mark, WA0TOP
*
* s/n 0503103.
* Preamp off, ATT off, mode AM, f=10 MHz
*/
#define X108G_STR_CAL { 14, \
{ \
{ 0, -54 }, /* first one is made up */ \
{ 5, -29 }, \
{ 15, -27 }, \
{ 43, -22 }, \
{ 68, -17 }, \
{ 92, -12 }, \
{ 120, -6 }, \
{ 141, 2 }, \
{ 162, 13 }, \
{ 182, 25 }, \
{ 202, 38 }, \
{ 222, 47 }, \
{ 241, 57 }, \
{ 255, 63 } \
} }
/*
*
* X108G channel caps.
*/
#define X108G_MEM_CAP { \
.freq = 1, \
.mode = 1, \
.width = 1, \
.split = 1, \
.tx_freq = 1, \
.tx_mode = 1, \
.tx_width = 1, \
.rptr_offs = 1, \
.rptr_shift = 1, \
.ctcss_tone = 1, \
.ctcss_sql = 1, \
.funcs = X108G_FUNCS, \
.levels = RIG_LEVEL_SET(X108G_LEVELS), \
}
/*
* Prototypes
*/
static int x108g_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
static int x108g_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo);
static int x108g_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq);
static int x108g_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width);
/*
* IC-7000 rig capabilities.
*
* TODO: complete command set (esp. the $1A bunch!) and testing..
*/
static const struct icom_priv_caps x108g_priv_caps = {
0x70, /* default address */
0, /* 731 mode */
0, /* no XCHG */
ic7200_ts_sc_list
};
const struct rig_caps x108g_caps = {
.rig_model = RIG_MODEL_X108G,
.model_name = "X108G",
.mfg_name = "Xeigu",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.rig_type = RIG_TYPE_TRANSCEIVER,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_RIG,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 300,
.serial_rate_max = 19200,
.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 = 3,
.has_get_func = X108G_FUNCS,
.has_set_func = X108G_FUNCS,
.has_get_level = X108G_LEVELS,
.has_set_level = RIG_LEVEL_SET(X108G_LEVELS),
.has_get_parm = X108G_PARMS,
.has_set_parm = RIG_PARM_SET(X108G_PARMS),
.level_gran = {
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
},
.parm_gran = {},
.ctcss_list = common_ctcss_list,
.dcs_list = common_dcs_list,
.preamp = { 10, RIG_DBLST_END, }, /* FIXME: TBC it's a guess*/
.attenuator = { 12, RIG_DBLST_END, },
.max_rit = Hz(9999),
.max_xit = Hz(9999),
.max_ifshift = Hz(0), /* TODO */
.targetable_vfo = 0,
.vfo_ops = X108G_VFO_OPS,
.scan_ops = X108G_SCAN_OPS,
.transceive = RIG_TRN_RIG,
.bank_qty = 5,
.chan_desc_sz = 0, /* TODO */
.chan_list = {
{ 1, 99, RIG_MTYPE_MEM, X108G_MEM_CAP },
{ 100, 105, RIG_MTYPE_EDGE, X108G_MEM_CAP }, /* two by two */
{ 106, 107, RIG_MTYPE_CALL, X108G_MEM_CAP },
RIG_CHAN_END,
},
.rx_range_list1 = { {kHz(30),MHz(199.999999),X108G_ALL_RX_MODES,-1,-1,X108G_VFOS},
{MHz(400),MHz(470), X108G_ALL_RX_MODES,-1,-1,X108G_VFOS}, RIG_FRNG_END, },
.tx_range_list1 = {
FRQ_RNG_HF(1,X108G_OTHER_TX_MODES, W(2),W(100),X108G_VFOS,RIG_ANT_1),
FRQ_RNG_6m(1,X108G_OTHER_TX_MODES, W(2),W(100),X108G_VFOS,RIG_ANT_1),
FRQ_RNG_2m(1,X108G_OTHER_TX_MODES, W(2),W(50),X108G_VFOS,RIG_ANT_2),
FRQ_RNG_70cm(1,X108G_OTHER_TX_MODES, W(2), W(35), X108G_VFOS, RIG_ANT_2),
FRQ_RNG_HF(1,X108G_AM_TX_MODES, W(1),W(40),X108G_VFOS,RIG_ANT_1), /* AM class */
FRQ_RNG_6m(1,X108G_AM_TX_MODES, W(1),W(40),X108G_VFOS,RIG_ANT_1), /* AM class */
FRQ_RNG_2m(1,X108G_AM_TX_MODES, W(2),W(20),X108G_VFOS,RIG_ANT_2),
FRQ_RNG_70cm(1,X108G_OTHER_TX_MODES, W(2), W(14), X108G_VFOS, RIG_ANT_2),
RIG_FRNG_END, },
.rx_range_list2 = { {kHz(30),MHz(199.999999),X108G_ALL_RX_MODES,-1,-1,X108G_VFOS},
{MHz(400),MHz(470), X108G_ALL_RX_MODES,-1,-1,X108G_VFOS}, RIG_FRNG_END, },
.tx_range_list2 = { /* needs the 5 mhz channels added */
FRQ_RNG_HF(2,X108G_OTHER_TX_MODES, W(2),W(100),X108G_VFOS,RIG_ANT_1),
FRQ_RNG_6m(2,X108G_OTHER_TX_MODES, W(2),W(100),X108G_VFOS,RIG_ANT_1),
FRQ_RNG_2m(2,X108G_OTHER_TX_MODES, W(2),W(50),X108G_VFOS,RIG_ANT_2),
FRQ_RNG_70cm(2,X108G_OTHER_TX_MODES, W(2), W(35), X108G_VFOS, RIG_ANT_2),
FRQ_RNG_HF(2,X108G_AM_TX_MODES, W(1),W(40),X108G_VFOS,RIG_ANT_1), /* AM class */
FRQ_RNG_6m(2,X108G_AM_TX_MODES, W(1),W(40),X108G_VFOS,RIG_ANT_1), /* AM class */
FRQ_RNG_2m(2,X108G_AM_TX_MODES, W(2),W(20),X108G_VFOS,RIG_ANT_2),
FRQ_RNG_70cm(2,X108G_OTHER_TX_MODES, W(2), W(14), X108G_VFOS, RIG_ANT_2),
RIG_FRNG_END, },
.tuning_steps = {
{X108G_1HZ_TS_MODES,1},
{X108G_NOT_TS_MODES,10},
{X108G_ALL_RX_MODES,Hz(100)},
{X108G_ALL_RX_MODES,kHz(1)},
{X108G_ALL_RX_MODES,kHz(5)},
{X108G_ALL_RX_MODES,kHz(9)},
{X108G_ALL_RX_MODES,kHz(10)},
{X108G_ALL_RX_MODES,kHz(12.5)},
{X108G_ALL_RX_MODES,kHz(20)},
{X108G_ALL_RX_MODES,kHz(25)},
{X108G_ALL_RX_MODES,kHz(100)},
{X108G_NOT_TS_MODES,MHz(1)},
RIG_TS_END,
},
/* mode/filter list, remember: order matters! But duplication may speed up search. Put the most commonly used modes first! Remember these are defaults, with dsp rigs you can change them to anything you want except FM and WFM which are fixed */
.filters = {
{RIG_MODE_SSB, kHz(2.4)},
{RIG_MODE_SSB, kHz(1.8)},
{RIG_MODE_SSB, kHz(3)},
{RIG_MODE_FM, kHz(10)},
{RIG_MODE_FM, kHz(15)},
{RIG_MODE_FM, kHz(7)},
{RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY|RIG_MODE_RTTYR, Hz(500)},
{RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY|RIG_MODE_RTTYR, Hz(250)},
{RIG_MODE_CW|RIG_MODE_CWR, kHz(1.2)},
{RIG_MODE_RTTY|RIG_MODE_RTTYR, kHz(2.4)},
{RIG_MODE_AM, kHz(6)},
{RIG_MODE_AM, kHz(3)},
{RIG_MODE_AM, kHz(9)},
{RIG_MODE_WFM, kHz(280)},
RIG_FLT_END,
},
.str_cal = X108G_STR_CAL,
.cfgparams = icom_cfg_params,
.set_conf = icom_set_conf,
.get_conf = icom_get_conf,
.priv = (void*)&x108g_priv_caps,
.rig_init = icom_init,
.rig_cleanup = icom_cleanup,
.rig_open = NULL,
.rig_close = NULL,
.set_freq = icom_set_freq,
.get_freq = icom_get_freq,
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.set_vfo = icom_set_vfo,
.set_ant = NULL, /*automatically set by rig depending band */
.get_ant = NULL,
.set_rit = icom_set_rit,
.decode_event = icom_decode_event,
.set_level = icom_set_level,
.get_level = icom_get_level,
.set_func = icom_set_func,
.get_func = icom_get_func,
.set_parm = NULL,
.get_parm = NULL,
.set_mem = icom_set_mem,
.set_bank = icom_set_bank,
.vfo_op = icom_vfo_op,
.scan = icom_scan,
.set_ptt = x108g_set_ptt,
.get_ptt = icom_get_ptt,
.get_dcd = icom_get_dcd,
.set_ts = icom_set_ts,
.get_ts = NULL,
.set_rptr_shift = icom_set_rptr_shift,
.get_rptr_shift = NULL,
.set_rptr_offs = icom_set_rptr_offs,
.get_rptr_offs = icom_get_rptr_offs,
.set_ctcss_tone = icom_set_ctcss_tone,
.get_ctcss_tone = icom_get_ctcss_tone,
.set_ctcss_sql = icom_set_ctcss_sql,
.get_ctcss_sql = icom_get_ctcss_sql,
.set_dcs_code = icom_set_dcs_code,
.get_dcs_code = icom_get_dcs_code,
.set_split_freq = x108g_set_split_freq,
.get_split_freq = icom_get_split_freq,
.set_split_mode = x108g_set_split_mode,
.get_split_mode = icom_get_split_mode,
.set_split_vfo = x108g_set_split_vfo,
.get_split_vfo = NULL,
};
/*
* x108g_set_ptt
* Assumes rig!=NULL, rig->state.priv!=NULL
* The response from the x108g isn't quite right at this time
* Eventually they may fix their firmware and we can use the icom_set_split_vfo
*/
int x108g_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
unsigned char ackbuf[MAXFRAMELEN], pttbuf[1];
int ack_len=sizeof(ackbuf), retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
pttbuf[0] = ptt == RIG_PTT_ON ? 1 : 0;
retval = icom_transaction (rig, C_CTL_PTT, S_PTT, pttbuf, 1,
ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
/* X108G doesn't quite follow ICOM protocol -- returns 0x1c instead of 0xfb */
if (ack_len !=3 || ackbuf[0] != 0x1c) {
rig_debug(RIG_DEBUG_ERR,"x108g_set_ptt: ack NG (%#.2x), "
"len=%d, ptt=%d\n", ackbuf[0],ack_len);
return -RIG_ERJCTED;
}
return RIG_OK;
}
/*
* The response from the x108g isn't quite right at this time
* Eventually they may fix their firmware and we can use the icom_set_split_vfo
* x108g_set_split
* Assumes rig!=NULL, rig->state.priv!=NULL
*/
static int x108g_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
{
struct icom_priv_data * priv = (struct icom_priv_data *)rig->state.priv;
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf), rc;
int split_sc;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (split) {
case RIG_SPLIT_OFF:
split_sc = S_SPLT_OFF;
break;
case RIG_SPLIT_ON:
split_sc = S_SPLT_ON;
if (!priv->split_on) {
/* ensure VFO A is Rx and VFO B is Tx as we assume that elsewhere */
if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B)) {
if (RIG_OK != (rc = icom_set_vfo(rig, RIG_VFO_A))) return rc;
}
}
break;
default:
rig_debug(RIG_DEBUG_ERR,"%s: Unsupported split %d", __FUNCTION__, split);
return -RIG_EINVAL;
}
if (RIG_OK != (rc = icom_transaction (rig, C_CTL_SPLT, split_sc, NULL, 0,
ackbuf, &ack_len))) return rc;
if (ack_len != 2 || ackbuf[0] != 0x0f) { // instead of len=1 & ACK
rig_debug(RIG_DEBUG_ERR,"x108g_set_split: ack NG (%#.2x), "
"len=%d\n", ackbuf[0],ack_len);
return -RIG_ERJCTED;
}
priv->split_on = RIG_SPLIT_ON == split;
return RIG_OK;
}
/*
* x108g_set_split_freq
* Assumes rig!=NULL, rig->state.priv!=NULL,
*
* Assumes also that the current VFO is the rx VFO.
*/
static int x108g_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
{
int rc;
vfo_t rx_vfo, tx_vfo;
struct icom_priv_data *priv;
struct rig_state *rs;
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
/* This method works also in memory mode(RIG_VFO_MEM) */
if (!priv->no_xchg && rig_has_vfo_op(rig, RIG_OP_XCHG)) {
if (RIG_OK != (rc = icom_vfo_op(rig, vfo, RIG_OP_XCHG))) return rc;
if (RIG_OK != (rc = icom_set_freq(rig, RIG_VFO_CURR, tx_freq))) return rc;
if (RIG_OK != (rc = icom_vfo_op(rig, vfo, RIG_OP_XCHG))) return rc;
return rc;
}
/* In the case of rigs with an A/B VFO arrangement we assume the
current VFO is VFO A and the split Tx VFO is always VFO B. These
assumptions allow us to deal with the lack of VFO and split
queries */
if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B)
&& priv->split_on) { /* broken if user changes split on rig :( */
/* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */
if (RIG_OK != (rc = icom_transaction (rig, C_CTL_SPLT, S_SPLT_OFF, NULL, 0, ackbuf, &ack_len))) return rc;
if (ack_len != 2 || ackbuf[0] != 0x0f) {
rig_debug(RIG_DEBUG_ERR,"x108g_set_split_freq: ack NG (%#.2x), "
"len=%d\n", ackbuf[0],ack_len);
return -RIG_ERJCTED;
}
}
if (RIG_OK != (rc = icom_get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) return rc;
if (RIG_OK != (rc = rig_set_freq(rig, RIG_VFO_CURR, tx_freq))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, rx_vfo))) return rc;
if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B)
&& priv->split_on) {
/* Re-enable split */
if (RIG_OK != (rc = icom_transaction (rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, &ack_len))) return rc;
}
return rc;
}
/*
* x108g_set_split_mode
* Assumes rig!=NULL, rig->state.priv!=NULL,
*/
static int x108g_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
{
int rc;
vfo_t rx_vfo, tx_vfo;
struct icom_priv_data *priv;
struct rig_state *rs;
unsigned char ackbuf[MAXFRAMELEN];
int ack_len=sizeof(ackbuf);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv;
/* This method works also in memory mode(RIG_VFO_MEM) */
if (!priv->no_xchg && rig_has_vfo_op(rig, RIG_OP_XCHG)) {
if (RIG_OK != (rc = icom_vfo_op(rig, vfo, RIG_OP_XCHG))) return rc;
if (RIG_OK != (rc = rig->caps->set_mode(rig, RIG_VFO_CURR, tx_mode, tx_width))) return rc;
if (RIG_OK != (rc = icom_vfo_op(rig, vfo, RIG_OP_XCHG))) return rc;
return rc;
}
/* In the case of rigs with an A/B VFO arrangement we assume the
current VFO is VFO A and the split Tx VFO is always VFO B. These
assumptions allow us to deal with the lack of VFO and split
queries */
if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B)
&& priv->split_on) { /* broken if user changes split on rig :( */
/* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */
if (RIG_OK != (rc = icom_transaction (rig, C_CTL_SPLT, S_SPLT_OFF, NULL, 0, ackbuf, &ack_len))) return rc;
if (ack_len != 2 || ackbuf[0] != 0x0f) {
rig_debug(RIG_DEBUG_ERR,"x108g_set_split_mode: ack NG (%#.2x), "
"len=%d\n", ackbuf[0],ack_len);
return -RIG_ERJCTED;
}
}
if (RIG_OK != (rc = icom_get_split_vfos(rig, &rx_vfo, &tx_vfo))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) return rc;
if (RIG_OK != (rc = rig->caps->set_mode(rig, RIG_VFO_CURR, tx_mode, tx_width))) return rc;
if (RIG_OK != (rc = icom_set_vfo(rig, rx_vfo))) return rc;
if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B)
&& priv->split_on) {
/* Re-enable split */
if (RIG_OK != (rc = icom_transaction (rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, &ack_len))) return rc;
}
return rc;
}

Wyświetl plik

@ -217,6 +217,7 @@
#define RIG_MODEL_IC7300 RIG_MAKE_MODEL(RIG_ICOM, 73)
#define RIG_MODEL_PERSEUS RIG_MAKE_MODEL(RIG_ICOM, 74)
#define RIG_MODEL_IC785x RIG_MAKE_MODEL(RIG_ICOM, 75)
#define RIG_MODEL_X108G RIG_MAKE_MODEL(RIG_ICOM, 76) /* Xiegu X108 */
/* next one is 77 */
/*