Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions QLog.pro
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ SOURCES += \
rig/drivers/GenericRigDrv.cpp \
rig/drivers/HamlibRigDrv.cpp \
rig/drivers/TCIRigDrv.cpp \
rig/rigctldmanager.cpp \
rotator/RotCaps.cpp \
rotator/Rotator.cpp \
rotator/drivers/GenericRotDrv.cpp \
Expand Down Expand Up @@ -252,6 +253,7 @@ HEADERS += \
rig/drivers/HamlibRigDrv.h \
rig/drivers/TCIRigDrv.h \
rig/macros.h \
rig/rigctldmanager.h \
rotator/RotCaps.h \
rotator/Rotator.h \
rotator/drivers/GenericRotDrv.h \
Expand Down Expand Up @@ -476,8 +478,32 @@ macx: {
INSTALLS += target
}

INCLUDEPATH += /usr/local/include /opt/homebrew/include
LIBS += -L/usr/local/lib -L/opt/homebrew/lib -lhamlib -lsqlite3
RIGCTLD_PATH =
RIGCTLD_CANDIDATES = \
/opt/homebrew/bin/rigctld \ # Apple Silicon Homebrew
/usr/local/bin/rigctld \ # Intel Homebrew or older setups
$$HOME/bin/rigctld \ # user bin
$$PWD/third_party/rigctld # project-local copy (if you keep one)

for (c, RIGCTLD_CANDIDATES) {
exists($$c) {
RIGCTLD_PATH = $$c
break()
}
}

!isEmpty(RIGCTLD_PATH) {
message(Embedding rigctld from: $$RIGCTLD_PATH)
rigctld.files = $$RIGCTLD_PATH
rigctld.path = Contents/MacOS # put next to your app binary
QMAKE_BUNDLE_DATA += rigctld
} else {
message(rigctld not found; not embedding)
}


INCLUDEPATH += /usr/local/include /opt/homebrew/include /opt/local/include
LIBS += -L/usr/local/lib -L/opt/homebrew/lib -lhamlib -lsqlite3 -L/opt/local/lib
equals(QT_MAJOR_VERSION, 6): LIBS += -lqt6keychain
equals(QT_MAJOR_VERSION, 5): LIBS += -lqt5keychain
DISTFILES +=
Expand Down
2 changes: 1 addition & 1 deletion core/Migration.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Migration : public QObject
QString fixIntlField(QSqlQuery &query, const QString &columName, const QString &columnNameIntl);
bool refreshUploadStatusTrigger();

static const int latestVersion = 34;
static const int latestVersion = 35;
};

#endif // QLOG_CORE_MIGRATION_H
19 changes: 14 additions & 5 deletions data/RigProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ QDataStream& operator<<(QDataStream& out, const RigProfile& v)
<< v.xitOffset << v.getRITInfo << v.getXITInfo
<< v.defaultPWR << v.getPTTInfo << v.QSYWiping
<< v.getKeySpeed << v.assignedCWKey << v.keySpeedSync
<< v.driver << v.dxSpot2Rig << v.pttType << v.pttPortPath;
<< v.driver << v.dxSpot2Rig << v.pttType << v.pttPortPath
<< v.use_rigctld << v.use_rigctld_debug;

return out;
}
Expand Down Expand Up @@ -57,6 +58,8 @@ QDataStream& operator>>(QDataStream& in, RigProfile& v)
in >> v.dxSpot2Rig;
in >> v.pttType;
in >> v.pttPortPath;
in >> v.use_rigctld;
in >> v.use_rigctld_debug;

