* \brief get the current split mode * \param rig The rig handle * \param vfo The target VFO * \param split The location where to store the current split mode * \param tx_vfo The transmit VFO * * Retrieves the current split mode. * * \return RIG_OK if the operation has been successful, otherwise * a negative value if an error occurred (in which case, cause is * set appropriately).
| 5997 | * \sa rig_set_split_vfo() |
| 5998 | */ |
| 5999 | int HAMLIB_API rig_get_split_vfo(RIG *rig, |
| 6000 | vfo_t vfo, |
| 6001 | split_t *split, |
| 6002 | vfo_t *tx_vfo) |
| 6003 | { |
| 6004 | const struct rig_caps *caps; |
| 6005 | struct rig_state *rs; |
| 6006 | struct rig_cache *cachep; |
| 6007 | int retcode; |
| 6008 | int cache_ms; |
| 6009 | int use_cache = 0; |
| 6010 | |
| 6011 | if (CHECK_RIG_ARG(rig)) |
| 6012 | { |
| 6013 | rig_debug(RIG_DEBUG_ERR, "%s: rig or rig->caps is null\n", __func__); |
| 6014 | return -RIG_EINVAL; |
| 6015 | } |
| 6016 | |
| 6017 | ELAPSED1; |
| 6018 | ENTERFUNC; |
| 6019 | |
| 6020 | if (!split || !tx_vfo) |
| 6021 | { |
| 6022 | rig_debug(RIG_DEBUG_ERR, "%s: split or tx_vfo is null, split=%p, tx_vfo=%p\n", |
| 6023 | __func__, split, tx_vfo); |
| 6024 | ELAPSED2; |
| 6025 | RETURNFUNC(-RIG_EINVAL); |
| 6026 | } |
| 6027 | |
| 6028 | caps = rig->caps; |
| 6029 | rs = STATE(rig); |
| 6030 | cachep = CACHE(rig); |
| 6031 | |
| 6032 | if (MUTEX_CHECK(&morse_mutex)) |
| 6033 | { |
| 6034 | use_cache = 1; |
| 6035 | } |
| 6036 | |
| 6037 | if (caps->get_split_vfo == NULL || use_cache) |
| 6038 | { |
| 6039 | rig_debug(RIG_DEBUG_TRACE, "%s: ?get_split_vfo=%d use_cache=%d\n", __func__, |
| 6040 | caps->get_split_vfo != NULL, use_cache); |
| 6041 | // if we can't get the vfo we will return whatever we have cached |
| 6042 | *split = cachep->split; |
| 6043 | *tx_vfo = cachep->split_vfo; |
| 6044 | ELAPSED2; |
| 6045 | RETURNFUNC(RIG_OK); |
| 6046 | } |
| 6047 | |
| 6048 | cache_ms = elapsed_ms(&cachep->time_split, HAMLIB_ELAPSED_GET); |
| 6049 | rig_debug(RIG_DEBUG_TRACE, "%s: cache check age=%dms\n", __func__, cache_ms); |
| 6050 | |
| 6051 | if (cache_ms < cachep->timeout_ms) |
| 6052 | { |
| 6053 | *split = cachep->split; |
| 6054 | *tx_vfo = cachep->split_vfo; |
| 6055 | rig_debug(RIG_DEBUG_TRACE, "%s: cache hit age=%dms, split=%d, tx_vfo=%s\n", |
| 6056 | __func__, cache_ms, *split, rig_strvfo(*tx_vfo)); |