/* * r7000_set_freq */ static int r7000_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { long long f = (long long)freq; /* * The R7000 cannot set freqencies higher than 1GHz, * this is done by flipping a switch on the front panel and * stripping the most significant digit. * This is the only change with the common icom_set_freq */ f %= (long long)GHz(1); return icom_set_freq(rig, vfo, (freq_t)f); }
static int ic910_set_freq(RIG* rig, vfo_t vfo, freq_t freq) { int retval; freq_t otherfreq; freq_t oldfreq; if (vfo==RIG_VFO_CURR) { /* try to detect active subband */ retval=icom_get_freq(rig, RIG_VFO_CURR, &oldfreq); if (retval!=RIG_OK) return retval; icom_set_vfo(rig, RIG_VFO_SUB); retval=icom_get_freq(rig, RIG_VFO_CURR, &otherfreq); if (retval!=RIG_OK) return retval; if (otherfreq == oldfreq) { /* were already in subband */ vfo = RIG_VFO_SUB; icom_set_vfo(rig, RIG_VFO_MAIN); retval=icom_get_freq(rig, RIG_VFO_CURR, &otherfreq); if (retval!=RIG_OK) return retval; } else { /* we were in mainband */ vfo = RIG_VFO_MAIN; } } else { /* get the freq of the other band */ if (vfo==RIG_VFO_MAIN) icom_set_vfo(rig, RIG_VFO_SUB); else icom_set_vfo(rig, RIG_VFO_MAIN); retval=icom_get_freq(rig, RIG_VFO_CURR, &otherfreq); if (retval!=RIG_OK) return retval; } if (compareFrequencies(rig, freq, otherfreq) == 0) icom_swap_bands(rig); icom_set_vfo(rig, vfo); return icom_set_freq(rig, RIG_VFO_CURR, freq); }
static int ic910_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { int retval; freq_t otherfreq; freq_t origfreq; if ((retval = icom_get_freq(rig, RIG_VFO_CURR, &origfreq)) != RIG_OK) return retval; if (compareFrequencies (rig, freq, origfreq)) { /* correct band already */ if (RIG_VFO_A == vfo || RIG_VFO_B == vfo) { /* switch to desired VFO and read its frequency */ if ((retval = icom_set_vfo (rig, vfo)) != RIG_OK) return retval; if ((retval = icom_get_freq(rig, vfo, &otherfreq)) != RIG_OK) return retval; retval = icom_set_freq (rig, RIG_VFO_CURR, freq); if (otherfreq != origfreq) { /* swap VFOs back as original was the other one */ icom_set_vfo (rig, RIG_VFO_A == vfo ? RIG_VFO_B : RIG_VFO_A); } } else if (RIG_VFO_MAIN == vfo || RIG_VFO_SUB == vfo) { /* switch to the desired of MAIN and SUB and read its frequency */ if ((retval = icom_set_vfo (rig, vfo)) != RIG_OK) return retval; if ((retval = icom_get_freq(rig, vfo, &otherfreq)) != RIG_OK) return retval; if (otherfreq != origfreq) { /* started on a different so band exchange MAIN and SUB */ if ((retval = icom_vfo_op(rig, RIG_VFO_CURR, RIG_OP_XCHG)) != RIG_OK) return retval; retval = icom_set_freq (rig, RIG_VFO_CURR, freq); /* swap MAIN/SUB back as original was the other one */ icom_set_vfo (rig, RIG_VFO_MAIN == vfo ? RIG_VFO_SUB : RIG_VFO_MAIN); } else { /* already correct one of MAIN and SUB */ retval = icom_set_freq (rig, RIG_VFO_CURR, freq); } } else if (RIG_VFO_CURR == vfo) { retval = icom_set_freq (rig, RIG_VFO_CURR, freq); } else retval = -RIG_EVFO; } else { /* wrong band */ if (RIG_VFO_A == vfo || RIG_VFO_B == vfo) { /* try and set frequency, may fail if band is already on other of MAIN/SUB */ retval = icom_set_freq (rig, RIG_VFO_CURR, freq); if (-RIG_ERJCTED == retval) { /* exchange MAIN & SUB */ if ((retval = icom_vfo_op(rig, RIG_VFO_CURR, RIG_OP_XCHG)) != RIG_OK) return retval; if ((retval = icom_get_freq(rig, vfo, &origfreq)) != RIG_OK) return retval; if ((retval = icom_set_vfo (rig, vfo)) != RIG_OK) return retval; if ((retval = icom_get_freq(rig, vfo, &otherfreq)) != RIG_OK) return retval; retval = icom_set_freq (rig, RIG_VFO_CURR, freq); if (-RIG_ERJCTED == retval) { /* band not fitted so swap MAIN & SUB back and give up */ icom_vfo_op(rig, RIG_VFO_CURR, RIG_OP_XCHG); return retval; } else if (retval != RIG_OK) return retval; if (otherfreq != origfreq) { /* swap VFOs back as original was the other one */ icom_set_vfo (rig, RIG_VFO_A == vfo ? RIG_VFO_B : RIG_VFO_A); } /* we do not exchange bands back as this is taken to mean set VFOA/B on MAIN to the specified frequency as Hamlib does not recognize A on MAIN or B on SUB etc. This is probably reasonable since we cannot Tx on SUB */ return retval; } /* we changed band to the "third band" which always makes VFO A current so just make the requested one the specified frequency as well if it is VFO B. There is no way of going to the "third band" without changing VFO A */ if (RIG_VFO_B == vfo) { if ((retval = icom_set_vfo (rig, vfo)) != RIG_OK) return retval; retval = icom_set_freq (rig, RIG_VFO_CURR, freq); icom_set_vfo (rig, RIG_VFO_A); } } else if (RIG_VFO_MAIN == vfo || RIG_VFO_SUB == vfo) { if ((retval = icom_set_vfo (rig, vfo)) != RIG_OK) return retval; if ((retval = icom_get_freq(rig, vfo, &otherfreq)) != RIG_OK) return retval; retval = icom_set_freq (rig, RIG_VFO_CURR, freq); if (-RIG_ERJCTED == retval) { /* required band is on other of MAIN or SUB */ if ((retval = icom_vfo_op(rig, RIG_VFO_CURR, RIG_OP_XCHG)) != RIG_OK) return retval; retval = icom_set_freq (rig, RIG_VFO_CURR, freq); } else if (retval != RIG_OK) return retval; if (otherfreq != origfreq) { /* started on other of MAIN & SUB so switch back */ icom_set_vfo (rig, RIG_VFO_MAIN == vfo ? RIG_VFO_SUB : RIG_VFO_MAIN); } } else if (RIG_VFO_CURR == vfo) { retval = icom_set_freq (rig, RIG_VFO_CURR, freq); if (-RIG_ERJCTED == retval) { /* exchange MAIN & SUB */ if ((retval = icom_vfo_op(rig, RIG_VFO_CURR, RIG_OP_XCHG)) != RIG_OK) return retval; retval = icom_set_freq (rig, RIG_VFO_CURR, freq); if (-RIG_ERJCTED == retval) { /* band not fitted so swap MAIN & SUB back and give up */ icom_vfo_op(rig, RIG_VFO_CURR, RIG_OP_XCHG); return retval; } } } else retval = -RIG_EVFO; } return retval; }