MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / generic_save_channel

Function generic_save_channel

src/mem.c:354–518  ·  view source on GitHub ↗

* stores current VFO state into chan by emulating rig_get_channel */

Source from the content-addressed store, hash-verified

352 * stores current VFO state into chan by emulating rig_get_channel
353 */
354static int generic_save_channel(RIG *rig, channel_t *chan)
355{
356 int i;
357 int chan_num;
358 vfo_t vfo;
359 setting_t setting;
360 const channel_cap_t *mem_cap = NULL;
361 value_t vdummy = {0};
362
363 chan_num = chan->channel_num;
364 vfo = chan->vfo;
365 memset(chan, 0, sizeof(channel_t));
366 chan->channel_num = chan_num;
367 chan->vfo = vfo;
368
369 if (vfo == RIG_VFO_MEM)
370 {
371 const chan_t *chan_cap;
372 chan_cap = rig_lookup_mem_caps(rig, chan_num);
373
374 if (chan_cap)
375 {
376 mem_cap = &chan_cap->mem_caps;
377 }
378 }
379
380 /* If vfo!=RIG_VFO_MEM or incomplete backend, try all properties */
381 if (mem_cap == NULL || rig_mem_caps_empty(mem_cap))
382 {
383 mem_cap = &mem_cap_all;
384 }
385
386 if (mem_cap->freq)
387 {
388 int retval = rig_get_freq(rig, RIG_VFO_CURR, &chan->freq);
389
390 /* empty channel ? */
391 if (retval == -RIG_ENAVAIL || chan->freq == RIG_FREQ_NONE)
392 {
393 return -RIG_ENAVAIL;
394 }
395 }
396
397 if (mem_cap->vfo)
398 {
399 rig_get_vfo(rig, &chan->vfo);
400 }
401
402 if (mem_cap->mode || mem_cap->width)
403 {
404 rig_get_mode(rig, RIG_VFO_CURR, &chan->mode, &chan->width);
405 }
406
407 chan->split = RIG_SPLIT_OFF;
408
409 if (mem_cap->split)
410 {
411 rig_get_split_vfo(rig, RIG_VFO_CURR, &chan->split, &chan->tx_vfo);

Callers 1

rig_get_channelFunction · 0.85

Calls 15

rig_lookup_mem_capsFunction · 0.85
rig_mem_caps_emptyFunction · 0.85
rig_get_freqFunction · 0.85
rig_get_vfoFunction · 0.85
rig_get_modeFunction · 0.85
rig_get_split_vfoFunction · 0.85
rig_get_split_freqFunction · 0.85
rig_get_split_modeFunction · 0.85
rig_get_rptr_shiftFunction · 0.85
rig_get_rptr_offsFunction · 0.85
rig_get_antFunction · 0.85
rig_get_tsFunction · 0.85

Tested by

no test coverage detected