kopia lustrzana https://github.com/Hamlib/Hamlib
Changes to get antenna calls working in rigctld
Change to ic785x.c to get antenna calls working Added automatic detection of # of antennas for Icom rigs Note that rig_get_ant returns a zero-based antenna# and not RIG_ANT1/2/3/4.... rig_set_ant on the other hand takes RIG_ANT1/2/3/4 as the argument for antenna These RIG_ANT settings are a bit mask This may have to be converted in the rig back end to whatever the rig expectspull/193/head
rodzic
42108f9638
commit
60215785e1
|
@ -1736,14 +1736,24 @@ static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
|
||||||
char cmd[CMD_MAX];
|
char cmd[CMD_MAX];
|
||||||
char buf[BUF_MAX];
|
char buf[BUF_MAX];
|
||||||
char vfostr[6] = "";
|
char vfostr[6] = "";
|
||||||
|
int i_ant = 0;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x, option=%d\n", __func__, ant, option.i);
|
||||||
|
|
||||||
|
switch(ant) {
|
||||||
|
case RIG_ANT_1: i_ant = 0; break;
|
||||||
|
case RIG_ANT_2: i_ant = 1; break;
|
||||||
|
case RIG_ANT_3: i_ant = 2; break;
|
||||||
|
case RIG_ANT_4: i_ant = 3; break;
|
||||||
|
default:
|
||||||
|
rig_debug(RIG_DEBUG_ERR,"%s: more than 4 antennas? ant=0x%02x\n", __func__, ant);
|
||||||
|
}
|
||||||
|
|
||||||
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
||||||
|
|
||||||
if (ret != RIG_OK) { return ret; }
|
if (ret != RIG_OK) { return ret; }
|
||||||
|
|
||||||
len = sprintf(cmd, "Y%s %d %d\n", vfostr, ant, option.i);
|
len = sprintf(cmd, "Y%s %d %d\n", vfostr, i_ant, option.i);
|
||||||
|
|
||||||
ret = netrigctl_transaction(rig, cmd, len, buf);
|
ret = netrigctl_transaction(rig, cmd, len, buf);
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,7 @@ static struct icom_priv_caps ic785x_priv_caps =
|
||||||
.civ_731_mode = 0, /* 731 mode */
|
.civ_731_mode = 0, /* 731 mode */
|
||||||
.no_xchg = 0, /* no XCHG */
|
.no_xchg = 0, /* no XCHG */
|
||||||
.antack_len = 3,
|
.antack_len = 3,
|
||||||
|
// .ant_count = 4, // disabled for test automatic detection
|
||||||
.ts_sc_list = ic756pro_ts_sc_list,
|
.ts_sc_list = ic756pro_ts_sc_list,
|
||||||
.agc_levels_present = 1,
|
.agc_levels_present = 1,
|
||||||
.agc_levels = {
|
.agc_levels = {
|
||||||
|
|
|
@ -673,7 +673,7 @@ int icom_get_usb_echo_off(RIG *rig)
|
||||||
// Check for echo on first
|
// Check for echo on first
|
||||||
priv->serial_USB_echo_off = 0;
|
priv->serial_USB_echo_off = 0;
|
||||||
retval = icom_transaction(rig, C_RD_FREQ, -1, NULL, 0, ackbuf, &ack_len);
|
retval = icom_transaction(rig, C_RD_FREQ, -1, NULL, 0, ackbuf, &ack_len);
|
||||||
|
return RIG_OK;
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected\n",
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected\n",
|
||||||
|
@ -5295,6 +5295,28 @@ int icom_set_bank(RIG *rig, vfo_t vfo, int bank)
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* gets the number of antennas detected by querying them until it fails */
|
||||||
|
static int icom_get_ant_count(RIG *rig)
|
||||||
|
{
|
||||||
|
struct icom_priv_caps *priv_caps = (struct icom_priv_caps *)
|
||||||
|
rig->caps->priv;
|
||||||
|
// we only need to do this once if we haven't done it yet
|
||||||
|
if (priv_caps->ant_count == 0) {
|
||||||
|
ant_t tmp_ant;
|
||||||
|
value_t tmp_option;
|
||||||
|
int retval;
|
||||||
|
do {
|
||||||
|
retval = rig_get_ant(rig, RIG_VFO_CURR, &tmp_ant, &tmp_option);
|
||||||
|
if (retval == RIG_OK) {
|
||||||
|
++priv_caps->ant_count;
|
||||||
|
rig_debug(RIG_DEBUG_TRACE,"%s: found ant#%d\n", __func__, priv_caps->ant_count);
|
||||||
|
}
|
||||||
|
} while(retval == RIG_OK);
|
||||||
|
}
|
||||||
|
rig_debug(RIG_DEBUG_TRACE,"%s: ant_count=%d\n", __func__, priv_caps->ant_count);
|
||||||
|
return priv_caps->ant_count;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* icom_set_ant
|
* icom_set_ant
|
||||||
* Assumes rig!=NULL, rig->state.priv!=NULL
|
* Assumes rig!=NULL, rig->state.priv!=NULL
|
||||||
|
@ -5308,11 +5330,15 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
|
||||||
const struct icom_priv_caps *priv_caps = (const struct icom_priv_caps *)
|
const struct icom_priv_caps *priv_caps = (const struct icom_priv_caps *)
|
||||||
rig->caps->priv;
|
rig->caps->priv;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x, option=%d\n", __func__, ant, option.i);
|
||||||
|
// query the antennas once and find out how many we have
|
||||||
/*
|
icom_get_ant_count(rig);
|
||||||
* TODO: IC-756* and [RX ANT]
|
if (ant >= rig_idx2setting(priv_caps->ant_count)) {
|
||||||
*/
|
return -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
if (ant > RIG_ANT_4) {
|
||||||
|
return -RIG_EDOM;
|
||||||
|
}
|
||||||
switch (ant)
|
switch (ant)
|
||||||
{
|
{
|
||||||
case RIG_ANT_1:
|
case RIG_ANT_1:
|
||||||
|
@ -5336,6 +5362,7 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (priv_caps->antack_len == 0) { // we need to find out the antack_len
|
if (priv_caps->antack_len == 0) { // we need to find out the antack_len
|
||||||
ant_t tmp_ant;
|
ant_t tmp_ant;
|
||||||
value_t tmp_option;
|
value_t tmp_option;
|
||||||
|
@ -5345,6 +5372,7 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some rigs have 3-byte ant cmd so there is an option to be set
|
// Some rigs have 3-byte ant cmd so there is an option to be set
|
||||||
if (priv_caps->antack_len == 3)
|
if (priv_caps->antack_len == 3)
|
||||||
{
|
{
|
||||||
|
@ -5429,7 +5457,7 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option)
|
||||||
return -RIG_ERJCTED;
|
return -RIG_ERJCTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ant = RIG_ANT_N(ackbuf[1]);
|
*ant = ackbuf[1];
|
||||||
|
|
||||||
// Note: with IC756/IC-756Pro/IC-7800 and more, ackbuf[2] deals with [RX ANT]
|
// Note: with IC756/IC-756Pro/IC-7800 and more, ackbuf[2] deals with [RX ANT]
|
||||||
// Hopefully any ack_len=3 can fit in the option field
|
// Hopefully any ack_len=3 can fit in the option field
|
||||||
|
|
Ładowanie…
Reference in New Issue