Logo Search packages:      
Sourcecode: hamlib version File versions  Download package

int HAMLIB_API rig_set_mode ( RIG rig,
vfo_t  vfo,
rmode_t  mode,
pbwidth_t  width 
)

set the mode of the target VFO

Parameters:
rig The rig handle
vfo The target VFO
mode The mode to set to
width The passband width to set to
Sets the mode and associated passband of the target VFO. The passband width must be supported by the backend of the rig.

Returns:
RIG_OK if the operation has been sucessful, otherwise a negative value if an error occured (in which case, cause is set appropriately).
See also:
rig_get_mode()

Definition at line 840 of file rig.c.

References caps, rig_state::current_mode, rig_state::current_vfo, rig_state::current_width, RIG_EINVAL, RIG_ENAVAIL, RIG_ENTARGET, RIG_OK, RIG_VFO_CURR, rig_caps::set_mode, rig_caps::set_vfo, state, and rig_caps::targetable_vfo.

{
      const struct rig_caps *caps;
      int retcode;
      vfo_t curr_vfo;

      if (CHECK_RIG_ARG(rig))
            return -RIG_EINVAL;

      caps = rig->caps;

      if (caps->set_mode == NULL)
            return -RIG_ENAVAIL;

      if ((caps->targetable_vfo&RIG_TARGETABLE_MODE) ||
                  vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) {
            retcode = caps->set_mode(rig, vfo, mode, width);
      } else {

            if (!caps->set_vfo)
                  return -RIG_ENTARGET;
            curr_vfo = rig->state.current_vfo;
            retcode = caps->set_vfo(rig, vfo);
            if (retcode != RIG_OK)
                  return retcode;

            retcode = caps->set_mode(rig, vfo, mode, width);
            caps->set_vfo(rig, curr_vfo);
      }

      if (retcode == RIG_OK &&
                  (vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)) {
            rig->state.current_mode = mode;
            rig->state.current_width = width;
      }

      return retcode;
}


Generated by  Doxygen 1.6.0   Back to index