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

Function rig_set_func

src/settings.c:499–574  ·  view source on GitHub ↗

* \brief activate/de-activate functions of radio * \param rig The rig handle * \param vfo The target VFO * \param func The functions to activate * \param status The status (on or off) to set to * * Activate/de-activate a function of the radio. * * The \a status argument is a non null value for "activate", * "de-activate" otherwise, much as TRUE/FALSE definitions in C language. *

Source from the content-addressed store, hash-verified

497 * \sa rig_get_func()
498 */
499int HAMLIB_API rig_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
500{
501 const struct rig_caps *caps;
502 struct rig_state *rs = STATE(rig);
503 int retcode;
504 vfo_t curr_vfo;
505
506 rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
507
508 if (CHECK_RIG_ARG(rig))
509 {
510 return -RIG_EINVAL;
511 }
512
513 caps = rig->caps;
514
515 if ((caps->set_func == NULL || !rig_has_set_func(rig, func))
516 && access(rs->tuner_control_pathname, X_OK) == -1)
517 {
518 return -RIG_ENAVAIL;
519 }
520
521 if (access(rs->tuner_control_pathname, X_OK) != -1)
522 {
523 char cmd[1024];
524 snprintf(cmd, sizeof(cmd), "%s %d", rs->tuner_control_pathname, status);
525 rig_debug(RIG_DEBUG_TRACE, "%s: Calling external script '%s'\n", __func__,
526 rs->tuner_control_pathname);
527 retcode = system(cmd);
528
529 if (retcode != 0) { rig_debug(RIG_DEBUG_ERR, "%s: executing %s failed\n", __func__, rs->tuner_control_pathname); }
530
531 return (retcode == 0 ? RIG_OK : -RIG_ERJCTED);
532 }
533 else
534 {
535 if (strcmp(rs->tuner_control_pathname, "hamlib_tuner_control"))
536 {
537 rig_debug(RIG_DEBUG_ERR, "%s: unable to find '%s'\n", __func__,
538 rs->tuner_control_pathname);
539 return -RIG_EINVAL;
540 }
541 }
542
543 if ((caps->targetable_vfo & RIG_TARGETABLE_FUNC)
544 || vfo == RIG_VFO_CURR
545 || vfo == rs->current_vfo)
546 {
547
548 return caps->set_func(rig, vfo, func, status);
549 }
550 else
551 {
552 int targetable = caps->targetable_vfo & RIG_TARGETABLE_FUNC;
553 rig_debug(RIG_DEBUG_TRACE, "%s: targetable=%d, vfo=%s, currvfo=%s\n", __func__,
554 targetable, rig_strvfo(vfo), rig_strvfo(rs->current_vfo));
555 }
556

Callers 9

dttsp_set_funcFunction · 0.85
icom_set_freqFunction · 0.85
icom_set_split_freqFunction · 0.85
icom_set_split_vfoFunction · 0.85
setFuncMethod · 0.85
generic_restore_channelFunction · 0.85
handle_ts2000Function · 0.85
mainFunction · 0.85
rigctl_parse.cFile · 0.85

Calls 3

rig_debugFunction · 0.85
rig_has_set_funcFunction · 0.85
rig_strvfoFunction · 0.85

Tested by 1

mainFunction · 0.68