* \brief get the mode of the target VFO * \param rig The rig handle * \param vfo The target VFO * \param mode The location where to store the current mode * \param width The location where to store the current passband width * * Retrieves the mode and passband of the target VFO. * If the backend is unable to determine the width, the \a width * will be set to RIG_PASSBAND_NORMAL as
| 3037 | * \sa rig_set_mode() |
| 3038 | */ |
| 3039 | int HAMLIB_API rig_get_mode(RIG *rig, |
| 3040 | vfo_t vfo, |
| 3041 | rmode_t *mode, |
| 3042 | pbwidth_t *width) |
| 3043 | { |
| 3044 | const struct rig_caps *caps; |
| 3045 | struct rig_state *rs; |
| 3046 | int retcode; |
| 3047 | int use_cache = 0; |
| 3048 | freq_t freq; |
| 3049 | vfo_t curr_vfo; |
| 3050 | struct rig_cache *cachep; |
| 3051 | |
| 3052 | if (CHECK_RIG_ARG(rig)) |
| 3053 | { |
| 3054 | rig_debug(RIG_DEBUG_ERR, "%s: rig or rig->caps is null\n", __func__); |
| 3055 | return -RIG_EINVAL; |
| 3056 | } |
| 3057 | |
| 3058 | ELAPSED1; |
| 3059 | ENTERFUNC; |
| 3060 | |
| 3061 | if (!mode || !width) |
| 3062 | { |
| 3063 | ELAPSED2; |
| 3064 | RETURNFUNC(-RIG_EINVAL); |
| 3065 | } |
| 3066 | |
| 3067 | caps = rig->caps; |
| 3068 | rs = STATE(rig); |
| 3069 | cachep = CACHE(rig); |
| 3070 | |
| 3071 | if (caps->get_mode == NULL) |
| 3072 | { |
| 3073 | ELAPSED2; |
| 3074 | RETURNFUNC(-RIG_ENAVAIL); |
| 3075 | } |
| 3076 | |
| 3077 | curr_vfo = rs->current_vfo; |
| 3078 | vfo = vfo_fixup(rig, vfo, cachep->split); |
| 3079 | |
| 3080 | if (vfo == RIG_VFO_CURR) { vfo = curr_vfo; } |
| 3081 | |
| 3082 | *mode = RIG_MODE_NONE; |
| 3083 | rig_cache_show(rig, __func__, __LINE__); |
| 3084 | int cache_ms_freq, cache_ms_mode, cache_ms_width; |
| 3085 | rig_get_cache(rig, vfo, &freq, &cache_ms_freq, mode, &cache_ms_mode, width, |
| 3086 | &cache_ms_width); |
| 3087 | rig_debug(RIG_DEBUG_TRACE, "%s: %s cache check age=%dms\n", __func__, |
| 3088 | rig_strvfo(vfo), cache_ms_mode); |
| 3089 | |
| 3090 | rig_cache_show(rig, __func__, __LINE__); |
| 3091 | |
| 3092 | if (MUTEX_CHECK(&morse_mutex)) |
| 3093 | { |
| 3094 | use_cache = 1; |
| 3095 | } |
| 3096 |