* \brief set the XIT * \param rig The rig handle * \param vfo The target VFO * \param xit The XIT offset to adjust to * * Sets the current XIT offset. A value of 0 for \a xit disables XIT. * * \return RIG_OK if the operation has been successful, otherwise * a negative value if an error occurred (in which case, cause is * set appropriately). * * \sa rig_get_xit() */
| 6246 | * \sa rig_get_xit() |
| 6247 | */ |
| 6248 | int HAMLIB_API rig_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit) |
| 6249 | { |
| 6250 | const struct rig_caps *caps; |
| 6251 | int retcode, rc2; |
| 6252 | vfo_t curr_vfo; |
| 6253 | |
| 6254 | if (CHECK_RIG_ARG(rig)) |
| 6255 | { |
| 6256 | rig_debug(RIG_DEBUG_ERR, "%s: rig or rig->caps is null\n", __func__); |
| 6257 | return -RIG_EINVAL; |
| 6258 | } |
| 6259 | |
| 6260 | ENTERFUNC; |
| 6261 | |
| 6262 | caps = rig->caps; |
| 6263 | |
| 6264 | if (caps->set_xit == NULL) |
| 6265 | { |
| 6266 | RETURNFUNC(-RIG_ENAVAIL); |
| 6267 | } |
| 6268 | |
| 6269 | if ((caps->targetable_vfo & RIG_TARGETABLE_RITXIT) |
| 6270 | || vfo == RIG_VFO_CURR |
| 6271 | || vfo == STATE(rig)->current_vfo) |
| 6272 | { |
| 6273 | HAMLIB_TRACE; |
| 6274 | retcode = caps->set_xit(rig, vfo, xit); |
| 6275 | RETURNFUNC(retcode); |
| 6276 | } |
| 6277 | |
| 6278 | if (!caps->set_vfo) |
| 6279 | { |
| 6280 | RETURNFUNC(-RIG_ENAVAIL); |
| 6281 | } |
| 6282 | |
| 6283 | curr_vfo = STATE(rig)->current_vfo; |
| 6284 | HAMLIB_TRACE; |
| 6285 | retcode = caps->set_vfo(rig, vfo); |
| 6286 | |
| 6287 | if (retcode != RIG_OK) |
| 6288 | { |
| 6289 | RETURNFUNC(retcode); |
| 6290 | } |
| 6291 | |
| 6292 | retcode = caps->set_xit(rig, vfo, xit); |
| 6293 | /* try and revert even if we had an error above */ |
| 6294 | rc2 = caps->set_vfo(rig, curr_vfo); |
| 6295 | |
| 6296 | if (RIG_OK == retcode) |
| 6297 | { |
| 6298 | /* Return the first error code */ |
| 6299 | retcode = rc2; |
| 6300 | } |
| 6301 | |
| 6302 | RETURNFUNC(retcode); |
| 6303 | } |
| 6304 | |
| 6305 |
no test coverage detected