mirror of https://github.com/saitohirga/WSJT-X.git
Turn on Hamlib PTT sharing by default and always apply config overrides
This commit is contained in:
parent
acdef27892
commit
469b9a5ef5
|
@ -232,7 +232,11 @@ HamlibTransceiver::HamlibTransceiver (logger_type * logger,
|
||||||
{
|
{
|
||||||
set_conf ("ptt_type", "RTS");
|
set_conf ("ptt_type", "RTS");
|
||||||
}
|
}
|
||||||
|
set_conf ("ptt_share", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do this late to allow any configuration option to be overriden
|
||||||
|
load_user_settings ();
|
||||||
}
|
}
|
||||||
|
|
||||||
HamlibTransceiver::HamlibTransceiver (logger_type * logger,
|
HamlibTransceiver::HamlibTransceiver (logger_type * logger,
|
||||||
|
@ -260,51 +264,6 @@ HamlibTransceiver::HamlibTransceiver (logger_type * logger,
|
||||||
|
|
||||||
// rig_->state.obj = this;
|
// rig_->state.obj = this;
|
||||||
|
|
||||||
//
|
|
||||||
// user defined Hamlib settings
|
|
||||||
//
|
|
||||||
auto settings_file_name = QStandardPaths::locate (QStandardPaths::AppConfigLocation
|
|
||||||
, "hamlib_settings.json");
|
|
||||||
if (!settings_file_name.isEmpty ())
|
|
||||||
{
|
|
||||||
QFile settings_file {settings_file_name};
|
|
||||||
qDebug () << "Using Hamlib settings file:" << settings_file_name;
|
|
||||||
if (settings_file.open (QFile::ReadOnly))
|
|
||||||
{
|
|
||||||
QJsonParseError status;
|
|
||||||
auto settings_doc = QJsonDocument::fromJson (settings_file.readAll (), &status);
|
|
||||||
if (status.error)
|
|
||||||
{
|
|
||||||
throw error {tr ("Hamlib settings file error: %1 at character offset %2")
|
|
||||||
.arg (status.errorString ()).arg (status.offset)};
|
|
||||||
}
|
|
||||||
qDebug () << "Hamlib settings JSON:" << settings_doc.toJson ();
|
|
||||||
if (!settings_doc.isObject ())
|
|
||||||
{
|
|
||||||
throw error {tr ("Hamlib settings file error: top level must be a JSON object")};
|
|
||||||
}
|
|
||||||
auto const& settings = settings_doc.object ();
|
|
||||||
|
|
||||||
//
|
|
||||||
// configuration settings
|
|
||||||
//
|
|
||||||
auto const& config = settings["config"];
|
|
||||||
if (!config.isUndefined ())
|
|
||||||
{
|
|
||||||
if (!config.isObject ())
|
|
||||||
{
|
|
||||||
throw error {tr ("Hamlib settings file error: config must be a JSON object")};
|
|
||||||
}
|
|
||||||
auto const& config_list = config.toObject ();
|
|
||||||
for (auto item = config_list.constBegin (); item != config_list.constEnd (); ++item)
|
|
||||||
{
|
|
||||||
set_conf (item.key ().toLocal8Bit ().constData ()
|
|
||||||
, (*item).toVariant ().toString ().toLocal8Bit ().constData ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_dummy_)
|
if (!is_dummy_)
|
||||||
{
|
{
|
||||||
switch (rig_->caps->port_type)
|
switch (rig_->caps->port_type)
|
||||||
|
@ -399,11 +358,15 @@ HamlibTransceiver::HamlibTransceiver (logger_type * logger,
|
||||||
{
|
{
|
||||||
set_conf ("ptt_type", "RTS");
|
set_conf ("ptt_type", "RTS");
|
||||||
}
|
}
|
||||||
|
set_conf ("ptt_share", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make Icom CAT split commands less glitchy
|
// Make Icom CAT split commands less glitchy
|
||||||
set_conf ("no_xchg", "1");
|
set_conf ("no_xchg", "1");
|
||||||
|
|
||||||
|
// do this late to allow any configuration option to be overriden
|
||||||
|
load_user_settings ();
|
||||||
|
|
||||||
// would be nice to get events but not supported on Windows and also not on a lot of rigs
|
// would be nice to get events but not supported on Windows and also not on a lot of rigs
|
||||||
// rig_set_freq_callback (rig_.data (), &frequency_change_callback, this);
|
// rig_set_freq_callback (rig_.data (), &frequency_change_callback, this);
|
||||||
}
|
}
|
||||||
|
@ -417,6 +380,54 @@ void HamlibTransceiver::error_check (int ret_code, QString const& doing) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HamlibTransceiver::load_user_settings ()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// user defined Hamlib settings
|
||||||
|
//
|
||||||
|
auto settings_file_name = QStandardPaths::locate (QStandardPaths::AppConfigLocation
|
||||||
|
, "hamlib_settings.json");
|
||||||
|
if (!settings_file_name.isEmpty ())
|
||||||
|
{
|
||||||
|
QFile settings_file {settings_file_name};
|
||||||
|
qDebug () << "Using Hamlib settings file:" << settings_file_name;
|
||||||
|
if (settings_file.open (QFile::ReadOnly))
|
||||||
|
{
|
||||||
|
QJsonParseError status;
|
||||||
|
auto settings_doc = QJsonDocument::fromJson (settings_file.readAll (), &status);
|
||||||
|
if (status.error)
|
||||||
|
{
|
||||||
|
throw error {tr ("Hamlib settings file error: %1 at character offset %2")
|
||||||
|
.arg (status.errorString ()).arg (status.offset)};
|
||||||
|
}
|
||||||
|
qDebug () << "Hamlib settings JSON:" << settings_doc.toJson ();
|
||||||
|
if (!settings_doc.isObject ())
|
||||||
|
{
|
||||||
|
throw error {tr ("Hamlib settings file error: top level must be a JSON object")};
|
||||||
|
}
|
||||||
|
auto const& settings = settings_doc.object ();
|
||||||
|
|
||||||
|
//
|
||||||
|
// configuration settings
|
||||||
|
//
|
||||||
|
auto const& config = settings["config"];
|
||||||
|
if (!config.isUndefined ())
|
||||||
|
{
|
||||||
|
if (!config.isObject ())
|
||||||
|
{
|
||||||
|
throw error {tr ("Hamlib settings file error: config must be a JSON object")};
|
||||||
|
}
|
||||||
|
auto const& config_list = config.toObject ();
|
||||||
|
for (auto item = config_list.constBegin (); item != config_list.constEnd (); ++item)
|
||||||
|
{
|
||||||
|
set_conf (item.key ().toLocal8Bit ().constData ()
|
||||||
|
, (*item).toVariant ().toString ().toLocal8Bit ().constData ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int HamlibTransceiver::do_start ()
|
int HamlibTransceiver::do_start ()
|
||||||
{
|
{
|
||||||
CAT_TRACE ("starting: " << rig_->caps->mfg_name
|
CAT_TRACE ("starting: " << rig_->caps->mfg_name
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
QObject * parent = nullptr);
|
QObject * parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void load_user_settings ();
|
||||||
int do_start () override;
|
int do_start () override;
|
||||||
void do_stop () override;
|
void do_stop () override;
|
||||||
void do_frequency (Frequency, MODE, bool no_ignore) override;
|
void do_frequency (Frequency, MODE, bool no_ignore) override;
|
||||||
|
|
Loading…
Reference in New Issue