diff options
Diffstat (limited to 'Transceiver/HamlibTransceiver.cpp')
| -rwxr-xr-x | Transceiver/HamlibTransceiver.cpp | 141 |
1 files changed, 123 insertions, 18 deletions
diff --git a/Transceiver/HamlibTransceiver.cpp b/Transceiver/HamlibTransceiver.cpp index 08da6d3b..4d2795a8 100755 --- a/Transceiver/HamlibTransceiver.cpp +++ b/Transceiver/HamlibTransceiver.cpp @@ -7,6 +7,7 @@ #include <QString>
#include <QStandardPaths>
#include <QFile>
+#include <QTimer>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>
@@ -148,6 +149,10 @@ public: , tickle_hamlib_ {false}
, get_vfo_works_ {true}
, set_vfo_works_ {true}
+ , do_snr_ {false}
+ , do_pwr_ {false}
+ , do_pwr2_ {false}
+ , do_swr_ {false}
{
}
@@ -167,6 +172,10 @@ public: , tickle_hamlib_ {false}
, get_vfo_works_ {true}
, set_vfo_works_ {true}
+ , do_snr_ {false}
+ , do_pwr_ {false}
+ , do_pwr2_ {false}
+ , do_swr_ {false}
{
}
@@ -207,6 +216,10 @@ public: // establish the Tx VFO
bool get_vfo_works_; // Net rigctl promises what it can't deliver
bool set_vfo_works_; // More rigctl promises which it can't deliver
+ bool do_snr_;
+ bool do_pwr_;
+ bool do_pwr2_;
+ bool do_swr_;
static int debug_callback (enum rig_debug_level_e level, rig_ptr_t arg, char const * format, va_list ap);
};
@@ -320,7 +333,7 @@ QByteArray HamlibTransceiver::impl::get_conf (char const * item) QByteArray value {128, '\0'};
if (RIG_CONF_END != token) // only get if valid for rig model
{
- error_check (rig_get_conf (rig_.data (), token, value.data ()), tr ("getting a configuration item"));
+ error_check (rig_get_conf2 (rig_.data (), token, value.data (),value.length()), tr ("getting a configuration item")); //changed to conf2, added parameter for buffer length
}
return value;
}
@@ -459,6 +472,9 @@ HamlibTransceiver::HamlibTransceiver (logger_type * logger, if (!m_->is_dummy_)
{
+ // printf("Hamlib open params: power_on=%d power_off=%d ptt_share=%d\n",(params.poll_interval & rig__power) == rig__power,(params.poll_interval & rig__power_off) == rig__power_off,(params.poll_interval & ptt__share) == ptt__share);
+ if (params.poll_interval & do__pwr) { do_pwr_ = true; do_pwr2_ = true; do_swr_ = true;}
+
switch (rig_get_caps_int (m_->model_, RIG_CAPS_PORT_TYPE))
{
case RIG_PORT_SERIAL:
@@ -619,6 +635,12 @@ int HamlibTransceiver::do_start () CAT_TRACE ("starting: " << rig_get_caps_cptr (m_->model_, RIG_CAPS_MFG_NAME_CPTR)
<< ": " << rig_get_caps_cptr (m_->model_, RIG_CAPS_MODEL_NAME_CPTR));
+ token_t token = rig_token_lookup (m_->rig_.data (), "client");
+ if (RIG_CONF_END != token) // only set if valid for rig model
+ {
+ rig_set_conf (m_->rig_.data (), token, "WSJTX");
+ }
+
m_->error_check (rig_open (m_->rig_.data ()), tr ("opening connection to rig"));
// reset dynamic state
@@ -630,6 +652,9 @@ int HamlibTransceiver::do_start () m_->tickle_hamlib_ = false;
m_->get_vfo_works_ = true;
m_->set_vfo_works_ = true;
+ do_pwr_ &= (!m_->is_dummy_ && rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_LEVEL) && (rig_get_caps_int (m_->model_, RIG_CAPS_HAS_GET_LEVEL) & RIG_LEVEL_RFPOWER_METER_WATTS) == RIG_LEVEL_RFPOWER_METER_WATTS);
+ do_pwr2_ &= (!m_->is_dummy_ && rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_LEVEL) && (rig_get_caps_int (m_->model_, RIG_CAPS_HAS_GET_LEVEL) & RIG_LEVEL_RFPOWER) == RIG_LEVEL_RFPOWER);
+ do_swr_ &= (!m_->is_dummy_ && rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_LEVEL) && (rig_get_caps_int (m_->model_, RIG_CAPS_HAS_GET_LEVEL) & RIG_LEVEL_SWR) == RIG_LEVEL_SWR);
// the Net rigctl back end promises all functions work but we must
// test get_vfo as it determines our strategy for Icom rigs
@@ -659,7 +684,7 @@ int HamlibTransceiver::do_start () rmode_t mb;
pbwidth_t w {RIG_PASSBAND_NORMAL};
pbwidth_t wb;
- if (m_->freq_query_works_
+ if (m_->freq_query_works_ && m_->mode_query_works_
&& (!m_->get_vfo_works_ || !rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_VFO)))
{
// Icom have deficient CAT protocol with no way of reading which
@@ -760,7 +785,7 @@ int HamlibTransceiver::do_start () m_->reversed_ = RIG_VFO_B == v;
- if (m_->mode_query_works_ && !(rig_get_caps_int (m_->model_, RIG_CAPS_TARGETABLE_VFO) & (RIG_TARGETABLE_MODE | RIG_TARGETABLE_PURE)))
+ if (m_->mode_query_works_ && !(rig_get_caps_int (m_->model_, RIG_CAPS_TARGETABLE_VFO) & RIG_TARGETABLE_MODE))
{
if (RIG_OK == rig_get_mode (m_->rig_.data (), RIG_VFO_CURR, &m, &w))
{
@@ -911,9 +936,9 @@ void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore) // to frequency such as the TS-2000 auto mode setting
CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode));
m_->error_check (rig_set_mode (m_->rig_.data (), target_vfo, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode"));
- // set mode on VFOB too if we are in split
- if (state ().split()) rig_set_mode (m_->rig_.data (), RIG_VFO_B, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting VFOB mode");
}
+ // set mode on VFOB too if we are in split
+ if (state ().split()) rig_set_mode (m_->rig_.data (), RIG_VFO_B, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting VFOB mode");
update_mode (m);
}
}
@@ -1147,7 +1172,7 @@ void HamlibTransceiver::do_poll () if ((WSJT_RIG_NONE_CAN_SPLIT || !m_->is_dummy_)
&& state ().split ()
- && (rig_get_caps_int (m_->model_, RIG_CAPS_TARGETABLE_VFO) & (RIG_TARGETABLE_FREQ | RIG_TARGETABLE_PURE))
+ && (rig_get_caps_int (m_->model_, RIG_CAPS_TARGETABLE_VFO) & RIG_TARGETABLE_FREQ)
&& !m_->one_VFO_)
{
// only read "other" VFO if in split, this allows rigs like
@@ -1190,27 +1215,78 @@ void HamlibTransceiver::do_poll () }
if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt && rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_PTT))
- {
- ptt_t p;
- auto rc = rig_get_ptt (m_->rig_.data (), RIG_VFO_CURR, &p);
- if (-RIG_ENAVAIL != rc && -RIG_ENIMPL != rc) // may fail if
- // Net rig ctl and target doesn't
- // support command
- {
- m_->error_check (rc, tr ("getting PTT state"));
- CAT_TRACE ("rig_get_ptt PTT=" << p);
- update_PTT (!(RIG_PTT_OFF == p));
+ {
+ ptt_t p;
+ auto rc = rig_get_ptt (m_->rig_.data (), RIG_VFO_CURR, &p);
+ if (-RIG_ENAVAIL != rc && -RIG_ENIMPL != rc) // may fail if
+ // Net rig ctl and target doesn't
+ // support command
+ {
+ m_->error_check (rc, tr ("getting PTT state"));
+ CAT_TRACE ("rig_get_ptt PTT=" << p);
+ update_PTT (!(RIG_PTT_OFF == p));
+ }
+ }
+
+ if (ptt_on_) {
+ // update PWR and SWR
+ value_t strength;
+ int rc;
+ if (do_swr_) {
+ rc = rig_get_level (m_->rig_.data (), RIG_VFO_CURR, RIG_LEVEL_SWR, &strength);
+ if (RIG_OK == rc && ptt_on_) {
+ // printf ("SWR %.3f\n",strength.f);
+ if (strength.f >= 1.000)
+ {
+ update_swr (strength.f*100);
+ }
+ else
+ {
+ update_swr (0);
+ }
+ } else {
+ CAT_TRACE ("rig_get_level RIG_LEVEL_SWR failed with rc:" << rc << "ignoring");
+ update_swr (0);
}
}
+ if (do_pwr_) {
+ rc = rig_get_level (m_->rig_.data (), RIG_VFO_CURR, RIG_LEVEL_RFPOWER_METER_WATTS, &strength);
+ if (RIG_OK == rc) {
+ update_power (strength.f*1000);
+ } else {
+ CAT_TRACE ("rig_get_level RFPOWER_METER_WATTS failed with rc:" << rc << "ignoring");
+ update_power (0);
+ }
+ } else if (do_pwr2_) {
+ rc = rig_get_level (m_->rig_.data (), RIG_VFO_CURR, RIG_LEVEL_RFPOWER, &strength);
+ if (RIG_OK == rc) {
+ unsigned int mwpower;
+ rc = rig_power2mW(m_->rig_.data (),&mwpower,strength.f,f,m);
+ if (RIG_OK != rc) {
+ CAT_TRACE ("rig_power2mW failed with rc:" << rc << "ignoring");
+ mwpower=0;
+ }
+ update_power (mwpower);
+ // printf ("POWER %.3f %.1f\n",strength.f,mwpower / 1000.);
+ } else {
+ CAT_TRACE ("rig_get_level RFPOWER failed with rc:" << rc << "ignoring");
+ update_power (0);
+ }
+ } else update_power (0);
+ } else {
+ update_power (0);
+ update_swr (0);
+ }
}
void HamlibTransceiver::do_ptt (bool on)
{
- CAT_TRACE ("PTT: " << on << " " << state () << " reversed=" << m_->reversed_);
+ CAT_TRACE ("PTT: " << on << " " << state () << " reversed=" << m_->reversed_);
if (on)
{
- if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt)
+ if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt)
{
+ ptt_on_ = true;
CAT_TRACE ("rig_set_ptt PTT=true");
auto ptt_type = rig_get_caps_int (m_->model_, RIG_CAPS_PTT_TYPE);
m_->error_check (rig_set_ptt (m_->rig_.data (), RIG_VFO_CURR
@@ -1222,6 +1298,7 @@ void HamlibTransceiver::do_ptt (bool on) {
if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt)
{
+ ptt_on_ = false;
CAT_TRACE ("rig_set_ptt PTT=false");
m_->error_check (rig_set_ptt (m_->rig_.data (), RIG_VFO_CURR, RIG_PTT_OFF), tr ("setting PTT off"));
}
@@ -1229,3 +1306,31 @@ void HamlibTransceiver::do_ptt (bool on) update_PTT (on);
}
+
+// pass in false if any post_action is needed for a rig -- don't know of any as of 2024-04-14
+void HamlibTransceiver::do_tune (bool on)
+{
+ CAT_TRACE ("Tune: " << on << " " << state ());
+ if (on)
+ {
+ if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt)
+ {
+ update_PTT (true); // we'll change the PTT button while we do this
+ CAT_TRACE ("rig_vfo_opt RIG_VFO_OP_TUNE=" << on);
+ // ptt button will stay lit if error message is displaye
+ m_->error_check(rig_vfo_op (m_->rig_.data (), RIG_VFO_CURR, RIG_OP_TUNE), "turning TUNE on");
+ update_PTT (false);
+ }
+ }
+#if 0
+ else // do we need to be able to turn PTT off on anybody?
+ {
+ if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt)
+ {
+ ptt_on_ = false;
+ CAT_TRACE ("rig_set_ptt PTT=false");
+ m_->error_check (rig_set_ptt (m_->rig_.data (), RIG_VFO_CURR, RIG_PTT_OFF), tr ("setting PTT off"));
+ }
+ }
+#endif
+}
|