return in;
}
Expand All @@ -73,7 +76,8 @@ RigProfilesManager::RigProfilesManager() :
"pollinterval, txfreq_start, txfreq_end, get_freq, get_mode, "
"get_vfo, get_pwr, rit_offset, xit_offset, get_rit, get_xit, "
"default_pwr, get_ptt, qsy_wiping, get_key_speed, assigned_cw_key, "
"key_speed_sync, driver, dxspot2rig, ptt_type, ptt_port_pathname "
"key_speed_sync, driver, dxspot2rig, ptt_type, ptt_port_pathname, "
"use_rigctld, use_rigctld_debug "
"FROM rig_profiles") )
{
qWarning()<< "Cannot prepare select";
Expand Down Expand Up @@ -115,7 +119,8 @@ RigProfilesManager::RigProfilesManager() :
profileDB.dxSpot2Rig = profileQuery.value(28).toBool();
profileDB.pttType = profileQuery.value(29).toString();
profileDB.pttPortPath = profileQuery.value(30).toString();

profileDB.use_rigctld = profileQuery.value(31).toBool();
profileDB.use_rigctld_debug = profileQuery.value(32).toBool();
addProfile(profileDB.profileName, profileDB);
}
}
Expand All @@ -142,12 +147,12 @@ void RigProfilesManager::save()
"baudrate, databits, stopbits, flowcontrol, parity, pollinterval, txfreq_start, "
"txfreq_end, get_freq, get_mode, get_vfo, get_pwr, rit_offset, xit_offset, get_rit, "
"get_xit, default_pwr, get_ptt, qsy_wiping, get_key_speed, assigned_cw_key, key_speed_sync, "
"driver, dxSpot2Rig, ptt_type, ptt_port_pathname ) "
"driver, dxSpot2Rig, ptt_type, ptt_port_pathname, use_rigctld, use_rigctld_debug ) "
"VALUES (:profile_name, :model, :port_pathname, :hostname, :netport, "
":baudrate, :databits, :stopbits, :flowcontrol, :parity, :pollinterval, :txfreq_start, "
":txfreq_end, :get_freq, :get_mode, :get_vfo, :get_pwr, :rit_offset, :xit_offset, :get_rit, "
":get_xit, :default_pwr, :get_ptt, :qsy_wiping, :get_key_speed, :assigned_cw_key, :key_speed_sync, "
":driver, :dxSpot2Rig, :ptt_type, :ptt_port_pathname)") )
":driver, :dxSpot2Rig, :ptt_type, :ptt_port_pathname, :use_rigctld, :use_rigctld_debug )") )
{
qWarning() << "cannot prepare Insert statement";
return;
Expand Down Expand Up @@ -191,6 +196,8 @@ void RigProfilesManager::save()
insertQuery.bindValue(":dxSpot2Rig", rigProfile.dxSpot2Rig);
insertQuery.bindValue(":ptt_type", rigProfile.pttType);
insertQuery.bindValue(":ptt_port_pathname", rigProfile.pttPortPath);
insertQuery.bindValue(":use_rigctld",rigProfile.use_rigctld);
insertQuery.bindValue(":use_rigctld_debug",rigProfile.use_rigctld_debug);

if ( ! insertQuery.exec() )
{
Expand Down Expand Up @@ -239,6 +246,8 @@ bool RigProfile::operator==(const RigProfile &profile)
&& profile.dxSpot2Rig == this->dxSpot2Rig
&& profile.pttType == this->pttType
&& profile.pttPortPath == this->pttPortPath
&& profile.use_rigctld == this->use_rigctld
&& profile.use_rigctld_debug == this->use_rigctld_debug
);
}

Expand Down
4 changes: 3 additions & 1 deletion data/RigProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RigProfile
ritOffset = 0.0; xitOffset = 0.0, getRITInfo = false;
getXITInfo = true; defaultPWR = 0.0, getPTTInfo = false;
QSYWiping = false, getKeySpeed = false, keySpeedSync = false;
driver = 0, dxSpot2Rig = false;
driver = 0, dxSpot2Rig = false, use_rigctld = false, use_rigctld_debug = false;
};

QString profileName;
Expand Down Expand Up @@ -63,6 +63,8 @@ class RigProfile
bool dxSpot2Rig;
QString pttType;
QString pttPortPath;
bool use_rigctld;
bool use_rigctld_debug;

