* flrig_get_mode * Assumes rig!=NULL, STATE(rig)->priv!=NULL, mode!=NULL */
| 1706 | * Assumes rig!=NULL, STATE(rig)->priv!=NULL, mode!=NULL |
| 1707 | */ |
| 1708 | static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) |
| 1709 | { |
| 1710 | int retval; |
| 1711 | int vfoSwitched; |
| 1712 | char value[MAXCMDLEN]; |
| 1713 | char *cmdp; |
| 1714 | vfo_t curr_vfo; |
| 1715 | rmode_t my_mode; |
| 1716 | struct rig_state *rs = STATE(rig); |
| 1717 | struct flrig_priv_data *priv = (struct flrig_priv_data *) rs->priv; |
| 1718 | |
| 1719 | ENTERFUNC; |
| 1720 | rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, |
| 1721 | rig_strvfo(vfo)); |
| 1722 | |
| 1723 | *width = 0; |
| 1724 | |
| 1725 | if (check_vfo(vfo) == FALSE) |
| 1726 | { |
| 1727 | rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", |
| 1728 | __func__, rig_strvfo(vfo)); |
| 1729 | RETURNFUNC(-RIG_EINVAL); |
| 1730 | } |
| 1731 | |
| 1732 | curr_vfo = rs->current_vfo; |
| 1733 | |
| 1734 | if (vfo == RIG_VFO_CURR) |
| 1735 | { |
| 1736 | vfo = rs->current_vfo; |
| 1737 | } |
| 1738 | |
| 1739 | rig_debug(RIG_DEBUG_TRACE, "%s: using vfo=%s\n", __func__, |
| 1740 | rig_strvfo(vfo)); |
| 1741 | |
| 1742 | if (priv->ptt) |
| 1743 | { |
| 1744 | if (vfo == RIG_VFO_A) { *mode = priv->curr_modeA; } |
| 1745 | else { *mode = priv->curr_modeB; } |
| 1746 | |
| 1747 | rig_debug(RIG_DEBUG_VERBOSE, "%s call not made as PTT=1\n", __func__); |
| 1748 | RETURNFUNC(RIG_OK); // just return OK and ignore this |
| 1749 | } |
| 1750 | |
| 1751 | // Switch to VFOB if appropriate |
| 1752 | vfoSwitched = 0; |
| 1753 | |
| 1754 | if (priv->has_get_modeA == 0 && vfo == RIG_VFO_B && curr_vfo != RIG_VFO_B) |
| 1755 | { |
| 1756 | vfoSwitched = 1; |
| 1757 | } |
| 1758 | |
| 1759 | if (vfoSwitched) |
| 1760 | { |
| 1761 | rig_debug(RIG_DEBUG_TRACE, "%s switch to VFOB=%d\n", __func__, |
| 1762 | priv->has_get_modeA); |
| 1763 | retval = flrig_set_vfo(rig, RIG_VFO_B); |
| 1764 | |
| 1765 | if (retval < 0) |
no test coverage detected