Skip to content

Commit efcd6ba

Browse files
committed
Hamlib tests
1 parent fbfe523 commit efcd6ba

File tree

9 files changed

+152
-73
lines changed

9 files changed

+152
-73
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ configure_file(
4343
# Detect OS and print to console
4444
if(WIN32)
4545
message(STATUS "Operating System: Windows")
46+
# Get the path to klog/../libs/win64/hamlib and convert it to an absolute path
47+
get_filename_component(HAMLIB_LOCAL_PATH "${CMAKE_SOURCE_DIR}/../libs/win64/hamlib" ABSOLUTE)
48+
49+
# Check if that folder actually exists before setting it
50+
if(EXISTS "${HAMLIB_LOCAL_PATH}")
51+
set(HAMLIB_ROOT "${HAMLIB_LOCAL_PATH}")
52+
message(STATUS "Generic Windows Libs path found: ${HAMLIB_ROOT}")
53+
endif()
4654
elseif(APPLE)
4755
message(STATUS "Operating System: macOS")
4856
elseif(UNIX)

cmake/FindHamlib.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ set(HAMLIB_ROOT "" CACHE PATH "Root directory of a Hamlib installation (Windows)
2222
#endif ()
2323

2424

25-
2625
# On Windows, auto-discover typical installers under Program Files without requiring a version
2726
if(WIN32)
27+
message(STATUS "Win32 detected in FindHamlib.cmake")
28+
set(HAMLIB_ROOT "C:/Users/radio/Documents/GitHub/libs/win64/hamlib")
2829
set(_hamlib_hints
2930
$ENV{HAMLIB_ROOT}
3031
${HAMLIB_ROOT}

src/hamlibclass.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,15 @@ bool HamLibClass::stop()
474474
bool HamLibClass::init(bool _active)
475475
{
476476
//logEvent(Q_FUNC_INFO, "Start Initialization", Debug);
477+
qDebug() << Q_FUNC_INFO << " - Start Initialization ";
477478
cleanup(); // Limpiar cualquier estado previo
478479
if (!_active)
479480
return true;
480481
loadSettings();
481482

482483
if (myrig_model <= 1) {
483484
//logEvent(Q_FUNC_INFO, "Hamlib disabled or invalid model.", Debug);
485+
qDebug() << Q_FUNC_INFO << " - ERROR: Hamlib disabled or invalid model.";
484486
return false;
485487
}
486488

@@ -489,6 +491,7 @@ bool HamLibClass::init(bool _active)
489491

490492
if (!my_rig) {
491493
//emit hamlibError("Failed to initialize Rig (rig_init returned NULL).");
494+
qDebug() << Q_FUNC_INFO << " - ERROR: Failed to initialize Rig (rig_init returned NULL).";
492495
return false;
493496
}
494497

@@ -497,11 +500,19 @@ bool HamLibClass::init(bool _active)
497500
if (!serialPort.isEmpty()) {
498501
strncpy(my_rig->state.rigport.pathname, serialPort.toLatin1().constData(), FILPATHLEN - 1);
499502
}
503+
else
504+
{
505+
qDebug() << Q_FUNC_INFO << " - ERROR: Serial port is empty!.";
506+
}
500507

501508
// 3. Configurar Velocidad (Baud Rate)
502509
if (bauds > 0) {
503510
my_rig->state.rigport.parm.serial.rate = bauds;
504511
}
512+
else
513+
{
514+
qDebug() << Q_FUNC_INFO << " - ERROR: Bauds <= 0";
515+
}
505516

506517
// Opcional: Configurar otros parámetros por defecto si fuera necesario
507518
// rig_set_conf(my_rig, "rts_state", "OFF");
@@ -516,6 +527,7 @@ bool HamLibClass::init(bool _active)
516527
QString err = QString("Failed to open rig. Error code: %1").arg(ret);
517528
//logEvent(Q_FUNC_INFO, err, Error);
518529
//emit hamlibError(err);
530+
qDebug() << Q_FUNC_INFO << " - ERROR: RIG_OK false: " << err;;
519531

520532
// Limpiamos memoria si falló la apertura
521533
rig_cleanup(my_rig);
@@ -530,7 +542,7 @@ bool HamLibClass::init(bool _active)
530542
timer->start(pollInterval);
531543
return true;
532544
/*
533-
545+
534546
qDebug() << Q_FUNC_INFO << ": " << getNameFromModelId(myrig_model);
535547
if (!loadSettings()) {
536548
qDebug() << Q_FUNC_INFO << ": loadSettings failed, exiting";
@@ -742,13 +754,13 @@ void HamLibClass::setSpeed(const int _speed)
742754
//TODO: Check that it is a valid speed
743755
bauds = _speed;
744756
connected = false;
745-
qDebug() << Q_FUNC_INFO << ": " << QString::number(bauds);
757+
//qDebug() << Q_FUNC_INFO << ": " << QString::number(bauds);
746758
}
747759

748760
void HamLibClass::setDataBits(const int _data)
749761
{
750762
//showDebugLog(Q_FUNC_INFO, "Start");
751-
qDebug() << Q_FUNC_INFO << ": rec: " << QString::number(_data);
763+
//qDebug() << Q_FUNC_INFO << ": rec: " << QString::number(_data);
752764
if ((_data >= 5) && (_data <= 8))
753765
{
754766
dataBits = _data;
@@ -764,7 +776,7 @@ void HamLibClass::setDataBits(const int _data)
764776
void HamLibClass::setStop(const QString &_stop)
765777
{
766778
//showDebugLog(Q_FUNC_INFO, "Start");
767-
qDebug() << Q_FUNC_INFO << ": " << _stop;
779+
//qDebug() << Q_FUNC_INFO << ": " << _stop;
768780

769781
if (_stop == "OneStop")
770782
{
@@ -1058,3 +1070,8 @@ bool HamLibClass::loadSettings()
10581070
pollInterval = 250; // Limit saturation
10591071
return true;
10601072
}
1073+
1074+
void HamLibClass::logEvent(const QString &_func, const QString &_msg, DebugLogLevel _level)
1075+
{
1076+
emit debugLog (_func, _msg, _level);
1077+
}

src/hamlibclass.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class HamLibClass : public QObject
9898
void freqChanged(double newFreq);
9999
void modeChanged(QString newFreq);
100100
void frequency(Frequency newfreq);
101+
void debugLog (QString _func, QString _msg, DebugLogLevel _level);
101102

102103
public slots:
103104
void slotTimer();
@@ -112,6 +113,10 @@ public slots:
112113
QString hamlibMode2Mode(rmode_t _rmode);
113114
rmode_t mode2HamlibMode (const QString &_mode);
114115
bool errorManage(const QString &_func, const int _errorcode);
116+
117+
void logEvent(const QString &_func,
118+
const QString &_msg,
119+
DebugLogLevel _level);
115120
//rmode_t mode2HamlibMode(const QString &_m);
116121
QStringList strings;
117122
QTimer *timer;

0 commit comments

Comments
 (0)