* \brief stop morse code * \param rig The rig handle * \param vfo The target VFO * * Stops the send morse message. * * \return RIG_OK if the operation has been successful, otherwise * a negative value if an error occurred (in which case, cause is * set appropriately). * */
| 7580 | * |
| 7581 | */ |
| 7582 | int HAMLIB_API rig_stop_morse(RIG *rig, vfo_t vfo) |
| 7583 | { |
| 7584 | const struct rig_caps *caps; |
| 7585 | struct rig_state *rs; |
| 7586 | int retcode, rc2; |
| 7587 | vfo_t curr_vfo; |
| 7588 | |
| 7589 | if (CHECK_RIG_ARG(rig)) |
| 7590 | { |
| 7591 | rig_debug(RIG_DEBUG_ERR, "%s: rig or rig->caps is null\n", __func__); |
| 7592 | return -RIG_EINVAL; |
| 7593 | } |
| 7594 | |
| 7595 | ENTERFUNC; |
| 7596 | |
| 7597 | caps = rig->caps; |
| 7598 | rs = STATE(rig); |
| 7599 | |
| 7600 | if (caps->stop_morse == NULL) |
| 7601 | { |
| 7602 | RETURNFUNC(-RIG_ENAVAIL); |
| 7603 | } |
| 7604 | |
| 7605 | resetFIFO(rs->fifo_morse); // clear out the CW queue |
| 7606 | |
| 7607 | LOCK(1); |
| 7608 | if (vfo == RIG_VFO_CURR |
| 7609 | || vfo == rs->current_vfo) |
| 7610 | { |
| 7611 | retcode = caps->stop_morse(rig, vfo); |
| 7612 | LOCK(0); |
| 7613 | RETURNFUNC(retcode); |
| 7614 | } |
| 7615 | |
| 7616 | if (!caps->set_vfo) |
| 7617 | { |
| 7618 | LOCK(0); |
| 7619 | RETURNFUNC(-RIG_ENAVAIL); |
| 7620 | } |
| 7621 | |
| 7622 | curr_vfo = rs->current_vfo; |
| 7623 | HAMLIB_TRACE; |
| 7624 | retcode = caps->set_vfo(rig, vfo); |
| 7625 | |
| 7626 | if (retcode != RIG_OK) |
| 7627 | { |
| 7628 | LOCK(0); |
| 7629 | RETURNFUNC(retcode); |
| 7630 | } |
| 7631 | |
| 7632 | retcode = caps->stop_morse(rig, vfo); |
| 7633 | /* try and revert even if we had an error above */ |
| 7634 | HAMLIB_TRACE; |
| 7635 | rc2 = caps->set_vfo(rig, curr_vfo); |
| 7636 | |
| 7637 | if (RIG_OK == retcode) |
| 7638 | { |
| 7639 | /* Return the first error code */ |
no test coverage detected