Merge branch 'ic910-set-freq' of git://git.code.sf.net/u/bsomervi/hamlib

Fix a logic error in band detection during IC-910 set frequency.
libusb-1-0
Nate Bargmann 2016-01-20 21:26:56 -06:00
commit 1f8f4510dd
1 zmienionych plików z 36 dodań i 33 usunięć

Wyświetl plik

@ -134,46 +134,49 @@ static int icom_swap_bands(RIG* rig) {
static int ic910_set_freq(RIG* rig, vfo_t vfo, freq_t freq) static int ic910_set_freq(RIG* rig, vfo_t vfo, freq_t freq)
{ {
int retval; int retval;
freq_t otherfreq; freq_t otherfreq;
freq_t oldfreq; freq_t oldfreq;
if (vfo==RIG_VFO_CURR) { retval=icom_get_freq(rig, vfo, &oldfreq);
/* try to detect active subband */ if (retval!=RIG_OK) return retval;
retval=icom_get_freq(rig, RIG_VFO_CURR, &oldfreq);
if (retval!=RIG_OK) return retval;
icom_set_vfo(rig, RIG_VFO_SUB); if (!compareFrequencies(rig, freq, oldfreq)) {
/* we are on the wrong band */
if (vfo==RIG_VFO_CURR) {
/* try to detect active subband */
icom_set_vfo(rig, RIG_VFO_SUB);
retval=icom_get_freq(rig, RIG_VFO_CURR, &otherfreq); retval=icom_get_freq(rig, RIG_VFO_CURR, &otherfreq);
if (retval!=RIG_OK) return retval; if (retval!=RIG_OK) return retval;
if (otherfreq == oldfreq) { if (otherfreq == oldfreq) {
/* were already in subband */ /* were already in subband */
vfo = RIG_VFO_SUB; vfo = RIG_VFO_SUB;
icom_set_vfo(rig, RIG_VFO_MAIN); icom_set_vfo(rig, RIG_VFO_MAIN);
retval=icom_get_freq(rig, RIG_VFO_CURR, &otherfreq); retval=icom_get_freq(rig, RIG_VFO_CURR, &otherfreq);
if (retval!=RIG_OK) return retval; if (retval!=RIG_OK) return retval;
} else { } else {
/* we were in mainband */ /* we were in mainband */
vfo = RIG_VFO_MAIN; vfo = RIG_VFO_MAIN;
} }
} else { } else {
/* get the freq of the other band */ /* get the freq of the other band */
if (vfo==RIG_VFO_MAIN) if (vfo==RIG_VFO_MAIN)
icom_set_vfo(rig, RIG_VFO_SUB); icom_set_vfo(rig, RIG_VFO_SUB);
else else
icom_set_vfo(rig, RIG_VFO_MAIN); icom_set_vfo(rig, RIG_VFO_MAIN);
retval=icom_get_freq(rig, RIG_VFO_CURR, &otherfreq); retval=icom_get_freq(rig, RIG_VFO_CURR, &otherfreq);
if (retval!=RIG_OK) return retval; if (retval!=RIG_OK) return retval;
} }
if (compareFrequencies(rig, freq, otherfreq) == 0) if (compareFrequencies(rig, freq, otherfreq))
icom_swap_bands(rig); icom_swap_bands(rig);
icom_set_vfo(rig, vfo); icom_set_vfo(rig, vfo);
return icom_set_freq(rig, RIG_VFO_CURR, freq); }
return icom_set_freq(rig, RIG_VFO_CURR, freq);
} }
/* /*