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

int HAMLIB_API rig_get_channel ( RIG rig,
channel_t chan 

get channel data

rig The rig handle
chan The location where to store the channel data
Retrieves 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.


  channel_t chan;
  int err;

  chan->vfo = RIG_VFO_MEM;
  chan->channel_num = 10;
  err = rig_get_channel(rig, &chan);
  if (err != RIG_OK)
      error("get_channel failed: %s", rigerror(err));

The rig_get_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 filled in completely.

Note: chan->ext_levels is a pointer to a newly mallocated memory. This is the responsability of the caller to manage and eventually free it.

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 613 of file mem.c.

References caps, channel::channel_num, rig_state::current_vfo, rig_caps::get_channel, 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_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->get_channel)
            return rc->get_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_save_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_save_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