bool operator== (const RigProfile &profile);
bool operator!= (const RigProfile &profile);
Expand Down
1 change: 1 addition & 0 deletions res/res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@
<file>sql/migration_032.sql</file>
<file>sql/migration_033.sql</file>
<file>sql/migration_034.sql</file>
<file>sql/migration_035.sql</file>
</qresource>
</RCC>
2 changes: 2 additions & 0 deletions res/sql/migration_035.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE rig_profiles ADD use_rigctld INTEGER DEFAULT 0;
ALTER TABLE rig_profiles ADD use_rigctld_debug INTEGER DEFAULT 0;
115 changes: 82 additions & 33 deletions rig/drivers/HamlibRigDrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "core/debug.h"
#include "rig/macros.h"
#include "data/SerialPort.h"
#include "rig/rigctldmanager.h"

#ifndef HAMLIB_FILPATHLEN
#define HAMLIB_FILPATHLEN FILPATHLEN
Expand Down Expand Up @@ -157,6 +158,8 @@ HamlibRigDrv::HamlibRigDrv(const RigProfile &profile,
lastErrorText = tr("Initialization Error");
}

// rigctld_ = std::make_unique<RigctldManager>(this);
rigctld_.reset(new RigctldManager(this));
rig_set_debug(RIG_DEBUG_BUG);

connect(&errorTimer, &QTimer::timeout,
Expand All @@ -174,6 +177,11 @@ HamlibRigDrv::~HamlibRigDrv()
return;
}

if (rigctld_)
{
rigctld_->stop();
}

if ( rig )
{
rig_close(rig);
Expand All @@ -198,52 +206,93 @@ bool HamlibRigDrv::open()
}

RigProfile::rigPortType portType = rigProfile.getPortType();
rigctld_->setDebugLogsEnabled(rigProfile.use_rigctld_debug);

if ( portType == RigProfile::NETWORK_ATTACHED )
QString err;
const QString rigctldPath = rigctld_->findRigctldExecutable();

if (!rigctldPath.isEmpty() &&
rigProfile.use_rigctld)
{
//handling Network Radio
const QString portString = rigProfile.hostname + ":" + QString::number(rigProfile.netport);
if(!rigctld_->startFromProfile(rigProfile, 4532, rigctldPath, &err))
{
qWarning() << "Couldn't Launch RigCtlD";
return false;
}
qCDebug(runtime) << "rigctld started; switching to NETRIGCTL model";

// 1) Dispose of the rig initialized with the hardware model
rig_close(rig); // safe even if not opened yet
rig_cleanup(rig);
rig = nullptr;

// 2) Re-init as NETRIGCTL (hamlib model 2)
rig = rig_init(RIG_MODEL_NETRIGCTL);

if (!rig) {
lastErrorText = tr("Initialization Error (NETRIGCTL)");
qCDebug(runtime) << "Cannot allocate NET rig structure";
return false;
}

// optional: keep your debug level
rig_set_debug(RIG_DEBUG_BUG);

// 3) Point NETRIG to local rigctld
QString portString = "127.0.0.1:" + QString::number(rigctld_->listenPort());
strncpy(rig->state.rigport.pathname, portString.toLocal8Bit().constData(), HAMLIB_FILPATHLEN - 1);

// From here down, treat it like a network-attached rig
// (skip the hardware serial config branch entirely)
portType = RigProfile::NETWORK_ATTACHED;
}
else if ( portType == RigProfile::SERIAL_ATTACHED )
else
{
//handling Serial Port Radio
strncpy(rig->state.rigport.pathname, rigProfile.portPath.toLocal8Bit().constData(), HAMLIB_FILPATHLEN - 1);
rig->state.rigport.parm.serial.rate = rigProfile.baudrate;
rig->state.rigport.parm.serial.data_bits = rigProfile.databits;
rig->state.rigport.parm.serial.stop_bits = rigProfile.stopbits;
rig->state.rigport.parm.serial.handshake = stringToHamlibFlowControl(rigProfile.flowcontrol);
rig->state.rigport.parm.serial.parity = stringToHamlibParity(rigProfile.parity);

qCDebug(runtime) << "Using PTT Type" << rigProfile.pttType.toLocal8Bit().constData()
<< "PTT Path" << rigProfile.pttPortPath;

if ( !rigProfile.pttPortPath.isEmpty() )
if ( portType == RigProfile::NETWORK_ATTACHED )
{
strncpy(PTTPORT(rig)->pathname, rigProfile.pttPortPath.toLocal8Bit().constData(), HAMLIB_FILPATHLEN - 1);
//handling Network Radio
const QString portString = rigProfile.hostname + ":" + QString::number(rigProfile.netport);
strncpy(rig->state.rigport.pathname, portString.toLocal8Bit().constData(), HAMLIB_FILPATHLEN - 1);
}

if ( rig_set_conf(rig, rig_token_lookup(rig, "ptt_type"), rigProfile.pttType.toLocal8Bit().constData()) != RIG_OK )
else if ( portType == RigProfile::SERIAL_ATTACHED )
{
lastErrorText = tr("Cannot set PTT Type");
qCDebug(runtime) << "Rig Open Error" << lastErrorText;
return false;
}
//handling Serial Port Radio
strncpy(rig->state.rigport.pathname, rigProfile.portPath.toLocal8Bit().constData(), HAMLIB_FILPATHLEN - 1);
rig->state.rigport.parm.serial.rate = rigProfile.baudrate;
rig->state.rigport.parm.serial.data_bits = rigProfile.databits;
rig->state.rigport.parm.serial.stop_bits = rigProfile.stopbits;
rig->state.rigport.parm.serial.handshake = stringToHamlibFlowControl(rigProfile.flowcontrol);
rig->state.rigport.parm.serial.parity = stringToHamlibParity(rigProfile.parity);

qCDebug(runtime) << "Using PTT Type" << rigProfile.pttType.toLocal8Bit().constData()
<< "PTT Path" << rigProfile.pttPortPath;

if ( !rigProfile.pttPortPath.isEmpty() )
{
strncpy(PTTPORT(rig)->pathname, rigProfile.pttPortPath.toLocal8Bit().constData(), HAMLIB_FILPATHLEN - 1);
}

if ( rig_set_conf(rig, rig_token_lookup(rig, "ptt_share"), "1") != RIG_OK )
if ( rig_set_conf(rig, rig_token_lookup(rig, "ptt_type"), rigProfile.pttType.toLocal8Bit().constData()) != RIG_OK )
{
lastErrorText = tr("Cannot set PTT Type");
qCDebug(runtime) << "Rig Open Error" << lastErrorText;
return false;
}

if ( rig_set_conf(rig, rig_token_lookup(rig, "ptt_share"), "1") != RIG_OK )
{
lastErrorText = tr("Cannot set PTT Share");
qCDebug(runtime) << "Rig Open Error" << lastErrorText;
return false;
}
}
else
{
lastErrorText = tr("Cannot set PTT Share");
lastErrorText = tr("Unsupported Rig Driver");
qCDebug(runtime) << "Rig Open Error" << lastErrorText;
return false;
}
}
else
{
lastErrorText = tr("Unsupported Rig Driver");
qCDebug(runtime) << "Rig Open Error" << lastErrorText;
return false;
}

}
int status = rig_open(rig);

if ( !isRigRespOK(status, tr("Rig Open Error"), false) )
Expand Down
3 changes: 2 additions & 1 deletion rig/drivers/HamlibRigDrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "GenericRigDrv.h"
#include "rig/RigCaps.h"
#include "rig/rigctldmanager.h"

class HamlibRigDrv : public GenericRigDrv
{
Expand Down Expand Up @@ -76,7 +77,7 @@ private slots:
serial_handshake_e stringToHamlibFlowControl(const QString &in_flowcontrol);
serial_parity_e stringToHamlibParity(const QString &in_parity);
QString hamlibErrorString(int);

std::unique_ptr<RigctldManager> rigctld_;
RIG* rig;
QTimer timer;
QTimer errorTimer;
Expand Down
Loading
Loading