From 94b1a00040872027556680e693a3e7cb8a0ae648 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 18 Jan 2017 13:44:32 +0000 Subject: [PATCH] Add some debug diagnostics for the Hamlib optional settings JSON file git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7530 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- HamlibTransceiver.cpp | 100 +++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/HamlibTransceiver.cpp b/HamlibTransceiver.cpp index 21b5323be..1d8134a3d 100644 --- a/HamlibTransceiver.cpp +++ b/HamlibTransceiver.cpp @@ -252,58 +252,58 @@ HamlibTransceiver::HamlibTransceiver (int model_number, TransceiverFactory::Para // rig_->state.obj = this; - { - // - // user defined Hamlib settings - // - auto settings_file_name = QStandardPaths::locate ( -#if QT_VERSION >= 0x050500 - QStandardPaths::AppConfigLocation -#else - QStandardPaths::ConfigLocation -#endif - , "hamlib_settings.json"); - if (!settings_file_name.isEmpty ()) - { - QFile 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)}; - } - 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_) { + // + // user defined Hamlib settings + // + auto settings_file_name = QStandardPaths::locate ( +#if QT_VERSION >= 0x050500 + QStandardPaths::AppConfigLocation +#else + QStandardPaths::ConfigLocation +#endif + , "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 ()); + } + } + } + } + switch (rig_->caps->port_type) { case RIG_PORT_SERIAL: