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

int HAMLIB_API rig_set_channel ( RIG rig,
const channel_t chan 

set channel data

rig The rig handle
chan The location of data to set for this channel
Sets the data associated with a channel. This channel can either be the state of a VFO specified by chan->vfo, or a memory channel specified with chan->vfo = RIG_VFO_MEM and chan->channel_num. See channel_t for more information.

The rig_set_channel is supposed to have no impact on the current VFO and memory number selected. Depending on backend and rig capabilities, the chan struct may not be set completely.

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:

Definition at line 505 of file mem.c.

References caps, channel::channel_num, rig_state::current_vfo, RIG_EINVAL, RIG_ENAVAIL, RIG_ENTARGET, rig_get_mem(), RIG_OK, rig_set_mem(), rig_set_vfo(), RIG_VFO_CURR, RIG_VFO_MEM, rig_caps::set_channel, rig_caps::set_mem, rig_caps::set_vfo, state, and channel::vfo.

      struct rig_caps *rc;
      int curr_chan_num, get_mem_status = RIG_OK;
      vfo_t curr_vfo;
      vfo_t vfo; /* requested vfo */
      int retcode;
      channel_t curr_chan;

      if (CHECK_RIG_ARG(rig) || !chan)
            return -RIG_EINVAL;

       * TODO: check chan->channel_num is valid

      rc = rig->caps;

      if (rc->set_channel)
            return rc->set_channel(rig, chan);

       * if not available, emulate it
       * Optional: get_vfo, set_vfo,
       * TODO: check return codes

      vfo = chan->vfo;
      if (vfo == RIG_VFO_MEM && !rc->set_mem)
            return -RIG_ENAVAIL;

      if (vfo == RIG_VFO_CURR)
            return generic_restore_channel(rig, chan);

      if (!rc->set_vfo)
            return -RIG_ENTARGET;

      curr_vfo = rig->state.current_vfo;
      /* may be needed if the restore_channel has some side effects */
      generic_save_channel(rig, &curr_chan);

      if (vfo == RIG_VFO_MEM)
            get_mem_status = rig_get_mem(rig, RIG_VFO_CURR, &curr_chan_num);

      if (curr_vfo != vfo) {
            retcode = rig_set_vfo(rig, vfo);
            if (retcode != RIG_OK)
                  return retcode;

      if (vfo == RIG_VFO_MEM)
            rig_set_mem(rig, RIG_VFO_CURR, chan->channel_num);

      retcode = generic_restore_channel(rig, chan);

      /* restore current memory number */
      if (vfo == RIG_VFO_MEM && get_mem_status == RIG_OK)
            rig_set_mem(rig, RIG_VFO_CURR, curr_chan_num);

      rig_set_vfo(rig, curr_vfo);

      generic_restore_channel(rig, &curr_chan);
      return retcode;

Generated by  Doxygen 1.6.0   Back to index