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

const chan_t* HAMLIB_API rig_lookup_mem_caps ( RIG rig,
int  ch 
)

lookup the memory type and capabilities

Parameters:
rig The rig handle
ch The memory channel number
Lookup the memory type and capabilities associated with a channel number. If ch equals RIG_MEM_CAPS_ALL, then a union of all the mem_caps sets is returned (pointer to static memory).

Returns:
a pointer to a chan_t structure if the operation has been sucessful, otherwise a NULL pointer, most probably because of incorrect channel number or buggy backend.

Definition at line 1176 of file mem.c.

References rig_state::chan_list, chan_list::end, chan_list::mem_caps, RIG_MEM_CAPS_ALL, RIG_MTYPE_NONE, chan_list::start, state, and chan_list::type.

{
      chan_t *chan_list;
      static chan_t chan_list_all;
      int i, j;

      if (CHECK_RIG_ARG(rig))
            return NULL;

      if (ch == RIG_MEM_CAPS_ALL)
      {
            memset (&chan_list_all, 0, sizeof(chan_list_all));
            chan_list = rig->state.chan_list;
            chan_list_all.start = chan_list[0].start;
            chan_list_all.type = RIG_MTYPE_NONE;      /* meaningless */
            for (i=0; i<CHANLSTSIZ && !RIG_IS_CHAN_END(chan_list[i]); i++) {

                  unsigned char *p1, *p2;
                  p1=(unsigned char*)&chan_list_all.mem_caps;
                  p2=(unsigned char*)&chan_list[i].mem_caps;
                  /* It's kind of hackish, we just want to do update set with:
                   *    chan_list_all.mem_caps |= chan_list[i].mem_caps
                   */
                  for (j=0; j<sizeof(channel_cap_t); j++) {
                        p1[j] |= p2[j];
                  }

                  /* til the end, most probably meaningless */
                  chan_list_all.end = chan_list[i].end;
            }

            return &chan_list_all;
      }

      chan_list = rig->state.chan_list;
      for (i=0; i<CHANLSTSIZ && !RIG_IS_CHAN_END(chan_list[i]); i++) {
            if (ch >= chan_list[i].start && ch <= chan_list[i].end) {
                  return &chan_list[i];
            }
      }

      return NULL;
}


Generated by  Doxygen 1.6.0   Back to index