diff --git a/adat/adat.c b/adat/adat.c index dce6181b5..90434387f 100644 --- a/adat/adat.c +++ b/adat/adat.c @@ -2962,10 +2962,12 @@ int adat_set_mode(RIG *pRig, vfo_t vfo, rmode_t mode, pbwidth_t width) pPriv->nRIGMode = mode; nRC = adat_vfo_rnr2anr(vfo, &(pPriv->nCurrentVFO)); - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(pRig, mode); + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal(pRig, mode); - pPriv->nWidth = width; + pPriv->nWidth = width; + } nRC = adat_transaction(pRig, &adat_cmd_list_set_mode); } diff --git a/alinco/alinco.c b/alinco/alinco.c index f6069c939..0d1609843 100644 --- a/alinco/alinco.c +++ b/alinco/alinco.c @@ -292,6 +292,8 @@ int alinco_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (retval != RIG_OK) return retval; + if (width == RIG_PASSBAND_NOCHANGE) return retval; + /* * TODO: please DX77 owners, check this, I'm not sure * which passband is default! diff --git a/aor/aor.c b/aor/aor.c index 3c20612d4..54674fb02 100644 --- a/aor/aor.c +++ b/aor/aor.c @@ -299,55 +299,57 @@ int format8k_mode(RIG *rig, char *buf, rmode_t mode, pbwidth_t width) switch (mode) { case RIG_MODE_AM: - if (rig->caps->rig_model == RIG_MODEL_AR8000) - { - aormode = AR8K_AM; - } - else - { - switch(width) { - case RIG_PASSBAND_NORMAL: - case s_kHz(9): aormode = AR8K_AM; break; + if (rig->caps->rig_model == RIG_MODEL_AR8000) + { + aormode = AR8K_AM; + } + else + { + switch(width) { + case RIG_PASSBAND_NORMAL: + case s_kHz(9): aormode = AR8K_AM; break; - case s_kHz(12): aormode = AR8K_WAM; break; - case s_kHz(3): aormode = AR8K_NAM; break; - default: - rig_debug(RIG_DEBUG_ERR, - "%s: unsupported passband %d %d\n", - __FUNCTION__, - mode, width); - return -RIG_EINVAL; - } - } + case s_kHz(12): aormode = AR8K_WAM; break; + case s_kHz(3): aormode = AR8K_NAM; break; + case RIG_PASSBAND_NOCHANGE: aormode = AR8K_AM; break; + default: + rig_debug(RIG_DEBUG_ERR, + "%s: unsupported passband %d %d\n", + __FUNCTION__, + mode, width); + return -RIG_EINVAL; + } + } break; case RIG_MODE_CW: aormode = AR8K_CW; break; case RIG_MODE_USB: aormode = AR8K_USB; break; case RIG_MODE_LSB: aormode = AR8K_LSB; break; case RIG_MODE_WFM: aormode = AR8K_WFM; break; case RIG_MODE_FM: - if (rig->caps->rig_model == RIG_MODEL_AR8000) - { - aormode = AR8K_NFM; - } - else - { - switch(width) { - case RIG_PASSBAND_NORMAL: - case s_kHz(12): aormode = AR8K_NFM; break; + if (rig->caps->rig_model == RIG_MODEL_AR8000) + { + aormode = AR8K_NFM; + } + else + { + switch(width) { + case RIG_PASSBAND_NORMAL: + case s_kHz(12): aormode = AR8K_NFM; break; - case s_kHz(9): aormode = AR8K_SFM; break; - default: - rig_debug(RIG_DEBUG_ERR, - "%s: unsupported passband %d %d\n", - __FUNCTION__, - mode, width); - return -RIG_EINVAL; - } - } + case s_kHz(9): aormode = AR8K_SFM; break; + case RIG_PASSBAND_NOCHANGE: aormode = AR8K_NFM; break; + default: + rig_debug(RIG_DEBUG_ERR, + "%s: unsupported passband %d %d\n", + __FUNCTION__, + mode, width); + return -RIG_EINVAL; + } + } break; default: rig_debug(RIG_DEBUG_ERR,"%s: unsupported mode %d\n", - __FUNCTION__, mode); + __FUNCTION__, mode); return -RIG_EINVAL; } diff --git a/aor/ar3030.c b/aor/ar3030.c index 3905726d5..cc060f150 100644 --- a/aor/ar3030.c +++ b/aor/ar3030.c @@ -379,9 +379,14 @@ int ar3030_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - mdbuf_len = sprintf(mdbuf, "%dB%c" EOM, - width < rig_passband_normal(rig,mode) ? 1 : 0, - aormode); + if (width != RIG_PASSBAND_NOCHANGE) { + mdbuf_len = sprintf(mdbuf, "%c" EOM, aormode); + } + else { + mdbuf_len = sprintf(mdbuf, "%dB%c" EOM, + width < rig_passband_normal(rig,mode) ? 1 : 0, + aormode); + } retval = ar3030_transaction (rig, mdbuf, mdbuf_len, NULL, NULL); return retval; diff --git a/aor/ar5000.c b/aor/ar5000.c index e2ea4a677..3a0979e35 100644 --- a/aor/ar5000.c +++ b/aor/ar5000.c @@ -396,9 +396,9 @@ const struct rig_caps ar5000a_caps = { int format5k_mode(RIG *rig, char *buf, rmode_t mode, pbwidth_t width) { - int aormode, aorwidth; + int aormode, aorwidth; - switch (mode) { + switch (mode) { case RIG_MODE_AM: aormode = AR5K_AM; break; case RIG_MODE_WFM: case RIG_MODE_FM: aormode = AR5K_FM; break; @@ -409,29 +409,34 @@ int format5k_mode(RIG *rig, char *buf, rmode_t mode, pbwidth_t width) case RIG_MODE_SAL: aormode = AR5K_SAL; break; case RIG_MODE_SAH: aormode = AR5K_SAH; break; default: - rig_debug(RIG_DEBUG_ERR,"%s: unsupported mode %d\n", - __FUNCTION__, mode); - return -RIG_EINVAL; - } + rig_debug(RIG_DEBUG_ERR,"%s: unsupported mode %d\n", + __FUNCTION__, mode); + return -RIG_EINVAL; + } + if (width != RIG_PASSBAND_NOCHANGE) { if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); + width = rig_passband_normal(rig, mode); switch (width) { - case 500: aorwidth = '0'; break; - case s_kHz(3): aorwidth = '1'; break; - case s_kHz(6): aorwidth = '2'; break; - case s_kHz(15): aorwidth = '3'; break; - case s_kHz(30): aorwidth = '4'; break; - case s_kHz(110): aorwidth = '5'; break; - case s_kHz(220): aorwidth = '6'; break; - default: - rig_debug(RIG_DEBUG_ERR,"%s: unsupported width %d\n", - __FUNCTION__, width); - return -RIG_EINVAL; + case 500: aorwidth = '0'; break; + case s_kHz(3): aorwidth = '1'; break; + case s_kHz(6): aorwidth = '2'; break; + case s_kHz(15): aorwidth = '3'; break; + case s_kHz(30): aorwidth = '4'; break; + case s_kHz(110): aorwidth = '5'; break; + case s_kHz(220): aorwidth = '6'; break; + default: + rig_debug(RIG_DEBUG_ERR,"%s: unsupported width %d\n", + __FUNCTION__, width); + return -RIG_EINVAL; } return sprintf(buf, "MD%c BW%c", aormode, aorwidth); + } + else { + return sprintf(buf, "MD%c", aormode); + } } diff --git a/aor/ar7030.c b/aor/ar7030.c index fb7b04999..569cf25e1 100644 --- a/aor/ar7030.c +++ b/aor/ar7030.c @@ -364,6 +364,8 @@ static int ar7030_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } + if (RIG_PASSBAND_NOCHANGE == width) return RIG_OK; + if (width == RIG_PASSBAND_NORMAL) width = rig_passband_normal(rig, mode); diff --git a/aor/ar7030p.c b/aor/ar7030p.c index 062eaf38a..ae2f5e472 100644 --- a/aor/ar7030p.c +++ b/aor/ar7030p.c @@ -572,46 +572,46 @@ static int ar7030p_set_mode( RIG * rig, vfo_t vfo, rmode_t mode, rc = lockRx( rig, LOCK_1 ); if ( RIG_OK == rc ) - { - /* TODO - deal with selected VFO */ - ar_mode = modeToNative( mode ); - - rc = writeByte( rig, WORKING, MODE, ar_mode ); - if ( RIG_OK == rc ) { - if ( RIG_PASSBAND_NORMAL == width ) - { - width = rig_passband_normal( rig, mode ); - } - else - { - /* TODO - get filter BWs at startup */ - ar_filter = (unsigned char) 6; - for ( i = 1; i <= 6; i++ ) - { - if ( width <= filterTab[ i ] ) - { - if ( filterTab[ i ] < filterTab[ (int) ar_filter ] ) - { - ar_filter = (unsigned char) i; - } - } + /* TODO - deal with selected VFO */ + ar_mode = modeToNative( mode ); - rig_debug( RIG_DEBUG_VERBOSE, "%s: width %d ar_filter %d filterTab[%d] %d\n", - __func__, width, ar_filter, i, filterTab[i] ); - } - } + rc = writeByte( rig, WORKING, MODE, ar_mode ); + if ( RIG_OK == rc && width != RIG_PASSBAND_NOCHANGE ) + { + if ( RIG_PASSBAND_NORMAL == width ) + { + width = rig_passband_normal( rig, mode ); + } + else + { + /* TODO - get filter BWs at startup */ + ar_filter = (unsigned char) 6; + for ( i = 1; i <= 6; i++ ) + { + if ( width <= filterTab[ i ] ) + { + if ( filterTab[ i ] < filterTab[ (int) ar_filter ] ) + { + ar_filter = (unsigned char) i; + } + } - rc = writeByte( rig, WORKING, FILTER, ar_filter ); - if ( RIG_OK == rc ) - { - rc = execRoutine( rig, SET_ALL ); - } + rig_debug( RIG_DEBUG_VERBOSE, "%s: width %d ar_filter %d filterTab[%d] %d\n", + __func__, width, ar_filter, i, filterTab[i] ); + } + } + + rc = writeByte( rig, WORKING, FILTER, ar_filter ); + if ( RIG_OK == rc ) + { + rc = execRoutine( rig, SET_ALL ); + } + } + + rc = lockRx( rig, LOCK_0 ); } - rc = lockRx( rig, LOCK_0 ); - } - return( rc ); } diff --git a/aor/sr2200.c b/aor/sr2200.c index 1e088ab53..05658d5bf 100644 --- a/aor/sr2200.c +++ b/aor/sr2200.c @@ -370,15 +370,21 @@ int sr2200_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) normal_width = rig_passband_normal(rig, mode); - if (width == 0) + if (width == RIG_PASSBAND_NORMAL) width = normal_width; switch (mode) { - case RIG_MODE_AM: aormode = width > normal_width ? - SR2200_WAM : SR2200_AM; break; - case RIG_MODE_FM: aormode = width < normal_width ? - SR2200_SFM : SR2200_FM; break; - case RIG_MODE_WFM: aormode = SR2200_WFM; break; + case RIG_MODE_AM: + aormode = width > normal_width ? + SR2200_WAM : SR2200_AM; + break; + case RIG_MODE_FM: + aormode = width >= normal_width ? + SR2200_FM : SR2200_SFM; + break; + case RIG_MODE_WFM: + aormode = SR2200_WFM; + break; default: rig_debug(RIG_DEBUG_ERR,"%s: unsupported mode %d\n", __FUNCTION__,mode); diff --git a/doc/utility_programs.texi b/doc/utility_programs.texi index d14b6bc6c..bf93de5bd 100644 --- a/doc/utility_programs.texi +++ b/doc/utility_programs.texi @@ -519,7 +519,9 @@ Set @var{Mode} to one of: @code{USB}, @code{LSB}, @code{CW}, @code{SAH}, @code{DSB}. Set @var{Passband} frequency in Hertz, or @code{0} for the Hamlib -backend default. +backend default. A value of @code{-1} may be passed which leaves the +rig passband unchanged from the current or default value for the mode +as defined by the rig. @strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of @var{Mode} will return a space separated list of radio @@ -677,12 +679,16 @@ Get @var{DCS Sql} code. @item I, set_split_freq @var{Tx Frequency} Set @var{TX Frequency}, in Hertz for ``split'' frequency operation. + +See also @command{set_split_freq_mode} below. @ifhtml @* @end ifhtml @item i, get_split_freq Get @var{TX Frequency}, in Hertz for ``split'' frequency operation. + +See also @command{get_split_freq_mode} below. @ifhtml @* @end ifhtml @@ -695,19 +701,75 @@ Set @var{TX Mode} to one of: @code{AM}, @code{FM}, @code{CW}, @code{SAH}, @code{DSB}. The @var{TX Passband} is the exact passband frequency in Hertz, or -@code{0} for the Hamlib backend default. +@code{0} for the Hamlib backend default. A value of @code{-1} may be +passed which leaves the rig passband unchanged from the current or +default value for the mode as defined by the rig. @strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of @var{TX Mode} will return a space separated list of radio backend supported TX Modes. Use this to determine the supported TX Modes of a given radio backend. +See also @command{set_split_freq_mode} below. +@ifhtml +@* +@end ifhtml + @item x, get_split_mode Get @var{TX Mode}, @var{TX Passband}. Returns TX mode as a string from @command{set_split_mode} above and TX passband in Hz. +See also @command{get_split_freq_mode} below. +@ifhtml +@* +@end ifhtml + +@item K, set_split_freq_mode @var{Tx Frequency}, @var{TX Mode}, @var{TX Passband} +Set @var{TX Frequency}, in Hertz for ``split'' frequency operation. +Set @var{TX Mode} to one of: @code{AM}, @code{FM}, @code{CW}, +@code{CWR}, @code{USB}, @code{LSB}, @code{RTTY}, @code{RTTYR}, +@code{WFM}, @code{AMS}, @code{PKTLSB}, @code{PKTUSB}, @code{PKTFM}, +@code{ECSSUSB}, @code{ECSSLSB}, @code{FAX}, @code{SAM}, @code{SAL}, +@code{SAH}, @code{DSB}. + +The @var{TX Passband} is the exact passband frequency in Hertz, or +@code{0} for the Hamlib backend default. A value of @code{-1} may be +passed which leaves the rig passband unchanged from the current or +default value for the mode as defined by the rig. + +This is a convenience function that combines the effect of +@command{set_split_freq} and @command{set_split_mode}. It should be +used when both are required since it allows the back end to optimize +the operations. For example on many Icom rigs the current VFO must be +changed temporarily while executing these commands and that can +disrupt receive or transmit, using this function may minimize that +disruption. + +See also @command{set_split_freq} and @command{set_split_mode} above. +@ifhtml +@* +@end ifhtml + +@item k, get_split_freq_mode +Get @var{TX Frequency}, in Hertz for ``split'' frequency operation +along with The @var{TX Mode} as a string from @command{set_split_mode} +above and @var{TX Passband} in Hz. + +This is a convenience function that combines the effect of +@command{get_split_freq} and @command{get_split_mode}. It should be +used when both are required since it allows the back end to optimize +the operations. For example on many Icom rigs the current VFO must be +changed temporarily while executing these commands and that can +disrupt receive or transmit, using this function may minimize that +disruption. + +See also @command{get_split_freq} and @command{get_split_mode} above. +@ifhtml +@* +@end ifhtml + @item S, set_split_vfo @var{Split}, @var{TX VFO} Set @var{Split} mode, @code{0} (off) or @code{1} (on), and @var{TX VFO} from @command{set_vfo} above. @@ -2104,12 +2166,16 @@ Get @var{DCS Sql} code. @item I, set_split_freq @var{Tx Frequency} Set @var{TX Frequency}, in Hertz for ``split'' frequency operation. + +See also @command{set_split_freq_mode} below. @ifhtml @* @end ifhtml @item i, get_split_freq Get @var{TX Frequency}, in Hertz for ``split'' frequency operation. + +See also @command{get_split_freq_mode} below. @ifhtml @* @end ifhtml @@ -2122,19 +2188,75 @@ Set @var{TX Mode} to one of: @code{AM}, @code{FM}, @code{CW}, @code{SAH}, @code{DSB}. The @var{TX Passband} is the exact passband frequency in Hertz, or -@code{0} for the Hamlib backend default. +@code{0} for the Hamlib backend default. A value of @code{-1} may be +passed which leaves the rig passband unchanged from the current or +default value for the mode as defined by the rig. @strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of @var{TX Mode} will return a space separated list of radio backend supported TX Modes. Use this to determine the supported TX Modes of a given radio backend. +See also @command{set_split_freq_mode} below. +@ifhtml +@* +@end ifhtml + @item x, get_split_mode Get @var{TX Mode}, @var{TX Passband}. Returns TX mode as a string from @command{set_split_mode} above and TX passband in Hz. +See also @command{get_split_freq_mode} below. +@ifhtml +@* +@end ifhtml + +@item K, set_split_freq_mode @var{Tx Frequency}, @var{TX Mode}, @var{TX Passband} +Set @var{TX Frequency}, in Hertz for ``split'' frequency operation. +Set @var{TX Mode} to one of: @code{AM}, @code{FM}, @code{CW}, +@code{CWR}, @code{USB}, @code{LSB}, @code{RTTY}, @code{RTTYR}, +@code{WFM}, @code{AMS}, @code{PKTLSB}, @code{PKTUSB}, @code{PKTFM}, +@code{ECSSUSB}, @code{ECSSLSB}, @code{FAX}, @code{SAM}, @code{SAL}, +@code{SAH}, @code{DSB}. + +The @var{TX Passband} is the exact passband frequency in Hertz, or +@code{0} for the Hamlib backend default. A value of @code{-1} may be +passed which leaves the rig passband unchanged from the current or +default value for the mode as defined by the rig. + +This is a convenience function that combines the effect of +@command{set_split_freq} and @command{set_split_mode}. It should be +used when both are required since it allows the back end to optimize +the operations. For example on many Icom rigs the current VFO must be +changed temporarily while executing these commands and that can +disrupt receive or transmit, using this function may minimize that +disruption. + +See also @command{set_split_freq} and @command{set_split_mode} above. +@ifhtml +@* +@end ifhtml + +@item k, get_split_freq_mode +Get @var{TX Frequency}, in Hertz for ``split'' frequency operation +along with the @var{TX Mode} as a string from @command{set_split_mode} +above and @var{TX Passband} in Hz. + +This is a convenience function that combines the effect of +@command{get_split_freq} and @command{get_split_mode}. It should be +used when both are required since it allows the back end to optimize +the operations. For example on many Icom rigs the current VFO must be +changed temporarily while executing these commands and that can +disrupt receive or transmit, using this function may minimize that +disruption. + +See also @command{get_split_freq} and @command{get_split_mode} above. +@ifhtml +@* +@end ifhtml + @item S, set_split_vfo @var{Split}, @var{TX VFO} Set @var{Split} mode, @code{0} (off) or @code{1} (on), and @var{TX VFO} from @command{set_vfo} above. diff --git a/drake/drake.c b/drake/drake.c index 16563c3ac..68abcedd6 100644 --- a/drake/drake.c +++ b/drake/drake.c @@ -290,30 +290,31 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (retval != RIG_OK) return retval; - if (mode != RIG_MODE_FM) { + if (width != RIG_PASSBAND_NOCHANGE) { + if (mode != RIG_MODE_FM) { - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal(rig, mode); - switch (width) { - case 500: width_sel = '0'; break; + if (width <= 500) { + width_sel = '0'; + } + else if (width <= 1800) { + width_sel = '1'; + } + else if (width <= 2300) { + width_sel = '2'; + } + else if (width <= 4000) { + width_sel = '4'; + } + else { + width_sel = '6'; + } - case 1800: width_sel = '1'; break; - - case 2300: width_sel = '2'; break; - - case 4000: width_sel = '4'; break; - - case 6000: width_sel = '6'; break; - - default: - rig_debug(RIG_DEBUG_ERR, "drake_set_mode: " - "unsupported width %d\n", width); - return -RIG_EINVAL; + mdbuf_len = sprintf((char *) mdbuf, "W%c" EOM, width_sel); + retval = drake_transaction(rig, (char *) mdbuf, mdbuf_len, (char *) ackbuf, &ack_len); } - - mdbuf_len = sprintf((char *) mdbuf, "W%c" EOM, width_sel); - retval = drake_transaction(rig, (char *) mdbuf, mdbuf_len, (char *) ackbuf, &ack_len); } if ((mode == RIG_MODE_AMS) || (mode == RIG_MODE_ECSSUSB) || (mode == RIG_MODE_ECSSLSB) || diff --git a/dummy/dummy.c b/dummy/dummy.c index 3a7ab1424..fdf46c1c7 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -338,6 +338,8 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) curr->mode = mode; + if (RIG_PASSBAND_NOCHANGE == width) return RIG_OK; + if (width == RIG_PASSBAND_NORMAL) curr->width = rig_passband_normal(rig, mode); else @@ -626,6 +628,8 @@ static int dummy_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t rig_strvfo(vfo), rig_strrmode(tx_mode), buf); curr->tx_mode = tx_mode; + if (RIG_PASSBAND_NOCHANGE == tx_width) return RIG_OK; + curr->tx_width = tx_width; return RIG_OK; diff --git a/flexradio/dttsp.c b/flexradio/dttsp.c index 2bbcfe795..9e1b91594 100644 --- a/flexradio/dttsp.c +++ b/flexradio/dttsp.c @@ -662,6 +662,16 @@ int dttsp_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) int ret = RIG_OK; int filter_l, filter_h; + /* DttSP set mode */ + + buf_len = sprintf (buf, "setMode %d\n", rmode2dttsp(mode) ); + ret = send_command (rig, buf, buf_len); + + rig_debug(RIG_DEBUG_VERBOSE,"%s: %s\n", + __FUNCTION__, buf); + + if (ret != RIG_OK || RIG_PASSBAND_NOCHANGE == width) return ret; + if (width == RIG_PASSBAND_NORMAL) width = rig_passband_normal(rig, mode); sprintf_freq(buf, width); @@ -692,11 +702,6 @@ int dttsp_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - /* DttSP set mode */ - - buf_len = sprintf (buf, "setMode %d\n", rmode2dttsp(mode) ); - ret = send_command (rig, buf, buf_len); - buf_len = sprintf (buf, "setFilter %d %d\n", filter_l, filter_h ); ret = send_command (rig, buf, buf_len); diff --git a/gnuradio/gnuradio.cc b/gnuradio/gnuradio.cc index 911ad7911..3fc19aff5 100644 --- a/gnuradio/gnuradio.cc +++ b/gnuradio/gnuradio.cc @@ -582,7 +582,8 @@ int gr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) rig_debug(RIG_DEBUG_VERBOSE,"%s called: %s %s %s\n", __FUNCTION__, rig_strvfo(vfo), rig_strrmode(mode), buf); - if (mode == chan->mode && width == chan->width) + if (mode == chan->mode + && (RIG_PASSBAND_NOCHANGE == width || width == chan->width)) return RIG_OK; @@ -605,7 +606,8 @@ int gr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) pthread_mutex_lock(&priv->mutex_process); /* Same mode, but different width */ - if (mode != RIG_MODE_NONE && mode == chan->mode) { + if (width != RIG_PASSBAND_NOCHANGE + && mode != RIG_MODE_NONE && mode == chan->mode) { mod->setWidth(width); chan->width = width; pthread_mutex_unlock(&priv->mutex_process); @@ -626,14 +628,16 @@ int gr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (mode == RIG_MODE_NONE) { /* ez */ - chan->mode = mode; - chan->width = width; + chan->mode = mode; + if (width != RIG_PASSBAND_NOCHANGE) chan->width = width; pthread_mutex_unlock(&priv->mutex_process); return RIG_OK; } float rf_gain = chan->levels[rig_setting2idx(RIG_LEVEL_RF)].f; + if (RIG_PASSBAND_NOCHANGE == width) width = chan->width; + switch(mode) { case RIG_MODE_LSB: mod = new LSBDemodChainCF(priv->source, priv->sink, mode, width, priv->input_rate, (freq_t)freq_offset); diff --git a/icom/frame.c b/icom/frame.c index 7ec67f658..7dd9ff9d8 100644 --- a/icom/frame.c +++ b/icom/frame.c @@ -338,21 +338,23 @@ int rig2icom_mode(RIG *rig, rmode_t mode, pbwidth_t width, return -RIG_EINVAL; } - medium_width = rig_passband_normal(rig, mode); - if (width == medium_width || width == RIG_PASSBAND_NORMAL) + if (width != RIG_PASSBAND_NOCHANGE) { + medium_width = rig_passband_normal(rig, mode); + if (width == medium_width || width == RIG_PASSBAND_NORMAL) icmode_ext = -1; /* medium, no passband data-> rig default. Is medium always the default? */ - else if (width < medium_width) + else if (width < medium_width) icmode_ext = PD_NARROW_3; - else + else icmode_ext = PD_WIDE_3; - if (rig->caps->rig_model == RIG_MODEL_ICR7000) { + if (rig->caps->rig_model == RIG_MODEL_ICR7000) { if (mode == RIG_MODE_USB || mode == RIG_MODE_LSB) { - icmode = S_R7000_SSB; - icmode_ext = 0x00; + icmode = S_R7000_SSB; + icmode_ext = 0x00; } else if (mode == RIG_MODE_AM && icmode_ext == -1) { - icmode_ext = PD_WIDE_3; /* default to Wide */ + icmode_ext = PD_WIDE_3; /* default to Wide */ } + } } *md = icmode; diff --git a/icom/ic706.c b/icom/ic706.c index acd0829a0..eaf719ce7 100644 --- a/icom/ic706.c +++ b/icom/ic706.c @@ -46,12 +46,14 @@ static int ic706_r2i_mode(RIG *rig, rmode_t mode, pbwidth_t width, err = rig2icom_mode(rig, mode, width, md, pd); if (err != RIG_OK) - return err; + return err; + if (width != RIG_PASSBAND_NOCHANGE) { if (*pd == -1) - *pd = PD_MEDIUM_2; + *pd = PD_MEDIUM_2; else - (*pd)--; + (*pd)--; + } return RIG_OK; } diff --git a/icom/icom.c b/icom/icom.c index 1d5ba3564..f56d39bfd 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -585,7 +585,6 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode) { } int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width) { - int retval, rfstatus, i; unsigned char ackbuf[MAXFRAMELEN]; unsigned char flt_ext; @@ -593,45 +592,46 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width) { int ack_len=sizeof(ackbuf), flt_idx; unsigned char fw_sub_cmd = RIG_MODEL_IC7200 == rig->caps->rig_model ? 0x02 : S_MEM_FILT_WDTH; - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); + if (RIG_PASSBAND_NOCHANGE == width) return RIG_OK; + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal(rig, mode); 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)) { - for (i=0; ichannel_num; + if ((retval = jrc_get_chan (rig, ¤t)) != RIG_OK) return retval; + sprintf(cmdbuf,"K%03d000",chan->channel_num); if (chan->levels[rig_setting2idx(RIG_LEVEL_ATT)].i == 20) cmdbuf[4] = '1'; - retval = rig2jrc_mode(rig, chan->mode, chan->width, - &cmdbuf[6], &cmdbuf[5]); + rmode_t mode = chan->mode; + pbwidth_t width = chan->width; + if (RIG_MODE_NONE == mode) mode = current.mode; + if (RIG_PASSBAND_NOCHANGE == width) width = current.width; + retval = rig2jrc_mode(rig, mode, width, &cmdbuf[6], &cmdbuf[5]); if (retval != RIG_OK) return retval; diff --git a/jrc/nrd525.c b/jrc/nrd525.c index c689a694e..3d129e3e5 100644 --- a/jrc/nrd525.c +++ b/jrc/nrd525.c @@ -192,6 +192,8 @@ static int nrd525_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (retval != RIG_OK) return retval; + if (RIG_PASSBAND_NOCHANGE == width) return retval; + // TODO: width return retval; diff --git a/kenwood/flex6xxx.c b/kenwood/flex6xxx.c index b510d8e9f..11f4abdf5 100644 --- a/kenwood/flex6xxx.c +++ b/kenwood/flex6xxx.c @@ -228,14 +228,17 @@ static int flex6k_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (err != RIG_OK) return err; - err = flex6k_find_width(mode, width, &idx); - if (err != RIG_OK) - return err; - if ((vfo == RIG_VFO_VFO) || (vfo == RIG_VFO_CURR)) { vfo = rig->state.current_vfo; rig_debug(RIG_DEBUG_VERBOSE, "%s: setting VFO to current\n", __func__); } + + if (RIG_PASSBAND_NOCHANGE == width) return err; + + err = flex6k_find_width(mode, width, &idx); + if (err != RIG_OK) + return err; + /* * The Flex CAT interface does not support FW for reading filter width, * so use the ZZFI or ZZFJ command diff --git a/kenwood/k2.c b/kenwood/k2.c index 8135e8803..8b423ae15 100644 --- a/kenwood/k2.c +++ b/kenwood/k2.c @@ -312,54 +312,58 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - if (width < 0) - width = labs(width); + if (width != RIG_PASSBAND_NOCHANGE) { + if (width < 0) + width = labs(width); - /* Step through the filter list looking for the best match - * for the passed in width. The choice is to select the filter - * that is wide enough for the width without being too narrow - * if possible. - */ - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); + /* Step through the filter list looking for the best match + * for the passed in width. The choice is to select the filter + * that is wide enough for the width without being too narrow + * if possible. + */ + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal(rig, mode); - if (width > flt->filt_list[0].width || ((flt->filt_list[0].width >= width) - && (width > flt->filt_list[1].width))) { - width = flt->filt_list[0].width; - f = '1'; - } else if ((flt->filt_list[1].width >= width) && (width > flt->filt_list[2].width)) { - width = flt->filt_list[1].width; - f = '2'; - } else if ((flt->filt_list[2].width >= width) && (width > flt->filt_list[3].width)) { - width = flt->filt_list[2].width; - f = '3'; - } else if ((flt->filt_list[3].width >= width) && (width >= freq)) { - width = flt->filt_list[3].width; - f = '4'; - } else { - return -RIG_EINVAL; + if (width > flt->filt_list[0].width || ((flt->filt_list[0].width >= width) + && (width > flt->filt_list[1].width))) { + width = flt->filt_list[0].width; + f = '1'; + } else if ((flt->filt_list[1].width >= width) && (width > flt->filt_list[2].width)) { + width = flt->filt_list[1].width; + f = '2'; + } else if ((flt->filt_list[2].width >= width) && (width > flt->filt_list[3].width)) { + width = flt->filt_list[2].width; + f = '3'; + } else if ((flt->filt_list[3].width >= width) && (width >= freq)) { + width = flt->filt_list[3].width; + f = '4'; + } else { + return -RIG_EINVAL; + } } - - /* Construct the filter command and set the radio mode and width*/ - snprintf(fcmd, 8, "FW0000%c", f); - + /* kenwood_set_mode() ignores width value for K2/K3/TS-570 */ err = kenwood_set_mode(rig, vfo, mode, width); if (err != RIG_OK) return err; - err = kenwood_transaction(rig, "K22", NULL, 0); - if (err != RIG_OK) - return err; + if (width != RIG_PASSBAND_NOCHANGE) { + err = kenwood_transaction(rig, "K22", NULL, 0); + if (err != RIG_OK) + return err; - /* Set the filter slot */ - err = kenwood_transaction(rig, fcmd, NULL, 0); - if (err != RIG_OK) - return err; + /* Construct the filter command and set the radio mode and width*/ + snprintf(fcmd, 8, "FW0000%c", f); - err = kenwood_transaction(rig, "K20", NULL, 0); - if (err != RIG_OK) - return err; + /* Set the filter slot */ + err = kenwood_transaction(rig, fcmd, NULL, 0); + if (err != RIG_OK) + return err; + + err = kenwood_transaction(rig, "K20", NULL, 0); + if (err != RIG_OK) + return err; + } return RIG_OK; } diff --git a/kenwood/k3.c b/kenwood/k3.c index 9e2a29f32..b747ea8ef 100644 --- a/kenwood/k3.c +++ b/kenwood/k3.c @@ -377,34 +377,36 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (err != RIG_OK) return err; - /* and set the requested bandwidth. On my K3, the bandwidth is rounded - * down to the nearest 50 Hz, i.e. sending BW0239; will cause the bandwidth - * to be set to 2.350 kHz. As the width must be divided by 10, 10 Hz values - * between 0 and 4 round down to the nearest 100 Hz and values between 5 - * and 9 round down to the nearest 50 Hz. - * - * width string value must be padded with leading '0' to equal four - * characters. - */ + if (width != RIG_PASSBAND_NOCHANGE) { + /* and set the requested bandwidth. On my K3, the bandwidth is rounded + * down to the nearest 50 Hz, i.e. sending BW0239; will cause the bandwidth + * to be set to 2.350 kHz. As the width must be divided by 10, 10 Hz values + * between 0 and 4 round down to the nearest 100 Hz and values between 5 + * and 9 round down to the nearest 50 Hz. + * + * width string value must be padded with leading '0' to equal four + * characters. + */ - /* passband widths vary by mode so gather lower and upper limits */ - pbwidth_t pb_nar = rig_passband_narrow(rig, mode); - pbwidth_t pb_wid = rig_passband_wide(rig, mode); + /* passband widths vary by mode so gather lower and upper limits */ + pbwidth_t pb_nar = rig_passband_narrow(rig, mode); + pbwidth_t pb_wid = rig_passband_wide(rig, mode); - if (width < 0) - width = labs(width); + if (width < 0) + width = labs(width); - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); - else if (width < pb_nar) - width = pb_nar; - else if (width > pb_wid) - width = pb_wid; + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal(rig, mode); + else if (width < pb_nar) + width = pb_nar; + else if (width > pb_wid) + width = pb_wid; - sprintf(cmd_s, "BW%04ld", width / 10); - err = kenwood_transaction(rig, cmd_s, NULL, 0); - if (err != RIG_OK) - return err; + sprintf(cmd_s, "BW%04ld", width / 10); + err = kenwood_transaction(rig, cmd_s, NULL, 0); + if (err != RIG_OK) + return err; + } /* Now set data sub-mode. K3 needs to be in a DATA mode before setting * the sub-mode. @@ -639,34 +641,36 @@ int k3_set_split_mode(RIG * rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) if (err != RIG_OK) return err; - /* and set the requested bandwidth. On my K3, the bandwidth is rounded - * down to the nearest 50 Hz, i.e. sending BW0239; will cause the bandwidth - * to be set to 2.350 kHz. As the width must be divided by 10, 10 Hz values - * between 0 and 4 round down to the nearest 100 Hz and values between 5 - * and 9 round down to the nearest 50 Hz. - * - * tx_width string value must be padded with leading '0' to equal four - * characters. - */ + if (tx_width != RIG_PASSBAND_NOCHANGE) { + /* and set the requested bandwidth. On my K3, the bandwidth is rounded + * down to the nearest 50 Hz, i.e. sending BW0239; will cause the bandwidth + * to be set to 2.350 kHz. As the width must be divided by 10, 10 Hz values + * between 0 and 4 round down to the nearest 100 Hz and values between 5 + * and 9 round down to the nearest 50 Hz. + * + * tx_width string value must be padded with leading '0' to equal four + * characters. + */ - /* passband widths vary by mode so gather lower and upper limits */ - pbwidth_t pb_nar = rig_passband_narrow(rig, tx_mode); - pbwidth_t pb_wid = rig_passband_wide(rig, tx_mode); + /* passband widths vary by mode so gather lower and upper limits */ + pbwidth_t pb_nar = rig_passband_narrow(rig, tx_mode); + pbwidth_t pb_wid = rig_passband_wide(rig, tx_mode); - if (tx_width < 0) - tx_width = labs(tx_width); + if (tx_width < 0) + tx_width = labs(tx_width); - if (tx_width == RIG_PASSBAND_NORMAL) - tx_width = rig_passband_normal(rig, tx_mode); - else if (tx_width < pb_nar) - tx_width = pb_nar; - else if (tx_width > pb_wid) - tx_width = pb_wid; + if (tx_width == RIG_PASSBAND_NORMAL) + tx_width = rig_passband_normal(rig, tx_mode); + else if (tx_width < pb_nar) + tx_width = pb_nar; + else if (tx_width > pb_wid) + tx_width = pb_wid; - sprintf(cmd_s, "BW$%04ld", tx_width / 10); - err = kenwood_transaction(rig, cmd_s, NULL, 0); - if (err != RIG_OK) - return err; + sprintf(cmd_s, "BW$%04ld", tx_width / 10); + err = kenwood_transaction(rig, cmd_s, NULL, 0); + if (err != RIG_OK) + return err; + } /* Now set data sub-mode. K3 needs to be in a DATA mode before setting * the sub-mode. diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index e2de9b314..a45d736d1 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -1437,6 +1437,7 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) } } + if (RIG_PASSBAND_NOCHANGE == width) return RIG_OK; if (rig->caps->rig_model == RIG_MODEL_TS450S || rig->caps->rig_model == RIG_MODEL_TS690S || rig->caps->rig_model == RIG_MODEL_TS850 diff --git a/kenwood/ts570.c b/kenwood/ts570.c index 43629c080..fc97c2879 100644 --- a/kenwood/ts570.c +++ b/kenwood/ts570.c @@ -156,6 +156,7 @@ static int ts570_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) retval = kenwood_transaction(rig, buf, NULL, 0); if (retval != RIG_OK) return retval; + if (RIG_PASSBAND_NOCHANGE == width) return retval; switch (mode) { case RIG_MODE_CW: diff --git a/kenwood/ts870s.c b/kenwood/ts870s.c index 4992b8943..8461b6e2b 100644 --- a/kenwood/ts870s.c +++ b/kenwood/ts870s.c @@ -185,33 +185,35 @@ static int ts870s_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) retval = kenwood_transaction(rig, buf, NULL, 0); if (retval != RIG_OK) return retval; - if (RIG_PASSBAND_NORMAL != width) /* leave well alone if default passband requested */ - { - if (RIG_MODE_USB == mode || RIG_MODE_LSB == mode || RIG_MODE_AM == mode) - { - /* we assume the HPF is set to default and set the LPF to - give the best approximaation of the requested width */ - if (RIG_MODE_AM == mode) - { - mode_default_hpf = 300; - } - else - { - mode_default_hpf = 100; - } - sprintf(buf, "IS %04d", (int)(width + mode_default_hpf)); - retval = kenwood_transaction(rig, buf, NULL, 0); + if (RIG_PASSBAND_NOCHANGE == width) { + if (RIG_PASSBAND_NORMAL != width) /* leave well alone if default passband requested */ + { + if (RIG_MODE_USB == mode || RIG_MODE_LSB == mode || RIG_MODE_AM == mode) + { + /* we assume the HPF is set to default and set the LPF to + give the best approximaation of the requested width */ + if (RIG_MODE_AM == mode) + { + mode_default_hpf = 300; + } + else + { + mode_default_hpf = 100; + } + sprintf(buf, "IS %04d", (int)(width + mode_default_hpf)); + retval = kenwood_transaction(rig, buf, NULL, 0); + } + else + { + /* + * This rig will simply use an IF bandpass which is closest to width, + * so we don't need to check the value... + */ + sprintf(buf, "FW%04d", (int)width/10); + retval = kenwood_transaction(rig, buf, NULL, 0); + } + } } - else - { - /* - * This rig will simply use an IF bandpass which is closest to width, - * so we don't need to check the value... - */ - sprintf(buf, "FW%04d", (int)width/10); - retval = kenwood_transaction(rig, buf, NULL, 0); - } - } return retval; } diff --git a/kit/fifisdr.c b/kit/fifisdr.c index d6cbf71a6..a83dd7638 100644 --- a/kit/fifisdr.c +++ b/kit/fifisdr.c @@ -487,6 +487,7 @@ static int fifisdr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EIO; } + if (RIG_PASSBAND_NOCHANGE == width) return ret; /* Set filter width */ fifi_width = fifisdr_tole32(width); ret = fifisdr_usb_write(rig, REQUEST_FIFISDR_WRITE, 0, diff --git a/pcr/pcr.c b/pcr/pcr.c index 25edab494..528f39e55 100644 --- a/pcr/pcr.c +++ b/pcr/pcr.c @@ -757,46 +757,52 @@ pcr_set_mode(RIG * rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal(rig, mode); - rig_debug(RIG_DEBUG_VERBOSE, "%s: will set to %d\n", - __func__, width); + rig_debug(RIG_DEBUG_VERBOSE, "%s: will set to %d\n", + __func__, width); - switch (width) { - /* nop, pcrfilter already set - * TODO: use rig_passband_normal instead? - */ - case s_kHz(2.8): - pcrfilter = FLT_2_8kHz; - break; - case s_kHz(6): - pcrfilter = FLT_6kHz; - break; - case s_kHz(15): - pcrfilter = FLT_15kHz; - break; - case s_kHz(50): - pcrfilter = FLT_50kHz; - break; - case s_kHz(230): - pcrfilter = FLT_230kHz; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: unsupported width %d\n", - __func__, width); - return -RIG_EINVAL; + switch (width) { + /* nop, pcrfilter already set + * TODO: use rig_passband_normal instead? + */ + case s_kHz(2.8): + pcrfilter = FLT_2_8kHz; + break; + case s_kHz(6): + pcrfilter = FLT_6kHz; + break; + case s_kHz(15): + pcrfilter = FLT_15kHz; + break; + case s_kHz(50): + pcrfilter = FLT_50kHz; + break; + case s_kHz(230): + pcrfilter = FLT_230kHz; + break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported width %d\n", + __func__, width); + return -RIG_EINVAL; + } + + rig_debug(RIG_DEBUG_VERBOSE, "%s: filter set to %d (%c)\n", + __func__, width, pcrfilter); + + buf_len = sprintf((char *) buf, "K%c%010" PRIll "0%c0%c00", + is_sub_rcvr(rig, vfo) ? '1':'0', + (int64_t) rcvr->last_freq, pcrmode, pcrfilter); + } + else { + buf_len = sprintf((char *) buf, "K%c%010" PRIll "0%c0%c00", + is_sub_rcvr(rig, vfo) ? '1':'0', + (int64_t) rcvr->last_freq, pcrmode, rcvr->last_filter); } - - rig_debug(RIG_DEBUG_VERBOSE, "%s: filter set to %d (%c)\n", - __func__, width, pcrfilter); - - buf_len = sprintf((char *) buf, "K%c%010" PRIll "0%c0%c00", - is_sub_rcvr(rig, vfo) ? '1':'0', - (int64_t) rcvr->last_freq, pcrmode, pcrfilter); if (buf_len < 0) return -RIG_ETRUNC; - err = pcr_transaction(rig, (char *) buf); if (err != RIG_OK) return err; diff --git a/racal/racal.c b/racal/racal.c index bc5fff7e7..5be57f0df 100644 --- a/racal/racal.c +++ b/racal/racal.c @@ -265,10 +265,15 @@ int racal_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal(rig, mode); - sprintf(buf, "D%dI%.0f", ra_mode, (double)(width/kHz(1))); + sprintf(buf, "D%dI%.0f", ra_mode, (double)(width/kHz(1))); + } + else { + sprintf(buf, "D%d", ra_mode); + } return racal_transaction (rig, buf, NULL, NULL); } diff --git a/rs/rs.c b/rs/rs.c index 3f2117f2f..a6f0d0be5 100644 --- a/rs/rs.c +++ b/rs/rs.c @@ -138,7 +138,10 @@ int rs_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) len = sprintf(buf, BOM "DEM %s" EOM, smode); retval = rs_transaction(rig, buf, len, NULL, NULL); + if (retval < 0) + return retval; + if (width == RIG_PASSBAND_NOCHANGE) return retval; if (width == RIG_PASSBAND_NORMAL) width = rig_passband_normal(rig, mode); diff --git a/skanti/skanti.c b/skanti/skanti.c index c5368ed83..f31425037 100644 --- a/skanti/skanti.c +++ b/skanti/skanti.c @@ -176,6 +176,7 @@ int skanti_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (retval != RIG_OK) return retval; + if (RIG_PASSBAND_NOCHANGE == width) return retval; /* * TODO: please sk8000 owners, check this, I'm not sure * which passband is default! diff --git a/skanti/trp8255.c b/skanti/trp8255.c index 353db1fa4..286435de4 100644 --- a/skanti/trp8255.c +++ b/skanti/trp8255.c @@ -299,6 +299,7 @@ int cu_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (ret != RIG_OK) return ret; + if (RIG_PASSBAND_NOCHANGE == width) return ret; if (width == RIG_PASSBAND_NORMAL) width = rig_passband_normal(rig, mode); diff --git a/src/rig.c b/src/rig.c index 221a80a66..b5ad89210 100644 --- a/src/rig.c +++ b/src/rig.c @@ -925,8 +925,11 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) * \param mode The mode to set to * \param width The passband width to set to * - * Sets the mode and associated passband of the target VFO. - * The passband \a width must be supported by the backend of the rig. + * Sets the mode and associated passband of the target VFO. The + * passband \a width must be supported by the backend of the rig or + * the special value RIG_PASSBAND_NOCHANGE which leaves the passband + * unchanged from the current value or default for the mode determined + * by the rig. * * \return RIG_OK if the operation has been sucessful, otherwise * a negative value if an error occured (in which case, cause is @@ -1838,7 +1841,10 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) * \param rig The rig handle * \param vfo The target VFO * \param tx_mode The transmit split mode to set to - * \param tx_width The transmit split width to set to + * \param tx_width The transmit split width to set to or the special + * value RIG_PASSBAND_NOCHANGE which leaves the passband unchanged + * from the current value or default for the mode determined by the + * rig. * * Sets the split(TX) mode. * @@ -1998,7 +2004,10 @@ int HAMLIB_API rig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth * \param vfo The target VFO * \param tx_freq The transmit frequency to set to * \param tx_mode The transmit split mode to set to - * \param tx_width The transmit split width to set to + * \param tx_width The transmit split width to set to or the special + * value RIG_PASSBAND_NOCHANGE which leaves the passband unchanged + * from the current value or default for the mode determined by the + * rig. * * Sets the split(TX) frequency and mode. * diff --git a/tentec/jupiter.c b/tentec/jupiter.c index 294ccc0fd..7d897dcf2 100644 --- a/tentec/jupiter.c +++ b/tentec/jupiter.c @@ -607,14 +607,15 @@ int tt538_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (retval != RIG_OK) return retval; + if (RIG_PASSBAND_NOCHANGE == width) return retval; + if (RIG_PASSBAND_NORMAL == width) + width = rig_passband_normal (rig, mode); /* Set rx filter bandwidth. */ - if (width != RIG_PASSBAND_NORMAL) /* leave untouched if normal */ - { - width = tt538_filter_number((int) width); + width = tt538_filter_number((int) width); + + cmd_len = sprintf((char *) cmdbuf, "*W%c" EOM, (unsigned char) width); + return tt538_transaction (rig, (char *) cmdbuf, cmd_len, NULL, NULL); - cmd_len = sprintf((char *) cmdbuf, "*W%c" EOM, (unsigned char) width); - return tt538_transaction (rig, (char *) cmdbuf, cmd_len, NULL, NULL); - } return RIG_OK; } diff --git a/tentec/omnivii.c b/tentec/omnivii.c index ae809c8dd..2d524af9d 100644 --- a/tentec/omnivii.c +++ b/tentec/omnivii.c @@ -699,12 +699,10 @@ int tt588_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return retval; /* Set rx filter bandwidth. */ - - if (width == RIG_PASSBAND_NORMAL) - width = tt588_filter_number(rig_passband_normal(rig, mode)); - else - width = tt588_filter_number((int) width); - + if (RIG_PASSBAND_NOCHANGE == width) return retval; + if (RIG_PASSBAND_NORMAL == width) + width = rig_passband_normal (rig, mode); + width = tt588_filter_number((int) width); cmd_len = sprintf((char *) cmdbuf, "*W%c" EOM, (unsigned char) width); return tt588_transaction (rig, (char *) cmdbuf, cmd_len, NULL, NULL); } diff --git a/tentec/paragon.c b/tentec/paragon.c index d166615b2..cf8c31ef6 100644 --- a/tentec/paragon.c +++ b/tentec/paragon.c @@ -424,9 +424,6 @@ int tt585_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) const char *mcmd, *wcmd; int ret; - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); - switch(mode) { case RIG_MODE_LSB: mcmd = "N"; break; case RIG_MODE_USB: mcmd = "O"; break; @@ -444,6 +441,9 @@ int tt585_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (ret < 0) return ret; + if (RIG_PASSBAND_NOCHANGE == width) return ret; + if (RIG_PASSBAND_NORMAL == width) + width = rig_passband_normal (rig, mode); if (width <= 250) wcmd = "V"; else if (width <= 500) diff --git a/tentec/rx331.c b/tentec/rx331.c index 2bfad84ec..b7ef74feb 100644 --- a/tentec/rx331.c +++ b/tentec/rx331.c @@ -433,15 +433,22 @@ int rx331_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - if (width == RIG_PASSBAND_NORMAL) + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == RIG_PASSBAND_NORMAL) width = rig_passband_normal(rig, mode); - /* - * Set DETECTION MODE and IF FILTER - */ - mdbuf_len = num_sprintf(mdbuf, "$%iD%cI%.02f" EOM, priv->receiver_id, - dmode, (float)width/1e3); - + /* + * Set DETECTION MODE and IF FILTER + */ + mdbuf_len = num_sprintf(mdbuf, "$%iD%cI%.02f" EOM, priv->receiver_id, + dmode, (float)width/1e3); + } + else { + /* + * Set DETECTION MODE + */ + mdbuf_len = num_sprintf(mdbuf, "$%iD%c" EOM, priv->receiver_id, dmode); + } retval = write_block(&rs->rigport, mdbuf, mdbuf_len); return retval; diff --git a/tentec/rx340.c b/tentec/rx340.c index 3b469dd66..827e9c686 100644 --- a/tentec/rx340.c +++ b/tentec/rx340.c @@ -345,15 +345,22 @@ int rx340_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - if (width == RIG_PASSBAND_NORMAL) + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == RIG_PASSBAND_NORMAL) width = rig_passband_normal(rig, mode); /* * Set DETECTION MODE and IF FILTER */ - mdbuf_len = num_sprintf(mdbuf, "D%cI%.02f" EOM, - dmode, (float)width/1e3); - + mdbuf_len = num_sprintf(mdbuf, "D%cI%.02f" EOM, + dmode, (float)width/1e3); + } + else { + /* + * Set DETECTION MODE + */ + mdbuf_len = num_sprintf(mdbuf, "D%c" EOM, dmode); + } retval = write_block(&rs->rigport, mdbuf, mdbuf_len); return retval; diff --git a/tentec/tentec.c b/tentec/tentec.c index b7175b635..7ab3c2425 100644 --- a/tentec/tentec.c +++ b/tentec/tentec.c @@ -272,44 +272,62 @@ int tentec_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); - - for (ttfilter=0; tentec_filters[ttfilter] != 0; ttfilter++) { - if (tentec_filters[ttfilter] == width) - break; - } - if (tentec_filters[ttfilter] != width) { - rig_debug(RIG_DEBUG_ERR, - "tentec_set_mode: unsupported width %d\n", - width); - return -RIG_EINVAL; - } - /* backup current values * in case we fail to write to port */ saved_mode = priv->mode; saved_width = priv->width; + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal(rig, mode); + + for (ttfilter=0; tentec_filters[ttfilter] != 0; ttfilter++) { + if (tentec_filters[ttfilter] == width) + break; + } + if (tentec_filters[ttfilter] != width) { + rig_debug(RIG_DEBUG_ERR, + "tentec_set_mode: unsupported width %d\n", + width); + return -RIG_EINVAL; + } + priv->width = width; + } + priv->mode = mode; - priv->width = width; tentec_tuning_factor_calc(rig); - mdbuf_len = sprintf(mdbuf, "W%c" EOM - "N%c%c%c%c%c%c" EOM - "M%c" EOM, - ttfilter, - priv->ctf >> 8, priv->ctf & 0xff, - priv->ftf >> 8, priv->ftf & 0xff, - priv->btf >> 8, priv->btf & 0xff, - ttmode); - retval = write_block(&rs->rigport, mdbuf, mdbuf_len); - if (retval != RIG_OK) { - priv->mode = saved_mode; - priv->width = saved_width; - return retval; + if (width != RIG_PASSBAND_NOCHANGE) { + mdbuf_len = sprintf(mdbuf, "W%c" EOM + "N%c%c%c%c%c%c" EOM + "M%c" EOM, + ttfilter, + priv->ctf >> 8, priv->ctf & 0xff, + priv->ftf >> 8, priv->ftf & 0xff, + priv->btf >> 8, priv->btf & 0xff, + ttmode); + retval = write_block(&rs->rigport, mdbuf, mdbuf_len); + if (retval != RIG_OK) { + priv->mode = saved_mode; + priv->width = saved_width; + return retval; + } + } + else { + mdbuf_len = sprintf(mdbuf, + "N%c%c%c%c%c%c" EOM + "M%c" EOM, + priv->ctf >> 8, priv->ctf & 0xff, + priv->ftf >> 8, priv->ftf & 0xff, + priv->btf >> 8, priv->btf & 0xff, + ttmode); + retval = write_block(&rs->rigport, mdbuf, mdbuf_len); + if (retval != RIG_OK) { + priv->mode = saved_mode; + return retval; + } } return RIG_OK; diff --git a/tentec/tentec2.c b/tentec/tentec2.c index ebe5865b0..d21c51291 100644 --- a/tentec/tentec2.c +++ b/tentec/tentec2.c @@ -363,8 +363,9 @@ int tentec2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (ret_len != 2 || mdbuf[0] != 'G') return -RIG_ERJCTED; - if (RIG_PASSBAND_NORMAL == width) /* with NORMAL we leave width alone */ - return RIG_OK; + if (RIG_PASSBAND_NOCHANGE == width) return retval; + if (RIG_PASSBAND_NORMAL == width) + width = rig_passband_normal (rig, mode); /* * Filter 0: 200 diff --git a/tentec/tt550.c b/tentec/tt550.c index 8c4159753..551cef8f2 100644 --- a/tentec/tt550.c +++ b/tentec/tt550.c @@ -705,45 +705,37 @@ tt550_set_rx_mode (RIG * rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal (rig, mode); - - for (ttfilter = 0; tt550_filters[ttfilter] != 0; ttfilter++) - { - if (tt550_filters[ttfilter] == width) - break; - } - if (tt550_filters[ttfilter] != width) - { - rig_debug (RIG_DEBUG_ERR, "tt550_set_mode: unsupported width %d\n", - width); - return -RIG_EINVAL; - - } - /* * backup current values in case we fail to write to port */ saved_mode = priv->rx_mode; saved_width = priv->width; + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal (rig, mode); + + for (ttfilter = 0; tt550_filters[ttfilter] != 0; ttfilter++) + { + if (tt550_filters[ttfilter] == width) + break; + } + if (tt550_filters[ttfilter] != width) + { + rig_debug (RIG_DEBUG_ERR, "tt550_set_mode: unsupported width %d\n", + width); + return -RIG_EINVAL; + + } + priv->width = width; + } + priv->rx_mode = mode; - priv->width = width; tt550_tuning_factor_calc (rig, RECEIVE); mdbuf_len = sprintf (mdbuf, "M%c%c" EOM, ttmode, ttmode); retval = write_block (&rs->rigport, mdbuf, mdbuf_len); - - - mdbuf_len = sprintf (mdbuf, "W%c" EOM - "N%c%c%c%c%c%c" EOM, - ttfilter, - priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8, - priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff); - retval = write_block (&rs->rigport, mdbuf, mdbuf_len); - if (retval != RIG_OK) { priv->rx_mode = saved_mode; @@ -751,6 +743,20 @@ tt550_set_rx_mode (RIG * rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return retval; } + if (width != RIG_PASSBAND_NOCHANGE) { + mdbuf_len = sprintf (mdbuf, "W%c" EOM + "N%c%c%c%c%c%c" EOM, + ttfilter, + priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8, + priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff); + retval = write_block (&rs->rigport, mdbuf, mdbuf_len); + if (retval != RIG_OK) + { + priv->width = saved_width; + return retval; + } + } + return RIG_OK; } @@ -796,62 +802,55 @@ tt550_set_tx_mode (RIG * rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - /* - * Limit the transmitter bandwidth - it's not the same as the receiver - */ - if (width < 1050) - width = 1050; - if (width > 3900) - width = 3900; - - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal (rig, mode); - - for (ttfilter = 0; tt550_tx_filters[ttfilter] != 0; ttfilter++) - { - if (tt550_tx_filters[ttfilter] == width) - break; - } - - if (tt550_tx_filters[ttfilter] != width) - { - rig_debug (RIG_DEBUG_ERR, - "tt550_set_mode: unsupported tx width %d,%d\n", width, - ttfilter); - return -RIG_EINVAL; - - } - - /* - * The tx filter array contains just the allowed filter values, but the - * command assumes that the first allowed value is at offset 7. We add - * 7 to compensate for the array difference - */ - - ttfilter += 7; - /* * backup current values in case we fail to write to port */ saved_mode = priv->tx_mode; saved_width = priv->tx_width; + if (width != RIG_PASSBAND_NOCHANGE) { + /* + * Limit the transmitter bandwidth - it's not the same as the receiver + */ + if (width < 1050) + width = 1050; + if (width > 3900) + width = 3900; + + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal (rig, mode); + + for (ttfilter = 0; tt550_tx_filters[ttfilter] != 0; ttfilter++) + { + if (tt550_tx_filters[ttfilter] == width) + break; + } + + if (tt550_tx_filters[ttfilter] != width) + { + rig_debug (RIG_DEBUG_ERR, + "tt550_set_mode: unsupported tx width %d,%d\n", width, + ttfilter); + return -RIG_EINVAL; + + } + + /* + * The tx filter array contains just the allowed filter values, but the + * command assumes that the first allowed value is at offset 7. We add + * 7 to compensate for the array difference + */ + + ttfilter += 7; + priv->tx_width = width; + } + priv->tx_mode = mode; - priv->tx_width = width; tt550_tuning_factor_calc (rig, TRANSMIT); mdbuf_len = sprintf (mdbuf, "M%c%c" EOM, ttmode, ttmode); retval = write_block (&rs->rigport, mdbuf, mdbuf_len); - - - mdbuf_len = sprintf (mdbuf, "C%c" EOM - "T%c%c%c%c%c%c" EOM, - ttfilter, - priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8, - priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff); - retval = write_block (&rs->rigport, mdbuf, mdbuf_len); - if (retval != RIG_OK) { priv->tx_mode = saved_mode; @@ -859,6 +858,20 @@ tt550_set_tx_mode (RIG * rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return retval; } + if (width != RIG_PASSBAND_NOCHANGE) { + mdbuf_len = sprintf (mdbuf, "C%c" EOM + "T%c%c%c%c%c%c" EOM, + ttfilter, + priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8, + priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff); + retval = write_block (&rs->rigport, mdbuf, mdbuf_len); + if (retval != RIG_OK) + { + priv->tx_width = saved_width; + return retval; + } + } + return RIG_OK; } diff --git a/wj/wj.c b/wj/wj.c index df13450e0..c39bfb124 100644 --- a/wj/wj.c +++ b/wj/wj.c @@ -122,7 +122,7 @@ static int wj_transaction(RIG *rig, int monitor) default: return -RIG_EINVAL; } - buf[5] |= (wj_width & 0x2)<<3; + buf[5] |= (wj_width & 0x7)<<3; /* Detection mode */ switch (priv->mode) { @@ -137,7 +137,7 @@ static int wj_transaction(RIG *rig, int monitor) __FUNCTION__, priv->mode); return -RIG_EINVAL; } - buf[5] |= wj_mode & 0x3; + buf[5] |= wj_mode & 0x7; /* BFO frequency, not sure though */ wj_bfo = (priv->ifshift.i/10) + 0x400; /* LSBit is 10Hz, +455kHz */ @@ -293,10 +293,12 @@ int wj_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) priv->mode = mode; - if (width == RIG_PASSBAND_NORMAL) - width = rig_passband_normal(rig, mode); + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == RIG_PASSBAND_NORMAL) + width = rig_passband_normal(rig, mode); - priv->width = width; + priv->width = width; + } return wj_transaction (rig, 0); } diff --git a/yaesu/frg100.c b/yaesu/frg100.c index 4278df888..2bbd6b4f4 100644 --- a/yaesu/frg100.c +++ b/yaesu/frg100.c @@ -416,22 +416,25 @@ int mode2rig(RIG *rig, rmode_t mode, pbwidth_t width) case RIG_MODE_USB: md = MODE_USB; break; case RIG_MODE_LSB: md = MODE_LSB; break; case RIG_MODE_AM: - if (width != RIG_PASSBAND_NORMAL || - width < rig_passband_normal(rig, mode)) + if (width != RIG_PASSBAND_NOCHANGE + && (width != RIG_PASSBAND_NORMAL || + width < rig_passband_normal(rig, mode))) md = MODE_AMN; else md = MODE_AMW; break; case RIG_MODE_FM: - if (width != RIG_PASSBAND_NORMAL || - width < rig_passband_normal(rig, mode)) + if (width != RIG_PASSBAND_NOCHANGE + && (width != RIG_PASSBAND_NORMAL || + width < rig_passband_normal(rig, mode))) md = MODE_FMN; else md = MODE_FMW; break; case RIG_MODE_CW: - if (width != RIG_PASSBAND_NORMAL || - width < rig_passband_normal(rig, mode)) + if (width != RIG_PASSBAND_NOCHANGE + && (width != RIG_PASSBAND_NORMAL || + width < rig_passband_normal(rig, mode))) md = MODE_CWN; else md = MODE_CWW; diff --git a/yaesu/frg8800.c b/yaesu/frg8800.c index 6dc12a1f0..56d731b94 100644 --- a/yaesu/frg8800.c +++ b/yaesu/frg8800.c @@ -216,8 +216,9 @@ int frg8800_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; /* sorry, wrong MODE */ } - if (width != RIG_PASSBAND_NORMAL && - width < rig_passband_normal(rig, mode)) { + if (width != RIG_PASSBAND_NOCHANGE + && width != RIG_PASSBAND_NORMAL + && width < rig_passband_normal(rig, mode)) { md |= 0x08; } diff --git a/yaesu/frg9600.c b/yaesu/frg9600.c index 5fdf6143d..56cd2f915 100644 --- a/yaesu/frg9600.c +++ b/yaesu/frg9600.c @@ -168,8 +168,9 @@ int frg9600_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) case RIG_MODE_FM: md = MODE_SET_FMN; break; case RIG_MODE_WFM: md = MODE_SET_WFM; break; case RIG_MODE_AM: - if (width != RIG_PASSBAND_NORMAL && - width < rig_passband_normal(rig, mode)) + if (width != RIG_PASSBAND_NOCHANGE + && width != RIG_PASSBAND_NORMAL + && width < rig_passband_normal(rig, mode)) md = MODE_SET_AMN; else md = MODE_SET_AMW; diff --git a/yaesu/ft100.c b/yaesu/ft100.c index 804c81ebe..f53d6a6a0 100644 --- a/yaesu/ft100.c +++ b/yaesu/ft100.c @@ -533,6 +533,7 @@ int ft100_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { if (ret != RIG_OK) return ret; + if (RIG_PASSBAND_NOCHANGE == width) return ret; #if 1 if (mode != RIG_MODE_FM && mode != RIG_MODE_WFM && width <= kHz(6)) { diff --git a/yaesu/ft736.c b/yaesu/ft736.c index 088d75ffe..18c6094b3 100644 --- a/yaesu/ft736.c +++ b/yaesu/ft736.c @@ -301,8 +301,9 @@ int ft736_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; /* sorry, wrong MODE */ } - if (width != RIG_PASSBAND_NORMAL && - width < rig_passband_normal(rig, mode)) { + if (width != RIG_PASSBAND_NOCHANGE + && width != RIG_PASSBAND_NORMAL + && width < rig_passband_normal(rig, mode)) { md |= 0x80; } @@ -368,8 +369,9 @@ int ft736_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; /* sorry, wrong MODE */ } - if (width != RIG_PASSBAND_NORMAL && - width < rig_passband_normal(rig, mode)) { + if (RIG_PASSBAND_NOCHANGE != width + && width != RIG_PASSBAND_NORMAL + && width < rig_passband_normal(rig, mode)) { md |= 0x80; } diff --git a/yaesu/ft747.c b/yaesu/ft747.c index ba0994782..c739fcf68 100644 --- a/yaesu/ft747.c +++ b/yaesu/ft747.c @@ -477,13 +477,15 @@ int ft747_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width ) { switch(mode) { case RIG_MODE_AM: - if (width < width_normal) + if (width != RIG_PASSBAND_NOCHANGE + && width < width_normal) cmd_index = FT_747_NATIVE_MODE_SET_AMN; else cmd_index = FT_747_NATIVE_MODE_SET_AMW; break; case RIG_MODE_CW: - if (width < width_normal) + if (width != RIG_PASSBAND_NOCHANGE + && width < width_normal) cmd_index = FT_747_NATIVE_MODE_SET_CWN; else cmd_index = FT_747_NATIVE_MODE_SET_CWW; @@ -495,7 +497,8 @@ int ft747_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width ) { cmd_index = FT_747_NATIVE_MODE_SET_LSB; break; case RIG_MODE_FM: - if (width < width_normal) + if (width != RIG_PASSBAND_NOCHANGE + && width < width_normal) cmd_index = FT_747_NATIVE_MODE_SET_FMN; else cmd_index = FT_747_NATIVE_MODE_SET_FMW; diff --git a/yaesu/ft757gx.c b/yaesu/ft757gx.c index 0f7bee958..ada18af8d 100644 --- a/yaesu/ft757gx.c +++ b/yaesu/ft757gx.c @@ -735,8 +735,9 @@ int mode2rig(RIG *rig, rmode_t mode, pbwidth_t width) break; case RIG_MODE_CW: - if (width == RIG_PASSBAND_NORMAL || - width >= rig_passband_normal(rig, mode)) + if (RIG_PASSBAND_NOCHANGE == width + || width == RIG_PASSBAND_NORMAL + || width >= rig_passband_normal(rig, mode)) md = MODE_CWW; else md = MODE_CWN; diff --git a/yaesu/ft840.c b/yaesu/ft840.c index 4334fbf22..aecf58979 100644 --- a/yaesu/ft840.c +++ b/yaesu/ft840.c @@ -628,24 +628,26 @@ static int ft840_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, * The FT-840 only supports narrow width in AM and CW modes * */ - if (width == rig_passband_narrow(rig, mode)) { - switch(mode) { - case RIG_MODE_CW: - mode_parm = MODE_SET_CW_N; - break; - case RIG_MODE_AM: - mode_parm = MODE_SET_AM_N; - break; - default: - return -RIG_EINVAL; /* Invalid mode, how can caller know? */ - } - } else { - if (width != RIG_PASSBAND_NORMAL && - width != rig_passband_normal(rig, mode)) { - return -RIG_EINVAL; /* Invalid width, how can caller know? */ + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == rig_passband_narrow(rig, mode)) { + switch(mode) { + case RIG_MODE_CW: + mode_parm = MODE_SET_CW_N; + break; + case RIG_MODE_AM: + mode_parm = MODE_SET_AM_N; + break; + default: + return -RIG_EINVAL; /* Invalid mode, how can caller know? */ + } + } else { + if (width != RIG_PASSBAND_NORMAL && + width != rig_passband_normal(rig, mode)) { + return -RIG_EINVAL; /* Invalid width, how can caller know? */ + } } } - + rig_debug(RIG_DEBUG_TRACE, "%s: set mode_parm = 0x%02x\n", __func__, mode_parm); err = ft840_send_dynamic_cmd(rig, FT840_NATIVE_MODE_SET, diff --git a/yaesu/ft847.c b/yaesu/ft847.c index 9063fd5fe..d0fd2c775 100644 --- a/yaesu/ft847.c +++ b/yaesu/ft847.c @@ -663,36 +663,38 @@ int ft847_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { /* * Now set width */ - - if (width == rig_passband_narrow(rig, mode)) { - switch(mode) { - case RIG_MODE_AM: - cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_AMN; - break; - case RIG_MODE_FM: - cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_FMN; - break; - case RIG_MODE_CW: - cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CWN; - break; - case RIG_MODE_CWR: - cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CWRN; - break; - case RIG_MODE_USB: - case RIG_MODE_LSB: - break; - default: - rig_debug(RIG_DEBUG_ERR,"%s: unsupported mode/width: %s/%d, narrow: %d\n", - __FUNCTION__, rig_strrmode(mode), width, - rig_passband_narrow(rig, mode)); - return -RIG_EINVAL; /* sorry, wrong MODE/WIDTH combo */ - } - } else { + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == rig_passband_narrow(rig, mode)) { + switch(mode) { + case RIG_MODE_AM: + cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_AMN; + break; + case RIG_MODE_FM: + cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_FMN; + break; + case RIG_MODE_CW: + cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CWN; + break; + case RIG_MODE_CWR: + cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CWRN; + break; + case RIG_MODE_USB: + case RIG_MODE_LSB: + break; + default: + rig_debug(RIG_DEBUG_ERR,"%s: unsupported mode/width: %s/%d, narrow: %d\n", + __FUNCTION__, rig_strrmode(mode), width, + rig_passband_narrow(rig, mode)); + return -RIG_EINVAL; /* sorry, wrong MODE/WIDTH combo */ + } + } else { if (width != RIG_PASSBAND_NORMAL && - width != rig_passband_normal(rig, mode)) { - return -RIG_EINVAL; /* sorry, wrong MODE/WIDTH combo */ - } - } + width != rig_passband_normal(rig, mode)) { + return -RIG_EINVAL; /* sorry, wrong MODE/WIDTH combo */ + } + } + } + /* * Now send the command */ diff --git a/yaesu/ft857.c b/yaesu/ft857.c index e14e75f39..cb1055434 100644 --- a/yaesu/ft857.c +++ b/yaesu/ft857.c @@ -783,7 +783,7 @@ int ft857_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - if (width != RIG_PASSBAND_NORMAL) + if (width != RIG_PASSBAND_NOCHANGE && width != RIG_PASSBAND_NORMAL) return -RIG_EINVAL; rig_force_cache_timeout(&((struct ft857_priv_data *) rig->state.priv)->fm_status_tv); diff --git a/yaesu/ft890.c b/yaesu/ft890.c index 439463117..ecbfc1820 100644 --- a/yaesu/ft890.c +++ b/yaesu/ft890.c @@ -566,21 +566,23 @@ static int ft890_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, * The FT-890 only supports narrow width in AM and CW modes * */ - if (width == rig_passband_narrow(rig, mode)) { - switch(mode) { - case RIG_MODE_CW: - mode_parm = MODE_SET_CW_N; - break; - case RIG_MODE_AM: - mode_parm = MODE_SET_AM_N; - break; - default: - return -RIG_EINVAL; /* Invalid mode, how can caller know? */ - } - } else { - if (width != RIG_PASSBAND_NORMAL && - width != rig_passband_normal(rig, mode)) { - return -RIG_EINVAL; /* Invalid width, how can caller know? */ + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == rig_passband_narrow(rig, mode)) { + switch(mode) { + case RIG_MODE_CW: + mode_parm = MODE_SET_CW_N; + break; + case RIG_MODE_AM: + mode_parm = MODE_SET_AM_N; + break; + default: + return -RIG_EINVAL; /* Invalid mode, how can caller know? */ + } + } else { + if (width != RIG_PASSBAND_NORMAL && + width != rig_passband_normal(rig, mode)) { + return -RIG_EINVAL; /* Invalid width, how can caller know? */ + } } } diff --git a/yaesu/ft897.c b/yaesu/ft897.c index bc78a4d74..cd091ca68 100644 --- a/yaesu/ft897.c +++ b/yaesu/ft897.c @@ -798,7 +798,7 @@ int ft897_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } - if (width != RIG_PASSBAND_NORMAL) + if (width != RIG_PASSBAND_NOCHANGE && width != RIG_PASSBAND_NORMAL) return -RIG_EINVAL; rig_force_cache_timeout(&((struct ft897_priv_data *) rig->state.priv)->fm_status_tv); diff --git a/yaesu/ft900.c b/yaesu/ft900.c index 2ce3132ad..0f2eb76fc 100644 --- a/yaesu/ft900.c +++ b/yaesu/ft900.c @@ -566,21 +566,23 @@ static int ft900_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, * The FT-900 only supports narrow width in AM and CW modes * */ - if (width == rig_passband_narrow(rig, mode)) { - switch(mode) { - case RIG_MODE_CW: - mode_parm = MODE_SET_CW_N; - break; - case RIG_MODE_AM: - mode_parm = MODE_SET_AM_N; - break; - default: - return -RIG_EINVAL; /* Invalid mode, how can caller know? */ - } - } else { - if (width != RIG_PASSBAND_NORMAL && - width != rig_passband_normal(rig, mode)) { - return -RIG_EINVAL; /* Invalid width, how can caller know? */ + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == rig_passband_narrow(rig, mode)) { + switch(mode) { + case RIG_MODE_CW: + mode_parm = MODE_SET_CW_N; + break; + case RIG_MODE_AM: + mode_parm = MODE_SET_AM_N; + break; + default: + return -RIG_EINVAL; /* Invalid mode, how can caller know? */ + } + } else { + if (width != RIG_PASSBAND_NORMAL && + width != rig_passband_normal(rig, mode)) { + return -RIG_EINVAL; /* Invalid width, how can caller know? */ + } } } diff --git a/yaesu/ft920.c b/yaesu/ft920.c index 41d81510d..eecd2cdfb 100644 --- a/yaesu/ft920.c +++ b/yaesu/ft920.c @@ -723,48 +723,50 @@ static int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width ) { * Yeah, it's ugly... -N0NB * */ - if (width == RIG_PASSBAND_NORMAL || width == rig_passband_normal(rig, mode)) { + if (width != RIG_PASSBAND_NOCHANGE) { + if (width == RIG_PASSBAND_NORMAL || width == rig_passband_normal(rig, mode)) { switch(vfo) { case RIG_VFO_A: case RIG_VFO_VFO: case RIG_VFO_MEM: case RIG_VFO_MAIN: - cmd_index = FT920_NATIVE_VFO_A_PASSBAND_WIDE; - break; + cmd_index = FT920_NATIVE_VFO_A_PASSBAND_WIDE; + break; case RIG_VFO_B: case RIG_VFO_SUB: - cmd_index = FT920_NATIVE_VFO_B_PASSBAND_WIDE; - break; + cmd_index = FT920_NATIVE_VFO_B_PASSBAND_WIDE; + break; } - } else { + } else { if (width == rig_passband_narrow(rig, mode)) { - switch(mode) { - case RIG_MODE_CW: - case RIG_MODE_AM: - case RIG_MODE_FM: - case RIG_MODE_PKTFM: - case RIG_MODE_RTTY: - switch(vfo) { - case RIG_VFO_A: - case RIG_VFO_VFO: - case RIG_VFO_MEM: - case RIG_VFO_MAIN: - cmd_index = FT920_NATIVE_VFO_A_PASSBAND_NAR; - break; - case RIG_VFO_B: - case RIG_VFO_SUB: - cmd_index = FT920_NATIVE_VFO_B_PASSBAND_NAR; - break; - } - break; - default: - return -RIG_EINVAL; /* Invalid mode; how can caller know? */ + switch(mode) { + case RIG_MODE_CW: + case RIG_MODE_AM: + case RIG_MODE_FM: + case RIG_MODE_PKTFM: + case RIG_MODE_RTTY: + switch(vfo) { + case RIG_VFO_A: + case RIG_VFO_VFO: + case RIG_VFO_MEM: + case RIG_VFO_MAIN: + cmd_index = FT920_NATIVE_VFO_A_PASSBAND_NAR; + break; + case RIG_VFO_B: + case RIG_VFO_SUB: + cmd_index = FT920_NATIVE_VFO_B_PASSBAND_NAR; + break; } + break; + default: + return -RIG_EINVAL; /* Invalid mode; how can caller know? */ + } } else { - if (width != RIG_PASSBAND_NORMAL && width != rig_passband_normal(rig, mode)) { - return -RIG_EINVAL; /* Invalid width; how can caller know? */ - } + if (width != RIG_PASSBAND_NORMAL && width != rig_passband_normal(rig, mode)) { + return -RIG_EINVAL; /* Invalid width; how can caller know? */ + } } + } } rig_debug(RIG_DEBUG_TRACE, "%s: set mode_parm = 0x%02x\n", __func__, mode_parm); diff --git a/yaesu/ft980.c b/yaesu/ft980.c index 7e28dabf3..26978c95a 100644 --- a/yaesu/ft980.c +++ b/yaesu/ft980.c @@ -728,7 +728,9 @@ int ft980_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; /* sorry, wrong MODE */ } - if (width != RIG_PASSBAND_NORMAL && width < rig_passband_normal(rig, mode)) { + if (width != RIG_PASSBAND_NOCHANGE + && width != RIG_PASSBAND_NORMAL + && width < rig_passband_normal(rig, mode)) { switch(md) { case MD_CW: md = MD_CWN; break; case MD_AM: md = MD_AMN; break; diff --git a/yaesu/ft990.c b/yaesu/ft990.c index 74b83d88b..616f12d0c 100644 --- a/yaesu/ft990.c +++ b/yaesu/ft990.c @@ -1608,6 +1608,7 @@ int ft990_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) ci == FT990_NATIVE_MODE_SET_PKT_FM) return RIG_OK; + if (RIG_PASSBAND_NOCHANGE == width) return err; switch(width) { case 250: bw = FT990_BW_F250; diff --git a/yaesu/newcat.c b/yaesu/newcat.c index 60d624d01..1636c5d17 100644 --- a/yaesu/newcat.c +++ b/yaesu/newcat.c @@ -555,9 +555,6 @@ int newcat_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) rig_debug(RIG_DEBUG_VERBOSE,"%s: generic mode = %x \n", __func__, mode); - if (RIG_PASSBAND_NORMAL == width) - width = rig_passband_normal(rig, mode); - switch(mode) { case RIG_MODE_LSB: priv->cmd_str[3] = '1'; @@ -600,6 +597,7 @@ int newcat_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (err != RIG_OK) return err; + if (RIG_PASSBAND_NOCHANGE == width) return err; if (RIG_PASSBAND_NORMAL == width) width = rig_passband_normal(rig, mode); diff --git a/yaesu/vr5000.c b/yaesu/vr5000.c index ea7fe53b0..56aa3da2e 100644 --- a/yaesu/vr5000.c +++ b/yaesu/vr5000.c @@ -450,7 +450,9 @@ int mode2rig(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) case RIG_MODE_WFM: md = MODE_WFM; break; case RIG_MODE_FM: md = MODE_FMN; break; case RIG_MODE_AM: - if (width != RIG_PASSBAND_NORMAL && width < rig_passband_normal(rig, mode)) + if (width != RIG_PASSBAND_NOCHANGE + && width != RIG_PASSBAND_NORMAL + && width < rig_passband_normal(rig, mode)) md = MODE_AMN; else if (width != RIG_PASSBAND_NORMAL && width > rig_passband_normal(rig, mode)) md = MODE_AMW;