| 728 | } |
| 729 | |
| 730 | QString RigctlProtocol::cmdSetFreq(const QString& arg) |
| 731 | { |
| 732 | QStringList parts = arg.split(' ', Qt::SkipEmptyParts); |
| 733 | const bool wantsTxVfo = !parts.isEmpty() |
| 734 | && (parts.first().toUpper() == QLatin1String("VFOB") |
| 735 | || parts.first().toUpper() == QLatin1String("SUB")); |
| 736 | SliceModel* slice = takeVfoPrefix(parts); |
| 737 | |
| 738 | bool ok; |
| 739 | double hz = parts.isEmpty() ? 0.0 : parts[0].toDouble(&ok); |
| 740 | if (parts.isEmpty() || !ok || hz < 0) return rprt(-1); // RIG_EINVAL |
| 741 | |
| 742 | // VFOB/SUB addresses the split TX slice. targetable_vfo lets clients set the |
| 743 | // TX VFO freq directly without a preceding set_split_vfo (WSJT-X Rig split |
| 744 | // does exactly this), so enable split on demand and route through the |
| 745 | // split-freq path, which creates/promotes the TX slice and applies/stashes. |
| 746 | if (wantsTxVfo) { |
| 747 | ensureSplitTxSlice(); |
| 748 | return cmdSetSplitFreq(parts[0]); |
| 749 | } |
| 750 | if (!slice) return rprt(-8); |
| 751 | |
| 752 | double mhz = hz / 1e6; |
| 753 | RadioModel* model = m_model; |
| 754 | QMetaObject::invokeMethod(slice, [slice, model, mhz]() { |
| 755 | // Recenter only when the target falls outside the pan's current |
| 756 | // span — the cross-band case (e.g. WSJT-X band changes, #536). |
| 757 | // In-span retunes use autopan=0: external Doppler software |
| 758 | // (SatPC32) issues set_freq every few seconds, and recentering |
| 759 | // each one keeps yanking the pan regardless of the GUI's |
| 760 | // Pan-Follows-VFO setting (the recenter happens radio-side). |
| 761 | bool inSpan = false; |
| 762 | if (auto* pan = model ? model->panadapter(slice->panId()) : nullptr) { |
| 763 | const double halfBw = pan->bandwidthMhz() / 2.0; |
| 764 | inSpan = halfBw > 0.0 && qAbs(mhz - pan->centerMhz()) <= halfBw; |
| 765 | } |
| 766 | if (inSpan) slice->setFrequency(mhz); |
| 767 | else slice->tuneAndRecenter(mhz); |
| 768 | }, Qt::QueuedConnection); |
| 769 | return rprt(0); |
| 770 | } |
| 771 | |
| 772 | QString RigctlProtocol::cmdGetMode(const QString& vfo) |
| 773 | { |
nothing calls this directly
no test coverage detected