diff --git a/CatRadio.pro b/CatRadio.pro new file mode 100644 index 0000000..c1e8eaa --- /dev/null +++ b/CatRadio.pro @@ -0,0 +1,53 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + dialogconfig.cpp \ + dialogsetup.cpp \ + guidata.cpp \ + main.cpp \ + mainwindow.cpp \ + rigcommand.cpp \ + rigdaemon.cpp \ + rigdata.cpp \ + smeter.cpp \ + submeter.cpp \ + vfodisplay.cpp + +HEADERS += \ + dialogconfig.h \ + dialogsetup.h \ + guidata.h \ + mainwindow.h \ + rigcommand.h \ + rigdaemon.h \ + rigdata.h \ + smeter.h \ + submeter.h \ + vfodisplay.h + +FORMS += \ + dialogconfig.ui \ + dialogsetup.ui \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +LIBS += -L$$PWD/hamlib/ -lhamlib +INCLUDEPATH += $$PWD/hamlib + +VERSION = 1.0.0 + +RC_ICONS = catradio.ico + +QMAKE_LFLAGS += -no-pie diff --git a/CatRadio.pro.user b/CatRadio.pro.user new file mode 100644 index 0000000..4506bf6 --- /dev/null +++ b/CatRadio.pro.user @@ -0,0 +1,425 @@ + + + + + + EnvironmentId + {3eda28a5-2ae6-4f98-9ee1-3326cb54ce82} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + -fno-delayed-template-parsing + + true + Builtin.BuildSystem + + true + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.1.3 MinGW 64-bit + Desktop Qt 6.1.3 MinGW 64-bit + qt.qt6.613.win64_mingw81_kit + 1 + 0 + 0 + + 0 + C:\Users\Johnny\Documents\QT\build-CatRadio-Desktop_Qt_6_1_3_MinGW_64_bit-Debug + C:/Users/Johnny/Documents/QT/build-CatRadio-Desktop_Qt_6_1_3_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + C:\Users\Johnny\Documents\QT\build-CatRadio-Desktop_Qt_6_1_3_MinGW_64_bit-Release + C:/Users/Johnny/Documents/QT/build-CatRadio-Desktop_Qt_6_1_3_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\Users\Johnny\Documents\QT\build-CatRadio-Desktop_Qt_6_1_3_MinGW_64_bit-Profile + C:/Users/Johnny/Documents/QT/build-CatRadio-Desktop_Qt_6_1_3_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Johnny/Documents/QT/CatRadio/CatRadio.pro + C:/Users/Johnny/Documents/QT/CatRadio/CatRadio.pro + false + true + true + false + true + C:/Users/Johnny/Documents/QT/build-CatRadio-Desktop_Qt_6_1_3_MinGW_64_bit-Release + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + Desktop Qt 5.15.2 MinGW 32-bit + Desktop Qt 5.15.2 MinGW 32-bit + qt.qt5.5152.win32_mingw81_kit + 0 + 0 + 0 + + 0 + C:\Users\Johnny\Documents\QT\build-CatRadio-Desktop_Qt_5_15_2_MinGW_32_bit-Debug + C:/Users/Johnny/Documents/QT/build-CatRadio-Desktop_Qt_5_15_2_MinGW_32_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + C:\Users\Johnny\Documents\QT\build-CatRadio-Desktop_Qt_5_15_2_MinGW_32_bit-Release + C:/Users/Johnny/Documents/QT/build-CatRadio-Desktop_Qt_5_15_2_MinGW_32_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\Users\Johnny\Documents\QT\build-CatRadio-Desktop_Qt_5_15_2_MinGW_32_bit-Profile + C:/Users/Johnny/Documents/QT/build-CatRadio-Desktop_Qt_5_15_2_MinGW_32_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Johnny/Documents/QT/CatRadio/CatRadio.pro + C:/Users/Johnny/Documents/QT/CatRadio/CatRadio.pro + false + true + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/ChangeLog.txt b/ChangeLog.txt new file mode 100644 index 0000000..d9c1e88 --- /dev/null +++ b/ChangeLog.txt @@ -0,0 +1,14 @@ +CatRadio + +1.1.0 + + AF Gain and Squelch slider + + Tab with CW and FM functions + * SWR meter with log scale + * CI-V Address entry in hex + * Bug: RF Gain slider now correctly updated + * Bug: noise filters init settings now correctly updated + * Cosmetic adjustement to fit the font for different SO compiler + + +1.0.0 + First release \ No newline at end of file diff --git a/catradio.ico b/catradio.ico new file mode 100644 index 0000000..37954a6 Binary files /dev/null and b/catradio.ico differ diff --git a/catradio.png b/catradio.png new file mode 100644 index 0000000..1b3c75d Binary files /dev/null and b/catradio.png differ diff --git a/dialogconfig.cpp b/dialogconfig.cpp new file mode 100644 index 0000000..fc8028f --- /dev/null +++ b/dialogconfig.cpp @@ -0,0 +1,117 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#include "dialogconfig.h" +#include "ui_dialogconfig.h" + +#include +#include +#include + +#include "rigdata.h" + +#include + + +extern rigConnect rigCom; + + +QString rigListFile = "rig.lst"; //Text file containing the list of rig supported by hamlib +QFile file(rigListFile); + + +DialogConfig::DialogConfig(QWidget *parent) : + QDialog(parent), + ui(new Ui::DialogConfig) +{ + ui->setupUi(this); + + //* rigModel comboBox + if (!file.exists()) //Create file rig.lst if not exists + { + file.open(QIODevice::ReadWrite); + rig_load_all_backends(); //Load all backends information + rig_list_foreach(printRigList, NULL); //Create the rig list + } + else file.open(QIODevice::ReadOnly); //Open file rig.lst and populate the combobox + file.seek(0); + ui->comboBox_rigModel->clear(); + while(!file.atEnd()) + { + QString line = file.readLine(); + ui->comboBox_rigModel->addItem(line.trimmed()); + } + file.close(); + + //* serialSpeed comboBox + ui->comboBox_serialSpeed->clear(); + ui->comboBox_serialSpeed->addItem("4800"); + ui->comboBox_serialSpeed->addItem("9600"); + ui->comboBox_serialSpeed->addItem("19200"); + ui->comboBox_serialSpeed->addItem("38400"); + ui->comboBox_serialSpeed->addItem("57600"); + ui->comboBox_serialSpeed->addItem("115200"); + + //* Update values in the GUI + ui->comboBox_rigModel->setCurrentIndex(ui->comboBox_rigModel->findText(QString::number(rigCom.rigModel),Qt::MatchStartsWith)); + ui->lineEdit_RigPath->setText(rigCom.rigPort); + ui->comboBox_serialSpeed->setCurrentText(QString::number(rigCom.serialSpeed)); + if (rigCom.civAddr) ui->lineEdit_civAddr->setText(QString::number(rigCom.civAddr,16)); + ui->spinBox_RefreshRate->setValue(rigCom.rigRefresh); + ui->checkBox_fullPoll->setChecked(rigCom.fullPoll); +} + +DialogConfig::~DialogConfig() +{ + delete ui; +} + +void DialogConfig::on_buttonBox_accepted() +{ + bool civAddrConv; + + //* Read settings from GUI + QString rigModel = ui->comboBox_rigModel->currentText(); + QRegularExpression regexp("[0-9]+"); + QRegularExpressionMatch rigNumber = regexp.match(rigModel); + rigCom.rigModel = rigNumber.captured(0).toInt(); + + rigCom.rigPort = ui->lineEdit_RigPath->text(); + rigCom.serialSpeed = ui->comboBox_serialSpeed->currentText().toInt(); + rigCom.civAddr = ui->lineEdit_civAddr->text().toInt(&civAddrConv,16); + rigCom.rigRefresh = ui->spinBox_RefreshRate->value(); + rigCom.fullPoll = ui->checkBox_fullPoll->isChecked(); + + //* Save settings in config.ini + QSettings configFile(QString("config.ini"), QSettings::IniFormat); + configFile.setValue("rigModel", rigCom.rigModel); + configFile.setValue("rigPort", ui->lineEdit_RigPath->text()); + configFile.setValue("serialSpeed", ui->comboBox_serialSpeed->currentText()); + configFile.setValue("civAddress", ui->lineEdit_civAddr->text().toInt(&civAddrConv,16)); + configFile.setValue("rigRefresh", ui->spinBox_RefreshRate->value()); + configFile.setValue("fullPolling", ui->checkBox_fullPoll->isChecked()); +} + +int printRigList(const struct rig_caps *rigCaps, void *data) //Load rig list from hamlib and save into file rig.lst +{ + if (data) return 0; + QTextStream stream(&file); + stream << rigCaps->rig_model << " " << rigCaps->mfg_name << " " << rigCaps->model_name << "\n"; + return 1; +} diff --git a/dialogconfig.h b/dialogconfig.h new file mode 100644 index 0000000..3afdf77 --- /dev/null +++ b/dialogconfig.h @@ -0,0 +1,46 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#ifndef DIALOGCONFIG_H +#define DIALOGCONFIG_H + +#include + +namespace Ui { +class DialogConfig; +} + +class DialogConfig : public QDialog +{ + Q_OBJECT + +public: + explicit DialogConfig(QWidget *parent = nullptr); + ~DialogConfig(); + +private slots: + void on_buttonBox_accepted(); + +private: + Ui::DialogConfig *ui; +}; + +int printRigList(const struct rig_caps *rigCaps, void *data); + +#endif // DIALOGCONFIG_H diff --git a/dialogconfig.ui b/dialogconfig.ui new file mode 100644 index 0000000..9473c2c --- /dev/null +++ b/dialogconfig.ui @@ -0,0 +1,192 @@ + + + DialogConfig + + + + 0 + 0 + 400 + 300 + + + + Config + + + + + + Model + + + + + + + + + + Path + + + lineEdit_RigPath + + + + + + + e.g. COM2 or /dev/ttyUSB1 + + + + + + + Speed + + + comboBox_serialSpeed + + + + + + + + + + Refresh Rate + + + spinBox_RefreshRate + + + + + + + 50 + + + 1000 + + + 50 + + + 200 + + + + + + + Options + + + + 11 + + + + + + + 7 + + + + + ArrowCursor + + + Icom CI-V + + + + + + + hex, Icom only + + + + + + + + + + h + + + + + + + + + Full polling + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + lineEdit_RigPath + comboBox_serialSpeed + spinBox_RefreshRate + + + + + buttonBox + accepted() + DialogConfig + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogConfig + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/dialogsetup.cpp b/dialogsetup.cpp new file mode 100644 index 0000000..ce6d7fb --- /dev/null +++ b/dialogsetup.cpp @@ -0,0 +1,43 @@ +#include "dialogsetup.h" +#include "ui_dialogsetup.h" + +#include "guidata.h" + +#include +#include + + +extern guiConfig guiConf; + + +DialogSetup::DialogSetup(QWidget *parent) : + QDialog(parent), + ui(new Ui::DialogSetup) +{ + ui->setupUi(this); + + if (guiConf.vfoDisplayMode) ui->radioButton_vfoDispMode_UD->setChecked(true); +} + +DialogSetup::~DialogSetup() +{ + delete ui; +} + +void DialogSetup::on_radioButton_vfoDispMode_LR_toggled(bool checked) +{ + if (checked) guiConf.vfoDisplayMode=0; +} + +void DialogSetup::on_radioButton_vfoDispMode_UD_toggled(bool checked) +{ + if (checked) guiConf.vfoDisplayMode=1; +} + +void DialogSetup::on_buttonBox_accepted() +{ + //* Save settings in config.ini + QSettings configFile(QString("config.ini"), QSettings::IniFormat); + configFile.setValue("vfoDisplayMode", guiConf.vfoDisplayMode); +} + diff --git a/dialogsetup.h b/dialogsetup.h new file mode 100644 index 0000000..c39b453 --- /dev/null +++ b/dialogsetup.h @@ -0,0 +1,31 @@ +#ifndef DIALOGSETUP_H +#define DIALOGSETUP_H + +#include + +namespace Ui { +class DialogSetup; +} + +class DialogSetup : public QDialog +{ + Q_OBJECT + +public: + explicit DialogSetup(QWidget *parent = nullptr); + ~DialogSetup(); + +private slots: + + + void on_radioButton_vfoDispMode_LR_toggled(bool checked); + + void on_radioButton_vfoDispMode_UD_toggled(bool checked); + + void on_buttonBox_accepted(); + +private: + Ui::DialogSetup *ui; +}; + +#endif // DIALOGSETUP_H diff --git a/dialogsetup.ui b/dialogsetup.ui new file mode 100644 index 0000000..9a40c03 --- /dev/null +++ b/dialogsetup.ui @@ -0,0 +1,103 @@ + + + DialogSetup + + + + 0 + 0 + 400 + 300 + + + + Setup + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + VFO Display Mode + + + + + + Left/Right buttons + + + true + + + + + + + Up/Down click + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + buttonBox + accepted() + DialogSetup + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogSetup + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/guidata.cpp b/guidata.cpp new file mode 100644 index 0000000..d700faa --- /dev/null +++ b/guidata.cpp @@ -0,0 +1,22 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#include "guidata.h" + +guiConfig guiConf; diff --git a/guidata.h b/guidata.h new file mode 100644 index 0000000..2fdd987 --- /dev/null +++ b/guidata.h @@ -0,0 +1,10 @@ +#ifndef GUIDATA_H +#define GUIDATA_H + +#endif // GUIDATA_H + + +typedef struct { + int vfoDisplayMode; //0: use Left/Right mouse button, 1: click digit up or down + +} guiConfig; diff --git a/hamlib/amplifier.h b/hamlib/amplifier.h new file mode 100644 index 0000000..d123c70 --- /dev/null +++ b/hamlib/amplifier.h @@ -0,0 +1,446 @@ +/* + * Hamlib Interface - Amplifier API header + * Copyright (c) 2000-2005 by Stephane Fillod + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _AMPLIFIER_H +#define _AMPLIFIER_H 1 + +#include +#include + +/** + * \addtogroup amplifier + * @{ + */ + +/** + * \brief Hamlib amplifier data structures. + * + * \file amplifier.h + * + * This file contains the data structures and declarations for the Hamlib + * amplifier Application Programming Interface (API). + * + * See the amplifier.c file for details on the amplifier API functions. + */ + + + +__BEGIN_DECLS + +/* Forward struct references */ + +struct amp; +struct amp_state; + + +/** + * \brief Main amplifier handle type definition. + * + * \typedef typedef struct amp AMP + * + * The #AMP handle is returned by amp_init() and is passed as a parameter to + * every amplifier specific API call. + * + * amp_cleanup() must be called when this handle is no longer needed. + */ +typedef struct amp AMP; + + +/** + * \brief Type definition for + * SWR (Standing Wave Ratio). + * + * \typedef typedef float swr_t + * + * The \a swr_t type is used as a parameter for the amp_get_swr() function. + * + * The unit of \a swr_t is 1.0 to the maximum value reported by the amplifier's + * internal antenna system tuner, i.e. + * transmatch, + * representing the ratio of 1.0:1 to Maximum:1. + */ +typedef float swr_t; + + +/** + * \brief Type definition for the + * transmatch + * tuning values of + * capacitance + * and + * inductance. + * + * \typedef typedef float tune_value_t + * + * The \a tune_value_t type is used as a parameter for amp_get_level(). + * + * The unit of \a tune_value_t is + * picoFarads (pF) + * or + * nanoHenrys (nH). + */ +typedef int tune_value_t; + + +/** + * \brief The token in the netampctl protocol for returning an error condition code. + */ +#define NETAMPCTL_RET "RPRT " + + +//! @cond Doxygen_Suppress +typedef enum +{ + AMP_RESET_MEM, // erase tuner memory + AMP_RESET_FAULT, // reset any fault + AMP_RESET_AMP // for kpa1500 +} amp_reset_t; +//! @endcond + +/** + * \brief Amplifier type flags + */ +typedef enum +{ + AMP_FLAG_1 = (1 << 1), /*!< TBD */ + AMP_FLAG_2 = (1 << 2) /*!< TBD */ +} amp_type_t; + +//! @cond Doxygen_Suppress +// TBD AMP_TYPE +#define AMP_TYPE_MASK (AMP_FLAG_1|AMP_FLAG_2) + +#define AMP_TYPE_OTHER 0 +#define AMP_TYPE_1 AMP_FLAG_1 +#define AMP_TYPE_2 AMP_FLAG_2 +#define AMP_TYPE_ALL (AMP_FLAG_1|AMP_FLAG_2) +//! @endcond + + +//! @cond Doxygen_Suppress +enum amp_level_e +{ + AMP_LEVEL_NONE = 0, /*!< '' -- No Level. */ + AMP_LEVEL_SWR = (1 << 0), /*!< \c SWR 1.0 or greater. */ + AMP_LEVEL_NH = (1 << 1), /*!< \c Tune setting in nanohenries. */ + AMP_LEVEL_PF = (1 << 2), /*!< \c Tune setting in picofarads. */ + AMP_LEVEL_PWR_INPUT = (1 << 3), /*!< \c Power reading from amplifier. */ + AMP_LEVEL_PWR_FWD = (1 << 4), /*!< \c Power reading forward. */ + AMP_LEVEL_PWR_REFLECTED = (1 << 5), /*!< \c Power reading reverse. */ + AMP_LEVEL_PWR_PEAK = (1 << 6), /*!< \c Power reading peak. */ + AMP_LEVEL_FAULT = (1 << 7) /*!< \c Fault code. */ +}; +//! @endcond + +//! @cond Doxygen_Suppress +#define AMP_LEVEL_FLOAT_LIST (AMP_LEVEL_SWR) +#define AMP_LEVEL_STRING_LIST (AMP_LEVEL_FAULT) +#define AMP_LEVEL_IS_FLOAT(l) ((l)&_LEVEL_FLOAT_LIST) +#define AMP_LEVEL_IS_STRING(l) ((l)&_LEVEL_STRING_LIST) +//! @endcond + +/* Basic amp type, can store some useful info about different amplifiers. Each + * lib must be able to populate this structure, so we can make useful + * enquiries about capabilities. + */ + +//! @cond Doxygen_Suppress +#define AMP_MODEL(arg) .amp_model=arg,.macro_name=#arg +//! @endcond + +/** + * \brief Amplifier capabilities. + * + * \struct amp_caps + * + * The main idea of this struct is that it will be defined by the backend + * amplifier driver and will remain read-only for the application. Fields + * that need to be modifiable by the application are copied into the + * amp_state structure, which is the private memory area of the #AMP instance. + * + * This way you can have several amplifiers running within the same + * application, sharing the amp_caps structure of the backend, while keeping + * their own customized data. + * + * \b Note: Don't move fields around and only add new fields at the end of the + * amp_caps structure. Shared libraries and DLLs depend on a constant + * structure to maintain compatibility. + */ +struct amp_caps +{ + amp_model_t amp_model; /*!< Amplifier model as defined in amplist.h. */ + const char *model_name; /*!< Model name, e.g. MM-5k. */ + const char *mfg_name; /*!< Manufacturer, e.g. Moonbeam. */ + const char *version; /*!< Driver version, typically in YYYYMMDD.x format. */ + const char *copyright; /*!< Copyright info (should be LGPL). */ + enum rig_status_e status; /*!< Driver status. */ + + int amp_type; /*!< Amplifier type. */ + enum rig_port_e port_type; /*!< Type of communication port (serial, ethernet, etc.). */ + + int serial_rate_min; /*!< Minimal serial speed. */ + int serial_rate_max; /*!< Maximal serial speed. */ + int serial_data_bits; /*!< Number of data bits. */ + int serial_stop_bits; /*!< Number of stop bits. */ + enum serial_parity_e serial_parity; /*!< Parity. */ + enum serial_handshake_e serial_handshake; /*!< Handshake. */ + + int write_delay; /*!< Write delay. */ + int post_write_delay; /*!< Post-write delay. */ + int timeout; /*!< Timeout. */ + int retry; /*!< Number of retries if a command fails. */ + + const struct confparams *cfgparams; /*!< Configuration parameters. */ + const rig_ptr_t priv; /*!< Private data. */ + const char *amp_model_macro_name; /*!< Model macro name. */ + + setting_t has_get_level; /*!< List of get levels. */ + setting_t has_set_level; /*!< List of set levels. */ + + gran_t level_gran[RIG_SETTING_MAX]; /*!< Level granularity. */ + gran_t parm_gran[RIG_SETTING_MAX]; /*!< Parameter granularity. */ + + /* + * Amp Admin API + * + */ + + int (*amp_init)(AMP *amp); /*!< Pointer to backend implementation of ::amp_init(). */ + int (*amp_cleanup)(AMP *amp); /*!< Pointer to backend implementation of ::amp_cleanup(). */ + int (*amp_open)(AMP *amp); /*!< Pointer to backend implementation of ::amp_open(). */ + int (*amp_close)(AMP *amp); /*!< Pointer to backend implementation of ::amp_close(). */ + + int (*set_freq)(AMP *amp, freq_t val); /*!< Pointer to backend implementation of ::amp_set_freq(). */ + int (*get_freq)(AMP *amp, freq_t *val); /*!< Pointer to backend implementation of ::amp_get_freq(). */ + + int (*set_conf)(AMP *amp, token_t token, const char *val); /*!< Pointer to backend implementation of ::amp_set_conf(). */ + int (*get_conf)(AMP *amp, token_t token, char *val); /*!< Pointer to backend implementation of ::amp_get_conf(). */ + + /* + * General API commands, from most primitive to least.. :() + * List Set/Get functions pairs + */ + + int (*reset)(AMP *amp, amp_reset_t reset); /*!< Pointer to backend implementation of ::amp_reset(). */ + int (*get_level)(AMP *amp, setting_t level, value_t *val); /*!< Pointer to backend implementation of ::amp_get_level(). */ + int (*get_ext_level)(AMP *amp, token_t level, value_t *val); /*!< Pointer to backend implementation of ::amp_get_ext_level(). */ + int (*set_powerstat)(AMP *amp, powerstat_t status); /*!< Pointer to backend implementation of ::amp_set_powerstat(). */ + int (*get_powerstat)(AMP *amp, powerstat_t *status); /*!< Pointer to backend implementation of ::amp_get_powerstat(). */ + + + /* get firmware info, etc. */ + const char *(*get_info)(AMP *amp); /*!< Pointer to backend implementation of ::amp_get_info(). */ + +//! @cond Doxygen_Suppress + setting_t levels; + unsigned ext_levels; +//! @endcond + const struct confparams *extlevels; /*!< Extension levels list. \sa extamp.c */ + const struct confparams *extparms; /*!< Extension parameters list. \sa extamp.c */ + + const char *macro_name; /*!< Amplifier model macro name. */ +}; + + +/** + * \brief Amplifier state structure. + * + * \struct amp_state + * + * This structure contains live data, as well as a copy of capability fields + * that may be updated, i.e. customized while the #AMP handle is instantiated. + * + * It is fine to move fields around, as this kind of struct should not be + * initialized like amp_caps are. + */ +struct amp_state +{ + /* + * overridable fields + */ + + /* + * non overridable fields, internal use + */ + hamlib_port_t ampport; /*!< Amplifier port (internal use). */ + + int comm_state; /*!< Comm port state, opened/closed. */ + rig_ptr_t priv; /*!< Pointer to private amplifier state data. */ + rig_ptr_t obj; /*!< Internal use by hamlib++ for event handling. */ + + setting_t has_get_level; /*!< List of get levels. */ + + gran_t level_gran[RIG_SETTING_MAX]; /*!< Level granularity. */ + gran_t parm_gran[RIG_SETTING_MAX]; /*!< Parameter granularity. */ +}; + + +/** + * \brief Master amplifier structure. + * + * \struct amp + * + * Master amplifier data structure acting as the #AMP handle for the + * controlled amplifier. A pointer to this structure is returned by the + * amp_init() API function and is passed as a parameter to every amplifier + * specific API call. + * + * \sa amp_init(), amp_caps, amp_state + */ +struct amp +{ + struct amp_caps *caps; /*!< Amplifier caps. */ + struct amp_state state; /*!< Amplifier state. */ +}; + + +//! @cond Doxygen_Suppress +/* --------------- API function prototypes -----------------*/ + +extern HAMLIB_EXPORT(AMP *) +amp_init HAMLIB_PARAMS((amp_model_t amp_model)); + +extern HAMLIB_EXPORT(int) +amp_open HAMLIB_PARAMS((AMP *amp)); + +extern HAMLIB_EXPORT(int) +amp_close HAMLIB_PARAMS((AMP *amp)); + +extern HAMLIB_EXPORT(int) +amp_cleanup HAMLIB_PARAMS((AMP *amp)); + +extern HAMLIB_EXPORT(int) +amp_set_conf HAMLIB_PARAMS((AMP *amp, + token_t token, + const char *val)); +extern HAMLIB_EXPORT(int) +amp_get_conf HAMLIB_PARAMS((AMP *amp, + token_t token, + char *val)); +extern HAMLIB_EXPORT(int) +amp_set_powerstat HAMLIB_PARAMS((AMP *amp, + powerstat_t status)); +extern HAMLIB_EXPORT(int) +amp_get_powerstat HAMLIB_PARAMS((AMP *amp, + powerstat_t *status)); + + +/* + * General API commands, from most primitive to least.. ) + * List Set/Get functions pairs + */ +extern HAMLIB_EXPORT(int) +amp_get_freq HAMLIB_PARAMS((AMP *amp, + freq_t *freq)); +extern HAMLIB_EXPORT(int) +amp_set_freq HAMLIB_PARAMS((AMP *amp, + freq_t freq)); + +extern HAMLIB_EXPORT(int) +amp_reset HAMLIB_PARAMS((AMP *amp, + amp_reset_t reset)); + +extern HAMLIB_EXPORT(const char *) +amp_get_info HAMLIB_PARAMS((AMP *amp)); + +extern HAMLIB_EXPORT(int) +amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val)); + +extern HAMLIB_EXPORT(int) +amp_register HAMLIB_PARAMS((const struct amp_caps *caps)); + +extern HAMLIB_EXPORT(int) +amp_unregister HAMLIB_PARAMS((amp_model_t amp_model)); + +extern HAMLIB_EXPORT(int) +amp_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct amp_caps *, + rig_ptr_t), + rig_ptr_t data)); + +extern HAMLIB_EXPORT(int) +amp_load_backend HAMLIB_PARAMS((const char *be_name)); + +extern HAMLIB_EXPORT(int) +amp_check_backend HAMLIB_PARAMS((amp_model_t amp_model)); + +extern HAMLIB_EXPORT(int) +amp_load_all_backends HAMLIB_PARAMS((void)); + +extern HAMLIB_EXPORT(amp_model_t) +amp_probe_all HAMLIB_PARAMS((hamlib_port_t *p)); + +extern HAMLIB_EXPORT(int) +amp_token_foreach HAMLIB_PARAMS((AMP *amp, + int (*cfunc)(const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); + +extern HAMLIB_EXPORT(const struct confparams *) +amp_confparam_lookup HAMLIB_PARAMS((AMP *amp, + const char *name)); + +extern HAMLIB_EXPORT(token_t) +amp_token_lookup HAMLIB_PARAMS((AMP *amp, + const char *name)); + +extern HAMLIB_EXPORT(const struct amp_caps *) +amp_get_caps HAMLIB_PARAMS((amp_model_t amp_model)); + +extern HAMLIB_EXPORT(setting_t) +amp_has_get_level HAMLIB_PARAMS((AMP *amp, + setting_t level)); + +extern HAMLIB_EXPORT(const struct confparams *) +amp_ext_lookup HAMLIB_PARAMS((AMP *amp, + const char *name)); + +extern HAMLIB_EXPORT(int) +amp_get_ext_level HAMLIB_PARAMS((AMP *amp, + token_t token, + value_t *val)); + +extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t); + +extern HAMLIB_EXPORT(const struct confparams *) +rig_ext_lookup HAMLIB_PARAMS((RIG *rig, + const char *name)); + +extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s); +extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t); + +//! @endcond + + +/** + * \brief Convenience macro for generating debugging messages. + * + * \def amp_debug + * + * This is an alias of the rig_debug() function call and is used in the same + * manner. + */ +#define amp_debug rig_debug + +__END_DECLS + +#endif /* _AMPLIFIER_H */ + +/** @} */ diff --git a/hamlib/amplist.h b/hamlib/amplist.h new file mode 100644 index 0000000..e52f66f --- /dev/null +++ b/hamlib/amplist.h @@ -0,0 +1,120 @@ +/* + * Hamlib Interface - list of known amplifiers + * Copyright (c) 2000-2011 by Stephane Fillod + * Copyright (c) 2000-2002 by Frank Singleton + * Copyright (C) 2019 by Michael Black W9MDB. Derived from rotlist.h + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _AMPLIST_H +#define _AMPLIST_H 1 + +//! @cond Doxygen_Suppress +#define AMP_MAKE_MODEL(a,b) ((a)*100+(b)) +#define AMP_BACKEND_NUM(a) ((a)/100) +//! @endcond + + +/** + * \addtogroup amplifier + * @{ + */ + +/** + * \brief Hamlib amplifier model definitions. + * + * \file amplist.h + * + * This file contains amplifier model definitions for the Hamlib amplifier + * Application Programming Interface (API). Each distinct amplifier type has + * a unique model number (ID) and is used by Hamlib to identify and + * distinguish between the different hardware drivers. The exact model + * numbers can be acquired using the macros in this file. To obtain a list of + * supported amplifier branches, one can use the statically defined + * AMP_BACKEND_LIST macro (defined in configure.ac). To obtain a full list of + * supported amplifiers (including each model in every branch), the + * foreach_opened_amp() API function can be used. + * + * The model number, or ID, is used to tell Hamlib which amplifier the client + * wishes to use which is done with the amp_init() API call. + */ + + +/** + * \brief A macro that returns the model number for an unknown model. + * + * \def AMP_MODEL_NONE + * + * The none backend, as the name suggests, does nothing. It is mainly for + * internal use. + */ +#define AMP_MODEL_NONE 0 + + +/** + * \brief A macro that returns the model number for the DUMMY backend. + * + * \def AMP_MODEL_DUMMY + * + * The DUMMY backend, as the name suggests, is a backend which performs no + * hardware operations and always behaves as one would expect. It can be + * thought of as a hardware simulator and is very useful for testing client + * applications. + */ +/** + * \brief A macro that returns the model number for the NETAMPCTL backend. + * + * \def AMP_MODEL_NETAMPCTL + * + * The NETAMPCTL backend allows use of the `ampctld` daemon through the normal + * Hamlib API. + */ +//! @cond Doxygen_Suppress +#define AMP_DUMMY 0 +#define AMP_BACKEND_DUMMY "dummy" +//! @endcond +#define AMP_MODEL_DUMMY AMP_MAKE_MODEL(AMP_DUMMY, 1) +#define AMP_MODEL_NETAMPCTL AMP_MAKE_MODEL(AMP_DUMMY, 2) + + +/** + * \brief A macro that returns the model number of the KPA1500 backend. + * + * \def AMP_MODEL_ELECRAFT_KPA1500 + * + * The KPA1500 backend can be used with amplifiers that support the Elecraft + * KPA-1500 protocol. + */ +//! @cond Doxygen_Suppress +#define AMP_ELECRAFT 2 +#define AMP_BACKEND_ELECRAFT "elecraft" +//! @endcond +#define AMP_MODEL_ELECRAFT_KPA1500 AMP_MAKE_MODEL(AMP_ELECRAFT, 1) +//#define AMP_MODEL_ELECRAFT_KPA500 AMP_MAKE_MODEL(AMP_ELECRAFT, 2) + +/** + * \brief Convenience type definition for an amplifier model. + * + * \typedef typedef int amp_model_t + */ +typedef int amp_model_t; + + +#endif /* _AMPLIST_H */ + +/** @} */ diff --git a/hamlib/libhamlib.dll.a b/hamlib/libhamlib.dll.a new file mode 100644 index 0000000..7942496 Binary files /dev/null and b/hamlib/libhamlib.dll.a differ diff --git a/hamlib/rig.h b/hamlib/rig.h new file mode 100644 index 0000000..00d10b2 --- /dev/null +++ b/hamlib/rig.h @@ -0,0 +1,3196 @@ +/* + * Hamlib Interface - API header + * Copyright (c) 2000-2003 by Frank Singleton + * Copyright (c) 2000-2012 by Stephane Fillod + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +#ifndef _RIG_H +#define _RIG_H 1 + +#define TRACE rig_debug(RIG_DEBUG_TRACE,"%s(%d) trace\n", __FILE__, __LINE__) +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) + +#include +#include +#include +#include +#include +#include + +/* Rig list is in a separate file so as not to mess up w/ this one */ +#include + +/** + * \addtogroup rig + * @{ + */ + +/*! \file rig.h + * \brief Hamlib rig data structures. + * + * This file contains the data structures and definitions for the Hamlib rig API. + * see the rig.c file for more details on the rig API. + */ + + +/* __BEGIN_DECLS should be used at the beginning of your declarations, + * so that C++ compilers don't mangle their names. Use __END_DECLS at + * the end of C declarations. */ +//! @cond Doxygen_Suppress +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif +//! @endcond + +/* HAMLIB_PARAMS is a macro used to wrap function prototypes, so that compilers + * that don't understand ANSI C prototypes still work, and ANSI C + * compilers can issue warnings about type mismatches. */ +//! @cond Doxygen_Suppress +#undef HAMLIB_PARAMS +#if defined (__STDC__) \ + || defined (_AIX) \ + || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ + || defined(__CYGWIN__) \ + || defined(_WIN32) \ + || defined(__cplusplus) +# define HAMLIB_PARAMS(protos) protos +# define rig_ptr_t void * +# define amp_ptr_t void * +#else +# define HAMLIB_PARAMS(protos) () +# define rig_ptr_t char * +# define amp_ptr_t char * +#endif +//! @endcond + +#include + +#ifndef SWIGLUA +//! @cond Doxygen_Suppress +#define CONSTANT_64BIT_FLAG(BIT) (1ull << (BIT)) +//! @endcond +#else +/* SWIG's older Lua generator doesn't grok ull due to Lua using a + double-precision floating point type internally for number + representations (max 53 bits of precision) so makes a string + constant from a constant number literal using ull */ +// #define CONSTANT_64BIT_FLAG(BIT) (1 << (BIT)) +// #define SWIGLUAHIDE +/* But this appears to have been fixed so we'll use the correct one now + If you have the older version of SWIG comment out this line and use + the two above */ +// This 1ul definition works on swig 4.0.1 and lua 5.3.5 +#define CONSTANT_64BIT_FLAG(BIT) (1ul << (BIT)) +#endif + +__BEGIN_DECLS + +/** + * \brief size of cookie request buffer + * Minimum size of cookie buffer to pass to rig_cookie + */ +// cookie is 26-char time code plus 10-char (2^31-1) random number +#define HAMLIB_COOKIE_SIZE 37 +extern int cookie_use; // this is global as once one client requests it everybody needs to honor it + +//! @cond Doxygen_Suppress +extern HAMLIB_EXPORT_VAR(const char) hamlib_version[]; +extern HAMLIB_EXPORT_VAR(const char) hamlib_copyright[]; +extern HAMLIB_EXPORT_VAR(const char *) hamlib_version2; +extern HAMLIB_EXPORT_VAR(const char *) hamlib_copyright2; +//! @endcond + +/** + * \brief Hamlib error codes + * Error code definition that can be returned by the Hamlib functions. + * Unless stated otherwise, Hamlib functions return the negative value + * of rig_errcode_e definitions in case of error, or 0 when successful. + */ +enum rig_errcode_e { + RIG_OK = 0, /*!< 0 No error, operation completed successfully */ + RIG_EINVAL, /*!< 1 invalid parameter */ + RIG_ECONF, /*!< 2 invalid configuration (serial,..) */ + RIG_ENOMEM, /*!< 3 memory shortage */ + RIG_ENIMPL, /*!< 4 function not implemented, but will be */ + RIG_ETIMEOUT, /*!< 5 communication timed out */ + RIG_EIO, /*!< 6 IO error, including open failed */ + RIG_EINTERNAL, /*!< 7 Internal Hamlib error, huh! */ + RIG_EPROTO, /*!< 8 Protocol error */ + RIG_ERJCTED, /*!< 9 Command rejected by the rig */ + RIG_ETRUNC, /*!< 10 Command performed, but arg truncated */ + RIG_ENAVAIL, /*!< 11 Function not available */ + RIG_ENTARGET, /*!< 12 VFO not targetable */ + RIG_BUSERROR, /*!< 13 Error talking on the bus */ + RIG_BUSBUSY, /*!< 14 Collision on the bus */ + RIG_EARG, /*!< 15 NULL RIG handle or any invalid pointer parameter in get arg */ + RIG_EVFO, /*!< 16 Invalid VFO */ + RIG_EDOM /*!< 17 Argument out of domain of func */ +}; + +/** + * \brief Determines if the given error code indicates a "soft" error + * Soft errors are caused by invalid parameters and software/hardware features + * and cannot be fixed by retries or by re-initializing hardware. + */ +#define RIG_IS_SOFT_ERRCODE(errcode) (errcode == RIG_EINVAL || errcode == RIG_ENIMPL || errcode == RIG_ERJCTED \ + || errcode == RIG_ETRUNC || errcode == RIG_ENAVAIL || errcode == RIG_ENTARGET \ + || errcode == RIG_EVFO || errcode == RIG_EDOM) + +/** + * \brief Token in the netrigctl protocol for returning error code + */ +#define NETRIGCTL_RET "RPRT " + + +/** + *\brief Hamlib debug levels + * + * NOTE: Numeric order matters for debug level + * + * \sa rig_set_debug() + */ +enum rig_debug_level_e { + RIG_DEBUG_NONE = 0, /*!< no bug reporting */ + RIG_DEBUG_BUG, /*!< serious bug */ + RIG_DEBUG_ERR, /*!< error case (e.g. protocol, memory allocation) */ + RIG_DEBUG_WARN, /*!< warning */ + RIG_DEBUG_VERBOSE, /*!< verbose */ + RIG_DEBUG_TRACE, /*!< tracing */ + RIG_DEBUG_CACHE /*!< caching */ +}; + + +/* --------------- Rig capabilities -----------------*/ + +/* Forward struct references */ + +struct rig; +struct rig_state; + +/** + * \brief Rig structure definition (see rig for details). + */ +typedef struct s_rig RIG; + +//! @cond Doxygen_Suppress +#define HAMLIB_RIGNAMSIZ 30 +#define HAMLIB_RIGVERSIZ 8 +#define HAMLIB_FILPATHLEN 512 +#define HAMLIB_FRQRANGESIZ 30 +#define HAMLIB_MAXCHANDESC 30 /* describe channel eg: "WWV 5Mhz" */ +#define HAMLIB_TSLSTSIZ 20 /* max tuning step list size, zero ended */ +#define HAMLIB_FLTLSTSIZ 60 /* max mode/filter list size, zero ended */ +#define HAMLIB_MAXDBLSTSIZ 8 /* max preamp/att levels supported, zero ended */ +#define HAMLIB_CHANLSTSIZ 16 /* max mem_list size, zero ended */ +#define HAMLIB_MAX_AGC_LEVELS 8 /* max AGC levels supported */ +#define HAMLIB_MAX_SPECTRUM_SCOPES 4 /* max number of spectrum scopes supported */ +#define HAMLIB_MAX_SPECTRUM_MODES 5 /* max number of spectrum modes supported */ +#define HAMLIB_MAX_SPECTRUM_AVG_MODES 12 /* max number of spectrum averaging modes supported */ +#define HAMLIB_MAX_SPECTRUM_SPANS 20 /* max number of spectrum modes supported */ +#define HAMLIB_MAX_CAL_LENGTH 32 /* max calibration plots in cal_table_t */ +#define HAMLIB_MAX_MODES 63 +#define HAMLIB_MAX_VFOS 31 +#define HAMLIB_MAX_ROTORS 63 +#define HAMLIB_MAX_VFO_OPS 31 +#define HAMLIB_MAX_RSCANS 31 +//! @endcond + + +/** + * \brief CTCSS and DCS type definition. + * + * Continuous Tone Controlled Squelch System (CTCSS) + * sub-audible tone frequency are expressed in \em tenth of Hz. + * For example, the subaudible tone of 88.5 Hz is represented within + * Hamlib by 885. + * + * Digitally-Coded Squelch codes are simple direct integers. + */ +#define CTCSS_LIST_SIZE 60 +#define DCS_LIST_SIZE 128 +typedef unsigned int tone_t; + + +/** + * \brief Port type + */ +typedef enum rig_port_e { + RIG_PORT_NONE = 0, /*!< No port */ + RIG_PORT_SERIAL, /*!< Serial */ + RIG_PORT_NETWORK, /*!< Network socket type */ + RIG_PORT_DEVICE, /*!< Device driver, like the WiNRADiO */ + RIG_PORT_PACKET, /*!< AX.25 network type, e.g. SV8CS protocol */ + RIG_PORT_DTMF, /*!< DTMF protocol bridge via another rig, eg. Kenwood Sky Cmd System */ + RIG_PORT_ULTRA, /*!< IrDA Ultra protocol! */ + RIG_PORT_RPC, /*!< RPC wrapper */ + RIG_PORT_PARALLEL, /*!< Parallel port */ + RIG_PORT_USB, /*!< USB port */ + RIG_PORT_UDP_NETWORK, /*!< UDP Network socket type */ + RIG_PORT_CM108, /*!< CM108 GPIO */ + RIG_PORT_GPIO, /*!< GPIO */ + RIG_PORT_GPION, /*!< GPIO inverted */ +} rig_port_t; + + +/** + * \brief Serial parity + */ +enum serial_parity_e { + RIG_PARITY_NONE = 0, /*!< No parity */ + RIG_PARITY_ODD, /*!< Odd */ + RIG_PARITY_EVEN, /*!< Even */ + RIG_PARITY_MARK, /*!< Mark */ + RIG_PARITY_SPACE /*!< Space */ +}; + + +/** + * \brief Serial handshake + */ +enum serial_handshake_e { + RIG_HANDSHAKE_NONE = 0, /*!< No handshake */ + RIG_HANDSHAKE_XONXOFF, /*!< Software XON/XOFF */ + RIG_HANDSHAKE_HARDWARE /*!< Hardware CTS/RTS */ +}; + + +/** + * \brief Serial control state + */ +enum serial_control_state_e { + RIG_SIGNAL_UNSET = 0, /*!< Unset or tri-state */ + RIG_SIGNAL_ON, /*!< ON */ + RIG_SIGNAL_OFF /*!< OFF */ +}; + + +/** + * \brief Rig type flags + */ +typedef enum { + RIG_FLAG_RECEIVER = (1 << 1), /*!< Receiver */ + RIG_FLAG_TRANSMITTER = (1 << 2), /*!< Transmitter */ + RIG_FLAG_SCANNER = (1 << 3), /*!< Scanner */ + RIG_FLAG_MOBILE = (1 << 4), /*!< mobile sized */ + RIG_FLAG_HANDHELD = (1 << 5), /*!< handheld sized */ + RIG_FLAG_COMPUTER = (1 << 6), /*!< "Computer" rig */ + RIG_FLAG_TRUNKING = (1 << 7), /*!< has trunking */ + RIG_FLAG_APRS = (1 << 8), /*!< has APRS */ + RIG_FLAG_TNC = (1 << 9), /*!< has TNC */ + RIG_FLAG_DXCLUSTER = (1 << 10), /*!< has DXCluster */ + RIG_FLAG_TUNER = (1 << 11) /*!< dumb tuner */ +} rig_type_t; + +//! @cond Doxygen_Suppress +#define RIG_FLAG_TRANSCEIVER (RIG_FLAG_RECEIVER|RIG_FLAG_TRANSMITTER) +#define RIG_TYPE_MASK (RIG_FLAG_TRANSCEIVER|RIG_FLAG_SCANNER|RIG_FLAG_MOBILE|RIG_FLAG_HANDHELD|RIG_FLAG_COMPUTER|RIG_FLAG_TRUNKING|RIG_FLAG_TUNER) + +#define RIG_TYPE_OTHER 0 +#define RIG_TYPE_TRANSCEIVER RIG_FLAG_TRANSCEIVER +#define RIG_TYPE_HANDHELD (RIG_FLAG_TRANSCEIVER|RIG_FLAG_HANDHELD) +#define RIG_TYPE_MOBILE (RIG_FLAG_TRANSCEIVER|RIG_FLAG_MOBILE) +#define RIG_TYPE_RECEIVER RIG_FLAG_RECEIVER +#define RIG_TYPE_PCRECEIVER (RIG_FLAG_COMPUTER|RIG_FLAG_RECEIVER) +#define RIG_TYPE_SCANNER (RIG_FLAG_SCANNER|RIG_FLAG_RECEIVER) +#define RIG_TYPE_TRUNKSCANNER (RIG_TYPE_SCANNER|RIG_FLAG_TRUNKING) +#define RIG_TYPE_COMPUTER (RIG_FLAG_TRANSCEIVER|RIG_FLAG_COMPUTER) +#define RIG_TYPE_TUNER RIG_FLAG_TUNER +//! @endcond + + +/** + * \brief Development status of the backend + */ +enum rig_status_e { + RIG_STATUS_ALPHA = 0, /*!< Alpha quality, i.e. development */ + RIG_STATUS_UNTESTED, /*!< Written from available specs, rig unavailable for test, feedback wanted! */ + RIG_STATUS_BETA, /*!< Beta quality */ + RIG_STATUS_STABLE, /*!< Stable */ + RIG_STATUS_BUGGY /*!< Was stable, but something broke it! */ + /* RIG_STATUS_NEW * *!< Initial release of code + * !! Use of RIG_STATUS_NEW is deprecated. Do not use it anymore */ +}; + +/** + * \brief Map all deprecated RIG_STATUS_NEW references to + * RIG_STATUS_UNTESTED for backward compatibility + */ +#define RIG_STATUS_NEW RIG_STATUS_UNTESTED + + +/** + * \brief Repeater shift type + */ +typedef enum { + RIG_RPT_SHIFT_NONE = 0, /*!< No repeater shift */ + RIG_RPT_SHIFT_MINUS, /*!< "-" shift */ + RIG_RPT_SHIFT_PLUS /*!< "+" shift */ +} rptr_shift_t; + + +/** + * \brief Split mode + */ +typedef enum { + RIG_SPLIT_OFF = 0, /*!< Split mode disabled */ + RIG_SPLIT_ON /*!< Split mode enabled */ +} split_t; + + +/** + * \brief Frequency type, + * + * Frequency type unit in Hz, able to hold SHF frequencies. + */ +typedef double freq_t; + +/** + * \brief printf(3) format to be used for freq_t type + */ +#define PRIfreq ".0f" + +/** + * \brief scanf(3) format to be used for freq_t type + */ +#define SCNfreq "lf" +/** + * \brief printf(3) format to be used for freq_t type + */ +#define FREQFMT SCNfreq + + +/** + * \brief Short frequency type + * + * Frequency in Hz restricted to 31bits, suitable for offsets, shifts, etc.. + */ +typedef signed long shortfreq_t; + +/** \brief \c Macro to return Hz when f=Hz */ +#define Hz(f) ((freq_t)(f)) +/** \brief \c Macro to return Hz when f=kHz */ +#define kHz(f) ((freq_t)((f)*(freq_t)1000)) +/** \brief \c Macro to return Hz when f=MHz */ +#define MHz(f) ((freq_t)((f)*(freq_t)1000000)) +/** \brief \c Macro to return Hz when f=GHz */ +#define GHz(f) ((freq_t)((f)*(freq_t)1000000000)) + +/** \brief \c Macro to return short Hz when f=Hz */ +#define s_Hz(f) ((shortfreq_t)(f)) +/** \brief \c Macro to return short Hz when f=kHz */ +#define s_kHz(f) ((shortfreq_t)((f)*(shortfreq_t)1000)) +/** \brief \c Macro to return short Hz when f=MHz */ +#define s_MHz(f) ((shortfreq_t)((f)*(shortfreq_t)1000000)) +/** \brief \c Macro to return short Hz when f=GHz */ +#define s_GHz(f) ((shortfreq_t)((f)*(shortfreq_t)1000000000)) + +/** \brief \c Frequency none -- used as default value for checking */ +#define RIG_FREQ_NONE Hz(0) + + +/** + * \brief VFO definition + * + * There are several ways of using a vfo_t. For most cases, using RIG_VFO_A, + * RIG_VFO_B, RIG_VFO_CURR, etc., as opaque macros should suffice. + * + * Strictly speaking a VFO is Variable Frequency Oscillator. + * Here, it is referred as a tunable channel, from the radio operator's + * point of view. The channel can be designated individually by its real + * number, or by using an alias. + * + * Aliases may or may not be honored by a backend and are defined using + * high significant bits, i.e. RIG_VFO_MEM, RIG_VFO_MAIN, etc. + */ +typedef unsigned int vfo_t; + +/** \brief '' -- used in caps */ + +#define RIG_VFO_N(n) (1u<<(n)) + +/** \brief \c VFONone -- vfo unknown */ +#define RIG_VFO_NONE 0 + +/** \brief \c VFOA -- VFO A */ +#define RIG_VFO_A RIG_VFO_N(0) + +/** \brief \c VFOB -- VFO B */ +#define RIG_VFO_B RIG_VFO_N(1) + +/** \brief \c VFOC -- VFO C */ +#define RIG_VFO_C RIG_VFO_N(2) + +// Any addition VFOS need to go from 3-20 +// To maintain backward compatibility these values cannot change + +/** \brief \c SubA -- alias for SUB_A */ +#define RIG_VFO_SUB_A RIG_VFO_N(21) + +/** \brief \c SubB -- alias for SUB_B */ +#define RIG_VFO_SUB_B RIG_VFO_N(22) + +/** \brief \c SubC -- alias for SUB_B */ +#define RIG_VFO_SUB_C RIG_VFO_N(3) + +/** \brief \c MainA -- alias for MAIN_A */ +#define RIG_VFO_MAIN_A RIG_VFO_N(23) + +/** \brief \c MainB -- alias for MAIN_B */ +#define RIG_VFO_MAIN_B RIG_VFO_N(24) + +/** \brief \c MainC -- alias for MAIN_C */ +#define RIG_VFO_MAIN_C RIG_VFO_N(4) + +/** \brief \c Other -- alias for OTHER -- e.g. Icom rigs without get_vfo capability */ +#define RIG_VFO_OTHER RIG_VFO_N(5) + +/** \brief \c Sub -- alias for SUB */ +#define RIG_VFO_SUB RIG_VFO_N(25) + +/** \brief \c Main -- alias for MAIN */ +#define RIG_VFO_MAIN RIG_VFO_N(26) + +/** \brief \c VFO -- means (last or any)VFO mode, with set_vfo */ +#define RIG_VFO_VFO RIG_VFO_N(27) + +/** \brief \c MEM -- means Memory mode, to be used with set_vfo */ +#define RIG_VFO_MEM RIG_VFO_N(28) + +/** \brief \c currVFO -- current "tunable channel"/VFO */ +#define RIG_VFO_CURR RIG_VFO_N(29) + +/** \brief \c Flag to set if VFO can transmit */ +#define RIG_VFO_TX_FLAG RIG_VFO_N(30) + +/** \brief \c Flag to set all VFOS */ +#define RIG_VFO_ALL RIG_VFO_N(31) + +// we can also use RIG_VFO_N(31) if needed + +// Misc VFO Macros + +/** \brief \c Macro to tell you if VFO can transmit */ +#define RIG_VFO_TX_VFO(v) ((v)|RIG_VFO_TX_FLAG) + +/** \brief \c TX -- alias for split tx or uplink, of VFO_CURR */ +#define RIG_VFO_TX RIG_VFO_TX_VFO(RIG_VFO_CURR) + +/** \brief \c RX -- alias for split rx or downlink */ +#define RIG_VFO_RX RIG_VFO_CURR + + +/* + * targetable bitfields, for internal use. + * In rig.c lack of a flag will case a VFO change if needed + * So setting this flag will mean the backend handles any VFO needs + * For many rigs RITXIT, PTT, MEM, and BANK are non-VFO commands so need these flags to avoid unnecessary VFO swapping + */ +//! @cond Doxygen_Suppress +#define RIG_TARGETABLE_NONE 0 +#define RIG_TARGETABLE_FREQ (1<<0) +#define RIG_TARGETABLE_MODE (1<<1) // mode by vfo or same mode on both vfos +#define RIG_TARGETABLE_PURE (1<<2) // deprecated -- not used -- reuse it +#define RIG_TARGETABLE_TONE (1<<3) +#define RIG_TARGETABLE_FUNC (1<<4) +#define RIG_TARGETABLE_LEVEL (1<<5) +#define RIG_TARGETABLE_RITXIT (1<<6) +#define RIG_TARGETABLE_PTT (1<<7) +#define RIG_TARGETABLE_MEM (1<<8) +#define RIG_TARGETABLE_BANK (1<<9) +#define RIG_TARGETABLE_ANT (1<<10) +#define RIG_TARGETABLE_ROOFING (1<<11) // roofing filter targetable by VFO +#define RIG_TARGETABLE_SPECTRUM (1<<12) // spectrum scope targetable by VFO +#define RIG_TARGETABLE_COMMON (RIG_TARGETABLE_RITXIT | RIG_TARGETABLE_PTT | RIG_TARGETABLE_MEM | RIG_TARGETABLE_BANK) +#define RIG_TARGETABLE_ALL 0x7fffffff +//! @endcond +// +// +// Newer Icoms like the 9700 and 910 have VFOA/B on both Main & Sub +// Compared to older rigs which have one or the other +// So we need to distinguish between them +//! @cond Doxygen_Suppress +#define VFO_HAS_A_B ((rig->state.vfo_list & (RIG_VFO_A|RIG_VFO_B)) == (RIG_VFO_A|RIG_VFO_B)) +#define VFO_HAS_MAIN_SUB ((rig->state.vfo_list & (RIG_VFO_MAIN|RIG_VFO_SUB)) == (RIG_VFO_MAIN|RIG_VFO_SUB)) +#define VFO_HAS_MAIN_SUB_ONLY ((!VFO_HAS_A_B) & VFO_HAS_MAIN_SUB) +#define VFO_HAS_MAIN_SUB_A_B_ONLY (VFO_HAS_A_B & VFO_HAS_MAIN_SUB) +#define VFO_HAS_A_B_ONLY (VFO_HAS_A_B & (!VFO_HAS_MAIN_SUB)) +#define VFO_DUAL (RIG_VFO_MAIN_A|RIG_VFO_MAIN_B|RIG_VFO_SUB_A|RIG_VFO_SUB_B) +#define VFO_HAS_DUAL ((rig->state.vfo_list & VFO_DUAL) == VFO_DUAL) +//! @endcond + +/** + * \brief Macro for bandpass to be set to normal + * \def RIG_PASSBAND_NORMAL + */ +#define RIG_PASSBAND_NORMAL s_Hz(0) + +/** + * \brief Macro for bandpass to be left alone + */ +#define RIG_PASSBAND_NOCHANGE s_Hz(-1) + +/** + * + * \sa rig_passband_normal(), rig_passband_narrow(), rig_passband_wide() + */ +typedef shortfreq_t pbwidth_t; + + +/** + * \brief DCD status + */ +typedef enum dcd_e { + RIG_DCD_OFF = 0, /*!< Squelch closed */ + RIG_DCD_ON /*!< Squelch open */ +} dcd_t; + + +/** + * \brief DCD type + * + * \sa rig_get_dcd() + */ +typedef enum { + RIG_DCD_NONE = 0, /*!< No DCD available */ + RIG_DCD_RIG, /*!< Rig has DCD status support, i.e. rig has get_dcd cap */ + RIG_DCD_SERIAL_DSR, /*!< DCD status from serial DSR signal */ + RIG_DCD_SERIAL_CTS, /*!< DCD status from serial CTS signal */ + RIG_DCD_SERIAL_CAR, /*!< DCD status from serial CD signal */ + RIG_DCD_PARALLEL, /*!< DCD status from parallel port pin */ + RIG_DCD_CM108, /*!< DCD status from CM108 vol dn pin */ + RIG_DCD_GPIO, /*!< DCD status from GPIO pin */ + RIG_DCD_GPION, /*!< DCD status from inverted GPIO pin */ +} dcd_type_t; + + +/** + * \brief PTT status + */ +typedef enum { + RIG_PTT_OFF = 0, /*!< PTT deactivated */ + RIG_PTT_ON, /*!< PTT activated */ + RIG_PTT_ON_MIC, /*!< PTT Mic only, fallbacks on RIG_PTT_ON if unavailable */ + RIG_PTT_ON_DATA /*!< PTT Data (Mic-muted), fallbacks on RIG_PTT_ON if unavailable */ +} ptt_t; + + +/** + * \brief PTT type + * + * \sa rig_get_ptt() + */ +typedef enum { + RIG_PTT_NONE = 0, /*!< No PTT available */ + RIG_PTT_RIG, /*!< Legacy PTT (CAT PTT) */ + RIG_PTT_SERIAL_DTR, /*!< PTT control through serial DTR signal */ + RIG_PTT_SERIAL_RTS, /*!< PTT control through serial RTS signal */ + RIG_PTT_PARALLEL, /*!< PTT control through parallel port */ + RIG_PTT_RIG_MICDATA, /*!< Legacy PTT (CAT PTT), supports RIG_PTT_ON_MIC/RIG_PTT_ON_DATA */ + RIG_PTT_CM108, /*!< PTT control through CM108 GPIO pin */ + RIG_PTT_GPIO, /*!< PTT control through GPIO pin */ + RIG_PTT_GPION, /*!< PTT control through inverted GPIO pin */ +} ptt_type_t; + + +/** + * \brief Radio power state + */ +typedef enum { + RIG_POWER_OFF = 0, /*!< Power off */ + RIG_POWER_ON = (1 << 0), /*!< Power on */ + RIG_POWER_STANDBY = (1 << 1), /*!< Standby */ + RIG_POWER_OPERATE = (1 << 2), /*!< Operate (from Standby) */ + RIG_POWER_UNKNOWN = (1 << 3) /*!< Unknown power status */ +} powerstat_t; + + +/** + * \brief Reset operation + */ +typedef enum { + RIG_RESET_NONE = 0, /*!< No reset */ + RIG_RESET_SOFT = (1 << 0), /*!< Software reset */ + RIG_RESET_VFO = (1 << 1), /*!< VFO reset */ + RIG_RESET_MCALL = (1 << 2), /*!< Memory clear */ + RIG_RESET_MASTER = (1 << 3) /*!< Master reset */ +} reset_t; + + +/** + * \brief VFO operation + * + * A VFO operation is an action on a VFO (or tunable memory). + * The difference with a function is that an action has no on/off + * status, it is performed at once. + * + * NOTE: the vfo argument for some vfo operation may be irrelevant, + * and thus will be ignored. + * + * The VFO/MEM "mode" is set by rig_set_vfo.\n + * \c STRING used in rigctl + * + * \sa rig_parse_vfo_op(), rig_strvfop() + */ +typedef enum { + RIG_OP_NONE = 0, /*!< '' No VFO_OP */ + RIG_OP_CPY = (1 << 0), /*!< \c CPY -- VFO A = VFO B */ + RIG_OP_XCHG = (1 << 1), /*!< \c XCHG -- Exchange VFO A/B */ + RIG_OP_FROM_VFO = (1 << 2), /*!< \c FROM_VFO -- VFO->MEM */ + RIG_OP_TO_VFO = (1 << 3), /*!< \c TO_VFO -- MEM->VFO */ + RIG_OP_MCL = (1 << 4), /*!< \c MCL -- Memory clear */ + RIG_OP_UP = (1 << 5), /*!< \c UP -- UP increment VFO freq by tuning step*/ + RIG_OP_DOWN = (1 << 6), /*!< \c DOWN -- DOWN decrement VFO freq by tuning step*/ + RIG_OP_BAND_UP = (1 << 7), /*!< \c BAND_UP -- Band UP */ + RIG_OP_BAND_DOWN = (1 << 8), /*!< \c BAND_DOWN -- Band DOWN */ + RIG_OP_LEFT = (1 << 9), /*!< \c LEFT -- LEFT */ + RIG_OP_RIGHT = (1 << 10), /*!< \c RIGHT -- RIGHT */ + RIG_OP_TUNE = (1 << 11), /*!< \c TUNE -- Start tune */ + RIG_OP_TOGGLE = (1 << 12) /*!< \c TOGGLE -- Toggle VFOA and VFOB */ +} vfo_op_t; + + +/** + * \brief Rig Scan operation + * + * Various scan operations supported by a rig.\n + * \c STRING used in rigctl + * + * \sa rig_parse_scan(), rig_strscan() + */ +typedef enum { + RIG_SCAN_NONE = 0, /*!< '' No-op value */ + RIG_SCAN_MEM = (1 << 0), /*!< \c MEM -- Scan all memory channels */ + RIG_SCAN_SLCT = (1 << 1), /*!< \c SLCT -- Scan all selected memory channels */ + RIG_SCAN_PRIO = (1 << 2), /*!< \c PRIO -- Priority watch (mem or call channel) */ + RIG_SCAN_PROG = (1 << 3), /*!< \c PROG -- Programmed(edge) scan */ + RIG_SCAN_DELTA = (1 << 4), /*!< \c DELTA -- delta-f scan */ + RIG_SCAN_VFO = (1 << 5), /*!< \c VFO -- most basic scan */ + RIG_SCAN_PLT = (1 << 6), /*!< \c PLT -- Scan using pipelined tuning */ + RIG_SCAN_STOP = (1 << 7) /*!< \c STOP -- Stop scanning */ +} scan_t; + + +/** + * \brief configuration token + */ +typedef long token_t; + + +//! @cond Doxygen_Suppress +#define RIG_CONF_END 0 +//! @endcond + + +/** + * \brief parameter types + * + * Used with configuration, parameter and extra-parm tables. + * + * Current internal implementation + * NUMERIC: val.f or val.i + * COMBO: val.i, starting from 0. Points to a table of strings or asci stored values. + * STRING: val.s or val.cs + * CHECKBUTTON: val.i 0/1 + * BINARY: val.b + */ + +/* strongly inspired from soundmodem. Thanks Thomas! */ +enum rig_conf_e { + RIG_CONF_STRING, /*!< String type */ + RIG_CONF_COMBO, /*!< Combo type */ + RIG_CONF_NUMERIC, /*!< Numeric type integer or real */ + RIG_CONF_CHECKBUTTON, /*!< on/off type */ + RIG_CONF_BUTTON, /*!< Button type */ + RIG_CONF_BINARY /*!< Binary buffer type */ +}; + +//! @cond Doxygen_Suppress +#define RIG_COMBO_MAX 16 +#define RIG_BIN_MAX 80 +//! @endcond + +/** + * \brief Configuration parameter structure. + */ +struct confparams { + token_t token; /*!< Conf param token ID */ + const char *name; /*!< Param name, no spaces allowed */ + const char *label; /*!< Human readable label */ + const char *tooltip; /*!< Hint on the parameter */ + const char *dflt; /*!< Default value */ + enum rig_conf_e type; /*!< Type of the parameter */ + union { /*!< */ + struct { /*!< */ + float min; /*!< Minimum value */ + float max; /*!< Maximum value */ + float step; /*!< Step */ + } n; /*!< Numeric type */ + struct { /*!< */ + const char *combostr[RIG_COMBO_MAX]; /*!< Combo list */ + } c; /*!< Combo type */ + } u; /*!< Type union */ +}; + + +/** + * \brief Announce + * + * Designate optional speech synthesizer. + */ +typedef enum { + RIG_ANN_NONE = 0, /*!< None */ + RIG_ANN_OFF = RIG_ANN_NONE, /*!< disable announces */ + RIG_ANN_FREQ = (1 << 0), /*!< Announce frequency */ + RIG_ANN_RXMODE = (1 << 1), /*!< Announce receive mode */ + RIG_ANN_CW = (1 << 2), /*!< CW */ + RIG_ANN_ENG = (1 << 3), /*!< English */ + RIG_ANN_JAP = (1 << 4) /*!< Japan */ +} ann_t; + + +/** + * \brief Antenna typedef + * \typedef ant_t + */ +/** + * \brief Antenna number + * \def RIG_ANT_NONE + * No antenna set yet or unknown + */ +/** + * \brief Antenna conversion macro + * \def RIG_ANT_N + * Convert antenna number to bit mask + */ +/** + * \brief Macro for Ant#1 + * \def RIG_ANT_1 + */ +/** + * \brief Macro for Ant#2 + * \def RIG_ANT_2 + */ +/** + * \brief Macro for Ant#3 + * \def RIG_ANT_3 + */ +/** + * \brief Macro for Ant#4 + * \def RIG_ANT_4 + */ +/** + * \brief Macro for Ant#5 + * \def RIG_ANT_5 + */ +/** + * \brief Antenna is on whatever "current" means + * \def RIG_ANT_CURR + */ +/** + * \brief Macro for unknown antenna + * \def RIG_ANT_UNKNOWN + */ +/** + * \brief Maximum antenna# + * \def RIG_ANT_MAX + */ +typedef unsigned int ant_t; + +#define RIG_ANT_NONE 0 +#define RIG_ANT_N(n) ((ant_t)1<<(n)) +#define RIG_ANT_1 RIG_ANT_N(0) +#define RIG_ANT_2 RIG_ANT_N(1) +#define RIG_ANT_3 RIG_ANT_N(2) +#define RIG_ANT_4 RIG_ANT_N(3) +#define RIG_ANT_5 RIG_ANT_N(4) + +#define RIG_ANT_UNKNOWN RIG_ANT_N(30) +#define RIG_ANT_CURR RIG_ANT_N(31) + +#define RIG_ANT_MAX 32 + + +/** + * \brief AGC delay settings + */ +/* TODO: kill me, and replace by real AGC delay */ +enum agc_level_e { + RIG_AGC_OFF = 0, + RIG_AGC_SUPERFAST, + RIG_AGC_FAST, + RIG_AGC_SLOW, + RIG_AGC_USER, /*!< user selectable */ + RIG_AGC_MEDIUM, + RIG_AGC_AUTO +}; + +//! @cond Doxygen_Suppress +#define RIG_AGC_LAST RIG_AGC_AUTO +//! @endcond + +/** + * \brief Level display meters + */ +enum meter_level_e { + RIG_METER_NONE = 0, /*< No display meter */ + RIG_METER_SWR = (1 << 0), /*< Stationary Wave Ratio */ + RIG_METER_COMP = (1 << 1), /*< Compression level */ + RIG_METER_ALC = (1 << 2), /*< ALC */ + RIG_METER_IC = (1 << 3), /*< IC */ + RIG_METER_DB = (1 << 4), /*< DB */ + RIG_METER_PO = (1 << 5), /*< Power Out */ + RIG_METER_VDD = (1 << 6), /*< Final Amp Voltage */ + RIG_METER_TEMP = (1 << 7) /*< Final Amp Voltage */ +}; + + +/** + * \brief Universal approach for passing values + * + * \sa rig_set_level(), rig_get_level(), rig_set_parm(), rig_get_parm() + */ +typedef union { + signed int i; /*!< Signed integer */ + float f; /*!< Single precision float */ + char *s; /*!< Pointer to char string */ + const char *cs; /*!< Pointer to constant char string */ +//! @cond Doxygen_Suppress + struct { + int l; /*!< Length of data */ + unsigned char *d; /* Pointer to data buffer */ + } b; +//! @endcond +} value_t; + + +/** + * \brief Rig Level Settings + * + * Various operating levels supported by a rig.\n + * \c STRING used in rigctl + * + * \sa rig_parse_level(), rig_strlevel() + */ +typedef uint64_t rig_level_e; +#define RIG_LEVEL_NONE 0 /*!< '' -- No Level */ +#define RIG_LEVEL_PREAMP CONSTANT_64BIT_FLAG(0) /*!< \c PREAMP -- Preamp, arg int (dB) */ +#define RIG_LEVEL_ATT CONSTANT_64BIT_FLAG(1) /*!< \c ATT -- Attenuator, arg int (dB) */ +#define RIG_LEVEL_VOXDELAY CONSTANT_64BIT_FLAG(2) /*!< \c VOXDELAY -- VOX delay, arg int (tenth of seconds) */ +#define RIG_LEVEL_AF CONSTANT_64BIT_FLAG(3) /*!< \c AF -- Volume, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_RF CONSTANT_64BIT_FLAG(4) /*!< \c RF -- RF gain (not TX power) arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_SQL CONSTANT_64BIT_FLAG(5) /*!< \c SQL -- Squelch, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_IF CONSTANT_64BIT_FLAG(6) /*!< \c IF -- IF, arg int (Hz) */ +#define RIG_LEVEL_APF CONSTANT_64BIT_FLAG(7) /*!< \c APF -- Audio Peak Filter, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_NR CONSTANT_64BIT_FLAG(8) /*!< \c NR -- Noise Reduction, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_PBT_IN CONSTANT_64BIT_FLAG(9) /*!< \c PBT_IN -- Twin PBT (inside) arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_PBT_OUT CONSTANT_64BIT_FLAG(10) /*!< \c PBT_OUT -- Twin PBT (outside) arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_CWPITCH CONSTANT_64BIT_FLAG(11) /*!< \c CWPITCH -- CW pitch, arg int (Hz) */ +#define RIG_LEVEL_RFPOWER CONSTANT_64BIT_FLAG(12) /*!< \c RFPOWER -- RF Power, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_MICGAIN CONSTANT_64BIT_FLAG(13) /*!< \c MICGAIN -- MIC Gain, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_KEYSPD CONSTANT_64BIT_FLAG(14) /*!< \c KEYSPD -- Key Speed, arg int (WPM) */ +#define RIG_LEVEL_NOTCHF CONSTANT_64BIT_FLAG(15) /*!< \c NOTCHF -- Notch Freq., arg int (Hz) */ +#define RIG_LEVEL_COMP CONSTANT_64BIT_FLAG(16) /*!< \c COMP -- Compressor, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_AGC CONSTANT_64BIT_FLAG(17) /*!< \c AGC -- AGC, arg int (see enum agc_level_e) */ +#define RIG_LEVEL_BKINDL CONSTANT_64BIT_FLAG(18) /*!< \c BKINDL -- BKin Delay, arg int (tenth of dots) */ +#define RIG_LEVEL_BALANCE CONSTANT_64BIT_FLAG(19) /*!< \c BAL -- Balance (Dual Watch) arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_METER CONSTANT_64BIT_FLAG(20) /*!< \c METER -- Display meter, arg int (see enum meter_level_e) */ +#define RIG_LEVEL_VOXGAIN CONSTANT_64BIT_FLAG(21) /*!< \c VOXGAIN -- VOX gain level, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_ANTIVOX CONSTANT_64BIT_FLAG(22) /*!< \c ANTIVOX -- anti-VOX level, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_SLOPE_LOW CONSTANT_64BIT_FLAG(23) /*!< \c SLOPE_LOW -- Slope tune, low frequency cut, arg int (Hz) */ +#define RIG_LEVEL_SLOPE_HIGH CONSTANT_64BIT_FLAG(24) /*!< \c SLOPE_HIGH -- Slope tune, high frequency cut, arg int (Hz) */ +#define RIG_LEVEL_BKIN_DLYMS CONSTANT_64BIT_FLAG(25) /*!< \c BKIN_DLYMS -- BKin Delay, arg int Milliseconds */ + + /*!< These are not settable */ +#define RIG_LEVEL_RAWSTR CONSTANT_64BIT_FLAG(26) /*!< \c RAWSTR -- Raw (A/D) value for signal strength, specific to each rig, arg int */ +//#define RIG_LEVEL_SQLSTAT CONSTANT_64BIT_FLAG(27) /*!< \c SQLSTAT -- SQL status, arg int (open=1/closed=0). Deprecated, use get_dcd instead */ +#define RIG_LEVEL_SWR CONSTANT_64BIT_FLAG(28) /*!< \c SWR -- SWR, arg float [0.0 ... infinite] */ +#define RIG_LEVEL_ALC CONSTANT_64BIT_FLAG(29) /*!< \c ALC -- ALC, arg float */ +#define RIG_LEVEL_STRENGTH CONSTANT_64BIT_FLAG(30) /*!< \c STRENGTH -- Effective (calibrated) signal strength relative to S9, arg int (dB) */ + /* RIG_LEVEL_BWC (1<<31) */ /*!< Bandwidth Control, arg int (Hz) */ +#define RIG_LEVEL_RFPOWER_METER CONSTANT_64BIT_FLAG(32) /*!< \c RFPOWER_METER -- RF power output meter, arg float [0.0 ... 1.0] (percentage of maximum power) */ +#define RIG_LEVEL_COMP_METER CONSTANT_64BIT_FLAG(33) /*!< \c COMP_METER -- Audio output level compression meter, arg float (dB) */ +#define RIG_LEVEL_VD_METER CONSTANT_64BIT_FLAG(34) /*!< \c VD_METER -- Input voltage level meter, arg float (V, volts) */ +#define RIG_LEVEL_ID_METER CONSTANT_64BIT_FLAG(35) /*!< \c ID_METER -- Current draw meter, arg float (A, amperes) */ + +#define RIG_LEVEL_NOTCHF_RAW CONSTANT_64BIT_FLAG(36) /*!< \c NOTCHF_RAW -- Notch Freq., arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_MONITOR_GAIN CONSTANT_64BIT_FLAG(37) /*!< \c MONITOR_GAIN -- Monitor gain (level for monitoring of transmitted audio) arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_NB CONSTANT_64BIT_FLAG(38) /*!< \c NB -- Noise Blanker level, arg float [0.0 ... 1.0] */ +#define RIG_LEVEL_RFPOWER_METER_WATTS CONSTANT_64BIT_FLAG(39) /*!< \c RFPOWER_METER_WATTS -- RF power output meter, arg float [0.0 ... MAX] (output power in watts) */ +#define RIG_LEVEL_SPECTRUM_MODE CONSTANT_64BIT_FLAG(40) /*!< \c SPECTRUM_MODE -- Spectrum scope mode, arg int (see enum rig_spectrum_mode_e). Supported modes defined in rig caps. */ +#define RIG_LEVEL_SPECTRUM_SPAN CONSTANT_64BIT_FLAG(41) /*!< \c SPECTRUM_SPAN -- Spectrum scope span in center mode, arg int (Hz). Supported spans defined in rig caps. */ +#define RIG_LEVEL_SPECTRUM_EDGE_LOW CONSTANT_64BIT_FLAG(42) /*!< \c SPECTRUM_EDGE_LOW -- Spectrum scope low edge in fixed mode, arg int (Hz) */ +#define RIG_LEVEL_SPECTRUM_EDGE_HIGH CONSTANT_64BIT_FLAG(43) /*!< \c SPECTRUM_EDGE_HIGH -- Spectrum scope high edge in fixed mode, arg int (Hz) */ +#define RIG_LEVEL_SPECTRUM_SPEED CONSTANT_64BIT_FLAG(44) /*!< \c SPECTRUM_SPEED -- Spectrum scope update speed, arg int (highest is fastest, define rig-specific granularity) */ +#define RIG_LEVEL_SPECTRUM_REF CONSTANT_64BIT_FLAG(45) /*!< \c SPECTRUM_REF -- Spectrum scope reference display level, arg float (dB, define rig-specific granularity) */ +#define RIG_LEVEL_SPECTRUM_AVG CONSTANT_64BIT_FLAG(46) /*!< \c SPECTRUM_AVG -- Spectrum scope averaging mode, arg int (see struct rig_spectrum_avg_mode). Supported averaging modes defined in rig caps. */ +#define RIG_LEVEL_SPECTRUM_ATT CONSTANT_64BIT_FLAG(47) /*!< \c SPECTRUM_ATT -- Spectrum scope attenuator, arg int (dB). Supported attenuator values defined in rig caps. */ +#define RIG_LEVEL_TEMP_METER CONSTANT_64BIT_FLAG(48) /*!< \c TEMP_METER -- arg int (C, centigrade) */ +#define RIG_LEVEL_48 CONSTANT_64BIT_FLAG(48) /*!< \c Future use */ +#define RIG_LEVEL_49 CONSTANT_64BIT_FLAG(49) /*!< \c Future use */ +#define RIG_LEVEL_50 CONSTANT_64BIT_FLAG(50) /*!< \c Future use */ +#define RIG_LEVEL_51 CONSTANT_64BIT_FLAG(51) /*!< \c Future use */ +#define RIG_LEVEL_52 CONSTANT_64BIT_FLAG(52) /*!< \c Future use */ +#define RIG_LEVEL_53 CONSTANT_64BIT_FLAG(53) /*!< \c Future use */ +#define RIG_LEVEL_54 CONSTANT_64BIT_FLAG(54) /*!< \c Future use */ +#define RIG_LEVEL_55 CONSTANT_64BIT_FLAG(55) /*!< \c Future use */ +#define RIG_LEVEL_56 CONSTANT_64BIT_FLAG(56) /*!< \c Future use */ +#define RIG_LEVEL_57 CONSTANT_64BIT_FLAG(57) /*!< \c Future use */ +#define RIG_LEVEL_58 CONSTANT_64BIT_FLAG(58) /*!< \c Future use */ +#define RIG_LEVEL_59 CONSTANT_64BIT_FLAG(59) /*!< \c Future use */ +#define RIG_LEVEL_60 CONSTANT_64BIT_FLAG(60) /*!< \c Future use */ +#define RIG_LEVEL_61 CONSTANT_64BIT_FLAG(61) /*!< \c Future use */ +#define RIG_LEVEL_62 CONSTANT_64BIT_FLAG(62) /*!< \c Future use */ +#define RIG_LEVEL_63 CONSTANT_64BIT_FLAG(63) /*!< \c Future use */ + +//! @cond Doxygen_Suppress +#define RIG_LEVEL_FLOAT_LIST (RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_APF|RIG_LEVEL_NR|RIG_LEVEL_PBT_IN|RIG_LEVEL_PBT_OUT|RIG_LEVEL_RFPOWER|RIG_LEVEL_MICGAIN|RIG_LEVEL_COMP|RIG_LEVEL_BALANCE|RIG_LEVEL_SWR|RIG_LEVEL_ALC|RIG_LEVEL_VOXGAIN|RIG_LEVEL_ANTIVOX|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_RFPOWER_METER_WATTS|RIG_LEVEL_COMP_METER|RIG_LEVEL_VD_METER|RIG_LEVEL_ID_METER|RIG_LEVEL_NOTCHF_RAW|RIG_LEVEL_MONITOR_GAIN|RIG_LEVEL_NB|RIG_LEVEL_SPECTRUM_REF) + +#define RIG_LEVEL_READONLY_LIST (RIG_LEVEL_SWR|RIG_LEVEL_ALC|RIG_LEVEL_STRENGTH|RIG_LEVEL_RAWSTR|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_COMP_METER|RIG_LEVEL_VD_METER|RIG_LEVEL_ID_METER) + +#define RIG_LEVEL_IS_FLOAT(l) ((l)&RIG_LEVEL_FLOAT_LIST) +#define RIG_LEVEL_SET(l) ((l)&~RIG_LEVEL_READONLY_LIST) +//! @endcond + + +/** + * \brief Rig Parameters + * + * Parameters are settings that are not VFO specific.\n + * \c STRING used in rigctl + * + * \sa rig_parse_parm(), rig_strparm() + */ +enum rig_parm_e { + RIG_PARM_NONE = 0, /*!< '' -- No Parm */ + RIG_PARM_ANN = (1 << 0), /*!< \c ANN -- "Announce" level, see ann_t */ + RIG_PARM_APO = (1 << 1), /*!< \c APO -- Auto power off, int in minute */ + RIG_PARM_BACKLIGHT = (1 << 2), /*!< \c BACKLIGHT -- LCD light, float [0.0 ... 1.0] */ + RIG_PARM_BEEP = (1 << 4), /*!< \c BEEP -- Beep on keypressed, int (0,1) */ + RIG_PARM_TIME = (1 << 5), /*!< \c TIME -- hh:mm:ss, int in seconds from 00:00:00 */ + RIG_PARM_BAT = (1 << 6), /*!< \c BAT -- battery level, float [0.0 ... 1.0] */ + RIG_PARM_KEYLIGHT = (1 << 7), /*!< \c KEYLIGHT -- Button backlight, on/off */ + RIG_PARM_SCREENSAVER = (1 << 8) /*!< \c SCREENSAVER -- rig specific timeouts */ +}; + +/** + * \brief Rig Cookie enumerations + * + * Cookies are used for a client to request exclusive control of the rig until the client releases the cookie + * Cookies will expire after 1 second unless renewed + * Normal flow would be cookie=rig_cookie(NULL, RIG_COOKIE_GET), rig op, rig_cookie(cookie, RIG_COOKIE_RENEW), rig op, etc.... + * + */ +enum cookie_e { + RIG_COOKIE_GET, /*!< Setup a cookie */ + RIG_COOKIE_RELEASE, /*!< Release a cookie */ + RIG_COOKIE_RENEW, /*!< Renew a cookie */ +}; + +/** + * \brief Multicast data items + * 3 different data item can be included in the multicast JSON + */ +enum multicast_item_e { + RIG_MULTICAST_POLL, // hamlib will be polling the rig for all rig items + RIG_MULTICAST_TRANSCEIVE, // transceive will be turned on and processed + RIG_MULTICAST_SPECTRUM // spectrum data will be included +}; + +//! @cond Doxygen_Suppress +#define RIG_PARM_FLOAT_LIST (RIG_PARM_BACKLIGHT|RIG_PARM_BAT|RIG_PARM_KEYLIGHT) +#define RIG_PARM_READONLY_LIST (RIG_PARM_BAT) + +#define RIG_PARM_IS_FLOAT(l) ((l)&RIG_PARM_FLOAT_LIST) +#define RIG_PARM_SET(l) ((l)&~RIG_PARM_READONLY_LIST) +//! @endcond + +/** + * \brief Setting + * + * This can be a func, a level or a parm. + * Each bit designates one of them. + */ +typedef uint64_t setting_t; + +/** + * \brief Maximum # of rig settings + * + */ +#define RIG_SETTING_MAX 64 + +/** + * \brief Transceive mode + * The rig notifies the host of any event, like freq changed, mode changed, etc. + * \def RIG_TRN_OFF + * Turn it off + * \brief Transceive mode + * \def RIG_TRN_RIG + * RIG_TRN_RIG means the rig acts asynchronously + * \brief Transceive mode + * \def RIG_TRN_POLL + * RIG_TRN_POLL means we have to poll the rig + * + */ +#define RIG_TRN_OFF 0 +#define RIG_TRN_RIG 1 +#define RIG_TRN_POLL 2 + + +/** + * \brief Rig Function Settings + * + * Various operating functions supported by a rig.\n + * \c STRING used in rigctl/rigctld + * + * \sa rig_parse_func(), rig_strfunc() + */ +/* + * The C standard dictates that an enum constant is a 32 bit signed integer. + * Setting a constant's bit 31 created a negative value that on amd64 had the + * upper 32 bits set as well when assigned to the misc.c:rig_func_str structure. + * This caused misc.c:rig_strfunc() to fail its comparison for RIG_FUNC_XIT + * on amd64 (x86_64). To use bit 31 as an unsigned long, preprocessor macros + * have been used instead as a 'const unsigned long' which cannot be used to + * initialize the rig_func_str.func members. TNX KA6MAL, AC6SL. - N0NB + */ +#define RIG_FUNC_NONE 0 /*!< '' -- No Function */ +#define RIG_FUNC_FAGC CONSTANT_64BIT_FLAG (0) /*!< \c FAGC -- Fast AGC */ +#define RIG_FUNC_NB CONSTANT_64BIT_FLAG (1) /*!< \c NB -- Noise Blanker */ +#define RIG_FUNC_COMP CONSTANT_64BIT_FLAG (2) /*!< \c COMP -- Speech Compression */ +#define RIG_FUNC_VOX CONSTANT_64BIT_FLAG (3) /*!< \c VOX -- Voice Operated Relay */ +#define RIG_FUNC_TONE CONSTANT_64BIT_FLAG (4) /*!< \c TONE -- CTCSS Tone TX */ +#define RIG_FUNC_TSQL CONSTANT_64BIT_FLAG (5) /*!< \c TSQL -- CTCSS Activate/De-activate RX */ +#define RIG_FUNC_SBKIN CONSTANT_64BIT_FLAG (6) /*!< \c SBKIN -- Semi Break-in (CW mode) */ +#define RIG_FUNC_FBKIN CONSTANT_64BIT_FLAG (7) /*!< \c FBKIN -- Full Break-in (CW mode) */ +#define RIG_FUNC_ANF CONSTANT_64BIT_FLAG (8) /*!< \c ANF -- Automatic Notch Filter (DSP) */ +#define RIG_FUNC_NR CONSTANT_64BIT_FLAG (9) /*!< \c NR -- Noise Reduction (DSP) */ +#define RIG_FUNC_AIP CONSTANT_64BIT_FLAG (10) /*!< \c AIP -- RF pre-amp (AIP on Kenwood, IPO on Yaesu, etc.) */ +#define RIG_FUNC_APF CONSTANT_64BIT_FLAG (11) /*!< \c APF -- Audio Peak Filter */ +#define RIG_FUNC_MON CONSTANT_64BIT_FLAG (12) /*!< \c MON -- Monitor transmitted signal */ +#define RIG_FUNC_MN CONSTANT_64BIT_FLAG (13) /*!< \c MN -- Manual Notch */ +#define RIG_FUNC_RF CONSTANT_64BIT_FLAG (14) /*!< \c RF -- RTTY Filter */ +#define RIG_FUNC_ARO CONSTANT_64BIT_FLAG (15) /*!< \c ARO -- Auto Repeater Offset */ +#define RIG_FUNC_LOCK CONSTANT_64BIT_FLAG (16) /*!< \c LOCK -- Lock */ +#define RIG_FUNC_MUTE CONSTANT_64BIT_FLAG (17) /*!< \c MUTE -- Mute */ +#define RIG_FUNC_VSC CONSTANT_64BIT_FLAG (18) /*!< \c VSC -- Voice Scan Control */ +#define RIG_FUNC_REV CONSTANT_64BIT_FLAG (19) /*!< \c REV -- Reverse transmit and receive frequencies */ +#define RIG_FUNC_SQL CONSTANT_64BIT_FLAG (20) /*!< \c SQL -- Turn Squelch Monitor on/off */ +#define RIG_FUNC_ABM CONSTANT_64BIT_FLAG (21) /*!< \c ABM -- Auto Band Mode */ +#define RIG_FUNC_BC CONSTANT_64BIT_FLAG (22) /*!< \c BC -- Beat Canceller */ +#define RIG_FUNC_MBC CONSTANT_64BIT_FLAG (23) /*!< \c MBC -- Manual Beat Canceller */ +#define RIG_FUNC_RIT CONSTANT_64BIT_FLAG (24) /*!< \c RIT -- Receiver Incremental Tuning */ +#define RIG_FUNC_AFC CONSTANT_64BIT_FLAG (25) /*!< \c AFC -- Auto Frequency Control ON/OFF */ +#define RIG_FUNC_SATMODE CONSTANT_64BIT_FLAG (26) /*!< \c SATMODE -- Satellite mode ON/OFF */ +#define RIG_FUNC_SCOPE CONSTANT_64BIT_FLAG (27) /*!< \c SCOPE -- Simple bandscope ON/OFF */ +#define RIG_FUNC_RESUME CONSTANT_64BIT_FLAG (28) /*!< \c RESUME -- Scan auto-resume */ +#define RIG_FUNC_TBURST CONSTANT_64BIT_FLAG (29) /*!< \c TBURST -- 1750 Hz tone burst */ +#define RIG_FUNC_TUNER CONSTANT_64BIT_FLAG (30) /*!< \c TUNER -- Enable automatic tuner */ +#define RIG_FUNC_XIT CONSTANT_64BIT_FLAG (31) /*!< \c XIT -- Transmitter Incremental Tuning */ +#ifndef SWIGLUAHIDE +/* Hide the top 32 bits from the old Lua binding as they can't be represented */ +#define RIG_FUNC_NB2 CONSTANT_64BIT_FLAG (32) /*!< \c NB2 -- 2nd Noise Blanker */ +#define RIG_FUNC_CSQL CONSTANT_64BIT_FLAG (33) /*!< \c CSQL -- DCS Squelch setting */ +#define RIG_FUNC_AFLT CONSTANT_64BIT_FLAG (34) /*!< \c AFLT -- AF Filter setting */ +#define RIG_FUNC_ANL CONSTANT_64BIT_FLAG (35) /*!< \c ANL -- Noise limiter setting */ +#define RIG_FUNC_BC2 CONSTANT_64BIT_FLAG (36) /*!< \c BC2 -- 2nd Beat Cancel */ +#define RIG_FUNC_DUAL_WATCH CONSTANT_64BIT_FLAG (37) /*!< \c DUAL_WATCH -- Dual Watch / Sub Receiver */ +#define RIG_FUNC_DIVERSITY CONSTANT_64BIT_FLAG (38) /*!< \c DIVERSITY -- Diversity receive */ +#define RIG_FUNC_DSQL CONSTANT_64BIT_FLAG (39) /*!< \c DSQL -- Digital modes squelch */ +#define RIG_FUNC_SCEN CONSTANT_64BIT_FLAG (40) /*!< \c SCEN -- scrambler/encryption */ +#define RIG_FUNC_SLICE CONSTANT_64BIT_FLAG (41) /*!< \c Rig slice selection -- Flex */ +#define RIG_FUNC_TRANSCEIVE CONSTANT_64BIT_FLAG (42) /*!< \c TRANSCEIVE -- Send radio state changes automatically ON/OFF */ +#define RIG_FUNC_SPECTRUM CONSTANT_64BIT_FLAG (43) /*!< \c SPECTRUM -- Spectrum scope data output ON/OFF */ +#define RIG_FUNC_SPECTRUM_HOLD CONSTANT_64BIT_FLAG (44) /*!< \c SPECTRUM_HOLD -- Pause spectrum scope updates ON/OFF */ +#define RIG_FUNC_BIT45 CONSTANT_64BIT_FLAG (45) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT46 CONSTANT_64BIT_FLAG (46) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT47 CONSTANT_64BIT_FLAG (47) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT48 CONSTANT_64BIT_FLAG (48) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT49 CONSTANT_64BIT_FLAG (49) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT50 CONSTANT_64BIT_FLAG (50) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT51 CONSTANT_64BIT_FLAG (51) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT52 CONSTANT_64BIT_FLAG (52) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT53 CONSTANT_64BIT_FLAG (53) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT54 CONSTANT_64BIT_FLAG (54) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT55 CONSTANT_64BIT_FLAG (55) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT56 CONSTANT_64BIT_FLAG (56) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT57 CONSTANT_64BIT_FLAG (57) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT58 CONSTANT_64BIT_FLAG (58) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT59 CONSTANT_64BIT_FLAG (59) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT60 CONSTANT_64BIT_FLAG (60) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT61 CONSTANT_64BIT_FLAG (61) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT62 CONSTANT_64BIT_FLAG (62) /*!< \c available for future RIG_FUNC items */ +#define RIG_FUNC_BIT63 CONSTANT_64BIT_FLAG (63) /*!< \c available for future RIG_FUNC items */ +/* 63 is this highest bit number that can be used */ +#endif + +/** + * \brief power unit macros + * \def mW + * Converts a power level integer to milliwatts. This is limited to 2 + * megawatts on 32 bit systems. + */ +#define mW(p) ((int)(p)) +/** + * \brief power unit macros + * \def Watts + * + * Converts a power level integer to watts. This is limited to 2 + * gigawatts on 32 bit systems. + */ +#define Watts(p) ((int)((p)*1000)) +/** + * \brief power unit macros + * \def W + * + * Same as Watts for the person who is too lazy to type Watts :-) + */ +#define W(p) Watts(p) +#if 0 // deprecating kW macro as this doesn't make sense +/** + * \brief power unit macros + * \def kW + * + * Same as Watts for the person who is too lazy to type Watts :-) + */ +#define kW(p) ((int)((p)*1000000L)) +#endif + + +/** + * \brief Radio mode + * + * Various modes supported by a rig.\n + * \c STRING used in rigctl + * + * \sa rig_parse_mode(), rig_strrmode() + * TODO: Add new 8600 modes to rig2icom_mode() and icom2rig_mode() in frame.c + */ +typedef uint64_t rmode_t; + +#define RIG_MODE_NONE 0 /*!< '' -- None */ +#define RIG_MODE_AM CONSTANT_64BIT_FLAG (0) /*!< \c AM -- Amplitude Modulation */ +#define RIG_MODE_CW CONSTANT_64BIT_FLAG (1) /*!< \c CW -- CW "normal" sideband */ +#define RIG_MODE_USB CONSTANT_64BIT_FLAG (2) /*!< \c USB -- Upper Side Band */ +#define RIG_MODE_LSB CONSTANT_64BIT_FLAG (3) /*!< \c LSB -- Lower Side Band */ +#define RIG_MODE_RTTY CONSTANT_64BIT_FLAG (4) /*!< \c RTTY -- Radio Teletype */ +#define RIG_MODE_FM CONSTANT_64BIT_FLAG (5) /*!< \c FM -- "narrow" band FM */ +#define RIG_MODE_WFM CONSTANT_64BIT_FLAG (6) /*!< \c WFM -- broadcast wide FM */ +#define RIG_MODE_CWR CONSTANT_64BIT_FLAG (7) /*!< \c CWR -- CW "reverse" sideband */ +#define RIG_MODE_RTTYR CONSTANT_64BIT_FLAG (8) /*!< \c RTTYR -- RTTY "reverse" sideband */ +#define RIG_MODE_AMS CONSTANT_64BIT_FLAG (9) /*!< \c AMS -- Amplitude Modulation Synchronous */ +#define RIG_MODE_PKTLSB CONSTANT_64BIT_FLAG (10) /*!< \c PKTLSB -- Packet/Digital LSB mode (dedicated port) */ +#define RIG_MODE_PKTUSB CONSTANT_64BIT_FLAG (11) /*!< \c PKTUSB -- Packet/Digital USB mode (dedicated port) */ +#define RIG_MODE_PKTFM CONSTANT_64BIT_FLAG (12) /*!< \c PKTFM -- Packet/Digital FM mode (dedicated port) */ +#define RIG_MODE_ECSSUSB CONSTANT_64BIT_FLAG (13) /*!< \c ECSSUSB -- Exalted Carrier Single Sideband USB */ +#define RIG_MODE_ECSSLSB CONSTANT_64BIT_FLAG (14) /*!< \c ECSSLSB -- Exalted Carrier Single Sideband LSB */ +#define RIG_MODE_FAX CONSTANT_64BIT_FLAG (15) /*!< \c FAX -- Facsimile Mode */ +#define RIG_MODE_SAM CONSTANT_64BIT_FLAG (16) /*!< \c SAM -- Synchronous AM double sideband */ +#define RIG_MODE_SAL CONSTANT_64BIT_FLAG (17) /*!< \c SAL -- Synchronous AM lower sideband */ +#define RIG_MODE_SAH CONSTANT_64BIT_FLAG (18) /*!< \c SAH -- Synchronous AM upper (higher) sideband */ +#define RIG_MODE_DSB CONSTANT_64BIT_FLAG (19) /*!< \c DSB -- Double sideband suppressed carrier */ +#define RIG_MODE_FMN CONSTANT_64BIT_FLAG (21) /*!< \c FMN -- FM Narrow Kenwood ts990s */ +#define RIG_MODE_PKTAM CONSTANT_64BIT_FLAG (22) /*!< \c PKTAM -- Packet/Digital AM mode e.g. IC7300 */ +#define RIG_MODE_P25 CONSTANT_64BIT_FLAG (23) /*!< \c P25 -- APCO/P25 VHF,UHF digital mode IC-R8600 */ +#define RIG_MODE_DSTAR CONSTANT_64BIT_FLAG (24) /*!< \c D-Star -- VHF,UHF digital mode IC-R8600 */ +#define RIG_MODE_DPMR CONSTANT_64BIT_FLAG (25) /*!< \c dPMR -- digital PMR, VHF,UHF digital mode IC-R8600 */ +#define RIG_MODE_NXDNVN CONSTANT_64BIT_FLAG (26) /*!< \c NXDN-VN -- VHF,UHF digital mode IC-R8600 */ +#define RIG_MODE_NXDN_N CONSTANT_64BIT_FLAG (27) /*!< \c NXDN-N -- VHF,UHF digital mode IC-R8600 */ +#define RIG_MODE_DCR CONSTANT_64BIT_FLAG (28) /*!< \c DCR -- VHF,UHF digital mode IC-R8600 */ +#define RIG_MODE_AMN CONSTANT_64BIT_FLAG (29) /*!< \c AM-N -- Narrow band AM mode IC-R30 */ +#define RIG_MODE_PSK CONSTANT_64BIT_FLAG (30) /*!< \c PSK - Kenwood PSK and others */ +#define RIG_MODE_PSKR CONSTANT_64BIT_FLAG (31) /*!< \c PSKR - Kenwood PSKR and others */ +#ifndef SWIGLUAHIDE +/* hide the top 32 bits from the Lua binding as they will not work */ +#define RIG_MODE_DD CONSTANT_64BIT_FLAG (32) /*!< \c DD Mode IC-9700 */ +#define RIG_MODE_C4FM CONSTANT_64BIT_FLAG (33) /*!< \c Yaesu C4FM mode */ +#define RIG_MODE_PKTFMN CONSTANT_64BIT_FLAG (34) /*!< \c Yaesu DATA-FM-N */ +#define RIG_MODE_SPEC CONSTANT_64BIT_FLAG (35) /*!< \c Unfiltered as in PowerSDR */ +#define RIG_MODE_CWN CONSTANT_64BIT_FLAG (36) /*!< \c CWN -- Narrow band CW (FT-736R) */ +#define RIG_MODE_IQ CONSTANT_64BIT_FLAG (37) /*!< \c IQ mode for a couple of kit rigs */ +#define RIG_MODE_BIT38 CONSTANT_64BIT_FLAG (38) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT39 CONSTANT_64BIT_FLAG (39) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT40 CONSTANT_64BIT_FLAG (40) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT41 CONSTANT_64BIT_FLAG (41) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT42 CONSTANT_64BIT_FLAG (42) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT43 CONSTANT_64BIT_FLAG (43) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT44 CONSTANT_64BIT_FLAG (44) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT45 CONSTANT_64BIT_FLAG (45) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT46 CONSTANT_64BIT_FLAG (46) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT47 CONSTANT_64BIT_FLAG (47) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT48 CONSTANT_64BIT_FLAG (48) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT49 CONSTANT_64BIT_FLAG (49) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT50 CONSTANT_64BIT_FLAG (50) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT51 CONSTANT_64BIT_FLAG (51) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT52 CONSTANT_64BIT_FLAG (52) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT53 CONSTANT_64BIT_FLAG (53) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT54 CONSTANT_64BIT_FLAG (54) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT55 CONSTANT_64BIT_FLAG (55) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT56 CONSTANT_64BIT_FLAG (56) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT57 CONSTANT_64BIT_FLAG (57) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT58 CONSTANT_64BIT_FLAG (58) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT59 CONSTANT_64BIT_FLAG (59) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT60 CONSTANT_64BIT_FLAG (60) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT61 CONSTANT_64BIT_FLAG (61) /*!< \c reserved for future expansion */ +#define RIG_MODE_BIT62 CONSTANT_64BIT_FLAG (62) /*!< \c reserved for future expansion */ +#define RIG_MODE_TESTS_MAX CONSTANT_64BIT_FLAG (63) /*!< \c last bit available for 64-bit enum MUST ALWAYS BE LAST, Max Count for dumpcaps.c */ +#endif + +/** + * \brief macro for backends, not to be used by rig_set_mode et al. + */ +#define RIG_MODE_SSB (RIG_MODE_USB|RIG_MODE_LSB) + +/** + * \brief macro for backends, not to be used by rig_set_mode et al. + */ +#define RIG_MODE_ECSS (RIG_MODE_ECSSUSB|RIG_MODE_ECSSLSB) + +//! @cond Doxygen_Suppress +#define RIG_DBLST_END 0 /* end marker in a preamp/att level list */ +#define RIG_IS_DBLST_END(d) ((d)==0) +//! @endcond + + +/** + * \brief Frequency range + * + * Put together a group of this struct in an array to define + * what frequencies your rig has access to. + */ +typedef struct freq_range_list { + freq_t startf; /*!< Start frequency */ + freq_t endf; /*!< End frequency */ + rmode_t modes; /*!< Bit field of RIG_MODE's */ + int low_power; /*!< Lower RF power in mW, -1 for no power (ie. rx list) */ + int high_power; /*!< Higher RF power in mW, -1 for no power (ie. rx list) */ + vfo_t vfo; /*!< VFO list equipped with this range */ + ant_t ant; /*!< Antenna list equipped with this range, 0 means all, RIG_ANT_CURR means dedicated to certain bands and automatically switches, no set_ant command */ + char *label; /*!< Label for this range that explains why. e.g. Icom rigs USA, EUR, ITR, TPE, KOR */ +} freq_range_t; + +//! @cond Doxygen_Suppress +#define RIG_FRNG_END {Hz(0),Hz(0),RIG_MODE_NONE,0,0,RIG_VFO_NONE} +#define RIG_IS_FRNG_END(r) ((r).startf == Hz(0) && (r).endf == Hz(0)) +//! @endcond + +/** + * \brief Tuning step definition + * + * Lists the tuning steps available for each mode. + * + * If a ts field in the list has RIG_TS_ANY value, this means the rig allows + * its tuning step to be set to any value ranging from the lowest to the + * highest (if any) value in the list for that mode. The tuning step must be + * sorted in the ascending order, and the RIG_TS_ANY value, if present, must + * be the last one in the list. + * + * Note also that the minimum frequency resolution of the rig is determined by + * the lowest value in the Tuning step list. + * + * \sa rig_set_ts(), rig_get_resolution() + */ +struct tuning_step_list { + rmode_t modes; /*!< Bit field of RIG_MODE's */ + shortfreq_t ts; /*!< Tuning step in Hz */ +}; + +//! @cond Doxygen_Suppress +#define RIG_TS_ANY 0 +#define RIG_TS_END {RIG_MODE_NONE, 0} +#define RIG_IS_TS_END(t) ((t).modes == RIG_MODE_NONE && (t).ts == 0) +//! @endcond + + +/** + * \brief Filter definition + * + * Lists the filters available for each mode. + * + * If more than one filter is available for a given mode, the first entry in + * the array will be the default filter to use for the normal passband of this + * mode. The first entry in the array below the default normal passband is + * the default narrow passband and the first entry in the array above the + * default normal passband is the default wide passband. Note: if there's no + * lower width or upper width, then narrow or respectively wide passband is + * equal to the default normal passband. + * + * If a width field in the list has RIG_FLT_ANY value, this means the rig + * allows its passband width to be set to any value ranging from the lowest to + * the highest value (if any) in the list for that mode. The RIG_FLT_ANY + * value, if present, must be the last one in the list. + * + * The width field is the narrowest passband in a transmit/receive chain with + * regard to different IF. + * + * \sa rig_set_mode(), rig_passband_normal(), rig_passband_narrow(), rig_passband_wide() + */ +struct filter_list { + rmode_t modes; /*!< Bit field of RIG_MODE's */ + pbwidth_t width; /*!< Passband width in Hz */ +}; +//! @cond Doxygen_Suppress +#define RIG_FLT_ANY 0 +#define RIG_FLT_END {RIG_MODE_NONE, 0} +#define RIG_IS_FLT_END(f) ((f).modes == RIG_MODE_NONE) +//! @endcond + + +/** + * \brief Empty channel_t.flags field + */ +#define RIG_CHFLAG_NONE 0 +/** + * \brief skip memory channel during scan (lock out), channel_t.flags + */ +#define RIG_CHFLAG_SKIP (1<<0) +/** + * \brief DATA port mode flag + */ +#define RIG_CHFLAG_DATA (1<<1) +/** + * \brief programmed skip (PSKIP) memory channel during scan (lock out), channel_t.flags + */ +#define RIG_CHFLAG_PSKIP (1<<2) + +/** + * \brief Extension attribute definition + * + */ +struct ext_list { + token_t token; /*!< Token ID */ + value_t val; /*!< Value */ +}; + +//! @cond Doxygen_Suppress +#define RIG_EXT_END {0, {.i=0}} +#define RIG_IS_EXT_END(x) ((x).token == 0) +//! @endcond + +/** + * \brief Channel structure + * + * The channel struct stores all the attributes peculiar to a VFO. + * + * \sa rig_set_channel(), rig_get_channel() + */ +struct channel { + int channel_num; /*!< Channel number */ + int bank_num; /*!< Bank number */ + vfo_t vfo; /*!< VFO */ + ant_t ant; /*!< Selected antenna */ + freq_t freq; /*!< Receive frequency */ + rmode_t mode; /*!< Receive mode */ + pbwidth_t width; /*!< Receive passband width associated with mode */ + + freq_t tx_freq; /*!< Transmit frequency */ + rmode_t tx_mode; /*!< Transmit mode */ + pbwidth_t tx_width; /*!< Transmit passband width associated with mode */ + + split_t split; /*!< Split mode */ + vfo_t tx_vfo; /*!< Split transmit VFO */ + + rptr_shift_t rptr_shift; /*!< Repeater shift */ + shortfreq_t rptr_offs; /*!< Repeater offset */ + shortfreq_t tuning_step; /*!< Tuning step */ + shortfreq_t rit; /*!< RIT */ + shortfreq_t xit; /*!< XIT */ + setting_t funcs; /*!< Function status */ + value_t levels[RIG_SETTING_MAX]; /*!< Level values */ + tone_t ctcss_tone; /*!< CTCSS tone */ + tone_t ctcss_sql; /*!< CTCSS squelch tone */ + tone_t dcs_code; /*!< DCS code */ + tone_t dcs_sql; /*!< DCS squelch code */ + int scan_group; /*!< Scan group */ + unsigned int flags; /*!< Channel flags, see RIG_CHFLAG's */ + char channel_desc[HAMLIB_MAXCHANDESC]; /*!< Name */ + struct ext_list + *ext_levels; /*!< Extension level value list, NULL ended. ext_levels can be NULL */ +}; + +/** + * \brief Channel structure typedef + */ +typedef struct channel channel_t; + +/** + * \brief Channel capability definition + * + * Definition of the attributes that can be stored/retrieved in/from memory + */ +struct channel_cap { + unsigned bank_num: 1; /*!< Bank number */ + unsigned vfo: 1; /*!< VFO */ + unsigned ant: 1; /*!< Selected antenna */ + unsigned freq: 1; /*!< Receive frequency */ + unsigned mode: 1; /*!< Receive mode */ + unsigned width: 1; /*!< Receive passband width associated with mode */ + + unsigned tx_freq: 1; /*!< Transmit frequency */ + unsigned tx_mode: 1; /*!< Transmit mode */ + unsigned tx_width: 1; /*!< Transmit passband width associated with mode */ + + unsigned split: 1; /*!< Split mode */ + unsigned tx_vfo: 1; /*!< Split transmit VFO */ + unsigned rptr_shift: 1; /*!< Repeater shift */ + unsigned rptr_offs: 1; /*!< Repeater offset */ + unsigned tuning_step: 1; /*!< Tuning step */ + unsigned rit: 1; /*!< RIT */ + unsigned xit: 1; /*!< XIT */ + setting_t funcs; /*!< Function status */ + setting_t levels; /*!< Level values */ + unsigned ctcss_tone: 1; /*!< CTCSS tone */ + unsigned ctcss_sql: 1; /*!< CTCSS squelch tone */ + unsigned dcs_code: 1; /*!< DCS code */ + unsigned dcs_sql: 1; /*!< DCS squelch code */ + unsigned scan_group: 1; /*!< Scan group */ + unsigned flags: 1; /*!< Channel flags */ + unsigned channel_desc: 1; /*!< Name */ + unsigned ext_levels: 1; /*!< Extension level value list */ +}; + +/** + * \brief Channel cap + */ +typedef struct channel_cap channel_cap_t; + + +/** + * \brief Memory channel type definition + * + * Definition of memory types. Depending on the type, the content + * of the memory channel has to be interpreted accordingly. + * For instance, a RIG_MTYPE_EDGE channel_t will hold only a start + * or stop frequency. + * + * \sa chan_list() + */ +typedef enum { + RIG_MTYPE_NONE = 0, /*!< None */ + RIG_MTYPE_MEM, /*!< Regular */ + RIG_MTYPE_EDGE, /*!< Scan edge */ + RIG_MTYPE_CALL, /*!< Call channel */ + RIG_MTYPE_MEMOPAD, /*!< Memory pad */ + RIG_MTYPE_SAT, /*!< Satellite */ + RIG_MTYPE_BAND, /*!< VFO/Band channel */ + RIG_MTYPE_PRIO /*!< Priority channel */ +} chan_type_t; + + +/** + * \brief Memory channel list definition + * + * Example for the Ic706MkIIG (99 memory channels, 2 scan edges, 2 call chans): +\code + chan_t chan_list[] = { + { 1, 99, RIG_MTYPE_MEM }, + { 100, 103, RIG_MTYPE_EDGE }, + { 104, 105, RIG_MTYPE_CALL }, + RIG_CHAN_END + } +\endcode + */ +struct chan_list { + int startc; /*!< Starting memory channel \b number */ + int endc; /*!< Ending memory channel \b number */ + chan_type_t type; /*!< Memory type. see chan_type_t */ + channel_cap_t + mem_caps; /*!< Definition of attributes that can be stored/retrieved */ +}; + +//! @cond Doxygen_Suppress +#define RIG_CHAN_END {0,0,RIG_MTYPE_NONE} +#define RIG_IS_CHAN_END(c) ((c).type == RIG_MTYPE_NONE) +//! @endcond + +/** + * \brief Special memory channel value to tell rig_lookup_mem_caps() to retrieve all the ranges + */ +#define RIG_MEM_CAPS_ALL -1 + +/** + * \brief chan_t type + */ +typedef struct chan_list chan_t; + + +/** + * \brief level/parm granularity definition + * + * The granularity is undefined if min = 0, max = 0, and step = 0. + * + * For float settings, if min.f = 0 and max.f = 0 (and step.f! = 0), max.f is + * assumed to be actually equal to 1.0. + * + * If step = 0 (and min and/or max are not null), then this means step can + * have maximum resolution, depending on type (int or float). + */ +struct gran { + value_t min; /*!< Minimum value */ + value_t max; /*!< Maximum value */ + value_t step; /*!< Step */ +}; + +/** + * \brief gran_t type + */ +typedef struct gran gran_t; + + +/** + * \brief Calibration table struct + */ +struct cal_table { + int size; /*!< number of plots in the table */ + struct { + int raw; /*!< raw (A/D) value, as returned by \a RIG_LEVEL_RAWSTR */ + int val; /*!< associated value, basically the measured dB value */ + } table[HAMLIB_MAX_CAL_LENGTH]; /*!< table of plots */ +}; + +/** + * \brief calibration table type + * + * cal_table_t is a data type suited to hold linear calibration. + * cal_table_t.size tells the number of plots cal_table_t.table contains. + * + * If a value is below or equal to cal_table_t.table[0].raw, + * rig_raw2val() will return cal_table_t.table[0].val. + * + * If a value is greater or equal to cal_table_t.table[cal_table_t.size-1].raw, + * rig_raw2val() will return cal_table_t.table[cal_table_t.size-1].val. + */ +typedef struct cal_table cal_table_t; + +//! @cond Doxygen_Suppress +#define EMPTY_STR_CAL { 0, { { 0, 0 }, } } +//! @endcond Doxygen_Suppress + + +/** + * \brief Calibration table struct for float values + */ +struct cal_table_float { + int size; /*!< number of plots in the table */ + struct { + int raw; /*!< raw (A/D) value */ + float val; /*!< associated value */ + } table[HAMLIB_MAX_CAL_LENGTH]; /*!< table of plots */ +}; + +/** + * \brief calibration table type for float values + * + * cal_table_float_t is a data type suited to hold linear calibration. + * cal_table_float_t.size tells the number of plots cal_table_float_t.table contains. + * + * If a value is below or equal to cal_table_float_t.table[0].raw, + * rig_raw2val_float() will return cal_table_float_t.table[0].val. + * + * If a value is greater or equal to cal_table_float_t.table[cal_table_float_t.size-1].raw, + * rig_raw2val_float() will return cal_table_float_t.table[cal_table_float_t.size-1].val. + */ +typedef struct cal_table_float cal_table_float_t; + +//! @cond Doxygen_Suppress +#define EMPTY_FLOAT_CAL { 0, { { 0, 0f }, } } + +typedef int (* chan_cb_t)(RIG *, channel_t **, int, const chan_t *, rig_ptr_t); +typedef int (* confval_cb_t)(RIG *, + const struct confparams *, + value_t *, + rig_ptr_t); +//! @endcond + +/** + * \brief Spectrum scope + */ +struct rig_spectrum_scope +{ + int id; + char *name; +}; + +/** + * \brief Spectrum scope modes + */ +enum rig_spectrum_mode_e { + RIG_SPECTRUM_MODE_NONE = 0, + RIG_SPECTRUM_MODE_CENTER, /*!< Spectrum scope centered around the VFO frequency */ + RIG_SPECTRUM_MODE_FIXED, /*!< Spectrum scope edge frequencies are fixed */ + RIG_SPECTRUM_MODE_CENTER_SCROLL, /*!< Spectrum scope edge frequencies are fixed, but identical to what the center mode would use. Scrolling is enabled. */ + RIG_SPECTRUM_MODE_FIXED_SCROLL, /*!< Spectrum scope edge frequencies are fixed with scrolling enabled */ +}; + +/** + * \brief Spectrum scope averaging modes + */ +struct rig_spectrum_avg_mode +{ + int id; + char *name; +}; + +/** + * \brief Represents a single line of rig spectrum scope FFT data. + * + * The data levels specify the range of the spectrum scope FFT data. + * The minimum level should represent the lowest numeric value and the lowest signal level in dB. + * The maximum level should represent the highest numeric value and the highest signal level in dB. + * The data level values are assumed to represent the dB strength scale in a linear way. + * + * Note that the data level and signal strength ranges may change depending on the settings of the rig. + * At least on Kenwood the sub-scope provides different kind of data compared to the main scope. + */ +struct rig_spectrum_line +{ + int id; /*!< Numeric ID of the spectrum scope data stream identifying the VFO/receiver. First ID is zero. Rigs with multiple scopes usually have identifiers, such as 0 = Main, 1 = Sub. */ + + int data_level_min; /*!< The numeric value that represents the minimum signal level. */ + int data_level_max; /*!< The numeric value that represents the maximum signal level. */ + double signal_strength_min; /*!< The strength of the minimum signal level in dB. */ + double signal_strength_max; /*!< The strength of the maximum signal level in dB. */ + + enum rig_spectrum_mode_e spectrum_mode; /*!< Spectrum mode. */ + + freq_t center_freq; /*!< Center frequency of the spectrum scope in Hz in RIG_SPECTRUM_CENTER mode. */ + freq_t span_freq; /*!< Span of the spectrum scope in Hz in RIG_SPECTRUM_CENTER mode. */ + + freq_t low_edge_freq; /*!< Low edge frequency of the spectrum scope in Hz in RIG_SPECTRUM_FIXED mode. */ + freq_t high_edge_freq; /*!< High edge frequency of the spectrum scope in Hz in RIG_SPECTRUM_FIXED mode. */ + + int spectrum_data_length; /*!< Number of bytes of 8-bit spectrum data in the data buffer. The amount of data may vary if the rig has multiple spectrum scopes, depending on the scope. */ + unsigned char *spectrum_data; /*!< 8-bit spectrum data covering bandwidth of either the span_freq in center mode or from low edge to high edge in fixed mode. A higher value represents higher signal strength. */ +}; + +/** + * \brief Rig data structure. + * + * Basic rig type, can store some useful info about different radios. Each + * backend must be able to populate this structure, so we can make useful + * inquiries about capabilities. + * + * The main idea of this struct is that it will be defined by the backend rig + * driver, and will remain readonly for the application. Fields that need to + * be modifiable by the application are copied into the struct rig_state, + * which is a kind of private storage of the RIG instance. + * + * This way, you can have several rigs running within the same application, + * sharing the struct rig_caps of the backend, while keeping their own + * customized data. + * + * mdblack: Don't move or add fields around without bumping the version numbers + * DLL or shared library replacement depends on order + */ +//! @cond Doxygen_Suppress +#define RIG_MODEL(arg) .rig_model=arg,.macro_name=#arg +struct rig_caps { + rig_model_t rig_model; /*!< Rig model. */ + const char *model_name; /*!< Model name. */ + const char *mfg_name; /*!< Manufacturer. */ + const char *version; /*!< Driver version. */ + const char *copyright; /*!< Copyright info. */ + enum rig_status_e status; /*!< Driver status. */ + + int rig_type; /*!< Rig type. */ + ptt_type_t ptt_type; /*!< Type of the PTT port. */ + dcd_type_t dcd_type; /*!< Type of the DCD port. */ + rig_port_t port_type; /*!< Type of communication port. */ + + int serial_rate_min; /*!< Minimum serial speed. */ + int serial_rate_max; /*!< Maximum serial speed. */ + int serial_data_bits; /*!< Number of data bits. */ + int serial_stop_bits; /*!< Number of stop bits. */ + enum serial_parity_e serial_parity; /*!< Parity. */ + enum serial_handshake_e serial_handshake; /*!< Handshake. */ + + int write_delay; /*!< Delay between each byte sent out, in mS */ + int post_write_delay; /*!< Delay between each commands send out, in mS */ + int timeout; /*!< Timeout, in mS */ + int retry; /*!< Maximum number of retries if command fails, 0 to disable */ + + setting_t has_get_func; /*!< List of get functions */ + setting_t has_set_func; /*!< List of set functions */ + setting_t has_get_level; /*!< List of get level */ + setting_t has_set_level; /*!< List of set level */ + setting_t has_get_parm; /*!< List of get parm */ + setting_t has_set_parm; /*!< List of set parm */ + + gran_t level_gran[RIG_SETTING_MAX]; /*!< level granularity (i.e. steps) */ + gran_t parm_gran[RIG_SETTING_MAX]; /*!< parm granularity (i.e. steps) */ + + const struct confparams *extparms; /*!< Extension parm list, \sa ext.c */ + const struct confparams *extlevels; /*!< Extension level list, \sa ext.c */ + const struct confparams *extfuncs; /*!< Extension func list, \sa ext.c */ + int *ext_tokens; /*!< Extension token list */ + + tone_t *ctcss_list; /*!< CTCSS tones list, zero ended */ + tone_t *dcs_list; /*!< DCS code list, zero ended */ + + int preamp[HAMLIB_MAXDBLSTSIZ]; /*!< Preamp list in dB, 0 terminated */ + int attenuator[HAMLIB_MAXDBLSTSIZ]; /*!< Attenuator list in dB, 0 terminated */ + shortfreq_t max_rit; /*!< max absolute RIT */ + shortfreq_t max_xit; /*!< max absolute XIT */ + shortfreq_t max_ifshift; /*!< max absolute IF-SHIFT */ + + int agc_level_count; /*!< Number of supported AGC levels. Zero indicates all modes should be available (for backwards-compatibility). */ + enum agc_level_e agc_levels[HAMLIB_MAX_AGC_LEVELS]; /*!< Supported AGC levels */ + + ann_t announces; /*!< Announces bit field list */ + + vfo_op_t vfo_ops; /*!< VFO op bit field list */ + scan_t scan_ops; /*!< Scan bit field list */ + int targetable_vfo; /*!< Bit field list of direct VFO access commands */ + int transceive; /*!< Supported transceive mode */ + + int bank_qty; /*!< Number of banks */ + int chan_desc_sz; /*!< Max length of memory channel name */ + + chan_t chan_list[HAMLIB_CHANLSTSIZ]; /*!< Channel list, zero ended */ + + // As of 2020-02-12 we know of 5 models from Icom USA, EUR, ITR, TPE, KOR for the IC-9700 + // So we currently have 5 ranges we need to deal with + // The backend for the model should fill in the label field to explain what model it is + // The the IC-9700 in ic7300.c for an example + freq_range_t rx_range_list1[HAMLIB_FRQRANGESIZ]; /*!< Receive frequency range list #1 */ + freq_range_t tx_range_list1[HAMLIB_FRQRANGESIZ]; /*!< Transmit frequency range list #1 */ + freq_range_t rx_range_list2[HAMLIB_FRQRANGESIZ]; /*!< Receive frequency range list #2 */ + freq_range_t tx_range_list2[HAMLIB_FRQRANGESIZ]; /*!< Transmit frequency range list #2 */ + freq_range_t rx_range_list3[HAMLIB_FRQRANGESIZ]; /*!< Receive frequency range list #3 */ + freq_range_t tx_range_list3[HAMLIB_FRQRANGESIZ]; /*!< Transmit frequency range list #3 */ + freq_range_t rx_range_list4[HAMLIB_FRQRANGESIZ]; /*!< Receive frequency range list #4 */ + freq_range_t tx_range_list4[HAMLIB_FRQRANGESIZ]; /*!< Transmit frequency range list #4 */ + freq_range_t rx_range_list5[HAMLIB_FRQRANGESIZ]; /*!< Receive frequency range list #5 */ + freq_range_t tx_range_list5[HAMLIB_FRQRANGESIZ]; /*!< Transmit frequency range list #5 */ + + struct tuning_step_list tuning_steps[HAMLIB_TSLSTSIZ]; /*!< Tuning step list */ + struct filter_list filters[HAMLIB_FLTLSTSIZ]; /*!< mode/filter table, at -6dB */ + + cal_table_t str_cal; /*!< S-meter calibration table */ + cal_table_float_t swr_cal; /*!< SWR meter calibration table */ + cal_table_float_t alc_cal; /*!< ALC meter calibration table */ + cal_table_float_t rfpower_meter_cal; /*!< RF power meter calibration table */ + cal_table_float_t comp_meter_cal; /*!< COMP meter calibration table */ + cal_table_float_t vd_meter_cal; /*!< Voltage meter calibration table */ + cal_table_float_t id_meter_cal; /*!< Current draw meter calibration table */ + + struct rig_spectrum_scope spectrum_scopes[HAMLIB_MAX_SPECTRUM_SCOPES]; /*!< Supported spectrum scopes. The array index must match the scope ID. Last entry must have NULL name. */ + enum rig_spectrum_mode_e spectrum_modes[HAMLIB_MAX_SPECTRUM_MODES]; /*!< Supported spectrum scope modes. Last entry must be RIG_SPECTRUM_MODE_NONE. */ + freq_t spectrum_spans[HAMLIB_MAX_SPECTRUM_SPANS]; /*!< Supported spectrum scope frequency spans in Hz in center mode. Last entry must be 0. */ + struct rig_spectrum_avg_mode spectrum_avg_modes[HAMLIB_MAX_SPECTRUM_AVG_MODES]; /*!< Supported spectrum scope averaging modes. Last entry must have NULL name. */ + int spectrum_attenuator[HAMLIB_MAXDBLSTSIZ]; /*!< Spectrum attenuator list in dB, 0 terminated */ + + const struct confparams *cfgparams; /*!< Configuration parameters. */ + const rig_ptr_t priv; /*!< Private data. */ + + /* + * Rig API + * + */ + + int (*rig_init)(RIG *rig); + int (*rig_cleanup)(RIG *rig); + int (*rig_open)(RIG *rig); + int (*rig_close)(RIG *rig); + + /* + * General API commands, from most primitive to least.. :() + * List Set/Get functions pairs + */ + + int (*set_freq)(RIG *rig, vfo_t vfo, freq_t freq); + int (*get_freq)(RIG *rig, vfo_t vfo, freq_t *freq); + + int (*set_mode)(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); + int (*get_mode)(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); + + int (*set_vfo)(RIG *rig, vfo_t vfo); + int (*get_vfo)(RIG *rig, vfo_t *vfo); + + int (*set_ptt)(RIG *rig, vfo_t vfo, ptt_t ptt); + int (*get_ptt)(RIG *rig, vfo_t vfo, ptt_t *ptt); + + int (*get_dcd)(RIG *rig, vfo_t vfo, dcd_t *dcd); + + int (*set_rptr_shift)(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift); + int (*get_rptr_shift)(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift); + + int (*set_rptr_offs)(RIG *rig, vfo_t vfo, shortfreq_t offs); + int (*get_rptr_offs)(RIG *rig, vfo_t vfo, shortfreq_t *offs); + + int (*set_split_freq)(RIG *rig, vfo_t vfo, freq_t tx_freq); + int (*get_split_freq)(RIG *rig, vfo_t vfo, freq_t *tx_freq); + + int (*set_split_mode)(RIG *rig, + vfo_t vfo, + rmode_t tx_mode, + pbwidth_t tx_width); + int (*get_split_mode)(RIG *rig, + vfo_t vfo, + rmode_t *tx_mode, + pbwidth_t *tx_width); + + int (*set_split_freq_mode)(RIG *rig, + vfo_t vfo, + freq_t tx_freq, + rmode_t tx_mode, + pbwidth_t tx_width); + int (*get_split_freq_mode)(RIG *rig, + vfo_t vfo, + freq_t *tx_freq, + rmode_t *tx_mode, + pbwidth_t *tx_width); + + int (*set_split_vfo)(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); + int (*get_split_vfo)(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); + + int (*set_rit)(RIG *rig, vfo_t vfo, shortfreq_t rit); + int (*get_rit)(RIG *rig, vfo_t vfo, shortfreq_t *rit); + + int (*set_xit)(RIG *rig, vfo_t vfo, shortfreq_t xit); + int (*get_xit)(RIG *rig, vfo_t vfo, shortfreq_t *xit); + + int (*set_ts)(RIG *rig, vfo_t vfo, shortfreq_t ts); + int (*get_ts)(RIG *rig, vfo_t vfo, shortfreq_t *ts); + + int (*set_dcs_code)(RIG *rig, vfo_t vfo, tone_t code); + int (*get_dcs_code)(RIG *rig, vfo_t vfo, tone_t *code); + + int (*set_tone)(RIG *rig, vfo_t vfo, tone_t tone); + int (*get_tone)(RIG *rig, vfo_t vfo, tone_t *tone); + + int (*set_ctcss_tone)(RIG *rig, vfo_t vfo, tone_t tone); + int (*get_ctcss_tone)(RIG *rig, vfo_t vfo, tone_t *tone); + + int (*set_dcs_sql)(RIG *rig, vfo_t vfo, tone_t code); + int (*get_dcs_sql)(RIG *rig, vfo_t vfo, tone_t *code); + + int (*set_tone_sql)(RIG *rig, vfo_t vfo, tone_t tone); + int (*get_tone_sql)(RIG *rig, vfo_t vfo, tone_t *tone); + + int (*set_ctcss_sql)(RIG *rig, vfo_t vfo, tone_t tone); + int (*get_ctcss_sql)(RIG *rig, vfo_t vfo, tone_t *tone); + + int (*power2mW)(RIG *rig, + unsigned int *mwpower, + float power, + freq_t freq, + rmode_t mode); + int (*mW2power)(RIG *rig, + float *power, + unsigned int mwpower, + freq_t freq, + rmode_t mode); + + int (*set_powerstat)(RIG *rig, powerstat_t status); + int (*get_powerstat)(RIG *rig, powerstat_t *status); + + int (*reset)(RIG *rig, reset_t reset); + + int (*set_ant)(RIG *rig, vfo_t vfo, ant_t ant, value_t option); + int (*get_ant)(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx); + + int (*set_level)(RIG *rig, vfo_t vfo, setting_t level, value_t val); + int (*get_level)(RIG *rig, vfo_t vfo, setting_t level, value_t *val); + + int (*set_func)(RIG *rig, vfo_t vfo, setting_t func, int status); + int (*get_func)(RIG *rig, vfo_t vfo, setting_t func, int *status); + + int (*set_parm)(RIG *rig, setting_t parm, value_t val); + int (*get_parm)(RIG *rig, setting_t parm, value_t *val); + + int (*set_ext_level)(RIG *rig, vfo_t vfo, token_t token, value_t val); + int (*get_ext_level)(RIG *rig, vfo_t vfo, token_t token, value_t *val); + + int (*set_ext_func)(RIG *rig, vfo_t vfo, token_t token, int status); + int (*get_ext_func)(RIG *rig, vfo_t vfo, token_t token, int *status); + + int (*set_ext_parm)(RIG *rig, token_t token, value_t val); + int (*get_ext_parm)(RIG *rig, token_t token, value_t *val); + + int (*set_conf)(RIG *rig, token_t token, const char *val); + int (*get_conf)(RIG *rig, token_t token, char *val); + + int (*send_dtmf)(RIG *rig, vfo_t vfo, const char *digits); + int (*recv_dtmf)(RIG *rig, vfo_t vfo, char *digits, int *length); + + int (*send_morse)(RIG *rig, vfo_t vfo, const char *msg); + int (*stop_morse)(RIG *rig, vfo_t vfo); + int (*wait_morse)(RIG *rig, vfo_t vfo); + + int (*send_voice_mem)(RIG *rig, vfo_t vfo, int ch); + + int (*set_bank)(RIG *rig, vfo_t vfo, int bank); + + int (*set_mem)(RIG *rig, vfo_t vfo, int ch); + int (*get_mem)(RIG *rig, vfo_t vfo, int *ch); + + int (*vfo_op)(RIG *rig, vfo_t vfo, vfo_op_t op); + + int (*scan)(RIG *rig, vfo_t vfo, scan_t scan, int ch); + + int (*set_trn)(RIG *rig, int trn); + int (*get_trn)(RIG *rig, int *trn); + + int (*decode_event)(RIG *rig); + + int (*set_channel)(RIG *rig, vfo_t vfo, const channel_t *chan); + int (*get_channel)(RIG *rig, vfo_t vfo, channel_t *chan, int read_only); + + const char * (*get_info)(RIG *rig); + + int (*set_chan_all_cb)(RIG *rig, vfo_t vfo, chan_cb_t chan_cb, rig_ptr_t); + int (*get_chan_all_cb)(RIG *rig, vfo_t vfo, chan_cb_t chan_cb, rig_ptr_t); + + int (*set_mem_all_cb)(RIG *rig, + chan_cb_t chan_cb, + confval_cb_t parm_cb, + rig_ptr_t); + int (*get_mem_all_cb)(RIG *rig, + chan_cb_t chan_cb, + confval_cb_t parm_cb, + rig_ptr_t); + + int (*set_vfo_opt)(RIG *rig, int status); // only for Net Rigctl device + int (*rig_get_vfo_info) (RIG *rig, + vfo_t vfo, + freq_t *freq, + rmode_t *mode, + pbwidth_t *width, + split_t *split); + int(*set_clock) (RIG *rig, int year, int month, int day, int hour, int min, int sec, double msec, int utc_offset); + int(*get_clock) (RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset); + + const char *clone_combo_set; /*!< String describing key combination to enter load cloning mode */ + const char *clone_combo_get; /*!< String describing key combination to enter save cloning mode */ + const char *macro_name; /*!< Rig model macro name */ +}; +//! @endcond + +/** + * \brief Enumeration of all rig_ functions + * + */ +//! @cond Doxygen_Suppress +// all functions enumerated for rig_get_function_ptr +enum rig_function_e { + RIG_FUNCTION_INIT, + RIG_FUNCTION_CLEANUP, + RIG_FUNCTION_OPEN, + RIG_FUNCTION_CLOSE, + RIG_FUNCTION_SET_FREQ, + RIG_FUNCTION_GET_FREQ, + RIG_FUNCTION_SET_MODE, + RIG_FUNCTION_GET_MODE, + RIG_FUNCTION_SET_VFO, + RIG_FUNCTION_GET_VFO, + RIG_FUNCTION_SET_PTT, + RIG_FUNCTION_GET_PTT, + RIG_FUNCTION_GET_DCD, + RIG_FUNCTION_SET_RPTR_SHIFT, + RIG_FUNCTION_GET_RPTR_SHIFT, + RIG_FUNCTION_SET_RPTR_OFFS, + RIG_FUNCTION_GET_RPTR_OFFS, + RIG_FUNCTION_SET_SPLIT_FREQ, + RIG_FUNCTION_GET_SPLIT_FREQ, + RIG_FUNCTION_SET_SPLIT_MODE, + RIG_FUNCTION_SET_SPLIT_FREQ_MODE, + RIG_FUNCTION_GET_SPLIT_FREQ_MODE, + RIG_FUNCTION_SET_SPLIT_VFO, + RIG_FUNCTION_GET_SPLIT_VFO, + RIG_FUNCTION_SET_RIT, + RIG_FUNCTION_GET_RIT, + RIG_FUNCTION_SET_XIT, + RIG_FUNCTION_GET_XIT, + RIG_FUNCTION_SET_TS, + RIG_FUNCTION_GET_TS, + RIG_FUNCTION_SET_DCS_CODE, + RIG_FUNCTION_GET_DCS_CODE, + RIG_FUNCTION_SET_TONE, + RIG_FUNCTION_GET_TONE, + RIG_FUNCTION_SET_CTCSS_TONE, + RIG_FUNCTION_GET_CTCSS_TONE, + RIG_FUNCTION_SET_DCS_SQL, + RIG_FUNCTION_GET_DCS_SQL, + RIG_FUNCTION_SET_TONE_SQL, + RIG_FUNCTION_GET_TONE_SQL, + RIG_FUNCTION_SET_CTCSS_SQL, + RIG_FUNCTION_GET_CTCSS_SQL, + RIG_FUNCTION_POWER2MW, + RIG_FUNCTION_MW2POWER, + RIG_FUNCTION_SET_POWERSTAT, + RIG_FUNCTION_GET_POWERSTAT, + RIG_FUNCTION_RESET, + RIG_FUNCTION_SET_ANT, + RIG_FUNCTION_GET_ANT, + RIG_FUNCTION_SET_LEVEL, + RIG_FUNCTION_GET_LEVEL, + RIG_FUNCTION_SET_FUNC, + RIG_FUNCTION_GET_FUNC, + RIG_FUNCTION_SET_PARM, + RIG_FUNCTION_GET_PARM, + RIG_FUNCTION_SET_EXT_LEVEL, + RIG_FUNCTION_GET_EXT_LEVEL, + RIG_FUNCTION_SET_EXT_FUNC, + RIG_FUNCTION_GET_EXT_FUNC, + RIG_FUNCTION_SET_EXT_PARM, + RIG_FUNCTION_GET_EXT_PARM, + RIG_FUNCTION_SET_CONF, + RIG_FUNCTION_GET_CONF, + RIG_FUNCTION_SEND_DTMF, + RIG_FUNCTION_SEND_MORSE, + RIG_FUNCTION_STOP_MORSE, + RIG_FUNCTION_WAIT_MORSE, + RIG_FUNCTION_SET_BANK, + RIG_FUNCTION_SET_MEM, + RIG_FUNCTION_GET_MEM, + RIG_FUNCTION_VFO_OP, + RIG_FUNCTION_SCAN, + RIG_FUNCTION_SET_TRN, + RIG_FUNCTION_GET_TRN, + RIG_FUNCTION_DECODE_EVENT, + RIG_FUNCTION_SET_CHANNEL, + RIG_FUNCTION_GET_CHANNEL, + RIG_FUNCTION_GET_INFO, + RIG_FUNCTION_SET_CHAN_ALL_CB, + RIG_FUNCTION_GET_CHAN_ALL_CB, + RIG_FUNCTION_SET_MEM_ALL_CB, + RIG_FUNCTION_GET_MEM_ALL_CB, + RIG_FUNCTION_SET_VFO_OPT, +}; + +/** + * \brief Function to return pointer to rig_* function + * + */ +//! @cond Doxygen_Suppress +extern HAMLIB_EXPORT (void *) rig_get_function_ptr(rig_model_t rig_model, enum rig_function_e rig_function); + +/** + * \brief Enumeration of rig->caps values + * + */ +//! @cond Doxygen_Suppress +// values enumerated for rig->caps values +enum rig_caps_int_e { + RIG_CAPS_TARGETABLE_VFO, + RIG_CAPS_RIG_MODEL, + RIG_CAPS_PORT_TYPE, + RIG_CAPS_PTT_TYPE, + RIG_CAPS_HAS_GET_LEVEL +}; + +enum rig_caps_cptr_e { + RIG_CAPS_VERSION_CPTR, + RIG_CAPS_MFG_NAME_CPTR, + RIG_CAPS_MODEL_NAME_CPTR, + RIG_CAPS_STATUS_CPTR +}; + +/** + * \brief Function to return int value from rig->caps + * Does not support > 32-bit rig_caps values + */ +//! @cond Doxygen_Suppress +extern HAMLIB_EXPORT (long long) rig_get_caps_int(rig_model_t rig_model, enum rig_caps_int_e rig_caps); + +/** + * \brief Function to return char pointer value from rig->caps + * + */ +//! @cond Doxygen_Suppress +extern HAMLIB_EXPORT (const char *) rig_get_caps_cptr(rig_model_t rig_model, enum rig_caps_cptr_e rig_caps); + +/** + * \brief Port definition + * + * Of course, looks like OO painstakingly programmed in C, sigh. + */ +//! @cond Doxygen_Suppress +typedef struct hamlib_port { + union { + rig_port_t rig; /*!< Communication port type */ + ptt_type_t ptt; /*!< PTT port type */ + dcd_type_t dcd; /*!< DCD port type */ + } type; + + int fd; /*!< File descriptor */ + void *handle; /*!< handle for USB */ + + int write_delay; /*!< Delay between each byte sent out, in mS */ + int post_write_delay; /*!< Delay between each commands send out, in mS */ + + struct { + int tv_sec, tv_usec; + } post_write_date; /*!< hamlib internal use */ + + int timeout; /*!< Timeout, in mS */ + short retry; /*!< Maximum number of retries, 0 to disable */ + short flushx; /*!< If true flush is done with read instead of TCFLUSH - MicroHam */ + + char pathname[HAMLIB_FILPATHLEN]; /*!< Port pathname */ + + union { + struct { + int rate; /*!< Serial baud rate */ + int data_bits; /*!< Number of data bits */ + int stop_bits; /*!< Number of stop bits */ + enum serial_parity_e parity; /*!< Serial parity */ + enum serial_handshake_e handshake; /*!< Serial handshake */ + enum serial_control_state_e rts_state; /*!< RTS set state */ + enum serial_control_state_e dtr_state; /*!< DTR set state */ + } serial; /*!< serial attributes */ + + struct { + int pin; /*!< Parallel port pin number */ + } parallel; /*!< parallel attributes */ + + struct { + int ptt_bitnum; /*!< Bit number for CM108 GPIO PTT */ + } cm108; /*!< CM108 attributes */ + + struct { + int vid; /*!< Vendor ID */ + int pid; /*!< Product ID */ + int conf; /*!< Configuration */ + int iface; /*!< interface */ + int alt; /*!< alternate */ + char *vendor_name; /*!< Vendor name (opt.) */ + char *product; /*!< Product (opt.) */ + } usb; /*!< USB attributes */ + + struct { + int on_value; /*!< GPIO: 1 == normal, GPION: 0 == inverted */ + int value; /*!< Toggle PTT ON or OFF */ + } gpio; /*!< GPIO attributes */ + } parm; /*!< Port parameter union */ + int client_port; /*!< client socket port for tcp connection */ + RIG *rig; /*!< our parent RIG device */ +} hamlib_port_t; +//! @endcond + +#if !defined(__APPLE__) || !defined(__cplusplus) +typedef hamlib_port_t port_t; +#endif + +#define HAMLIB_ELAPSED_GET 0 +#define HAMLIB_ELAPSED_SET 1 +#define HAMLIB_ELAPSED_INVALIDATE 2 + +#define HAMLIB_CACHE_ALWAYS -1 /*< value to set cache timeout to always use cache */ + +typedef enum { + HAMLIB_CACHE_ALL, // to set all cache timeouts at once + HAMLIB_CACHE_VFO, + HAMLIB_CACHE_FREQ, + HAMLIB_CACHE_MODE, + HAMLIB_CACHE_PTT, + HAMLIB_CACHE_SPLIT, + HAMLIB_CACHE_WIDTH +} hamlib_cache_t; + +typedef enum { + TWIDDLE_OFF, + TWIDDLE_ON +} twiddle_state_t; + +/** + * \brief Rig cache data + * + * This struct contains all the items we cache at the highest level + */ +struct rig_cache { + int timeout_ms; // the cache timeout for invalidating itself + vfo_t vfo; + //freq_t freq; // to be deprecated in 4.1 when full Main/Sub/A/B caching is implemented in 4.1 + // other abstraction here is based on dual vfo rigs and mapped to all others + // So we have four possible states of rig + // MainA, MainB, SubA, SubB + // Main is the Main VFO and Sub is for the 2nd VFO + // Most rigs have MainA and MainB + // Dual VFO rigs can have SubA and SubB too + // For dual VFO rigs simplex operations are all done on MainA/MainB -- ergo this abstraction + freq_t freqCurr; // Other VFO + freq_t freqOther; // Other VFO + freq_t freqMainA; // VFO_A, VFO_MAIN, and VFO_MAINA + freq_t freqMainB; // VFO_B, VFO_SUB, and VFO_MAINB + freq_t freqMainC; // VFO_C, VFO_MAINC + freq_t freqSubA; // VFO_SUBA -- only for rigs with dual Sub VFOs + freq_t freqSubB; // VFO_SUBB -- only for rigs with dual Sub VFOs + freq_t freqSubC; // VFO_SUBC -- only for rigs with 3 Sub VFOs + freq_t freqMem; // VFO_MEM -- last MEM channel + rmode_t modeCurr; + rmode_t modeOther; + rmode_t modeMainA; + rmode_t modeMainB; + rmode_t modeMainC; + rmode_t modeSubA; + rmode_t modeSubB; + rmode_t modeSubC; + rmode_t modeMem; + pbwidth_t widthCurr; // if non-zero then rig has separate width for MainA + pbwidth_t widthOther; // if non-zero then rig has separate width for MainA + pbwidth_t widthMainA; // if non-zero then rig has separate width for MainA + pbwidth_t widthMainB; // if non-zero then rig has separate width for MainB + pbwidth_t widthMainC; // if non-zero then rig has separate width for MainC + pbwidth_t widthSubA; // if non-zero then rig has separate width for SubA + pbwidth_t widthSubB; // if non-zero then rig has separate width for SubB + pbwidth_t widthSubC; // if non-zero then rig has separate width for SubC + pbwidth_t widthMem; // if non-zero then rig has separate width for Mem + ptt_t ptt; + split_t split; + vfo_t split_vfo; // split caches two values + struct timespec time_freqCurr; + struct timespec time_freqOther; + struct timespec time_freqMainA; + struct timespec time_freqMainB; + struct timespec time_freqMainC; + struct timespec time_freqSubA; + struct timespec time_freqSubB; + struct timespec time_freqSubC; + struct timespec time_freqMem; + struct timespec time_vfo; + struct timespec time_modeCurr; + struct timespec time_modeOther; + struct timespec time_modeMainA; + struct timespec time_modeMainB; + struct timespec time_modeMainC; + struct timespec time_modeSubA; + struct timespec time_modeSubB; + struct timespec time_modeSubC; + struct timespec time_modeMem; + struct timespec time_widthCurr; + struct timespec time_widthOther; + struct timespec time_widthMainA; + struct timespec time_widthMainB; + struct timespec time_widthMainC; + struct timespec time_widthSubA; + struct timespec time_widthSubB; + struct timespec time_widthSubC; + struct timespec time_widthMem; + struct timespec time_ptt; + struct timespec time_split; + int satmode; // if rig is in satellite mode +}; + + +/** + * \brief Rig state containing live data and customized fields. + * + * This struct contains live data, as well as a copy of capability fields + * that may be updated (ie. customized) + * + * It is NOT fine to move fields around as it can break share library offset + * As of 2021-03-03 vfo_list is the last known item being reference externally + * So any additions or changes to this structure must be after vfo_list. + */ +struct rig_state { + /* + * overridable fields + */ + hamlib_port_t rigport; /*!< Rig port (internal use). */ + hamlib_port_t pttport; /*!< PTT port (internal use). */ + hamlib_port_t dcdport; /*!< DCD port (internal use). */ + + double vfo_comp; /*!< VFO compensation in PPM, 0.0 to disable */ + + int deprecated_itu_region; /*!< ITU region to select among freq_range_t */ + freq_range_t rx_range_list[HAMLIB_FRQRANGESIZ]; /*!< Receive frequency range list */ + freq_range_t tx_range_list[HAMLIB_FRQRANGESIZ]; /*!< Transmit frequency range list */ + + struct tuning_step_list tuning_steps[HAMLIB_TSLSTSIZ]; /*!< Tuning step list */ + + struct filter_list filters[HAMLIB_FLTLSTSIZ]; /*!< Mode/filter table, at -6dB */ + + cal_table_t str_cal; /*!< S-meter calibration table */ + + chan_t chan_list[HAMLIB_CHANLSTSIZ]; /*!< Channel list, zero ended */ + + shortfreq_t max_rit; /*!< max absolute RIT */ + shortfreq_t max_xit; /*!< max absolute XIT */ + shortfreq_t max_ifshift; /*!< max absolute IF-SHIFT */ + + ann_t announces; /*!< Announces bit field list */ + + int preamp[HAMLIB_MAXDBLSTSIZ]; /*!< Preamp list in dB, 0 terminated */ + int attenuator[HAMLIB_MAXDBLSTSIZ]; /*!< Preamp list in dB, 0 terminated */ + + setting_t has_get_func; /*!< List of get functions */ + setting_t has_set_func; /*!< List of set functions */ + setting_t has_get_level; /*!< List of get level */ + setting_t has_set_level; /*!< List of set level */ + setting_t has_get_parm; /*!< List of get parm */ + setting_t has_set_parm; /*!< List of set parm */ + + gran_t level_gran[RIG_SETTING_MAX]; /*!< level granularity */ + gran_t parm_gran[RIG_SETTING_MAX]; /*!< parm granularity */ + + + /* + * non overridable fields, internal use + */ + + int hold_decode; /*!< set to 1 to hold the event decoder (async) otherwise 0 */ + vfo_t current_vfo; /*!< VFO currently set */ + int vfo_list; /*!< Complete list of VFO for this rig */ + int comm_state; /*!< Comm port state, opened/closed. */ + rig_ptr_t priv; /*!< Pointer to private rig state data. */ + rig_ptr_t obj; /*!< Internal use by hamlib++ for event handling. */ + + int transceive; /*!< Whether the transceive mode is on */ + int poll_interval; /*!< Event notification polling period in milliseconds */ + freq_t current_freq; /*!< Frequency currently set */ + rmode_t current_mode; /*!< Mode currently set */ + //rmode_t current_modeB; /*!< Mode currently set VFOB */ + pbwidth_t current_width; /*!< Passband width currently set */ + vfo_t tx_vfo; /*!< Tx VFO currently set */ + rmode_t mode_list; /*!< Complete list of modes for this rig */ + // mode_list is used by some + // so anything added to this structure must be below here + int transmit; /*!< rig should be transmitting i.e. hard + wired PTT asserted - used by rigs that + don't do CAT while in Tx */ + freq_t lo_freq; /*!< Local oscillator frequency of any transverter */ + time_t twiddle_time; /*!< time when vfo twiddling was detected */ + int twiddle_timeout; /*!< timeout to resume from twiddling */ + // uplink allows gpredict to behave better by no reading the uplink VFO + int uplink; /*!< uplink=1 will not read Sub, uplink=2 will not read Main */ + struct rig_cache cache; + int vfo_opt; /*!< Is -o switch turned on? */ + int auto_power_on; /*!< Allow Hamlib to power on rig + automatically if supported */ + int auto_power_off; /*!< Allow Hamlib to power off rig + automatically if supported */ + int auto_disable_screensaver; /*!< Allow Hamlib to disable the + rig's screen saver automatically if + supported */ + int ptt_share; /*!< Share ptt port by open/close during get_ptt, set_ptt hogs the port while active */ + int power_now; /*!< Current RF power level in rig units */ + int power_min; /*!< Minimum RF power level in rig units */ + int power_max; /*!< Maximum RF power level in rig units */ + unsigned char disable_yaesu_bandselect; /*!< Disables Yaeus band select logic */ + int twiddle_rit; /*!< Suppresses VFOB reading (cached value used) so RIT control can be used */ + int twiddle_state; /*!< keeps track of twiddle status */ + vfo_t rx_vfo; /*!< Rx VFO currently set */ +}; + +//! @cond Doxygen_Suppress +typedef int (*vprintf_cb_t)(enum rig_debug_level_e, + rig_ptr_t, + const char *, + va_list); + +typedef int (*freq_cb_t)(RIG *, vfo_t, freq_t, rig_ptr_t); +typedef int (*mode_cb_t)(RIG *, vfo_t, rmode_t, pbwidth_t, rig_ptr_t); +typedef int (*vfo_cb_t)(RIG *, vfo_t, rig_ptr_t); +typedef int (*ptt_cb_t)(RIG *, vfo_t, ptt_t, rig_ptr_t); +typedef int (*dcd_cb_t)(RIG *, vfo_t, dcd_t, rig_ptr_t); +typedef int (*pltune_cb_t)(RIG *, + vfo_t, freq_t *, + rmode_t *, + pbwidth_t *, + rig_ptr_t); +typedef int (*spectrum_cb_t)(RIG *, + struct rig_spectrum_line *, + rig_ptr_t); + +//! @endcond + +/** + * \brief Callback functions and args for rig event. + * + * Some rigs are able to notify the host computer the operator changed + * the freq/mode from the front panel, depressed a button, etc. + * + * Events from the rig are received through async io, + * so callback functions will be called from the SIGIO sighandler context. + * + * Don't set these fields directly, use rig_set_freq_callback et. al. instead. + * + * Callbacks suit event based programming very well, + * really appropriate in a GUI. + * + * \sa rig_set_freq_callback(), rig_set_mode_callback(), rig_set_vfo_callback(), + * rig_set_ptt_callback(), rig_set_dcd_callback() + */ +struct rig_callbacks { + freq_cb_t freq_event; /*!< Frequency change event */ + rig_ptr_t freq_arg; /*!< Frequency change argument */ + mode_cb_t mode_event; /*!< Mode change event */ + rig_ptr_t mode_arg; /*!< Mode change argument */ + vfo_cb_t vfo_event; /*!< VFO change event */ + rig_ptr_t vfo_arg; /*!< VFO change argument */ + ptt_cb_t ptt_event; /*!< PTT change event */ + rig_ptr_t ptt_arg; /*!< PTT change argument */ + dcd_cb_t dcd_event; /*!< DCD change event */ + rig_ptr_t dcd_arg; /*!< DCD change argument */ + pltune_cb_t pltune; /*!< Pipeline tuning module freq/mode/width callback */ + rig_ptr_t pltune_arg; /*!< Pipeline tuning argument */ + spectrum_cb_t spectrum_event; /*!< Spectrum line reception event */ + rig_ptr_t spectrum_arg; /*!< Spectrum line reception argument */ + /* etc.. */ +}; + + +/** + * \brief The Rig structure + * + * This is the master data structure, acting as a handle for the controlled + * rig. A pointer to this structure is returned by the rig_init() API + * function and is passed as a parameter to every rig specific API call. + * + * \sa rig_init(), rig_caps(), rig_state() + */ +struct s_rig { + struct rig_caps *caps; /*!< Pointer to rig capabilities (read only) */ + struct rig_state state; /*!< Rig state */ + struct rig_callbacks callbacks; /*!< registered event callbacks */ +}; + + + +/* --------------- API function prototypes -----------------*/ + +//! @cond Doxygen_Suppress + +extern HAMLIB_EXPORT(RIG *) rig_init HAMLIB_PARAMS((rig_model_t rig_model)); +extern HAMLIB_EXPORT(int) rig_open HAMLIB_PARAMS((RIG *rig)); + +/* + * General API commands, from most primitive to least.. :() + * List Set/Get functions pairs + */ + +extern HAMLIB_EXPORT(int) +rig_flush(hamlib_port_t *port); + +extern HAMLIB_EXPORT(int) +rig_set_freq HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + freq_t freq)); +extern HAMLIB_EXPORT(int) +rig_get_freq HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + freq_t *freq)); + +extern HAMLIB_EXPORT(int) +rig_set_mode HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + rmode_t mode, + pbwidth_t width)); +extern HAMLIB_EXPORT(int) +rig_get_mode HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + rmode_t *mode, + pbwidth_t *width)); + +#if 0 +#define rig_set_vfo(r,v) rig_set_vfo(r,v,__builtin_FUNCTION()) +extern HAMLIB_EXPORT(int) +rig_set_vfo HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, const char *func)); +#else +extern HAMLIB_EXPORT(int) +rig_set_vfo HAMLIB_PARAMS((RIG *rig, + vfo_t vfo)); +#endif +extern HAMLIB_EXPORT(int) +rig_get_vfo HAMLIB_PARAMS((RIG *rig, + vfo_t *vfo)); + +extern HAMLIB_EXPORT(int) +rig_get_vfo_info HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + freq_t *freq, + rmode_t *mode, + pbwidth_t *width, + split_t *split, + int *satmode)); + +extern HAMLIB_EXPORT(int) +rig_get_vfo_list HAMLIB_PARAMS((RIG *rig, char *buf, int buflen)); + +extern HAMLIB_EXPORT(int) +netrigctl_get_vfo_mode HAMLIB_PARAMS((RIG *rig)); + +extern HAMLIB_EXPORT(int) +rig_set_ptt HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + ptt_t ptt)); +extern HAMLIB_EXPORT(int) +rig_get_ptt HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + ptt_t *ptt)); + +extern HAMLIB_EXPORT(int) +rig_get_dcd HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + dcd_t *dcd)); + +extern HAMLIB_EXPORT(int) +rig_set_rptr_shift HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + rptr_shift_t rptr_shift)); +extern HAMLIB_EXPORT(int) +rig_get_rptr_shift HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + rptr_shift_t *rptr_shift)); + +extern HAMLIB_EXPORT(int) +rig_set_rptr_offs HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + shortfreq_t rptr_offs)); +extern HAMLIB_EXPORT(int) +rig_get_rptr_offs HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + shortfreq_t *rptr_offs)); + +extern HAMLIB_EXPORT(int) +rig_set_ctcss_tone HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + tone_t tone)); +extern HAMLIB_EXPORT(int) +rig_get_ctcss_tone HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + tone_t *tone)); + +extern HAMLIB_EXPORT(int) +rig_set_dcs_code HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + tone_t code)); +extern HAMLIB_EXPORT(int) +rig_get_dcs_code HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + tone_t *code)); + +extern HAMLIB_EXPORT(int) +rig_set_ctcss_sql HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + tone_t tone)); +extern HAMLIB_EXPORT(int) +rig_get_ctcss_sql HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + tone_t *tone)); + +extern HAMLIB_EXPORT(int) +rig_set_dcs_sql HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + tone_t code)); +extern HAMLIB_EXPORT(int) +rig_get_dcs_sql HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + tone_t *code)); + +extern HAMLIB_EXPORT(int) +rig_set_split_freq HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + freq_t tx_freq)); +extern HAMLIB_EXPORT(int) +rig_get_split_freq HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + freq_t *tx_freq)); + +extern HAMLIB_EXPORT(int) +rig_set_split_mode HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + rmode_t tx_mode, + pbwidth_t tx_width)); +extern HAMLIB_EXPORT(int) +rig_get_split_mode HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + rmode_t *tx_mode, + pbwidth_t *tx_width)); + +extern HAMLIB_EXPORT(int) +rig_set_split_freq_mode HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + freq_t tx_freq, + rmode_t tx_mode, + pbwidth_t tx_width)); +extern HAMLIB_EXPORT(int) +rig_get_split_freq_mode HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + freq_t *tx_freq, + rmode_t *tx_mode, + pbwidth_t *tx_width)); + +extern HAMLIB_EXPORT(int) +rig_set_split_vfo HAMLIB_PARAMS((RIG *, + vfo_t rx_vfo, + split_t split, + vfo_t tx_vfo)); +extern HAMLIB_EXPORT(int) +rig_get_split_vfo HAMLIB_PARAMS((RIG *, + vfo_t rx_vfo, + split_t *split, + vfo_t *tx_vfo)); + +#define rig_set_split(r,v,s) rig_set_split_vfo((r),(v),(s),RIG_VFO_CURR) +#define rig_get_split(r,v,s) ({ vfo_t _tx_vfo; rig_get_split_vfo((r),(v),(s),&_tx_vfo); }) + +extern HAMLIB_EXPORT(int) +rig_set_rit HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + shortfreq_t rit)); +extern HAMLIB_EXPORT(int) +rig_get_rit HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + shortfreq_t *rit)); + +extern HAMLIB_EXPORT(int) +rig_set_xit HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + shortfreq_t xit)); +extern HAMLIB_EXPORT(int) +rig_get_xit HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + shortfreq_t *xit)); + +extern HAMLIB_EXPORT(int) +rig_set_ts HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + shortfreq_t ts)); +extern HAMLIB_EXPORT(int) +rig_get_ts HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + shortfreq_t *ts)); + +extern HAMLIB_EXPORT(int) +rig_power2mW HAMLIB_PARAMS((RIG *rig, + unsigned int *mwpower, + float power, + freq_t freq, + rmode_t mode)); +extern HAMLIB_EXPORT(int) +rig_mW2power HAMLIB_PARAMS((RIG *rig, + float *power, + unsigned int mwpower, + freq_t freq, + rmode_t mode)); + +extern HAMLIB_EXPORT(shortfreq_t) +rig_get_resolution HAMLIB_PARAMS((RIG *rig, + rmode_t mode)); + +extern HAMLIB_EXPORT(int) +rig_set_level HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + setting_t level, + value_t val)); +extern HAMLIB_EXPORT(int) +rig_get_level HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + setting_t level, + value_t *val)); + +#define rig_get_strength(r,v,s) rig_get_level((r),(v),RIG_LEVEL_STRENGTH, (value_t*)(s)) + +extern HAMLIB_EXPORT(int) +rig_set_parm HAMLIB_PARAMS((RIG *rig, + setting_t parm, + value_t val)); +extern HAMLIB_EXPORT(int) +rig_get_parm HAMLIB_PARAMS((RIG *rig, + setting_t parm, + value_t *val)); + +extern HAMLIB_EXPORT(int) +rig_set_conf HAMLIB_PARAMS((RIG *rig, + token_t token, + const char *val)); +extern HAMLIB_EXPORT(int) +rig_get_conf HAMLIB_PARAMS((RIG *rig, + token_t token, + char *val)); + +extern HAMLIB_EXPORT(int) +rig_set_powerstat HAMLIB_PARAMS((RIG *rig, + powerstat_t status)); +extern HAMLIB_EXPORT(int) +rig_get_powerstat HAMLIB_PARAMS((RIG *rig, + powerstat_t *status)); + +extern HAMLIB_EXPORT(int) +rig_reset HAMLIB_PARAMS((RIG *rig, + reset_t reset)); /* dangerous! */ + +extern HAMLIB_EXPORT(int) +rig_set_ext_level HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + token_t token, + value_t val)); +extern HAMLIB_EXPORT(int) +rig_get_ext_level HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + token_t token, + value_t *val)); + +extern HAMLIB_EXPORT(int) +rig_set_ext_func HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + token_t token, + int status)); +extern HAMLIB_EXPORT(int) +rig_get_ext_func HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + token_t token, + int *status)); + +extern HAMLIB_EXPORT(int) +rig_set_ext_parm HAMLIB_PARAMS((RIG *rig, + token_t token, + value_t val)); +extern HAMLIB_EXPORT(int) +rig_get_ext_parm HAMLIB_PARAMS((RIG *rig, + token_t token, + value_t *val)); + +extern HAMLIB_EXPORT(int) +rig_ext_func_foreach HAMLIB_PARAMS((RIG *rig, + int (*cfunc)(RIG *, + const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); +extern HAMLIB_EXPORT(int) +rig_ext_level_foreach HAMLIB_PARAMS((RIG *rig, + int (*cfunc)(RIG *, + const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); +extern HAMLIB_EXPORT(int) +rig_ext_parm_foreach HAMLIB_PARAMS((RIG *rig, + int (*cfunc)(RIG *, + const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); + +extern HAMLIB_EXPORT(const struct confparams *) +rig_ext_lookup HAMLIB_PARAMS((RIG *rig, + const char *name)); + +extern HAMLIB_EXPORT(const struct confparams *) +rig_ext_lookup_tok HAMLIB_PARAMS((RIG *rig, + token_t token)); +extern HAMLIB_EXPORT(token_t) +rig_ext_token_lookup HAMLIB_PARAMS((RIG *rig, + const char *name)); + + +extern HAMLIB_EXPORT(int) +rig_token_foreach HAMLIB_PARAMS((RIG *rig, + int (*cfunc)(const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); + +extern HAMLIB_EXPORT(const struct confparams *) +rig_confparam_lookup HAMLIB_PARAMS((RIG *rig, + const char *name)); +extern HAMLIB_EXPORT(token_t) +rig_token_lookup HAMLIB_PARAMS((RIG *rig, + const char *name)); + +extern HAMLIB_EXPORT(int) +rig_close HAMLIB_PARAMS((RIG *rig)); + +extern HAMLIB_EXPORT(int) +rig_cleanup HAMLIB_PARAMS((RIG *rig)); + +extern HAMLIB_EXPORT(int) +rig_set_ant HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + ant_t ant, /* antenna */ + value_t option)); /* optional ant info */ +extern HAMLIB_EXPORT(int) +rig_get_ant HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + ant_t ant, + value_t *option, + ant_t *ant_curr, + ant_t *ant_tx, + ant_t *ant_rx)); + +extern HAMLIB_EXPORT(setting_t) +rig_has_get_level HAMLIB_PARAMS((RIG *rig, + setting_t level)); +extern HAMLIB_EXPORT(setting_t) +rig_has_set_level HAMLIB_PARAMS((RIG *rig, + setting_t level)); + +extern HAMLIB_EXPORT(setting_t) +rig_has_get_parm HAMLIB_PARAMS((RIG *rig, + setting_t parm)); +extern HAMLIB_EXPORT(setting_t) +rig_has_set_parm HAMLIB_PARAMS((RIG *rig, + setting_t parm)); + +extern HAMLIB_EXPORT(setting_t) +rig_has_get_func HAMLIB_PARAMS((RIG *rig, + setting_t func)); +extern HAMLIB_EXPORT(setting_t) +rig_has_set_func HAMLIB_PARAMS((RIG *rig, + setting_t func)); + +extern HAMLIB_EXPORT(int) +rig_set_func HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + setting_t func, + int status)); +extern HAMLIB_EXPORT(int) +rig_get_func HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + setting_t func, + int *status)); + +extern HAMLIB_EXPORT(int) +rig_send_dtmf HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + const char *digits)); +extern HAMLIB_EXPORT(int) +rig_recv_dtmf HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + char *digits, + int *length)); + +extern HAMLIB_EXPORT(int) +rig_send_morse HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + const char *msg)); + +extern HAMLIB_EXPORT(int) +rig_stop_morse HAMLIB_PARAMS((RIG *rig, + vfo_t vfo)); + +extern HAMLIB_EXPORT(int) +rig_wait_morse HAMLIB_PARAMS((RIG *rig, + vfo_t vfo)); + +extern HAMLIB_EXPORT(int) +rig_send_voice_mem HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + int ch)); + +extern HAMLIB_EXPORT(int) +rig_set_bank HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + int bank)); + +extern HAMLIB_EXPORT(int) +rig_set_mem HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + int ch)); +extern HAMLIB_EXPORT(int) +rig_get_mem HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + int *ch)); + +extern HAMLIB_EXPORT(int) +rig_vfo_op HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + vfo_op_t op)); + +extern HAMLIB_EXPORT(vfo_op_t) +rig_has_vfo_op HAMLIB_PARAMS((RIG *rig, + vfo_op_t op)); + +extern HAMLIB_EXPORT(int) +rig_scan HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + scan_t scan, + int ch)); + +extern HAMLIB_EXPORT(scan_t) +rig_has_scan HAMLIB_PARAMS((RIG *rig, + scan_t scan)); + +extern HAMLIB_EXPORT(int) +rig_set_channel HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + const channel_t *chan)); /* mem */ +extern HAMLIB_EXPORT(int) +rig_get_channel HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + channel_t *chan, int read_only)); + +extern HAMLIB_EXPORT(int) +rig_set_chan_all HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + const channel_t chans[])); +extern HAMLIB_EXPORT(int) +rig_get_chan_all HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + channel_t chans[])); + +extern HAMLIB_EXPORT(int) +rig_set_chan_all_cb HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + chan_cb_t chan_cb, + rig_ptr_t)); +extern HAMLIB_EXPORT(int) +rig_get_chan_all_cb HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + chan_cb_t chan_cb, + rig_ptr_t)); + +extern HAMLIB_EXPORT(int) +rig_set_mem_all_cb HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + chan_cb_t chan_cb, + confval_cb_t parm_cb, + rig_ptr_t)); +extern HAMLIB_EXPORT(int) +rig_get_mem_all_cb HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + chan_cb_t chan_cb, + confval_cb_t parm_cb, + rig_ptr_t)); + +extern HAMLIB_EXPORT(int) +rig_set_mem_all HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + const channel_t *chan, + const struct confparams *, + const value_t *)); +extern HAMLIB_EXPORT(int) +rig_get_mem_all HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + channel_t *chan, + const struct confparams *, + value_t *)); + +extern HAMLIB_EXPORT(const chan_t *) +rig_lookup_mem_caps HAMLIB_PARAMS((RIG *rig, + int ch)); + +extern HAMLIB_EXPORT(int) +rig_mem_count HAMLIB_PARAMS((RIG *rig)); + +extern HAMLIB_EXPORT(int) +rig_set_trn HAMLIB_PARAMS((RIG *rig, + int trn)); +extern HAMLIB_EXPORT(int) +rig_get_trn HAMLIB_PARAMS((RIG *rig, + int *trn)); + +extern HAMLIB_EXPORT(int) +rig_set_freq_callback HAMLIB_PARAMS((RIG *, + freq_cb_t, + rig_ptr_t)); + +extern HAMLIB_EXPORT(int) +rig_set_mode_callback HAMLIB_PARAMS((RIG *, + mode_cb_t, + rig_ptr_t)); +extern HAMLIB_EXPORT(int) +rig_set_vfo_callback HAMLIB_PARAMS((RIG *, + vfo_cb_t, + rig_ptr_t)); + +extern HAMLIB_EXPORT(int) +rig_set_ptt_callback HAMLIB_PARAMS((RIG *, + ptt_cb_t, + rig_ptr_t)); + +extern HAMLIB_EXPORT(int) +rig_set_dcd_callback HAMLIB_PARAMS((RIG *, + dcd_cb_t, + rig_ptr_t)); + +extern HAMLIB_EXPORT(int) +rig_set_pltune_callback HAMLIB_PARAMS((RIG *, + pltune_cb_t, + rig_ptr_t)); + +extern HAMLIB_EXPORT(int) +rig_set_spectrum_callback HAMLIB_PARAMS((RIG *, + spectrum_cb_t, + rig_ptr_t)); + +extern HAMLIB_EXPORT(int) +rig_set_twiddle HAMLIB_PARAMS((RIG *rig, + int seconds)); + +extern HAMLIB_EXPORT(int) +rig_get_twiddle HAMLIB_PARAMS((RIG *rig, + int *seconds)); + +extern HAMLIB_EXPORT(int) +rig_set_uplink HAMLIB_PARAMS((RIG *rig, + int val)); + +extern HAMLIB_EXPORT(const char *) +rig_get_info HAMLIB_PARAMS((RIG *rig)); + +extern HAMLIB_EXPORT(const struct rig_caps *) +rig_get_caps HAMLIB_PARAMS((rig_model_t rig_model)); + +extern HAMLIB_EXPORT(const freq_range_t *) +rig_get_range HAMLIB_PARAMS((const freq_range_t *range_list, + freq_t freq, + rmode_t mode)); + +extern HAMLIB_EXPORT(pbwidth_t) +rig_passband_normal HAMLIB_PARAMS((RIG *rig, + rmode_t mode)); +extern HAMLIB_EXPORT(pbwidth_t) +rig_passband_narrow HAMLIB_PARAMS((RIG *rig, + rmode_t mode)); +extern HAMLIB_EXPORT(pbwidth_t) +rig_passband_wide HAMLIB_PARAMS((RIG *rig, + rmode_t mode)); + +extern HAMLIB_EXPORT(const char *) +rigerror HAMLIB_PARAMS((int errnum)); + +extern HAMLIB_EXPORT(int) +rig_setting2idx HAMLIB_PARAMS((setting_t s)); + +extern HAMLIB_EXPORT(setting_t) +rig_idx2setting(int i); +/* + * Even if these functions are prefixed with "rig_", they are not rig specific + * Maybe "hamlib_" would have been better. Let me know. --SF + */ +extern HAMLIB_EXPORT(void) +rig_set_debug HAMLIB_PARAMS((enum rig_debug_level_e debug_level)); + +extern HAMLIB_EXPORT(void) +rig_set_debug_time_stamp HAMLIB_PARAMS((int flag)); + +#define rig_set_debug_level(level) rig_set_debug(level) + +extern HAMLIB_EXPORT(int) +rig_need_debug HAMLIB_PARAMS((enum rig_debug_level_e debug_level)); + + +// this need to be fairly big to avoid compiler warnings +#define DEBUGMSGSAVE_SIZE 24000 +extern HAMLIB_EXPORT_VAR(char) debugmsgsave[DEBUGMSGSAVE_SIZE]; // last debug msg +extern HAMLIB_EXPORT_VAR(char) debugmsgsave2[DEBUGMSGSAVE_SIZE]; // last-1 debug msg +extern HAMLIB_EXPORT_VAR(char) debugmsgsave3[DEBUGMSGSAVE_SIZE]; // last-2 debug msg +#ifndef __cplusplus +#ifdef __GNUC__ +// doing the debug macro with a dummy sprintf allows gcc to check the format string +#define rig_debug(debug_level,fmt,...) do { strncpy(debugmsgsave3, debugmsgsave2,sizeof(debugmsgsave3));strncpy(debugmsgsave2, debugmsgsave, sizeof(debugmsgsave2));snprintf(debugmsgsave,sizeof(debugmsgsave),fmt,__VA_ARGS__);rig_debug(debug_level,fmt,##__VA_ARGS__); } while(0); +#endif +#endif +extern HAMLIB_EXPORT(void) +rig_debug HAMLIB_PARAMS((enum rig_debug_level_e debug_level, + const char *fmt, ...)); + +extern HAMLIB_EXPORT(vprintf_cb_t) +rig_set_debug_callback HAMLIB_PARAMS((vprintf_cb_t cb, + rig_ptr_t arg)); + +extern HAMLIB_EXPORT(FILE *) +rig_set_debug_file HAMLIB_PARAMS((FILE *stream)); + +extern HAMLIB_EXPORT(int) +rig_register HAMLIB_PARAMS((const struct rig_caps *caps)); + +extern HAMLIB_EXPORT(int) +rig_unregister HAMLIB_PARAMS((rig_model_t rig_model)); + +extern HAMLIB_EXPORT(int) +rig_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct rig_caps *, rig_ptr_t), + rig_ptr_t data)); + +extern HAMLIB_EXPORT(int) +rig_list_foreach_model HAMLIB_PARAMS((int (*cfunc)(const rig_model_t rig_model, rig_ptr_t), + rig_ptr_t data)); + +extern HAMLIB_EXPORT(int) +rig_load_backend HAMLIB_PARAMS((const char *be_name)); + +extern HAMLIB_EXPORT(int) +rig_check_backend HAMLIB_PARAMS((rig_model_t rig_model)); + +extern HAMLIB_EXPORT(int) +rig_load_all_backends HAMLIB_PARAMS((void)); + +typedef int (*rig_probe_func_t)(const hamlib_port_t *, rig_model_t, rig_ptr_t); + +extern HAMLIB_EXPORT(int) +rig_probe_all HAMLIB_PARAMS((hamlib_port_t *p, + rig_probe_func_t, + rig_ptr_t)); + +extern HAMLIB_EXPORT(rig_model_t) +rig_probe HAMLIB_PARAMS((hamlib_port_t *p)); + + +/* Misc calls */ +extern HAMLIB_EXPORT(const char *) rig_strrmode(rmode_t mode); +extern HAMLIB_EXPORT(int) rig_strrmodes(rmode_t modes, char *buf, int buflen); +extern HAMLIB_EXPORT(const char *) rig_strvfo(vfo_t vfo); +extern HAMLIB_EXPORT(const char *) rig_strfunc(setting_t); +extern HAMLIB_EXPORT(const char *) rig_strlevel(setting_t); +extern HAMLIB_EXPORT(const char *) rig_strparm(setting_t); +extern HAMLIB_EXPORT(const char *) rig_stragclevel(enum agc_level_e level); +extern HAMLIB_EXPORT(const char *) rig_strptrshift(rptr_shift_t); +extern HAMLIB_EXPORT(const char *) rig_strvfop(vfo_op_t op); +extern HAMLIB_EXPORT(const char *) rig_strscan(scan_t scan); +extern HAMLIB_EXPORT(const char *) rig_strstatus(enum rig_status_e status); +extern HAMLIB_EXPORT(const char *) rig_strmtype(chan_type_t mtype); +extern HAMLIB_EXPORT(const char *) rig_strspectrummode(enum rig_spectrum_mode_e mode); + +extern HAMLIB_EXPORT(rmode_t) rig_parse_mode(const char *s); +extern HAMLIB_EXPORT(vfo_t) rig_parse_vfo(const char *s); +extern HAMLIB_EXPORT(setting_t) rig_parse_func(const char *s); +extern HAMLIB_EXPORT(setting_t) rig_parse_level(const char *s); +extern HAMLIB_EXPORT(setting_t) rig_parse_parm(const char *s); +extern HAMLIB_EXPORT(vfo_op_t) rig_parse_vfo_op(const char *s); +extern HAMLIB_EXPORT(scan_t) rig_parse_scan(const char *s); +extern HAMLIB_EXPORT(rptr_shift_t) rig_parse_rptr_shift(const char *s); +extern HAMLIB_EXPORT(chan_type_t) rig_parse_mtype(const char *s); + +extern HAMLIB_EXPORT(const char *) rig_license HAMLIB_PARAMS(()); +extern HAMLIB_EXPORT(const char *) rig_version HAMLIB_PARAMS(()); +extern HAMLIB_EXPORT(const char *) rig_copyright HAMLIB_PARAMS(()); + +extern HAMLIB_EXPORT(void) rig_no_restore_ai(); + +extern HAMLIB_EXPORT(int) rig_get_cache_timeout_ms(RIG *rig, hamlib_cache_t selection); +extern HAMLIB_EXPORT(int) rig_set_cache_timeout_ms(RIG *rig, hamlib_cache_t selection, int ms); + +extern HAMLIB_EXPORT(int) rig_set_vfo_opt(RIG *rig, int status); +extern HAMLIB_EXPORT(int) rig_get_vfo_info(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, pbwidth_t *width, split_t *split, int *satmode); +extern HAMLIB_EXPORT(int) rig_get_rig_info(RIG *rig, char *response, int max_response_len); +extern HAMLIB_EXPORT(int) rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int * cache_ms_freq, rmode_t *mode, int *cache_ms_mode, pbwidth_t *width, int *cache_ms_width); + +extern HAMLIB_EXPORT(int) rig_set_clock(RIG *rig, int year, int month, int day, int hour, int min, int sec, double msec, int utc_offset); +extern HAMLIB_EXPORT(int) rig_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset); + +typedef unsigned long rig_useconds_t; +extern HAMLIB_EXPORT(int) hl_usleep(rig_useconds_t msec); + +extern HAMLIB_EXPORT(int) rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie, int cookie_len); + +//! @endcond + +__END_DECLS + +#endif /* _RIG_H */ + +/*! @} */ diff --git a/hamlib/rig_dll.h b/hamlib/rig_dll.h new file mode 100644 index 0000000..3a78801 --- /dev/null +++ b/hamlib/rig_dll.h @@ -0,0 +1,90 @@ +/* + * Hamlib Win32 DLL build definitions + * Copyright (c) 2001-2009 by Stephane Fillod + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/* + * Provide definitions to compile in Windows + * using C-friendly options, e.g. + * + * HAMLIB_API -> __cdecl + * HAMLIB_EXPORT, HAMLIB_EXPORT_VAR -> __declspec(dllexport) + * BACKEND_EXPORT, BACKEND_EXPORT_VAR -> __declspec(dllexport) + * + * No effect in non-Windows environments. + */ + +#if defined(_WIN32) && !defined(__CYGWIN__) +# undef HAMLIB_IMPEXP +# undef HAMLIB_CPP_IMPEXP +# undef HAMLIB_API +# undef HAMLIB_EXPORT +# undef HAMLIB_EXPORT_VAR +# undef BACKEND_EXPORT +# undef BACKEND_EXPORT_VAR +# undef HAMLIB_DLL_IMPORT +# undef HAMLIB_DLL_EXPORT + +# if defined (__BORLANDC__) +# define HAMLIB_DLL_IMPORT __import +# define HAMLIB_DLL_EXPORT __export +# else +# define HAMLIB_DLL_IMPORT __declspec(dllimport) +# define HAMLIB_DLL_EXPORT __declspec(dllexport) +# endif + +# ifdef DLL_EXPORT +/* HAMLIB_API may be set to __stdcall for VB, .. */ +# define HAMLIB_API __cdecl +# ifdef IN_HAMLIB +# define HAMLIB_CPP_IMPEXP HAMLIB_DLL_EXPORT +# define HAMLIB_IMPEXP HAMLIB_DLL_EXPORT +# else +# define HAMLIB_CPP_IMPEXP HAMLIB_DLL_IMPORT +# define HAMLIB_IMPEXP HAMLIB_DLL_IMPORT +# endif +# else +/* static build, only export the backend entry points for lt_dlsym */ +# define HAMLIB_CPP_IMPEXP HAMLIB_DLL_EXPORT +# endif +#endif + + +/* Take care of non-cygwin platforms */ +#if !defined(HAMLIB_IMPEXP) +# define HAMLIB_IMPEXP +#endif +#if !defined(HAMLIB_CPP_IMPEXP) +# define HAMLIB_CPP_IMPEXP +#endif +#if !defined(HAMLIB_API) +# define HAMLIB_API +#endif +#if !defined(HAMLIB_EXPORT) +# define HAMLIB_EXPORT(type) HAMLIB_IMPEXP type HAMLIB_API +#endif +#if !defined(HAMLIB_EXPORT_VAR) +# define HAMLIB_EXPORT_VAR(type) HAMLIB_IMPEXP type +#endif +#if !defined(BACKEND_EXPORT) +# define BACKEND_EXPORT(type) HAMLIB_CPP_IMPEXP type HAMLIB_API +#endif +#if !defined(BACKEND_EXPORT_VAR) +# define BACKEND_EXPORT_VAR(type) HAMLIB_CPP_IMPEXP type +#endif diff --git a/hamlib/riglist.h b/hamlib/riglist.h new file mode 100644 index 0000000..aeadfac --- /dev/null +++ b/hamlib/riglist.h @@ -0,0 +1,662 @@ +/* + * Hamlib Interface - list of known rigs + * Copyright (c) 2000-2003 by Frank Singleton + * Copyright (c) 2000-2015 by Stephane Fillod + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _RIGLIST_H +#define _RIGLIST_H 1 + +//! @cond Doxygen_Suppress + +// The rig model number is designed to fit in a 32-bit int +// As of 2020-02-18 we have 33 backends defined +// With a max of 1000 models per backend we get total a model number range of 1001-33001 +// This MAX was 100 prior to 2020-02-18 and Icom was close to running out of the 100 range +#define MAX_MODELS_PER_BACKEND 1000 +#define RIG_MAKE_MODEL(a,b) ((a)*MAX_MODELS_PER_BACKEND+(b)) +#define RIG_BACKEND_NUM(a) ((a)/MAX_MODELS_PER_BACKEND) + +/*! \file riglist.h + * \brief Hamlib rig(radio) model definitions. + * + * This file contains rig model definitions for the Hamlib rig API. Each + * distinct rig type has a unique model number (ID) and is used by hamlib to + * identify and distinguish between the different hardware drivers. The + * exact model numbers can be acquired using the macros in this file. To + * obtain a list of supported rig branches, one can use the statically + * defined RIG_BACKEND_LIST macro. To obtain a full list of supported rig + * (including each model in every branch), the foreach_opened_rig() API + * function can be used. + * + * The model number, or ID, is used to tell hamlib, which rig the client + * whishes to use. It is done with the rig_init() API call. + */ + +#define RIG_MODEL_NONE 0 + +/*! \def RIG_MODEL_DUMMY + * \brief A macro that returns the model number for the dummy backend. + * + * The dummy backend, as the name suggests, is a backend which performs no + * hardware operations and always behaves as one would expect. It can be + * thought of as a hardware simulator and is very useful for testing client + * applications. + * + * It has also been expanded to provide support to "virtual" type of rigs + * such as the network rig control backend and W1HKJ's Flrig application. + */ +#define RIG_DUMMY 0 +#define RIG_BACKEND_DUMMY "dummy" +#define RIG_MODEL_DUMMY RIG_MAKE_MODEL(RIG_DUMMY, 1) +#define RIG_MODEL_NETRIGCTL RIG_MAKE_MODEL(RIG_DUMMY, 2) +#define RIG_MODEL_ARMSTRONG RIG_MAKE_MODEL(RIG_DUMMY, 3) +#define RIG_MODEL_FLRIG RIG_MAKE_MODEL(RIG_DUMMY, 4) +#define RIG_MODEL_TRXMANAGER_RIG RIG_MAKE_MODEL(RIG_DUMMY, 5) +#define RIG_MODEL_DUMMY_NOVFO RIG_MAKE_MODEL(RIG_DUMMY, 6) +#define RIG_MODEL_TCI1X RIG_MAKE_MODEL(RIG_DUMMY, 7) + + +/* + * Yaesu + */ +#define RIG_YAESU 1 +#define RIG_BACKEND_YAESU "yaesu" +#define RIG_MODEL_FT847 RIG_MAKE_MODEL(RIG_YAESU, 1) +#define RIG_MODEL_FT1000 RIG_MAKE_MODEL(RIG_YAESU, 2) +#define RIG_MODEL_FT1000D RIG_MAKE_MODEL(RIG_YAESU, 3) +#define RIG_MODEL_FT1000MPMKV RIG_MAKE_MODEL(RIG_YAESU, 4) +#define RIG_MODEL_FT747 RIG_MAKE_MODEL(RIG_YAESU, 5) +#define RIG_MODEL_FT757 RIG_MAKE_MODEL(RIG_YAESU, 6) +#define RIG_MODEL_FT757GXII RIG_MAKE_MODEL(RIG_YAESU, 7) +#define RIG_MODEL_FT575 RIG_MAKE_MODEL(RIG_YAESU, 8) +#define RIG_MODEL_FT767 RIG_MAKE_MODEL(RIG_YAESU, 9) +#define RIG_MODEL_FT736R RIG_MAKE_MODEL(RIG_YAESU, 10) +#define RIG_MODEL_FT840 RIG_MAKE_MODEL(RIG_YAESU, 11) +#define RIG_MODEL_FT820 RIG_MAKE_MODEL(RIG_YAESU, 12) +#define RIG_MODEL_FT900 RIG_MAKE_MODEL(RIG_YAESU, 13) +#define RIG_MODEL_FT920 RIG_MAKE_MODEL(RIG_YAESU, 14) +#define RIG_MODEL_FT890 RIG_MAKE_MODEL(RIG_YAESU, 15) +#define RIG_MODEL_FT990 RIG_MAKE_MODEL(RIG_YAESU, 16) +#define RIG_MODEL_FRG100 RIG_MAKE_MODEL(RIG_YAESU, 17) +#define RIG_MODEL_FRG9600 RIG_MAKE_MODEL(RIG_YAESU, 18) +#define RIG_MODEL_FRG8800 RIG_MAKE_MODEL(RIG_YAESU, 19) +#define RIG_MODEL_FT817 RIG_MAKE_MODEL(RIG_YAESU, 20) +#define RIG_MODEL_FT100 RIG_MAKE_MODEL(RIG_YAESU, 21) +#define RIG_MODEL_FT857 RIG_MAKE_MODEL(RIG_YAESU, 22) +#define RIG_MODEL_FT897 RIG_MAKE_MODEL(RIG_YAESU, 23) +#define RIG_MODEL_FT1000MP RIG_MAKE_MODEL(RIG_YAESU, 24) +#define RIG_MODEL_FT1000MPMKVFLD RIG_MAKE_MODEL(RIG_YAESU, 25) +#define RIG_MODEL_VR5000 RIG_MAKE_MODEL(RIG_YAESU, 26) +#define RIG_MODEL_FT450 RIG_MAKE_MODEL(RIG_YAESU, 27) +#define RIG_MODEL_FT950 RIG_MAKE_MODEL(RIG_YAESU, 28) +#define RIG_MODEL_FT2000 RIG_MAKE_MODEL(RIG_YAESU, 29) +#define RIG_MODEL_FT9000 RIG_MAKE_MODEL(RIG_YAESU, 30) +#define RIG_MODEL_FT980 RIG_MAKE_MODEL(RIG_YAESU, 31) +#define RIG_MODEL_FTDX5000 RIG_MAKE_MODEL(RIG_YAESU, 32) +#define RIG_MODEL_VX1700 RIG_MAKE_MODEL(RIG_YAESU, 33) +#define RIG_MODEL_FTDX1200 RIG_MAKE_MODEL(RIG_YAESU, 34) +#define RIG_MODEL_FT991 RIG_MAKE_MODEL(RIG_YAESU, 35) +#define RIG_MODEL_FT891 RIG_MAKE_MODEL(RIG_YAESU, 36) +#define RIG_MODEL_FTDX3000 RIG_MAKE_MODEL(RIG_YAESU, 37) +#define RIG_MODEL_FT847UNI RIG_MAKE_MODEL(RIG_YAESU, 38) +#define RIG_MODEL_FT600 RIG_MAKE_MODEL(RIG_YAESU, 39) +#define RIG_MODEL_FTDX101D RIG_MAKE_MODEL(RIG_YAESU, 40) +#define RIG_MODEL_FT818 RIG_MAKE_MODEL(RIG_YAESU, 41) +#define RIG_MODEL_FTDX10 RIG_MAKE_MODEL(RIG_YAESU, 42) +#define RIG_MODEL_FT897D RIG_MAKE_MODEL(RIG_YAESU, 43) +#define RIG_MODEL_FTDX101MP RIG_MAKE_MODEL(RIG_YAESU, 44) +#define RIG_MODEL_MCHFQRP RIG_MAKE_MODEL(RIG_YAESU, 45) + + +/* + * Kenwood + */ +#define RIG_KENWOOD 2 +#define RIG_BACKEND_KENWOOD "kenwood" +#define RIG_MODEL_TS50 RIG_MAKE_MODEL(RIG_KENWOOD, 1) +#define RIG_MODEL_TS440 RIG_MAKE_MODEL(RIG_KENWOOD, 2) +#define RIG_MODEL_TS450S RIG_MAKE_MODEL(RIG_KENWOOD, 3) +#define RIG_MODEL_TS570D RIG_MAKE_MODEL(RIG_KENWOOD, 4) +#define RIG_MODEL_TS690S RIG_MAKE_MODEL(RIG_KENWOOD, 5) +#define RIG_MODEL_TS711 RIG_MAKE_MODEL(RIG_KENWOOD, 6) +#define RIG_MODEL_TS790 RIG_MAKE_MODEL(RIG_KENWOOD, 7) +#define RIG_MODEL_TS811 RIG_MAKE_MODEL(RIG_KENWOOD, 8) +#define RIG_MODEL_TS850 RIG_MAKE_MODEL(RIG_KENWOOD, 9) +#define RIG_MODEL_TS870S RIG_MAKE_MODEL(RIG_KENWOOD, 10) +#define RIG_MODEL_TS940 RIG_MAKE_MODEL(RIG_KENWOOD, 11) +#define RIG_MODEL_TS950S RIG_MAKE_MODEL(RIG_KENWOOD, 12) +#define RIG_MODEL_TS950SDX RIG_MAKE_MODEL(RIG_KENWOOD, 13) +#define RIG_MODEL_TS2000 RIG_MAKE_MODEL(RIG_KENWOOD, 14) +#define RIG_MODEL_R5000 RIG_MAKE_MODEL(RIG_KENWOOD, 15) +#define RIG_MODEL_TS570S RIG_MAKE_MODEL(RIG_KENWOOD, 16) +#define RIG_MODEL_THD7A RIG_MAKE_MODEL(RIG_KENWOOD, 17) +#define RIG_MODEL_THD7AG RIG_MAKE_MODEL(RIG_KENWOOD, 18) +#define RIG_MODEL_THF6A RIG_MAKE_MODEL(RIG_KENWOOD, 19) +#define RIG_MODEL_THF7E RIG_MAKE_MODEL(RIG_KENWOOD, 20) +#define RIG_MODEL_K2 RIG_MAKE_MODEL(RIG_KENWOOD, 21) +#define RIG_MODEL_TS930 RIG_MAKE_MODEL(RIG_KENWOOD, 22) +#define RIG_MODEL_THG71 RIG_MAKE_MODEL(RIG_KENWOOD, 23) +#define RIG_MODEL_TS680S RIG_MAKE_MODEL(RIG_KENWOOD, 24) +#define RIG_MODEL_TS140S RIG_MAKE_MODEL(RIG_KENWOOD, 25) +#define RIG_MODEL_TMD700 RIG_MAKE_MODEL(RIG_KENWOOD, 26) +#define RIG_MODEL_TMV7 RIG_MAKE_MODEL(RIG_KENWOOD, 27) +#define RIG_MODEL_TS480 RIG_MAKE_MODEL(RIG_KENWOOD, 28) +#define RIG_MODEL_K3 RIG_MAKE_MODEL(RIG_KENWOOD, 29) +#define RIG_MODEL_TRC80 RIG_MAKE_MODEL(RIG_KENWOOD, 30) +#define RIG_MODEL_TS590S RIG_MAKE_MODEL(RIG_KENWOOD, 31) +#define RIG_MODEL_TRANSFOX RIG_MAKE_MODEL(RIG_KENWOOD, 32) /* SigFox Transfox */ +#define RIG_MODEL_THD72A RIG_MAKE_MODEL(RIG_KENWOOD, 33) +#define RIG_MODEL_TMD710 RIG_MAKE_MODEL(RIG_KENWOOD, 34) +#define RIG_MODEL_TMV71 RIG_MAKE_MODEL(RIG_KENWOOD, 35) +#define RIG_MODEL_F6K RIG_MAKE_MODEL(RIG_KENWOOD, 36) /* Flex 6000 Series */ +#define RIG_MODEL_TS590SG RIG_MAKE_MODEL(RIG_KENWOOD, 37) +#define RIG_MODEL_XG3 RIG_MAKE_MODEL(RIG_KENWOOD, 38) /* Elecraft XG-3 signal generator */ +#define RIG_MODEL_TS990S RIG_MAKE_MODEL(RIG_KENWOOD, 39) +#define RIG_MODEL_HPSDR RIG_MAKE_MODEL(RIG_KENWOOD, 40) /* OpenHPSDR, PiHPSDR */ +#define RIG_MODEL_TS890S RIG_MAKE_MODEL(RIG_KENWOOD, 41) +#define RIG_MODEL_THD74 RIG_MAKE_MODEL(RIG_KENWOOD, 42) +#define RIG_MODEL_K3S RIG_MAKE_MODEL(RIG_KENWOOD, 43) +#define RIG_MODEL_KX2 RIG_MAKE_MODEL(RIG_KENWOOD, 44) +#define RIG_MODEL_KX3 RIG_MAKE_MODEL(RIG_KENWOOD, 45) +#define RIG_MODEL_PT8000A RIG_MAKE_MODEL(RIG_KENWOOD, 46) +#define RIG_MODEL_K4 RIG_MAKE_MODEL(RIG_KENWOOD, 47) +#define RIG_MODEL_POWERSDR RIG_MAKE_MODEL(RIG_KENWOOD, 48) +#define RIG_MODEL_MALACHITE RIG_MAKE_MODEL(RIG_KENWOOD, 49) + +/* + * Icom + */ +#define RIG_ICOM 3 +#define RIG_BACKEND_ICOM "icom" +#define RIG_MODEL_IC1271 RIG_MAKE_MODEL(RIG_ICOM, 1) +#define RIG_MODEL_IC1275 RIG_MAKE_MODEL(RIG_ICOM, 2) +#define RIG_MODEL_IC271 RIG_MAKE_MODEL(RIG_ICOM, 3) +#define RIG_MODEL_IC275 RIG_MAKE_MODEL(RIG_ICOM, 4) +#define RIG_MODEL_IC375 RIG_MAKE_MODEL(RIG_ICOM, 5) +#define RIG_MODEL_IC471 RIG_MAKE_MODEL(RIG_ICOM, 6) +#define RIG_MODEL_IC475 RIG_MAKE_MODEL(RIG_ICOM, 7) +#define RIG_MODEL_IC575 RIG_MAKE_MODEL(RIG_ICOM, 8) +#define RIG_MODEL_IC706 RIG_MAKE_MODEL(RIG_ICOM, 9) +#define RIG_MODEL_IC706MKII RIG_MAKE_MODEL(RIG_ICOM, 10) +#define RIG_MODEL_IC706MKIIG RIG_MAKE_MODEL(RIG_ICOM, 11) +#define RIG_MODEL_IC707 RIG_MAKE_MODEL(RIG_ICOM, 12) +#define RIG_MODEL_IC718 RIG_MAKE_MODEL(RIG_ICOM, 13) +#define RIG_MODEL_IC725 RIG_MAKE_MODEL(RIG_ICOM, 14) +#define RIG_MODEL_IC726 RIG_MAKE_MODEL(RIG_ICOM, 15) +#define RIG_MODEL_IC728 RIG_MAKE_MODEL(RIG_ICOM, 16) +#define RIG_MODEL_IC729 RIG_MAKE_MODEL(RIG_ICOM, 17) +#define RIG_MODEL_IC731 RIG_MAKE_MODEL(RIG_ICOM, 18) +#define RIG_MODEL_IC735 RIG_MAKE_MODEL(RIG_ICOM, 19) +#define RIG_MODEL_IC736 RIG_MAKE_MODEL(RIG_ICOM, 20) +#define RIG_MODEL_IC737 RIG_MAKE_MODEL(RIG_ICOM, 21) +#define RIG_MODEL_IC738 RIG_MAKE_MODEL(RIG_ICOM, 22) +#define RIG_MODEL_IC746 RIG_MAKE_MODEL(RIG_ICOM, 23) +#define RIG_MODEL_IC751 RIG_MAKE_MODEL(RIG_ICOM, 24) +#define RIG_MODEL_IC751A RIG_MAKE_MODEL(RIG_ICOM, 25) +#define RIG_MODEL_IC756 RIG_MAKE_MODEL(RIG_ICOM, 26) +#define RIG_MODEL_IC756PRO RIG_MAKE_MODEL(RIG_ICOM, 27) +#define RIG_MODEL_IC761 RIG_MAKE_MODEL(RIG_ICOM, 28) +#define RIG_MODEL_IC765 RIG_MAKE_MODEL(RIG_ICOM, 29) +#define RIG_MODEL_IC775 RIG_MAKE_MODEL(RIG_ICOM, 30) +#define RIG_MODEL_IC781 RIG_MAKE_MODEL(RIG_ICOM, 31) +#define RIG_MODEL_IC820 RIG_MAKE_MODEL(RIG_ICOM, 32) +//#define RIG_MODEL_IC821 RIG_MAKE_MODEL(RIG_ICOM, 33) // not implemented and can be reused +#define RIG_MODEL_IC821H RIG_MAKE_MODEL(RIG_ICOM, 34) +#define RIG_MODEL_IC970 RIG_MAKE_MODEL(RIG_ICOM, 35) +#define RIG_MODEL_ICR10 RIG_MAKE_MODEL(RIG_ICOM, 36) +#define RIG_MODEL_ICR71 RIG_MAKE_MODEL(RIG_ICOM, 37) +#define RIG_MODEL_ICR72 RIG_MAKE_MODEL(RIG_ICOM, 38) +#define RIG_MODEL_ICR75 RIG_MAKE_MODEL(RIG_ICOM, 39) +#define RIG_MODEL_ICR7000 RIG_MAKE_MODEL(RIG_ICOM, 40) +#define RIG_MODEL_ICR7100 RIG_MAKE_MODEL(RIG_ICOM, 41) +#define RIG_MODEL_ICR8500 RIG_MAKE_MODEL(RIG_ICOM, 42) +#define RIG_MODEL_ICR9000 RIG_MAKE_MODEL(RIG_ICOM, 43) +#define RIG_MODEL_IC910 RIG_MAKE_MODEL(RIG_ICOM, 44) +#define RIG_MODEL_IC78 RIG_MAKE_MODEL(RIG_ICOM, 45) +#define RIG_MODEL_IC746PRO RIG_MAKE_MODEL(RIG_ICOM, 46) +#define RIG_MODEL_IC756PROII RIG_MAKE_MODEL(RIG_ICOM, 47) /* 48-53 defined below */ +#define RIG_MODEL_ICID1 RIG_MAKE_MODEL(RIG_ICOM, 54) +#define RIG_MODEL_IC703 RIG_MAKE_MODEL(RIG_ICOM, 55) +#define RIG_MODEL_IC7800 RIG_MAKE_MODEL(RIG_ICOM, 56) +#define RIG_MODEL_IC756PROIII RIG_MAKE_MODEL(RIG_ICOM, 57) +#define RIG_MODEL_ICR20 RIG_MAKE_MODEL(RIG_ICOM, 58) /* 59 defined below */ +#define RIG_MODEL_IC7000 RIG_MAKE_MODEL(RIG_ICOM, 60) +#define RIG_MODEL_IC7200 RIG_MAKE_MODEL(RIG_ICOM, 61) +#define RIG_MODEL_IC7700 RIG_MAKE_MODEL(RIG_ICOM, 62) +#define RIG_MODEL_IC7600 RIG_MAKE_MODEL(RIG_ICOM, 63) /* 64 defined below */ +#define RIG_MODEL_IC92D RIG_MAKE_MODEL(RIG_ICOM, 65) +#define RIG_MODEL_ICR9500 RIG_MAKE_MODEL(RIG_ICOM, 66) +#define RIG_MODEL_IC7410 RIG_MAKE_MODEL(RIG_ICOM, 67) +#define RIG_MODEL_IC9100 RIG_MAKE_MODEL(RIG_ICOM, 68) +#define RIG_MODEL_ICRX7 RIG_MAKE_MODEL(RIG_ICOM, 69) +#define RIG_MODEL_IC7100 RIG_MAKE_MODEL(RIG_ICOM, 70) +#define RIG_MODEL_ID5100 RIG_MAKE_MODEL(RIG_ICOM, 71) +#define RIG_MODEL_IC2730 RIG_MAKE_MODEL(RIG_ICOM, 72) +#define RIG_MODEL_IC7300 RIG_MAKE_MODEL(RIG_ICOM, 73) +#define RIG_MODEL_PERSEUS RIG_MAKE_MODEL(RIG_ICOM, 74) +#define RIG_MODEL_IC785x RIG_MAKE_MODEL(RIG_ICOM, 75) +#define RIG_MODEL_X108G RIG_MAKE_MODEL(RIG_ICOM, 76) /* Xiegu X108 */ +#define RIG_MODEL_ICR6 RIG_MAKE_MODEL(RIG_ICOM, 77) +#define RIG_MODEL_IC7610 RIG_MAKE_MODEL(RIG_ICOM, 78) +#define RIG_MODEL_ICR8600 RIG_MAKE_MODEL(RIG_ICOM, 79) +#define RIG_MODEL_ICR30 RIG_MAKE_MODEL(RIG_ICOM, 80) +#define RIG_MODEL_IC9700 RIG_MAKE_MODEL(RIG_ICOM, 81) +#define RIG_MODEL_ID4100 RIG_MAKE_MODEL(RIG_ICOM, 82) +#define RIG_MODEL_ID31 RIG_MAKE_MODEL(RIG_ICOM, 83) +#define RIG_MODEL_ID51 RIG_MAKE_MODEL(RIG_ICOM, 84) +#define RIG_MODEL_IC705 RIG_MAKE_MODEL(RIG_ICOM, 85) +/* next one is 86 */ + + +/* + * Optoelectronics (CI-V) + */ +#define RIG_MODEL_MINISCOUT RIG_MAKE_MODEL(RIG_ICOM, 48) +#define RIG_MODEL_XPLORER RIG_MAKE_MODEL(RIG_ICOM, 49) +#define RIG_MODEL_OS535 RIG_MAKE_MODEL(RIG_ICOM, 52) +#define RIG_MODEL_OS456 RIG_MAKE_MODEL(RIG_ICOM, 53) + + +/* + * TenTec (CI-V) + */ +#define RIG_MODEL_OMNIVI RIG_MAKE_MODEL(RIG_ICOM, 50) +#define RIG_MODEL_OMNIVIP RIG_MAKE_MODEL(RIG_ICOM, 51) /* OMNI-VI+ */ +#define RIG_MODEL_PARAGON2 RIG_MAKE_MODEL(RIG_ICOM, 59) +#define RIG_MODEL_DELTAII RIG_MAKE_MODEL(RIG_ICOM, 64) + + +/* + * Icom PCR + */ +#define RIG_PCR 4 +#define RIG_BACKEND_PCR "pcr" +#define RIG_MODEL_PCR1000 RIG_MAKE_MODEL(RIG_PCR, 1) +#define RIG_MODEL_PCR100 RIG_MAKE_MODEL(RIG_PCR, 2) +#define RIG_MODEL_PCR1500 RIG_MAKE_MODEL(RIG_PCR, 3) +#define RIG_MODEL_PCR2500 RIG_MAKE_MODEL(RIG_PCR, 4) + + +/* + * AOR + */ +#define RIG_AOR 5 +#define RIG_BACKEND_AOR "aor" +#define RIG_MODEL_AR8200 RIG_MAKE_MODEL(RIG_AOR, 1) +#define RIG_MODEL_AR8000 RIG_MAKE_MODEL(RIG_AOR, 2) +#define RIG_MODEL_AR7030 RIG_MAKE_MODEL(RIG_AOR, 3) +#define RIG_MODEL_AR5000 RIG_MAKE_MODEL(RIG_AOR, 4) +#define RIG_MODEL_AR3030 RIG_MAKE_MODEL(RIG_AOR, 5) +#define RIG_MODEL_AR3000A RIG_MAKE_MODEL(RIG_AOR, 6) +#define RIG_MODEL_AR3000 RIG_MAKE_MODEL(RIG_AOR, 7) +#define RIG_MODEL_AR2700 RIG_MAKE_MODEL(RIG_AOR, 8) +#define RIG_MODEL_AR2500 RIG_MAKE_MODEL(RIG_AOR, 9) +#define RIG_MODEL_AR16 RIG_MAKE_MODEL(RIG_AOR, 10) +#define RIG_MODEL_SDU5500 RIG_MAKE_MODEL(RIG_AOR, 11) +#define RIG_MODEL_SDU5000 RIG_MAKE_MODEL(RIG_AOR, 12) +#define RIG_MODEL_AR8600 RIG_MAKE_MODEL(RIG_AOR, 13) +#define RIG_MODEL_AR5000A RIG_MAKE_MODEL(RIG_AOR, 14) +#define RIG_MODEL_AR7030P RIG_MAKE_MODEL(RIG_AOR, 15) +#define RIG_MODEL_SR2200 RIG_MAKE_MODEL(RIG_AOR, 16) + + +/* + * JRC + */ +#define RIG_JRC 6 +#define RIG_BACKEND_JRC "jrc" +#define RIG_MODEL_JST145 RIG_MAKE_MODEL(RIG_JRC, 1) +#define RIG_MODEL_JST245 RIG_MAKE_MODEL(RIG_JRC, 2) +#define RIG_MODEL_CMH530 RIG_MAKE_MODEL(RIG_JRC, 3) +#define RIG_MODEL_NRD345 RIG_MAKE_MODEL(RIG_JRC, 4) +#define RIG_MODEL_NRD525 RIG_MAKE_MODEL(RIG_JRC, 5) +#define RIG_MODEL_NRD535 RIG_MAKE_MODEL(RIG_JRC, 6) +#define RIG_MODEL_NRD545 RIG_MAKE_MODEL(RIG_JRC, 7) + + +/* + * Radio Shack + * Actually, they might be either Icom or Uniden. TBC --SF + */ +#define RIG_RADIOSHACK 7 +#define RIG_BACKEND_RADIOSHACK "radioshack" +#define RIG_MODEL_RS64 RIG_MAKE_MODEL(RIG_RADIOSHACK, 1) /* PRO-64 */ +#define RIG_MODEL_RS2005 RIG_MAKE_MODEL(RIG_RADIOSHACK, 2) /* w/ OptoElectronics OS456 Board */ +#define RIG_MODEL_RS2006 RIG_MAKE_MODEL(RIG_RADIOSHACK, 3) /* w/ OptoElectronics OS456 Board */ +#define RIG_MODEL_RS2035 RIG_MAKE_MODEL(RIG_RADIOSHACK, 4) /* w/ OptoElectronics OS435 Board */ +#define RIG_MODEL_RS2042 RIG_MAKE_MODEL(RIG_RADIOSHACK, 5) /* w/ OptoElectronics OS435 Board */ +#define RIG_MODEL_RS2041 RIG_MAKE_MODEL(RIG_RADIOSHACK, 6) /* PRO-2041 */ + + +/* + * Uniden + */ +#define RIG_UNIDEN 8 +#define RIG_BACKEND_UNIDEN "uniden" +#define RIG_MODEL_BC780 RIG_MAKE_MODEL(RIG_UNIDEN, 1) /* Uniden BC780 - Trunk Tracker "Desktop Radio" */ +#define RIG_MODEL_BC245 RIG_MAKE_MODEL(RIG_UNIDEN, 2) +#define RIG_MODEL_BC895 RIG_MAKE_MODEL(RIG_UNIDEN, 3) +#define RIG_MODEL_PRO2052 RIG_MAKE_MODEL(RIG_UNIDEN, 4) /* Radio Shack PRO-2052 */ +#define RIG_MODEL_BC235 RIG_MAKE_MODEL(RIG_UNIDEN, 5) +#define RIG_MODEL_BC250 RIG_MAKE_MODEL(RIG_UNIDEN, 6) +#define RIG_MODEL_BC785 RIG_MAKE_MODEL(RIG_UNIDEN, 7) +#define RIG_MODEL_BC786 RIG_MAKE_MODEL(RIG_UNIDEN, 8) +#define RIG_MODEL_BCT8 RIG_MAKE_MODEL(RIG_UNIDEN, 9) +#define RIG_MODEL_BCD396T RIG_MAKE_MODEL(RIG_UNIDEN, 10) +#define RIG_MODEL_BCD996T RIG_MAKE_MODEL(RIG_UNIDEN, 11) +#define RIG_MODEL_BC898 RIG_MAKE_MODEL(RIG_UNIDEN, 12) + + +/* + * Drake + */ +#define RIG_DRAKE 9 +#define RIG_BACKEND_DRAKE "drake" +#define RIG_MODEL_DKR8 RIG_MAKE_MODEL(RIG_DRAKE, 1) +#define RIG_MODEL_DKR8A RIG_MAKE_MODEL(RIG_DRAKE, 2) +#define RIG_MODEL_DKR8B RIG_MAKE_MODEL(RIG_DRAKE, 3) + + +/* + * Lowe + */ +#define RIG_LOWE 10 +#define RIG_BACKEND_LOWE "lowe" +#define RIG_MODEL_HF150 RIG_MAKE_MODEL(RIG_LOWE, 1) +#define RIG_MODEL_HF225 RIG_MAKE_MODEL(RIG_LOWE, 2) +#define RIG_MODEL_HF250 RIG_MAKE_MODEL(RIG_LOWE, 3) +#define RIG_MODEL_HF235 RIG_MAKE_MODEL(RIG_LOWE, 4) + + +/* + * Racal + */ +#define RIG_RACAL 11 +#define RIG_BACKEND_RACAL "racal" +#define RIG_MODEL_RA3790 RIG_MAKE_MODEL(RIG_RACAL, 1) +#define RIG_MODEL_RA3720 RIG_MAKE_MODEL(RIG_RACAL, 2) +#define RIG_MODEL_RA6790 RIG_MAKE_MODEL(RIG_RACAL, 3) +#define RIG_MODEL_RA3710 RIG_MAKE_MODEL(RIG_RACAL, 4) +#define RIG_MODEL_RA3702 RIG_MAKE_MODEL(RIG_RACAL, 5) + + +/* + * Watkins-Johnson + */ +#define RIG_WJ 12 +#define RIG_BACKEND_WJ "wj" +#define RIG_MODEL_HF1000 RIG_MAKE_MODEL(RIG_WJ, 1) +#define RIG_MODEL_HF1000A RIG_MAKE_MODEL(RIG_WJ, 2) +#define RIG_MODEL_WJ8711 RIG_MAKE_MODEL(RIG_WJ, 3) +#define RIG_MODEL_WJ8888 RIG_MAKE_MODEL(RIG_WJ, 4) + + +/* + * Rohde & Schwarz--ek + */ +#define RIG_EK 13 +#define RIG_BACKEND_EK "ek" +#define RIG_MODEL_ESM500 RIG_MAKE_MODEL(RIG_EK, 1) +#define RIG_MODEL_EK890 RIG_MAKE_MODEL(RIG_EK, 2) +#define RIG_MODEL_EK891 RIG_MAKE_MODEL(RIG_EK, 3) +#define RIG_MODEL_EK895 RIG_MAKE_MODEL(RIG_EK, 4) +#define RIG_MODEL_EK070 RIG_MAKE_MODEL(RIG_EK, 5) + + +/* + * Skanti + */ +#define RIG_SKANTI 14 +#define RIG_BACKEND_SKANTI "skanti" +#define RIG_MODEL_TRP7000 RIG_MAKE_MODEL(RIG_SKANTI, 1) +#define RIG_MODEL_TRP8000 RIG_MAKE_MODEL(RIG_SKANTI, 2) +#define RIG_MODEL_TRP9000 RIG_MAKE_MODEL(RIG_SKANTI, 3) +#define RIG_MODEL_TRP8255 RIG_MAKE_MODEL(RIG_SKANTI, 4) + + +/* + * WiNRADiO/LinRADiO + */ +#define RIG_WINRADIO 15 +#define RIG_BACKEND_WINRADIO "winradio" +#define RIG_MODEL_WR1000 RIG_MAKE_MODEL(RIG_WINRADIO, 1) +#define RIG_MODEL_WR1500 RIG_MAKE_MODEL(RIG_WINRADIO, 2) +#define RIG_MODEL_WR1550 RIG_MAKE_MODEL(RIG_WINRADIO, 3) +#define RIG_MODEL_WR3100 RIG_MAKE_MODEL(RIG_WINRADIO, 4) +#define RIG_MODEL_WR3150 RIG_MAKE_MODEL(RIG_WINRADIO, 5) +#define RIG_MODEL_WR3500 RIG_MAKE_MODEL(RIG_WINRADIO, 6) +#define RIG_MODEL_WR3700 RIG_MAKE_MODEL(RIG_WINRADIO, 7) +#define RIG_MODEL_G303 RIG_MAKE_MODEL(RIG_WINRADIO, 8) +#define RIG_MODEL_G313 RIG_MAKE_MODEL(RIG_WINRADIO, 9) +#define RIG_MODEL_G305 RIG_MAKE_MODEL(RIG_WINRADIO, 10) +#define RIG_MODEL_G315 RIG_MAKE_MODEL(RIG_WINRADIO, 11) + + +/* + * Ten Tec + */ +#define RIG_TENTEC 16 +#define RIG_BACKEND_TENTEC "tentec" +#define RIG_MODEL_TT550 RIG_MAKE_MODEL(RIG_TENTEC, 1) /* Pegasus */ +#define RIG_MODEL_TT538 RIG_MAKE_MODEL(RIG_TENTEC, 2) /* Jupiter */ +#define RIG_MODEL_RX320 RIG_MAKE_MODEL(RIG_TENTEC, 3) +#define RIG_MODEL_RX340 RIG_MAKE_MODEL(RIG_TENTEC, 4) +#define RIG_MODEL_RX350 RIG_MAKE_MODEL(RIG_TENTEC, 5) +#define RIG_MODEL_TT526 RIG_MAKE_MODEL(RIG_TENTEC, 6) /* 6N2 */ +#define RIG_MODEL_TT516 RIG_MAKE_MODEL(RIG_TENTEC, 7) /* Argonaut V */ +#define RIG_MODEL_TT565 RIG_MAKE_MODEL(RIG_TENTEC, 8) /* Orion */ +#define RIG_MODEL_TT585 RIG_MAKE_MODEL(RIG_TENTEC, 9) /* Paragon */ +#define RIG_MODEL_TT588 RIG_MAKE_MODEL(RIG_TENTEC, 11) /* Omni-VII */ +#define RIG_MODEL_RX331 RIG_MAKE_MODEL(RIG_TENTEC, 12) +#define RIG_MODEL_TT599 RIG_MAKE_MODEL(RIG_TENTEC, 13) /* Eagle */ + + +/* + * Alinco + */ +#define RIG_ALINCO 17 +#define RIG_BACKEND_ALINCO "alinco" +#define RIG_MODEL_DX77 RIG_MAKE_MODEL(RIG_ALINCO, 1) +#define RIG_MODEL_DXSR8 RIG_MAKE_MODEL(RIG_ALINCO, 2) + + +/* + * Kachina + */ +#define RIG_KACHINA 18 +#define RIG_BACKEND_KACHINA "kachina" +#define RIG_MODEL_505DSP RIG_MAKE_MODEL(RIG_KACHINA, 1) + + +/* + * Gnuradio backend + */ +#define RIG_GNURADIO 20 +#define RIG_BACKEND_GNURADIO "gnuradio" +#define RIG_MODEL_GNURADIO RIG_MAKE_MODEL(RIG_GNURADIO, 1) /* dev model, Chirp source */ +#define RIG_MODEL_MC4020 RIG_MAKE_MODEL(RIG_GNURADIO, 2) /* MC4020 */ +#define RIG_MODEL_GRAUDIO RIG_MAKE_MODEL(RIG_GNURADIO, 3) /* Sound card source */ +#define RIG_MODEL_GRAUDIOIQ RIG_MAKE_MODEL(RIG_GNURADIO, 4) /* I&Q stereo sound card source */ +#define RIG_MODEL_USRP_G RIG_MAKE_MODEL(RIG_GNURADIO, 5) /* Universal Software Radio Peripheral */ + + +/* + * Microtune tuners + */ +#define RIG_MICROTUNE 21 +#define RIG_BACKEND_MICROTUNE "microtune" +#define RIG_MODEL_MICROTUNE_4937 RIG_MAKE_MODEL(RIG_MICROTUNE, 1) /* eval board */ +#define RIG_MODEL_MICROTUNE_4702 RIG_MAKE_MODEL(RIG_MICROTUNE, 2) /* Alan's */ +#define RIG_MODEL_MICROTUNE_4707 RIG_MAKE_MODEL(RIG_MICROTUNE, 3) + + +/* + * TAPR + */ +#define RIG_TAPR 22 +#define RIG_BACKEND_TAPR "tapr" +#define RIG_MODEL_DSP10 RIG_MAKE_MODEL(RIG_TAPR, 1) + + +/* + * Flex-radio + */ +#define RIG_FLEXRADIO 23 +#define RIG_BACKEND_FLEXRADIO "flexradio" +#define RIG_MODEL_SDR1000 RIG_MAKE_MODEL(RIG_FLEXRADIO, 1) +#define RIG_MODEL_SDR1000RFE RIG_MAKE_MODEL(RIG_FLEXRADIO, 2) +#define RIG_MODEL_DTTSP RIG_MAKE_MODEL(RIG_FLEXRADIO, 3) +#define RIG_MODEL_DTTSP_UDP RIG_MAKE_MODEL(RIG_FLEXRADIO, 4) + + +/* + * VEB Funkwerk Köpenick RFT + */ +#define RIG_RFT 24 +#define RIG_BACKEND_RFT "rft" +#define RIG_MODEL_EKD500 RIG_MAKE_MODEL(RIG_RFT, 1) + + +/* + * Various kits + */ +#define RIG_KIT 25 +#define RIG_BACKEND_KIT "kit" +#define RIG_MODEL_ELEKTOR304 RIG_MAKE_MODEL(RIG_KIT, 1) +#define RIG_MODEL_DRT1 RIG_MAKE_MODEL(RIG_KIT, 2) +#define RIG_MODEL_DWT RIG_MAKE_MODEL(RIG_KIT, 3) +#define RIG_MODEL_USRP0 RIG_MAKE_MODEL(RIG_KIT, 4) /* prototype */ +#define RIG_MODEL_USRP RIG_MAKE_MODEL(RIG_KIT, 5) +#define RIG_MODEL_DDS60 RIG_MAKE_MODEL(RIG_KIT, 6) +#define RIG_MODEL_ELEKTOR507 RIG_MAKE_MODEL(RIG_KIT, 7) /* Elektor SDR USB */ +#define RIG_MODEL_MINIVNA RIG_MAKE_MODEL(RIG_KIT, 8) +#define RIG_MODEL_SI570AVRUSB RIG_MAKE_MODEL(RIG_KIT, 9) /* SoftRock Si570 AVR */ +#define RIG_MODEL_PMSDR RIG_MAKE_MODEL(RIG_KIT, 10) +#define RIG_MODEL_SI570PICUSB RIG_MAKE_MODEL(RIG_KIT, 11) /* SoftRock Si570 PIC */ +#define RIG_MODEL_FIFISDR RIG_MAKE_MODEL(RIG_KIT, 12) /* FiFi-SDR USB */ +#define RIG_MODEL_FUNCUBEDONGLE RIG_MAKE_MODEL(RIG_KIT, 13) /* FunCUBE Dongle */ +#define RIG_MODEL_HIQSDR RIG_MAKE_MODEL(RIG_KIT, 14) /* HiQSDR */ +#define RIG_MODEL_FASDR RIG_MAKE_MODEL(RIG_KIT,15) /* Funkamateur Sdr */ +#define RIG_MODEL_SI570PEABERRY1 RIG_MAKE_MODEL(RIG_KIT, 16) /* Peaberry V1 */ +#define RIG_MODEL_SI570PEABERRY2 RIG_MAKE_MODEL(RIG_KIT, 17) /* Peaberry V2 */ +#define RIG_MODEL_FUNCUBEDONGLEPLUS RIG_MAKE_MODEL(RIG_KIT, 18) /* FunCUBE Dongle Pro+ */ +#define RIG_MODEL_RSHFIQ RIG_MAKE_MODEL(RIG_KIT, 19) /* RS-HFIQ */ + + +/* + * SW/FM/TV tuner cards supported by Video4Linux,*BSD, .. + */ +#define RIG_TUNER 26 +#define RIG_BACKEND_TUNER "tuner" +#define RIG_MODEL_V4L RIG_MAKE_MODEL(RIG_TUNER, 1) +#define RIG_MODEL_V4L2 RIG_MAKE_MODEL(RIG_TUNER, 2) + + +/* + * Rohde & Schwarz--rs + */ +#define RIG_RS 27 +#define RIG_BACKEND_RS "rs" +#define RIG_MODEL_ESMC RIG_MAKE_MODEL(RIG_RS, 1) +#define RIG_MODEL_EB200 RIG_MAKE_MODEL(RIG_RS, 2) +#define RIG_MODEL_XK2100 RIG_MAKE_MODEL(RIG_RS, 3) + + +/* + * Phillips/Simoco PRM80 + */ +#define RIG_PRM80 28 +#define RIG_BACKEND_PRM80 "prm80" +#define RIG_MODEL_PRM8060 RIG_MAKE_MODEL(RIG_PRM80, 1) +#define RIG_MODEL_PRM8070 RIG_MAKE_MODEL(RIG_PRM80, 2) + + +/* + * ADAT by HB9CBU + * + * ADDED: frgo (DG1SBG), 2012-01-01 + */ +#define RIG_ADAT 29 +#define RIG_BACKEND_ADAT "adat" +#define RIG_MODEL_ADT_200A RIG_MAKE_MODEL(RIG_ADAT, 1) + + +/* + * ICOM Marine + */ +#define RIG_ICMARINE 30 +#define RIG_BACKEND_ICMARINE "icmarine" +#define RIG_MODEL_IC_M700PRO RIG_MAKE_MODEL(RIG_ICMARINE, 1) +#define RIG_MODEL_IC_M802 RIG_MAKE_MODEL(RIG_ICMARINE, 2) +#define RIG_MODEL_IC_M710 RIG_MAKE_MODEL(RIG_ICMARINE, 3) +#define RIG_MODEL_IC_M803 RIG_MAKE_MODEL(RIG_ICMARINE, 4) + + +/* + * Dorji transceiver modules + */ +#define RIG_DORJI 31 +#define RIG_BACKEND_DORJI "dorji" +#define RIG_MODEL_DORJI_DRA818V RIG_MAKE_MODEL(RIG_DORJI, 1) +#define RIG_MODEL_DORJI_DRA818U RIG_MAKE_MODEL(RIG_DORJI, 2) + +/* + * Barrett + */ +#define RIG_BARRETT 32 +#define RIG_BACKEND_BARRETT "barrett" +#define RIG_MODEL_BARRETT_2050 RIG_MAKE_MODEL(RIG_BARRETT, 1) +#define RIG_MODEL_BARRETT_950 RIG_MAKE_MODEL(RIG_BARRETT, 2) + +/* + * Elad + */ +#define RIG_ELAD 33 +#define RIG_BACKEND_ELAD "elad" +#define RIG_MODEL_ELAD_FDM_DUO RIG_MAKE_MODEL(RIG_ELAD, 1) +//! @endcond + + +/* + * TODO: + RIG_MODEL_KWZ30, KNEISNER +DOERING + RIG_MODEL_E1800, DASA-Telefunken + etc. +*/ + + +/*! \typedef typedef int rig_model_t + \brief Convenience type definition for rig model. +*/ +typedef uint32_t rig_model_t; + + +/* + * struct rig_backend_list { + * rig_model_t model; + * const char *backend; + * } rig_backend_list[] = RIG_LIST; + * + * TODO: + * + { RIG_RADIOSHACK, RIG_BACKEND_RADIOSHACK }, \ + */ + +#endif /* _RIGLIST_H */ diff --git a/hamlib/rotator.h b/hamlib/rotator.h new file mode 100644 index 0000000..83f379e --- /dev/null +++ b/hamlib/rotator.h @@ -0,0 +1,805 @@ +/* + * Hamlib Interface - Rotator API header + * Copyright (c) 2000-2005 by Stephane Fillod + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _ROTATOR_H +#define _ROTATOR_H 1 + +#include +#include + +/** + * \addtogroup rotator + * @{ + */ + +/** + * \file rotator.h + * \brief Hamlib rotator data structures. + * + * This file contains the data structures and declarations for the Hamlib + * rotator Application Programming Interface (API). + * + * See the rotator.c file for more details on the rotator API functions. + */ + + + +__BEGIN_DECLS + +/* Forward struct references */ + +struct rot; +struct rot_state; + + +/** + * \typedef typedef struct s_rot ROT + * \brief Main rotator handle type definition. + * + * The #ROT handle is returned by rot_init() and is passed as a parameter to + * every rotator specific API call. + * + * rot_cleanup() must be called when this handle is no longer needed. + */ +typedef struct s_rot ROT; + + +/** + * \typedef typedef float elevation_t + * \brief Type definition for elevation. + * + * The \a elevation_t type is used as parameter for the rot_set_position() and + * rot_get_position() functions. + * + * Unless specified otherwise, the unit of \a elevation_t is decimal degrees. + */ +typedef float elevation_t; + + +/** + * \typedef typedef float azimuth_t + * \brief Type definition for azimuth. + * + * The \a azimuth_t type is used as parameter for the rot_set_position() and + * rot_get_position() functions. + * + * Unless specified otherwise, the unit of \a azimuth_t is decimal degrees. + */ +typedef float azimuth_t; + + +/** + * \brief The token in the netrotctl protocol for returning an error condition code. + */ +#define NETROTCTL_RET "RPRT " + + +/** + * \def ROT_RESET_ALL + * \brief A macro that returns the flag for the \b reset operation. + * + * \sa rot_reset(), rot_reset_t + */ +#define ROT_RESET_ALL 1 + + +/** + * \typedef typedef int rot_reset_t + * \brief Type definition for rotator reset. + * + * The \a rot_reset_t type is used as parameter for the rot_reset() API + * function. + */ +typedef int rot_reset_t; + + +/** + * \brief Rotator type flags for bitmasks. + */ +typedef enum { + ROT_FLAG_AZIMUTH = (1 << 1), /*!< Azimuth */ + ROT_FLAG_ELEVATION = (1 << 2) /*!< Elevation */ +} rot_type_t; + +//! @cond Doxygen_Suppress +/* So far only used in ests/dumpcaps_rot.c. */ +#define ROT_TYPE_MASK (ROT_FLAG_AZIMUTH|ROT_FLAG_ELEVATION) +//! @endcond + +/** + * \def ROT_TYPE_OTHER + * \brief Other type of rotator. + * \def ROT_TYPE_AZIMUTH + * \brief Azimuth only rotator. + * \def ROT_TYPE_ELEVATION + * \brief Elevation only rotator. + * \def ROT_TYPE_AZEL + * \brief Combination azimuth/elevation rotator. + */ +#define ROT_TYPE_OTHER 0 +#define ROT_TYPE_AZIMUTH ROT_FLAG_AZIMUTH +#define ROT_TYPE_ELEVATION ROT_FLAG_ELEVATION +#define ROT_TYPE_AZEL (ROT_FLAG_AZIMUTH|ROT_FLAG_ELEVATION) + + +/** + * \def ROT_MOVE_UP + * \brief A macro that returns the flag for the \b UP direction. + * + * This macro defines the value of the \b UP direction which can be + * used with the rot_move() function. + * + * \sa rot_move(), ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT, ROT_MOVE_CW + */ +#define ROT_MOVE_UP (1<<1) + +/** + * \def ROT_MOVE_DOWN + * \brief A macro that returns the flag for the \b DOWN direction. + * + * This macro defines the value of the \b DOWN direction which can be + * used with the rot_move() function. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_LEFT, ROT_MOVE_CCW, ROT_MOVE_RIGHT, + * ROT_MOVE_CW +*/ +#define ROT_MOVE_DOWN (1<<2) + +/** + * \def ROT_MOVE_LEFT + * \brief A macro that returns the flag for the \b LEFT direction. + * + * This macro defines the value of the \b LEFT direction which can be + * used with the rot_move function. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_CCW, ROT_MOVE_RIGHT, + * ROT_MOVE_CW + */ +#define ROT_MOVE_LEFT (1<<3) + +/** + * \def ROT_MOVE_CCW + * \brief A macro that returns the flag for the \b counterclockwise direction. + * + * This macro defines the value of the \b counterclockwise direction which + * can be used with the rot_move() function. This value is equivalent to + * ROT_MOVE_LEFT. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_RIGHT, + * ROT_MOVE_CW + */ +#define ROT_MOVE_CCW ROT_MOVE_LEFT + +/** + * \def ROT_MOVE_RIGHT + * \brief A macro that returns the flag for the \b RIGHT direction. + * + * This macro defines the value of the \b RIGHT direction which can be used + * with the rot_move() function. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_CW + */ +#define ROT_MOVE_RIGHT (1<<4) + +/** + * \def ROT_MOVE_CW + * \brief A macro that returns the flag for the \b clockwise direction. + * + * This macro defines the value of the \b clockwise direction which can be + * used with the rot_move() function. This value is equivalent to + * ROT_MOVE_RIGHT. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT + */ +#define ROT_MOVE_CW ROT_MOVE_RIGHT + + +/** + * \brief Rotator status flags + */ +typedef enum { + ROT_STATUS_NONE = 0, /*!< '' -- No status. */ + ROT_STATUS_BUSY = (1 << 0), /*!< Rotator is busy, not accepting commands. */ + ROT_STATUS_MOVING = (1 << 1), /*!< Rotator is currently moving (direction type not specified). */ + ROT_STATUS_MOVING_AZ = (1 << 2), /*!< Azimuth rotator is currently moving (direction not specified). */ + ROT_STATUS_MOVING_LEFT = (1 << 3), /*!< Azimuth rotator is currently moving left. */ + ROT_STATUS_MOVING_RIGHT = (1 << 4), /*!< Azimuth rotator is currently moving right. */ + ROT_STATUS_MOVING_EL = (1 << 5), /*!< Elevation rotator is currently moving (direction not specified). */ + ROT_STATUS_MOVING_UP = (1 << 6), /*!< Elevation rotator is currently moving up. */ + ROT_STATUS_MOVING_DOWN = (1 << 7), /*!< Elevation rotator is currently moving down. */ + ROT_STATUS_LIMIT_UP = (1 << 8), /*!< The elevation rotator has reached its limit to move up. */ + ROT_STATUS_LIMIT_DOWN = (1 << 9), /*!< The elevation rotator has reached its limit to move down.*/ + ROT_STATUS_LIMIT_LEFT = (1 << 10), /*!< The azimuth rotator has reached its limit to move left (CCW). */ + ROT_STATUS_LIMIT_RIGHT = (1 << 11), /*!< The azimuth rotator has reached its limit to move right (CW). */ + ROT_STATUS_OVERLAP_UP = (1 << 12), /*!< The elevation rotator has rotated up past 360 degrees. */ + ROT_STATUS_OVERLAP_DOWN = (1 << 13), /*!< The elevation rotator has rotated down past 0 degrees. */ + ROT_STATUS_OVERLAP_LEFT = (1 << 14), /*!< The azimuth rotator has rotated left (CCW) past 0 degrees. */ + ROT_STATUS_OVERLAP_RIGHT = (1 << 16), /*!< The azimuth rotator has rotated right (CW) past 360 degrees. */ +} rot_status_t; + +//! @cond Doxygen_Suppress +/* So far only used in tests/sprintflst.c. */ +#define ROT_STATUS_N(n) (1u<<(n)) +//! @endcond + +/** + * \brief Macro for not changing the rotator speed with move() function. + */ +#define ROT_SPEED_NOCHANGE (-1) + + +/** + * \brief Rotator Level Settings. + * + * Various operating levels supported by a rotator. + * + * \c STRING used in the \c rotctl and \c rotctld utilities. + * + * \sa rot_parse_level(), rot_strlevel() + */ +enum rot_level_e { + ROT_LEVEL_NONE = 0, /*!< '' -- No Level. */ + ROT_LEVEL_SPEED = (1 << 0), /*!< \c SPEED -- Rotation speed, arg int (default range 1-100 if not specified). */ + ROT_LEVEL_63 = CONSTANT_64BIT_FLAG(63), /*!< **Future use**, last level. */ +}; + + +//! @cond Doxygen_Suppress +#define ROT_LEVEL_FLOAT_LIST (0) + +#define ROT_LEVEL_READONLY_LIST (0) + +#define ROT_LEVEL_IS_FLOAT(l) ((l)&ROT_LEVEL_FLOAT_LIST) +#define ROT_LEVEL_SET(l) ((l)&~ROT_LEVEL_READONLY_LIST) +//! @endcond + + +/** @cond Doxygen_Suppress + * FIXME: The following needs more explanation about how STRING relates + * to this macro. + * @endcond + */ +/** + * \brief Rotator Parameters + * + * Parameters are settings that are not related to core rotator functionality, + * i.e. antenna rotation. + * + * \c STRING used in the \c rotctl and \c rotctld utilities. + * + * \sa rot_parse_parm(), rot_strparm() + */ +enum rot_parm_e { + ROT_PARM_NONE = 0, /*!< '' -- No Parm */ +}; + + +//! @cond Doxygen_Suppress +#define ROT_PARM_FLOAT_LIST (0) +#define ROT_PARM_READONLY_LIST (0) + +#define ROT_PARM_IS_FLOAT(l) ((l)&ROT_PARM_FLOAT_LIST) +#define ROT_PARM_SET(l) ((l)&~ROT_PARM_READONLY_LIST) +//! @endcond + + +/** @cond Doxygen_Suppress + * FIXME: The following needs more explanation about how STRING relates + * to these macros. + * @endcond + */ +/** + * \brief Rotator Function Settings. + * + * Various operating functions supported by a rotator. + * + * \c STRING used in the \c rotctl and \c rotctld utilities. + * + * \sa rot_parse_func(), rot_strfunc() + */ +#define ROT_FUNC_NONE 0 /*!< '' -- No Function */ +#ifndef SWIGLUAHIDE +/* Hide the top 32 bits from the old Lua binding as they can't be represented */ +#define ROT_FUNC_BIT63 CONSTANT_64BIT_FLAG (63) /*!< **Future use**, ROT_FUNC items. */ +/* 63 is this highest bit number that can be used */ +#endif + + +/* Basic rot type, can store some useful info about different rotators. Each + * lib must be able to populate this structure, so we can make useful + * enquiries about capabilities. + */ + +/** + * \struct rot_caps + * \brief Rotator capability data structure. + * + * The main idea of this structure is that it will be defined by the backend + * rotator driver, and will remain read-only for the application. Fields that + * need to be modifiable by the application are copied into the rot_state + * structure, which is the private memory area of the #ROT instance. + * + * This way, you can have several rotators running within the same + * application, sharing the rot_caps structure of the backend, while keeping + * their own customized data. + * + * \b Note: Don't move fields around and only add new fields at the end of the + * rot_caps structure. Shared libraries and DLLs depend on a constant + * structure to maintain compatibility. + */ +struct rot_caps { + rot_model_t rot_model; /*!< Rotator model as defined in rotlist.h. */ + const char *model_name; /*!< Model name, e.g. TT-360. */ + const char *mfg_name; /*!< Manufacturer, e.g. Tower Torquer. */ + const char *version; /*!< Driver version, typically in YYYYMMDD.x format. */ + const char *copyright; /*!< Copyright info (should be LGPL). */ + enum rig_status_e status; /*!< Driver status. */ + + int rot_type; /*!< Rotator type. */ + enum rig_port_e port_type; /*!< Type of communication port (serial, ethernet, etc.). */ + + int serial_rate_min; /*!< Minimal serial speed. */ + int serial_rate_max; /*!< Maximal serial speed. */ + int serial_data_bits; /*!< Number of data bits. */ + int serial_stop_bits; /*!< Number of stop bits. */ + enum serial_parity_e serial_parity; /*!< Parity. */ + enum serial_handshake_e serial_handshake; /*!< Handshake. */ + + int write_delay; /*!< Write delay. */ + int post_write_delay; /*!< Post-write delay. */ + int timeout; /*!< Timeout. */ + int retry; /*!< Number of retries if command fails. */ + + setting_t has_get_func; /*!< List of get functions. */ + setting_t has_set_func; /*!< List of set functions. */ + setting_t has_get_level; /*!< List of get levels. */ + setting_t has_set_level; /*!< List of set levels. */ + setting_t has_get_parm; /*!< List of get parameters. */ + setting_t has_set_parm; /*!< List of set parameters. */ + + rot_status_t has_status; /*!< Supported status flags. */ + + gran_t level_gran[RIG_SETTING_MAX]; /*!< level granularity (i.e. steps). */ + gran_t parm_gran[RIG_SETTING_MAX]; /*!< parm granularity (i.e. steps). */ + + const struct confparams *extparms; /*!< Extension parameters list, \sa rot_ext.c. */ + const struct confparams *extlevels; /*!< Extension levels list, \sa rot_ext.c. */ + const struct confparams *extfuncs; /*!< Extension functions list, \sa rot_ext.c. */ + int *ext_tokens; /*!< Extension token list. */ + + /* + * Movement range, az is relative to North + * negative values allowed for overlap + */ + azimuth_t min_az; /*!< Lower limit for azimuth (relative to North). */ + azimuth_t max_az; /*!< Upper limit for azimuth (relative to North). */ + elevation_t + min_el; /*!< Lower limit for elevation. */ + elevation_t + max_el; /*!< Upper limit for elevation. */ + + + const struct confparams *cfgparams; /*!< Configuration parameters. */ + const rig_ptr_t priv; /*!< Private data. */ + + /* + * Rot Admin API + * + */ + + int (*rot_init)(ROT *rot); /*!< Pointer to backend implementation of ::rot_init(). */ + int (*rot_cleanup)(ROT *rot); /*!< Pointer to backend implementation of ::rot_cleanup(). */ + int (*rot_open)(ROT *rot); /*!< Pointer to backend implementation of ::rot_open(). */ + int (*rot_close)(ROT *rot); /*!< Pointer to backend implementation of ::rot_close(). */ + + int (*set_conf)(ROT *rot, token_t token, const char *val); /*!< Pointer to backend implementation of ::rot_set_conf(). */ + int (*get_conf)(ROT *rot, token_t token, char *val); /*!< Pointer to backend implementation of ::rot_get_conf(). */ + + /* + * General API commands, from most primitive to least.. :() + * List Set/Get functions pairs + */ + + int (*set_position)(ROT *rot, azimuth_t azimuth, elevation_t elevation); /*!< Pointer to backend implementation of ::rot_set_position(). */ + int (*get_position)(ROT *rot, azimuth_t *azimuth, elevation_t *elevation); /*!< Pointer to backend implementation of ::rot_get_position(). */ + + int (*stop)(ROT *rot); /*!< Pointer to backend implementation of ::rot_stop(). */ + int (*park)(ROT *rot); /*!< Pointer to backend implementation of ::rot_park(). */ + int (*reset)(ROT *rot, rot_reset_t reset); /*!< Pointer to backend implementation of ::rot_reset(). */ + int (*move)(ROT *rot, int direction, int speed); /*!< Pointer to backend implementation of ::rot_move(). */ + + /* get firmware info, etc. */ + const char * (*get_info)(ROT *rot); /*!< Pointer to backend implementation of ::rot_get_info(). */ + + int (*set_level)(ROT *rot, setting_t level, value_t val); /*!< Pointer to backend implementation of ::rot_set_level(). */ + int (*get_level)(ROT *rot, setting_t level, value_t *val); /*!< Pointer to backend implementation of ::rot_get_level(). */ + + int (*set_func)(ROT *rot, setting_t func, int status); /*!< Pointer to backend implementation of ::rot_set_func(). */ + int (*get_func)(ROT *rot, setting_t func, int *status); /*!< Pointer to backend implementation of ::rot_get_func(). */ + + int (*set_parm)(ROT *rot, setting_t parm, value_t val); /*!< Pointer to backend implementation of ::rot_set_parm(). */ + int (*get_parm)(ROT *rot, setting_t parm, value_t *val); /*!< Pointer to backend implementation of ::rot_get_parm(). */ + + int (*set_ext_level)(ROT *rot, token_t token, value_t val); /*!< Pointer to backend implementation of ::rot_set_ext_level(). */ + int (*get_ext_level)(ROT *rot, token_t token, value_t *val); /*!< Pointer to backend implementation of ::rot_get_ext_level(). */ + + int (*set_ext_func)(ROT *rot, token_t token, int status); /*!< Pointer to backend implementation of ::rot_set_ext_func(). */ + int (*get_ext_func)(ROT *rot, token_t token, int *status); /*!< Pointer to backend implementation of ::rot_get_ext_func(). */ + + int (*set_ext_parm)(ROT *rot, token_t token, value_t val); /*!< Pointer to backend implementation of ::rot_set_ext_parm(). */ + int (*get_ext_parm)(ROT *rot, token_t token, value_t *val); /*!< Pointer to backend implementation of ::rot_get_ext_parm(). */ + + int (*get_status)(ROT *rot, rot_status_t *status); /*!< Pointer to backend implementation of ::rot_get_status(). */ + + const char *macro_name; /*!< Rotator model macro name. */ +}; +//! @cond Doxygen_Suppress +#define ROT_MODEL(arg) .rot_model=arg,.macro_name=#arg +//! @endcond + + +/** + * \struct rot_state + * \brief Rotator state structure + * + * This structure contains live data, as well as a copy of capability fields + * that may be updated, i.e. customized while the #ROT handle is instantiated. + * + * It is fine to move fields around, as this kind of structure should not be + * initialized like rot_caps are. + */ +struct rot_state { + /* + * overridable fields + */ + azimuth_t min_az; /*!< Lower limit for azimuth (overridable). */ + azimuth_t max_az; /*!< Upper limit for azimuth (overridable). */ + elevation_t min_el; /*!< Lower limit for elevation (overridable). */ + elevation_t max_el; /*!< Upper limit for elevation (overridable). */ + int south_zero; /*!< South is zero degrees. */ + azimuth_t az_offset; /*!< Offset to be applied to azimuth. */ + elevation_t el_offset; /*!< Offset to be applied to elevation. */ + + setting_t has_get_func; /*!< List of get functions. */ + setting_t has_set_func; /*!< List of set functions. */ + setting_t has_get_level; /*!< List of get levels. */ + setting_t has_set_level; /*!< List of set levels. */ + setting_t has_get_parm; /*!< List of get parameters. */ + setting_t has_set_parm; /*!< List of set parameters. */ + + rot_status_t has_status; /*!< Supported status flags. */ + + gran_t level_gran[RIG_SETTING_MAX]; /*!< Level granularity. */ + gran_t parm_gran[RIG_SETTING_MAX]; /*!< Parameter granularity. */ + + /* + * non overridable fields, internal use + */ + hamlib_port_t rotport; /*!< Rotator port (internal use). */ + hamlib_port_t rotport2; /*!< 2nd Rotator port (internal use). */ + + int comm_state; /*!< Comm port state, i.e. opened or closed. */ + rig_ptr_t priv; /*!< Pointer to private rotator state data. */ + rig_ptr_t obj; /*!< Internal use by hamlib++ for event handling. */ + + int current_speed; /*!< Current speed 1-100, to be used when no change to speed is requested. */ + /* etc... */ +}; + + +/** + * \struct s_rot + * \brief Master rotator structure. + * + * This is the master data structure acting as the #ROT handle for the + * controlled rotator. A pointer to this structure is returned by the + * rot_init() API function and is passed as a parameter to every rotator + * specific API call. + * + * \sa rot_init(), rot_caps, rot_state + */ +struct s_rot { + struct rot_caps *caps; /*!< Rotator caps. */ + struct rot_state state; /*!< Rotator state. */ +}; + + +//! @cond Doxygen_Suppress +/* --------------- API function prototypes -----------------*/ + +extern HAMLIB_EXPORT(ROT *) +rot_init HAMLIB_PARAMS((rot_model_t rot_model)); + +extern HAMLIB_EXPORT(int) +rot_open HAMLIB_PARAMS((ROT *rot)); + +extern HAMLIB_EXPORT(int) +rot_close HAMLIB_PARAMS((ROT *rot)); + +extern HAMLIB_EXPORT(int) +rot_cleanup HAMLIB_PARAMS((ROT *rot)); + +extern HAMLIB_EXPORT(int) +rot_set_conf HAMLIB_PARAMS((ROT *rot, + token_t token, + const char *val)); +extern HAMLIB_EXPORT(int) +rot_get_conf HAMLIB_PARAMS((ROT *rot, + token_t token, + char *val)); + +/* + * General API commands, from most primitive to least.. ) + * List Set/Get functions pairs + */ +extern HAMLIB_EXPORT(int) +rot_set_position HAMLIB_PARAMS((ROT *rot, + azimuth_t azimuth, + elevation_t elevation)); +extern HAMLIB_EXPORT(int) +rot_get_position HAMLIB_PARAMS((ROT *rot, + azimuth_t *azimuth, + elevation_t *elevation)); + +extern HAMLIB_EXPORT(int) +rot_stop HAMLIB_PARAMS((ROT *rot)); + +extern HAMLIB_EXPORT(int) +rot_park HAMLIB_PARAMS((ROT *rot)); + +extern HAMLIB_EXPORT(int) +rot_reset HAMLIB_PARAMS((ROT *rot, + rot_reset_t reset)); + +extern HAMLIB_EXPORT(int) +rot_move HAMLIB_PARAMS((ROT *rot, + int direction, + int speed)); + +extern HAMLIB_EXPORT(setting_t) +rot_has_get_level HAMLIB_PARAMS((ROT *rot, + setting_t level)); +extern HAMLIB_EXPORT(setting_t) +rot_has_set_level HAMLIB_PARAMS((ROT *rot, + setting_t level)); + +extern HAMLIB_EXPORT(setting_t) +rot_has_get_parm HAMLIB_PARAMS((ROT *rot, + setting_t parm)); +extern HAMLIB_EXPORT(setting_t) +rot_has_set_parm HAMLIB_PARAMS((ROT *rot, + setting_t parm)); + +extern HAMLIB_EXPORT(setting_t) +rot_has_get_func HAMLIB_PARAMS((ROT *rot, + setting_t func)); +extern HAMLIB_EXPORT(setting_t) +rot_has_set_func HAMLIB_PARAMS((ROT *rot, + setting_t func)); + +extern HAMLIB_EXPORT(int) +rot_set_func HAMLIB_PARAMS((ROT *rot, + setting_t func, + int status)); +extern HAMLIB_EXPORT(int) +rot_get_func HAMLIB_PARAMS((ROT *rot, + setting_t func, + int *status)); + +extern HAMLIB_EXPORT(int) +rot_set_level HAMLIB_PARAMS((ROT *rig, + setting_t level, + value_t val)); +extern HAMLIB_EXPORT(int) +rot_get_level HAMLIB_PARAMS((ROT *rig, + setting_t level, + value_t *val)); + +extern HAMLIB_EXPORT(int) +rot_set_parm HAMLIB_PARAMS((ROT *rig, + setting_t parm, + value_t val)); +extern HAMLIB_EXPORT(int) +rot_get_parm HAMLIB_PARAMS((ROT *rig, + setting_t parm, + value_t *val)); + +extern HAMLIB_EXPORT(int) +rot_set_ext_level HAMLIB_PARAMS((ROT *rig, + token_t token, + value_t val)); +extern HAMLIB_EXPORT(int) +rot_get_ext_level HAMLIB_PARAMS((ROT *rig, + token_t token, + value_t *val)); + +extern HAMLIB_EXPORT(int) +rot_set_ext_func HAMLIB_PARAMS((ROT *rig, + token_t token, + int status)); +extern HAMLIB_EXPORT(int) +rot_get_ext_func HAMLIB_PARAMS((ROT *rig, + token_t token, + int *status)); + +extern HAMLIB_EXPORT(int) +rot_set_ext_parm HAMLIB_PARAMS((ROT *rig, + token_t token, + value_t val)); +extern HAMLIB_EXPORT(int) +rot_get_ext_parm HAMLIB_PARAMS((ROT *rig, + token_t token, + value_t *val)); + +extern HAMLIB_EXPORT(const char *) +rot_get_info HAMLIB_PARAMS((ROT *rot)); + +extern HAMLIB_EXPORT(int) +rot_get_status HAMLIB_PARAMS((ROT *rot, + rot_status_t *status)); + +extern HAMLIB_EXPORT(int) +rot_register HAMLIB_PARAMS((const struct rot_caps *caps)); + +extern HAMLIB_EXPORT(int) +rot_unregister HAMLIB_PARAMS((rot_model_t rot_model)); + +extern HAMLIB_EXPORT(int) +rot_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct rot_caps *, + rig_ptr_t), + rig_ptr_t data)); + +extern HAMLIB_EXPORT(int) +rot_load_backend HAMLIB_PARAMS((const char *be_name)); + +extern HAMLIB_EXPORT(int) +rot_check_backend HAMLIB_PARAMS((rot_model_t rot_model)); + +extern HAMLIB_EXPORT(int) +rot_load_all_backends HAMLIB_PARAMS((void)); + +extern HAMLIB_EXPORT(rot_model_t) +rot_probe_all HAMLIB_PARAMS((hamlib_port_t *p)); + +extern HAMLIB_EXPORT(int) +rot_token_foreach HAMLIB_PARAMS((ROT *rot, + int (*cfunc)(const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); + +extern HAMLIB_EXPORT(const struct confparams *) +rot_confparam_lookup HAMLIB_PARAMS((ROT *rot, + const char *name)); + +extern HAMLIB_EXPORT(token_t) +rot_token_lookup HAMLIB_PARAMS((ROT *rot, + const char *name)); + +extern HAMLIB_EXPORT(int) +rot_ext_func_foreach HAMLIB_PARAMS((ROT *rot, + int (*cfunc)(ROT *, + const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); +extern HAMLIB_EXPORT(int) +rot_ext_level_foreach HAMLIB_PARAMS((ROT *rot, + int (*cfunc)(ROT *, + const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); +extern HAMLIB_EXPORT(int) +rot_ext_parm_foreach HAMLIB_PARAMS((ROT *rot, + int (*cfunc)(ROT *, + const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); + +extern HAMLIB_EXPORT(const struct confparams *) +rot_ext_lookup HAMLIB_PARAMS((ROT *rot, + const char *name)); + +extern HAMLIB_EXPORT(const struct confparams *) +rot_ext_lookup_tok HAMLIB_PARAMS((ROT *rot, + token_t token)); +extern HAMLIB_EXPORT(token_t) +rot_ext_token_lookup HAMLIB_PARAMS((ROT *rot, + const char *name)); + +extern HAMLIB_EXPORT(const struct rot_caps *) +rot_get_caps HAMLIB_PARAMS((rot_model_t rot_model)); + +extern HAMLIB_EXPORT(int) +qrb HAMLIB_PARAMS((double lon1, + double lat1, + double lon2, + double lat2, + double *distance, + double *azimuth)); + +extern HAMLIB_EXPORT(double) +distance_long_path HAMLIB_PARAMS((double distance)); + +extern HAMLIB_EXPORT(double) +azimuth_long_path HAMLIB_PARAMS((double azimuth)); + +extern HAMLIB_EXPORT(int) +longlat2locator HAMLIB_PARAMS((double longitude, + double latitude, + char *locator_res, + int pair_count)); + +extern HAMLIB_EXPORT(int) +locator2longlat HAMLIB_PARAMS((double *longitude, + double *latitude, + const char *locator)); + +extern HAMLIB_EXPORT(double) +dms2dec HAMLIB_PARAMS((int degrees, + int minutes, + double seconds, + int sw)); + +extern HAMLIB_EXPORT(int) +dec2dms HAMLIB_PARAMS((double dec, + int *degrees, + int *minutes, + double *seconds, + int *sw)); + +extern HAMLIB_EXPORT(int) +dec2dmmm HAMLIB_PARAMS((double dec, + int *degrees, + double *minutes, + int *sw)); + +extern HAMLIB_EXPORT(double) +dmmm2dec HAMLIB_PARAMS((int degrees, + double minutes, + double seconds, + int sw)); + +extern HAMLIB_EXPORT(setting_t) rot_parse_func(const char *s); +extern HAMLIB_EXPORT(setting_t) rot_parse_level(const char *s); +extern HAMLIB_EXPORT(setting_t) rot_parse_parm(const char *s); +extern HAMLIB_EXPORT(const char *) rot_strfunc(setting_t); +extern HAMLIB_EXPORT(const char *) rot_strlevel(setting_t); +extern HAMLIB_EXPORT(const char *) rot_strparm(setting_t); +extern HAMLIB_EXPORT(const char *) rot_strstatus(rot_status_t); + +//! @endcond + +/** + * \def rot_debug + * \brief Convenience macro for generating debugging messages. + * + * This is an alias of the rig_debug() function call and is used in the same + * manner. + */ +#define rot_debug rig_debug + +__END_DECLS + +#endif /* _ROTATOR_H */ + +/** @} */ diff --git a/hamlib/rotlist.h b/hamlib/rotlist.h new file mode 100644 index 0000000..338972a --- /dev/null +++ b/hamlib/rotlist.h @@ -0,0 +1,637 @@ +/* + * Hamlib Interface - list of known rotators + * Copyright (c) 2000-2011 by Stephane Fillod + * Copyright (c) 2000-2002 by Frank Singleton + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _ROTLIST_H +#define _ROTLIST_H 1 + +//! @cond Doxygen_Suppress +#define ROT_MAKE_MODEL(a,b) ((a)*100+(b)) +#define ROT_BACKEND_NUM(a) ((a)/100) +//! @endcond + + +/** + * \addtogroup rotator + * @{ + */ + +/** + * \file rotlist.h + * \brief Hamlib rotator model definitions. + * + * This file contains rotator model definitions for the Hamlib rotator + * Application Programming Interface (API). Each distinct rotator type has a + * unique model number (ID) and is used by Hamlib to identify and distinguish + * between the different hardware drivers. The exact model numbers can be + * acquired using the macros in this file. To obtain a list of supported + * rotator branches, one can use the statically defined ROT_BACKEND_LIST macro + * (defined in configure.ac). To obtain a full list of supported rotators + * (including each model in every branch), the foreach_opened_rot() API + * function can be used. + * + * The model number, or ID, is used to tell Hamlib which rotator the client + * wishes to use which is done with the rot_init() API call. + */ + +/** + * \def ROT_MODEL_NONE + * \brief A macro that returns the model number for an unknown model. + * + * The none backend, as the name suggests, does nothing. It is mainly for + * internal use. + */ +#define ROT_MODEL_NONE 0 + + +/** + * \brief A macro that returns the model number for the DUMMY backend. + * + * \def ROT_MODEL_DUMMY + * + * The DUMMY backend, as the name suggests, is a backend which performs + * no hardware operations and always behaves as one would expect. It can + * be thought of as a hardware simulator and is very useful for testing + * client applications. + */ +/** + * \brief A macro that returns the model number for the NETROTCTL backend. + * + * \def ROT_MODEL_NETROTCTL + * + * The NETROTCTL backend allows use of the `rotctld` daemon through the normal + * Hamlib API. + */ +//! @cond Doxygen_Suppress +#define ROT_DUMMY 0 +#define ROT_BACKEND_DUMMY "dummy" +//! @endcond +#define ROT_MODEL_DUMMY ROT_MAKE_MODEL(ROT_DUMMY, 1) +#define ROT_MODEL_NETROTCTL ROT_MAKE_MODEL(ROT_DUMMY, 2) + + +/** + * \brief A macro that returns the model number of the EASYCOMM 1 backend. + * + * \def ROT_MODEL_EASYCOMM1 + * + * The EASYCOMM1 backend can be used with rotators that support the EASYCOMM + * I Standard. + */ +/** + * \brief A macro that returns the model number of the EASYCOMM 2 backend. + * + * \def ROT_MODEL_EASYCOMM2 + * + * The EASYCOMM2 backend can be used with rotators that support the EASYCOMM + * II Standard. + */ +/** + * \brief A macro that returns the model number of the EASYCOMM 3 backend. + * + * \def ROT_MODEL_EASYCOMM3 + * + * The EASYCOMM3 backend can be used with rotators that support the EASYCOMM + * III Standard. + */ +//! @cond Doxygen_Suppress +#define ROT_EASYCOMM 2 +#define ROT_BACKEND_EASYCOMM "easycomm" +//! @endcond +#define ROT_MODEL_EASYCOMM1 ROT_MAKE_MODEL(ROT_EASYCOMM, 1) +#define ROT_MODEL_EASYCOMM2 ROT_MAKE_MODEL(ROT_EASYCOMM, 2) +#define ROT_MODEL_EASYCOMM3 ROT_MAKE_MODEL(ROT_EASYCOMM, 4) + + +/** + * \brief A macro that returns the model number of the FODTRACK backend. + * + * \def ROT_MODEL_FODTRACK + * + * The FODTRACK backend can be used with rotators that support the FODTRACK + * Standard. + */ +//! @cond Doxygen_Suppress +#define ROT_FODTRACK 3 +#define ROT_BACKEND_FODTRACK "fodtrack" +//! @endcond +#define ROT_MODEL_FODTRACK ROT_MAKE_MODEL(ROT_FODTRACK, 1) + + +/** + * \brief A macro that returns the model number of the ROTOREZ backend. + * + * \def ROT_MODEL_ROTOREZ + * + * The ROTOREZ backend can be used with Hy-Gain rotators that support the + * extended DCU command set by the Idiom Press Rotor-EZ board. + */ +/** + * \brief A macro that returns the model number of the ROTORCARD backend. + * + * \def ROT_MODEL_ROTORCARD + * + * The ROTORCARD backend can be used with Yaesu rotators that support the + * extended DCU command set by the Idiom Press Rotor Card board. + */ +/** + * \brief A macro that returns the model number of the DCU backend. + * + * \def ROT_MODEL_DCU + * + * The DCU backend can be used with rotators that support the DCU command set + * by Hy-Gain (currently the DCU-1). + */ +/** + * \brief A macro that returns the model number of the ERC backend. + * + * \def ROT_MODEL_ERC + * + * The ERC backend can be used with rotators that support the DCU command set + * by DF9GR (currently the ERC). + */ +/** + * \brief A macro that returns the model number of the RT21 backend. + * + * \def ROT_MODEL_RT21 + * + * The RT21 backend can be used with rotators that support the DCU command set + * by Green Heron (currently the RT-21). + */ +//! @cond Doxygen_Suppress +#define ROT_ROTOREZ 4 +#define ROT_BACKEND_ROTOREZ "rotorez" +//! @endcond +#define ROT_MODEL_ROTOREZ ROT_MAKE_MODEL(ROT_ROTOREZ, 1) +#define ROT_MODEL_ROTORCARD ROT_MAKE_MODEL(ROT_ROTOREZ, 2) +#define ROT_MODEL_DCU ROT_MAKE_MODEL(ROT_ROTOREZ, 3) +#define ROT_MODEL_ERC ROT_MAKE_MODEL(ROT_ROTOREZ, 4) +#define ROT_MODEL_RT21 ROT_MAKE_MODEL(ROT_ROTOREZ, 5) + + +/** + * \brief A macro that returns the model number of the SARTEK1 backend. + * + * \def ROT_MODEL_SARTEK1 + * + * The SARTEK1 backend can be used with rotators that support the SARtek + * protocol. + */ +//! @cond Doxygen_Suppress +#define ROT_SARTEK 5 +#define ROT_BACKEND_SARTEK "sartek" +//! @endcond +#define ROT_MODEL_SARTEK1 ROT_MAKE_MODEL(ROT_SARTEK, 1) + + +/** + * \brief A macro that returns the model number of the GS232A backend. + * + * \def ROT_MODEL_GS232A + * + * The GS232A backend can be used with rotators that support the GS-232A + * protocol. + */ +/** + * \brief A macro that returns the model number of the GS232 backend. + * + * \def ROT_MODEL_GS232_GENERIC + * + * The GS232_GENERIC backend can be used with rotators that support the + * generic (even if not coded correctly) GS-232 protocol. + */ +/** + * \brief A macro that returns the model number of the GS232B backend. + * + * \def ROT_MODEL_GS232B + * + * The GS232B backend can be used with rotators that support the GS232B + * protocol. + */ +/** + * \brief A macro that returns the model number of the F1TETRACKER backend. + * + * \def ROT_MODEL_F1TETRACKER + * + * The F1TETRACKER backend can be used with rotators that support the F1TE + * Tracker protocol. + */ +/** + * \brief A macro that returns the model number of the GS23 backend. + * + * \def ROT_MODEL_GS23 + * + * The GS23 backend can be used with rotators that support the GS-23 protocol. + */ +/** + * \brief A macro that returns the model number of the GS232 backend. + * + * \def ROT_MODEL_GS232 + * + * The GS232 backend can be used with rotators that support the GS-232 + * protocol. + */ +/** + * \brief A macro that returns the model number of the LVB backend. + * + * \def ROT_MODEL_LVB + * + * The LVB backend can be used with rotators that support the G6LVB AMSAT LVB + * Tracker GS-232 based protocol. + */ +/** + * \brief A macro that returns the model number of the ST2 backend. + * + * \def ROT_MODEL_ST2 + * + * The ST2 backend can be used with rotators that support the Fox Delta ST2 + * GS-232 based protocol. + */ +/** + * \brief A macro that returns the model number of the GS232A_AZ Azimuth backend. + * + * \def ROT_MODEL_GS232A_AZ + * + * The GS232A_AZ backend can be used with azimuth rotators that support the + * GS-232A protocol. + */ +/** + * \brief A macro that returns the model number of the GS232A_EL Elevation backend. + * + * \def ROT_MODEL_GS232A_EL + * + * The GS232A_EL backend can be used with elevation rotators that support the + * GS-232A protocol. + */ +/** + * \brief A macro that returns the model number of the GS232B_AZ Azimuth backend. + * + * \def ROT_MODEL_GS232B_AZ + * + * The GS232B_AZ backend can be used with azimuth rotators that support the + * GS-232B protocol. + */ +/** + * \brief A macro that returns the model number of the GS232B_EL Elevation backend. + * + * \def ROT_MODEL_GS232B_EL + * + * The GS232B_EL backend can be used with elevation rotators that support the + * GS-232B protocol. + */ + +//! @cond Doxygen_Suppress +#define ROT_GS232A 6 +#define ROT_BACKEND_GS232A "gs232a" +//! @endcond +#define ROT_MODEL_GS232A ROT_MAKE_MODEL(ROT_GS232A, 1) +#define ROT_MODEL_GS232_GENERIC ROT_MAKE_MODEL(ROT_GS232A, 2) /* GENERIC */ +#define ROT_MODEL_GS232B ROT_MAKE_MODEL(ROT_GS232A, 3) +#define ROT_MODEL_F1TETRACKER ROT_MAKE_MODEL(ROT_GS232A, 4) +#define ROT_MODEL_GS23 ROT_MAKE_MODEL(ROT_GS232A, 5) +#define ROT_MODEL_GS232 ROT_MAKE_MODEL(ROT_GS232A, 6) /* Not A or B */ +#define ROT_MODEL_LVB ROT_MAKE_MODEL(ROT_GS232A, 7) +#define ROT_MODEL_ST2 ROT_MAKE_MODEL(ROT_GS232A, 8) +#define ROT_MODEL_GS232A_AZ ROT_MAKE_MODEL(ROT_GS232A, 9) +#define ROT_MODEL_GS232A_EL ROT_MAKE_MODEL(ROT_GS232A, 10) +#define ROT_MODEL_GS232B_AZ ROT_MAKE_MODEL(ROT_GS232A, 11) +#define ROT_MODEL_GS232B_EL ROT_MAKE_MODEL(ROT_GS232A, 12) + + +/** + * \brief A macro that returns the model number of the PCROTOR backend. + * + * \def ROT_MODEL_PCROTOR + * + * The PCROTOR backend is a member of the kit backend group that can be used + * with home brewed rotators. + */ +//! @cond Doxygen_Suppress +#define ROT_KIT 7 +#define ROT_BACKEND_KIT "kit" +//! @endcond +#define ROT_MODEL_PCROTOR ROT_MAKE_MODEL(ROT_KIT, 1) + + +/** + * \brief A macro that returns the model number of the HD1780 backend. + * + * \def ROT_MODEL_HD1780 + * + * The HD1780 backend can be used with rotators that support the Heathkit + * HD-1780 protocol. + */ +//! @cond Doxygen_Suppress +#define ROT_HEATHKIT 8 +#define ROT_BACKEND_HEATHKIT "heathkit" +//! @endcond +#define ROT_MODEL_HD1780 ROT_MAKE_MODEL(ROT_HEATHKIT, 1) + + +/** + * \brief A macro that returns the model number of the ROT2PROG backend. + * + * \def ROT_MODEL_SPID_ROT2PROG + * + * The SPID_ROT2PROG backend can be used with rotators that support the SPID + * azimuth and elevation protocol. + */ +/** + * \brief A macro that returns the model number of the ROT1PROG backend. + * + * \def ROT_MODEL_SPID_ROT1PROG + * + * The SPID_ROT1PROG backend can be used with rotators that support the SPID + * azimuth protocol. + */ +/** + * \brief A macro that returns the model number of the SPID_MD01_ROT2PROG backend. + * + * \def ROT_MODEL_SPID_MD01_ROT2PROG + * + * The SPID_MD01_ROT2PROG backend can be used with rotators that support the + * extended SPID ROT2PROG azimuth and elevation protocol. + */ +//! @cond Doxygen_Suppress +#define ROT_SPID 9 +#define ROT_BACKEND_SPID "spid" +//! @endcond +#define ROT_MODEL_SPID_ROT2PROG ROT_MAKE_MODEL(ROT_SPID, 1) +#define ROT_MODEL_SPID_ROT1PROG ROT_MAKE_MODEL(ROT_SPID, 2) +#define ROT_MODEL_SPID_MD01_ROT2PROG ROT_MAKE_MODEL(ROT_SPID, 3) + + +/** + * \brief A macro that returns the model number of the RC2800 backend. + * + * \def ROT_MODEL_RC2800 + * + * The RC2800 backend can be used with rotators that support the M2 (M + * Squared) RC2800 protocol. + */ +/** + * \brief A macro that returns the model number of the RC2800_EARLY_AZ + * backend. + * + * \def ROT_MODEL_RC2800_EARLY_AZ + * + * The RC2800_EARLY_AZ backend can be used with rotators that support the M2 + * (M Squared) RC2800 early azimuth protocol. + */ +/** + * \brief A macro that returns the model number of the RC2800_EARLY_AZEL + * backend. + * + * \def ROT_MODEL_RC2800_EARLY_AZEL + * + * The RC2800_EARLY_AZEL backend can be used with rotators that support the M2 + * (M Squared) RC2800 early azimuth and elevation protocol. + */ +//! @cond Doxygen_Suppress +#define ROT_M2 10 +#define ROT_BACKEND_M2 "m2" +//! @endcond +#define ROT_MODEL_RC2800 ROT_MAKE_MODEL(ROT_M2, 1) +#define ROT_MODEL_RC2800_EARLY_AZ ROT_MAKE_MODEL(ROT_M2, 2) +#define ROT_MODEL_RC2800_EARLY_AZEL ROT_MAKE_MODEL(ROT_M2, 3) + + +/** + * \brief A macro that returns the model number of the RCI_AZEL backend. + * + * \def ROT_MODEL_RCI_AZEL + * + * The RCI_AZEL backend can be used with rotators that support the ARS azimuth + * and elevation protocol. + */ +/** + * \brief A macro that returns the model number of the RCI_AZ backend. + * + * \def ROT_MODEL_RCI_AZ + * + * The RCI_AZ backend can be used with rotators that support the ARS azimuth + * protocol. + */ +//! @cond Doxygen_Suppress +#define ROT_ARS 11 +#define ROT_BACKEND_ARS "ars" +//! @endcond +#define ROT_MODEL_RCI_AZEL ROT_MAKE_MODEL(ROT_ARS, 1) +#define ROT_MODEL_RCI_AZ ROT_MAKE_MODEL(ROT_ARS, 2) + + +/** + * \brief A macro that returns the model number of the IF100 backend. + * + * \def ROT_MODEL_IF100 + * + * The IF100 backend can be used with rotators that support the AMSAT IF-100 + * interface. + */ +//! @cond Doxygen_Suppress +#define ROT_AMSAT 12 +#define ROT_BACKEND_AMSAT "amsat" +//! @endcond +#define ROT_MODEL_IF100 ROT_MAKE_MODEL(ROT_AMSAT, 1) + + +/** + * \brief A macro that returns the model number of the TS7400 backend. + * + * \def ROT_MODEL_TS7400 + * + * The TS7400 backend supports an embedded ARM board using the TS-7400 Linux + * board. More information is at https://www.embeddedarm.com + */ +//! @cond Doxygen_Suppress +#define ROT_TS7400 13 +#define ROT_BACKEND_TS7400 "ts7400" +//! @endcond +#define ROT_MODEL_TS7400 ROT_MAKE_MODEL(ROT_TS7400, 1) + + +/** + * \brief A macro that returns the model number of the NEXSTAR backend. + * + * \def ROT_MODEL_NEXSTAR + * + * The NEXSTAR backend can be used with rotators that support the Celestron + * NexStar protocol and alike. + */ +//! @cond Doxygen_Suppress +#define ROT_CELESTRON 14 +#define ROT_BACKEND_CELESTRON "celestron" +//! @endcond +#define ROT_MODEL_NEXSTAR ROT_MAKE_MODEL(ROT_CELESTRON, 1) + + +/** + * \brief A macro that returns the model number of the ETHER6 backend. + * + * \def ROT_MODEL_ETHER6 + * + * The ETHER6 backend can be used with rotators that support the Ether6 + * protocol. + */ +//! @cond Doxygen_Suppress +#define ROT_ETHER6 15 +#define ROT_BACKEND_ETHER6 "ether6" +//! @endcond +#define ROT_MODEL_ETHER6 ROT_MAKE_MODEL(ROT_ETHER6, 1) + + +/** + * \brief A macro that returns the model number of the CNCTRK backend. + * + * \def ROT_MODEL_CNCTRK + * + * The CNCTRK backend can be used with rotators that support the LinuxCNC + * running Axis GUI interface. + */ +//! @cond Doxygen_Suppress +#define ROT_CNCTRK 16 +#define ROT_BACKEND_CNCTRK "cnctrk" +//! @endcond +#define ROT_MODEL_CNCTRK ROT_MAKE_MODEL(ROT_CNCTRK, 1) + + +/** + * \brief A macro that returns the model number of the PROSISTEL_D_AZ backend. + * + * \def ROT_MODEL_PROSISTEL_D_AZ + * + * The PROSISTEL_D_AZ backend can be used with rotators that support the Prosistel + * azimuth protocol. + */ +/** + * \brief A macro that returns the model number of the PROSISTEL_D_EL backend. + * + * \def ROT_MODEL_PROSISTEL_D_EL + * + * The PROSISTEL_D_EL backend can be used with rotators that support the Prosistel + * elevation protocol. + */ +/** + * \brief A macro that returns the model number of the + * PROSISTEL_COMBI_TRACK_AZEL backend. + * + * \def ROT_MODEL_PROSISTEL_COMBI_TRACK_AZEL + * + * The PROSISTEL_AZEL_COMBI_TRACK_AZEL backend can be used with rotators that + * support the Prosistel combination azimuth and elevation protocol. + */ +//! @cond Doxygen_Suppress +#define ROT_PROSISTEL 17 +#define ROT_BACKEND_PROSISTEL "prosistel" +//! @endcond +#define ROT_MODEL_PROSISTEL_D_AZ ROT_MAKE_MODEL(ROT_PROSISTEL, 1) +#define ROT_MODEL_PROSISTEL_D_EL ROT_MAKE_MODEL(ROT_PROSISTEL, 2) +#define ROT_MODEL_PROSISTEL_COMBI_TRACK_AZEL ROT_MAKE_MODEL(ROT_PROSISTEL, 3) + + +/** + * \brief A macro that returns the model number of the MEADE backend. + * + * \def ROT_MODEL_MEADE + * + * The MEADE backend can be used with Meade telescope rotators like the + * DS-2000. + */ +//! @cond Doxygen_Suppress +#define ROT_MEADE 18 +#define ROT_BACKEND_MEADE "meade" +//! @endcond +#define ROT_MODEL_MEADE ROT_MAKE_MODEL(ROT_MEADE, 1) + +/** + * \brief A macro that returns the model number of the IOPTRON backend. + * + * \def ROT_MODEL_IOPTRON + * + * The IOPTRON backend can be used with IOPTRON telescope mounts. + */ +//! @cond Doxygen_Suppress +#define ROT_IOPTRON 19 +#define ROT_BACKEND_IOPTRON "ioptron" +//! @endcond +#define ROT_MODEL_IOPTRON ROT_MAKE_MODEL(ROT_IOPTRON, 1) + + +/** + * \brief A macro that returns the model number of the INDI backend. + * + * \def ROT_MODEL_INDI + * + * The INDI backend can be used with rotators that support the INDI interface. + */ +//! @cond Doxygen_Suppress +#define ROT_INDI 20 +#define ROT_BACKEND_INDI "indi" +//! @endcond +#define ROT_MODEL_INDI ROT_MAKE_MODEL(ROT_INDI, 1) + + +/** + * \brief A macro that returns the model number of the SATEL backend. + * + * \def ROT_MODEL_SATEL + * + * The SATEL backend can be used with rotators that support the VE5FP + * interface. + */ +//! @cond Doxygen_Suppress +#define ROT_SATEL 21 +#define ROT_BACKEND_SATEL "satel" +//! @endcond +#define ROT_MODEL_SATEL ROT_MAKE_MODEL(ROT_SATEL, 1) + + +/** + * \brief A macro that returns the model number of the RADANT backend. + * + * \def ROT_MODEL_RADANT + * + * The RADANT backend can be used with rotators that support the MS232 + * interface. + */ +//! @cond Doxygen_Suppress +#define ROT_RADANT 22 +#define ROT_BACKEND_RADANT "radant" +//! @endcond +#define ROT_MODEL_RADANT ROT_MAKE_MODEL(ROT_RADANT, 1) + + +#define ROT_ANDROIDSENSOR 23 +#define ROT_BACKEND_ANDROIDSENSOR "androidsensor" +#define ROT_MODEL_ANDROIDSENSOR ROT_MAKE_MODEL(ROT_ANDROIDSENSOR, 1) + + +/** + * \brief Convenience type definition for a rotator model. + * + * \typedef typedef int rot_model_t +*/ +typedef int rot_model_t; + + +#endif /* _ROTLIST_H */ + +/** @} */ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..f8a5cf6 --- /dev/null +++ b/main.cpp @@ -0,0 +1,43 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + +#include "mainwindow.h" + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + +/* + QFile file("./CatRadio.qss"); //open qss file + //if(!file.open(QFile::ReadOnly)) + file.open(QFile::ReadOnly); + + QString styleSheet (file.readAll()); + file.close(); + + a.setStyleSheet(styleSheet); //setup stylesheet +*/ + + w.show(); + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..9890bcc --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,1014 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "dialogconfig.h" +#include "dialogsetup.h" +#include "rigdaemon.h" +#include "rigdata.h" +#include "guidata.h" +#include "rigcommand.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include //Hamlib + +extern RIG *my_rig; //Defined in rigdaemon.cpp + +extern rigConnect rigCom; +extern rigSettings rigGet; +extern rigSettings rigSet; +extern rigCommand rigCmd; +extern rigCommand rigCap; +extern guiConfig guiConf; + +int retcode; //Return code from function +int i; //Index +int prevDial; //Previous dial value +int fastDial; //Fast pushbutton state + +FILE* debugFile; + + +QThread workerThread; // +RigDaemon *rigDaemon = new RigDaemon; + + +//***** MainWindow ***** + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + timer = new QTimer(this); //timer for rigDaemon thread call + + //* Debug + rig_set_debug_level(RIG_DEBUG_WARN); + rig_set_debug_time_stamp(true); + if ((debugFile=fopen("debug.log","w+")) == NULL) rig_set_debug_level(RIG_DEBUG_NONE); + else rig_set_debug_file(debugFile); + + //* Signal and Slot connection for Slider and associated Label + connect(ui->verticalSlider_RFpower, &QAbstractSlider::valueChanged, ui->label_RFpowerValue, QOverload::of(&QLabel::setNum)); + connect(ui->verticalSlider_RFgain, &QAbstractSlider::valueChanged, ui->label_RFgainValue, QOverload::of(&QLabel::setNum)); + connect(ui->verticalSlider_AFGain, &QAbstractSlider::valueChanged, ui->label_AFGainValue, QOverload::of(&QLabel::setNum)); + connect(ui->verticalSlider_Squelch, &QAbstractSlider::valueChanged, ui->label_SquelchValue, QOverload::of(&QLabel::setNum)); + connect(ui->horizontalSlider_IFshift, &QAbstractSlider::valueChanged, ui->label_IFshiftValue,QOverload::of(&QLabel::setNum)); + + //* Signal and Slot connection for vfoDisplay + connect(ui->lineEdit_vfoMain, &vfoDisplay::on_valueChanged, this, &MainWindow::on_vfoDisplayValueChanged); + + //* Thread for RigDaemon + rigDaemon->moveToThread(&workerThread); // + connect(&workerThread, &QThread::finished, rigDaemon, &QObject::deleteLater); + connect(timer, &QTimer::timeout, rigDaemon, &RigDaemon::rigUpdate); + connect(rigDaemon, &RigDaemon::resultReady, this, &MainWindow::on_rigDaemonResultReady); + workerThread.start(); + + //* Load settings from config.ini + QSettings configFile(QString("config.ini"), QSettings::IniFormat); + rigCom.rigModel = configFile.value("rigModel", 0).toInt(); + rigCom.rigPort = configFile.value("rigPort").toString(); + rigCom.serialSpeed = configFile.value("serialSpeed", 9600).toInt(); + rigCom.civAddr = configFile.value("civAddress", 0).toInt(); + rigCom.rigRefresh = configFile.value("rigRefresh", 100).toInt(); + rigCom.fullPoll = configFile.value("fullPolling", true).toBool(); + guiConf.vfoDisplayMode = configFile.value("vfoDisplayMode", 0).toInt(); + + //* Style + //ui->pushButton_PTT->setStyleSheet("QPushButton::checked {font: bold; color: red;}"); +} + +MainWindow::~MainWindow() +{ + workerThread.quit(); // + workerThread.wait(); + + if (rigCom.connected) + { + timer->stop(); + + rigCom.connected = 0; + rig_close(my_rig); //Close the communication to the rig + } + + rig_cleanup(my_rig); //Release rig handle and free associated memory + + fclose(debugFile); //Close debug.log + + delete ui; +} + + +//***** GUI function ***** + +void MainWindow::guiInit() +{ + ui->statusbar->showMessage(my_rig->caps->model_name); + + if (rig_has_set_func(my_rig, RIG_FUNCTION_SET_POWERSTAT)==0) //Power pushbutton + { + ui->pushButton_Power->setDisabled(true); + rigCap.onoff = 0; + } + else + { + ui->pushButton_Power->setDisabled(false); + rigCap.onoff = 1; + } + + if (rig_has_set_func(my_rig, RIG_FUNCTION_SET_PTT)==0) //PTT pushbutton + { + ui->pushButton_PTT->setDisabled(true); + rigCap.ptt = 0; + } + else + { + ui->pushButton_PTT->setDisabled(false); + rigCap.ptt = 1; + } + + //* Mode combobox + if (my_rig->state.mode_list==RIG_MODE_NONE) + { + ui->comboBox_Mode->setDisabled(true); + ui->comboBox_ModeSub->setDisabled(true); + } + else + { + ui->comboBox_Mode->clear(); //Clear old contents + ui->comboBox_ModeSub->clear(); + for (i=0; istate.mode_list & (1ULL << i)) + { + ui->comboBox_Mode->addItem(rig_strrmode(my_rig->state.mode_list & (1ULL << i))); + ui->comboBox_ModeSub->addItem(rig_strrmode(my_rig->state.mode_list & (1ULL << i))); + } + } + ui->comboBox_ModeSub->addItem(rig_strrmode(RIG_MODE_NONE)); //add None mode in the modeSub list, used in case mode sub vfo is not targetable + rigCmd.bwidthList = 1; //Command to populate BW combobox in guiUpdate() + } + + //* AGC level comboBox + ui->comboBox_AGC->clear(); + /* It seems that has_set_level or has_get_level is not well implemented in Hamlib, at the moment it is skipped in favour of fix values entry + agc_level_e agcLevel; + for (i = 0; i < 7; i++) + { + agcLevel = levelagcvalue(i); + if (rig_has_set_level(my_rig, agcLevel)) + { + ui->comboBox_AGC->addItem(rig_stragclevel(agcLevel)); + } + }*/ + ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_OFF)); + ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_AUTO)); + ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_FAST)); + ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_MEDIUM)); + ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_SLOW)); + + //* Meter comboBox + ui->comboBox_Meter->clear(); + if (rig_has_get_level(my_rig, RIG_METER_SWR)) ui->comboBox_Meter->addItem("SWR"); + if (rig_has_get_level(my_rig, RIG_METER_ALC)) ui->comboBox_Meter->addItem("ALC"); + rigSet.meter = levelmeterstr (ui->comboBox_Meter->currentText()); + setSubMeter(); + + //* Attenuator comboBox + ui->comboBox_Att->clear(); + ui->comboBox_Att->addItem("0"); + for (i = 0; i < HAMLIB_MAXDBLSTSIZ && my_rig->state.attenuator[i] != 0; i++) + { + ui->comboBox_Att->addItem(QString::number(my_rig->state.attenuator[i])); + } + + //* Preamp comboBox + ui->comboBox_Preamp->clear(); + ui->comboBox_Preamp->addItem("0"); + for (i = 0; i < HAMLIB_MAXDBLSTSIZ && my_rig->state.preamp[i] != 0; i++) + { + ui->comboBox_Preamp->addItem(QString::number(my_rig->state.preamp[i])); + } + + //* Tone + ui->comboBox_toneType->clear(); + ui->comboBox_toneType->addItem(" "); //None + ui->comboBox_toneType->addItem("1750Hz"); //Burst 1750 Hz + ui->comboBox_toneType->addItem("TONE"); //CTCSS Tx + ui->comboBox_toneType->addItem("TSQL"); //CTCSS Tx + Rx squelch + //ui->comboBox_toneType->addItem("DTONE"); //DCS Tx + //ui->comboBox_toneType->addItem("DTSQL"); //DCS Tx + Rx squelch + + rigCmd.rangeList = 1; //update range list + rigCmd.antList = 1; //update antenna list + rigCmd.toneList = 1; //update tone list + + rigCap.modeSub = 1; //assume targetable mode for sub VFO, will be checked later + + /* + if (my_rig->caps->targetable_vfo) //check for targetable sub VFO + rigCap.modeSub = 1; //assume also targetable mode for sub VFO, will be checked later + else + { + rigCap.modeSub = 0; //disable get/set mode for subVFO + ui->radioButton_VFOSub->setCheckable(false); //disable VFOsub radio button + }*/ +} + +void MainWindow::guiUpdate() +{ + //* Power button + if (rigGet.onoff == RIG_POWER_ON) ui->pushButton_Power->setChecked(true); + + //* VFOs + ui->lineEdit_vfoMain->setValue(rigGet.freqMain); + ui->lineEdit_vfoSub->setText(QString::number(rigGet.freqSub/1000,'f',2)); + + ui->label_vfoMain->setText(rig_strvfo(rigGet.vfoMain)); + switch (rigGet.vfoMain) + { + case RIG_VFO_A: rigGet.vfoSub = RIG_VFO_B; break; + case RIG_VFO_B: rigGet.vfoSub = RIG_VFO_A; break; + case RIG_VFO_MAIN: rigGet.vfoSub = RIG_VFO_SUB; break; + case RIG_VFO_SUB: rigGet.vfoSub = RIG_VFO_MAIN; break; + } + ui->label_vfoSub->setText(rig_strvfo(rigGet.vfoSub)); + + //* Mode + ui->comboBox_Mode->setCurrentText(rig_strrmode(rigGet.mode)); + ui->comboBox_ModeSub->setCurrentText(rig_strrmode(rigGet.modeSub)); + + if (rigGet.mode == RIG_MODE_CW || rigGet.mode == RIG_MODE_CWR || rigGet.mode == RIG_MODE_CWN) ui->tabWidget->setCurrentIndex(0); //CW tab + if (rigGet.mode == RIG_MODE_FM || rigGet.mode == RIG_MODE_FMN || rigGet.mode == RIG_MODE_PKTFM || rigGet.mode == RIG_MODE_PKTFMN || rigGet.mode == RIG_MODE_C4FM || rigGet.mode == RIG_MODE_DSTAR) ui->tabWidget->setCurrentIndex(1); //FM tab + + //* BW combobox + if (rigCmd.bwidthList) + { + ui->comboBox_BW->clear(); + filter_list bwidth_list; //IF filter bandwidth per mode + for (i=0; istate.filters[i]); i++) + { + char modeslist[1000] = ""; + QString modes, mode; + bwidth_list = my_rig->state.filters[i]; + rig_strrmodes(bwidth_list.modes, modeslist, sizeof(modeslist)); + modes = modeslist; + modes.append(" "); + mode = rig_strrmode(rigGet.mode); + if (mode != "") + { + //qDebug() << modes << mode << bwidth_list.width; + QRegularExpression rx("\\b"+mode+"?\\s"); + if (modes.contains (rx) && bwidth_list.width != RIG_FLT_ANY) ui->comboBox_BW->addItem(QString::number(bwidth_list.width)); + } + //else qDebug() << "vuoto" << rigGet.mode; + } + ui->comboBox_BW->model()->sort(0, Qt::DescendingOrder); + rigCmd.bwidthList = 0; + } + + ui->comboBox_BW->setCurrentText(QString::number(rigGet.bwidth)); + ui->checkBox_NAR->setChecked(rigGet.bwNarrow); + + //* Range list + if (rigCmd.rangeList) + { + for (i=0; i= my_rig->state.tx_range_list[i].startf && rigGet.freqMain <= my_rig->state.tx_range_list[i].endf) break; + } + rigGet.rangeListTxIndex = i; + + for (i=0; i= my_rig->state.rx_range_list[i].startf && rigGet.freqMain <= my_rig->state.rx_range_list[i].endf) break; + } + if (rigGet.rangeListRxIndex != i) rigCmd.antList = 1; + rigGet.rangeListRxIndex = i; + + rigCmd.rangeList = 0; + } + + //* Antenna list + if (rigCmd.antList) + { + ui->comboBox_Ant->clear(); + if (my_rig->state.tx_range_list[rigGet.rangeListRxIndex].ant == RIG_ANT_NONE) ui->comboBox_Ant->addItem("NONE"); //RIG_ANT_NONE + else for (i=0; i < RIG_ANT_MAX; i++) + { + if (my_rig->state.tx_range_list[rigGet.rangeListRxIndex].ant & (1UL << i)) + { + switch (i) + { + case 0: ui->comboBox_Ant->addItem("ANT1"); break; //RIG_ANT_1 + case 1: ui->comboBox_Ant->addItem("ANT2"); break; //RIG_ANT_2 + case 2: ui->comboBox_Ant->addItem("ANT3"); break; //RIG_ANT_3 + case 3: ui->comboBox_Ant->addItem("ANT4"); break; //RIG_ANT_4 + case 4: ui->comboBox_Ant->addItem("ANT5"); break; //RIG_ANT_5 + case 30: ui->comboBox_Ant->addItem("UNK"); break; //RIG_ANT_UNKNOWN + case 31: ui->comboBox_Ant->addItem("CURR"); break; //RIG_ANT_CURR + default: ui->comboBox_Ant->addItem("UNK"); break; + } + } + } + rigCmd.antList = 0; + } + + //* Tone list + if (rigCmd.toneList) + { + ui->comboBox_toneFreq->clear(); + + if (rigGet.toneType == 2 || rigGet.toneType == 3) + { + for (i = 0; i < CTCSS_LIST_SIZE; i++) //CTCSS tone + { + if (my_rig->caps->ctcss_list[i] == 0) break; + ui->comboBox_toneFreq->addItem(QString::number(my_rig->caps->ctcss_list[i]/10.0,'f',1)); + } + } + + //for (i = 0; i < DCS_LIST_SIZE; i++) //DCS tone + //{ + // if (my_rig->caps->dcs_list[i] == 0) break; + // ui->comboBox_toneFreq->addItem(QString::number(my_rig->caps->dcs_list[i])); + //} + + rigCmd.toneList = 0; + } + + //* RF + ui->radioButton_Tuner->setChecked(rigGet.tuner); + ui->comboBox_AGC->setCurrentText(rig_stragclevel(rigGet.agc)); + ui->comboBox_Att->setCurrentText(QString::number(rigGet.att)); + ui->comboBox_Preamp->setCurrentText(QString::number(rigGet.pre)); + + //* Split + if (rigGet.split == RIG_SPLIT_ON) + { + ui->pushButton_Split->setChecked(true); + if (rigGet.vfoSub == rigGet.vfoTx) + { + ui->label_vfoMainRxTx->setText("RX"); + ui->label_vfoSubRxTx->setText("TX"); + } + else + { + ui->label_vfoMainRxTx->setText("TX"); + ui->label_vfoSubRxTx->setText("RX"); + } + } + else + { + ui->pushButton_Split->setChecked(false); + ui->label_vfoMainRxTx->setText("RX TX"); + ui->label_vfoSubRxTx->setText(""); + } + + //* PTT & Meter + if (rigGet.ptt == RIG_PTT_ON) + { + ui->pushButton_PTT->setChecked(true); + ui->label_vfoMain->setStyleSheet("QLabel {background-color: red}"); + + ui->progressBar_Smeter->setTx(true); + ui->progressBar_Smeter->setValue(rigGet.powerMeter.f*100); + ui->progressBar_subMeter->setValue(rigGet.subMeter.f); + } + else + { + ui->pushButton_PTT->setChecked(false); + ui->label_vfoMain->setStyleSheet("QLabel {}"); + + ui->progressBar_Smeter->setTx(false); + ui->progressBar_Smeter->setValue(rigGet.sMeter.i); + if (rigSet.meter == RIG_LEVEL_SWR) ui->progressBar_subMeter->setValue(1.0); + else ui->progressBar_subMeter->setValue(0.0); + } + + //* Sliders + if (!ui->verticalSlider_RFpower->isSliderDown()) ui->verticalSlider_RFpower->setValue((int)(rigGet.rfPower*100)); + if (!ui->verticalSlider_RFgain->isSliderDown()) ui->verticalSlider_RFgain->setValue((int)(rigGet.rfGain*100)); + if (!ui->verticalSlider_AFGain->isSliderDown()) ui->verticalSlider_AFGain->setValue((int)(rigGet.afGain*100)); + if (!ui->verticalSlider_Squelch->isSliderDown()) ui->verticalSlider_Squelch->setValue((int)(rigGet.squelch*100)); + + //* Filter + ui->checkBox_NB->setChecked(rigGet.noiseBlanker); + ui->checkBox_NR->setChecked(rigGet.noiseReduction); + ui->spinBox_NR->setValue(rigGet.noiseReductionLevel); + ui->checkBox_NF->setChecked(rigGet.notchFilter); + + //* CW + ui->checkBox_BKIN->setChecked(rigGet.bkin); + ui->checkBox_APF->setChecked(rigGet.apf); + ui->spinBox_WPM->setValue(rigGet.wpm); + + //* FM + if (rigGet.rptShift == RIG_RPT_SHIFT_MINUS) ui->radioButton_RPTshiftMinus->setChecked(true); //- + else if (rigGet.rptShift == RIG_RPT_SHIFT_PLUS) ui->radioButton_RPTshiftPlus->setChecked(true); //+ + else ui->radioButton_RPTshiftSimplex->setChecked(true); //Simplex + + ui->comboBox_toneType->setCurrentIndex(rigGet.toneType); + if (rigGet.toneType == 2 || rigGet.toneType ==3) ui->comboBox_toneFreq->setCurrentText(QString::number(rigGet.tone/10.0)); //CTCSS + else if (rigGet.toneType == 4 || rigGet.toneType ==5) ui->comboBox_toneFreq->setCurrentText(QString::number(rigGet.tone)); //DCS +} + + +//* RigDaemon handle results +void MainWindow::on_rigDaemonResultReady() +{ + guiUpdate(); +} + +//* SubMeter +void MainWindow::setSubMeter() +{ + if (rigSet.meter == RIG_LEVEL_SWR) + { + ui->progressBar_subMeter->setMeterSWR(true); + ui->progressBar_subMeter->setMaxValue(4.0); + ui->progressBar_subMeter->setGateValue(2.0); + ui->progressBar_subMeter->setLongStep(0.5); + ui->progressBar_subMeter->setShortStep(0.1); + ui->progressBar_subMeter->setValue(1.0); + } + else + { + ui->progressBar_subMeter->setMeterSWR(false); + ui->progressBar_subMeter->setMaxValue(1.0); + ui->progressBar_subMeter->setMinValue(0.0); + ui->progressBar_subMeter->setGateValue(0.5); + ui->progressBar_subMeter->setPrecision(1); + ui->progressBar_subMeter->setLongStep(0.5); + ui->progressBar_subMeter->setShortStep(0.1); + ui->progressBar_subMeter->setValue(0); + } +} + + +//***** PushButton ***** + +void MainWindow::on_pushButton_Connect_toggled(bool checked) +{ + if (checked && rigCom.connected == 0) + { + retcode = rigDaemon->rigConnect(); //Open Rig connection + + if (retcode != RIG_OK) //Connection error + { + rigCom.connected = 0; + ui->statusbar->showMessage(rigerror(retcode)); + ui->pushButton_Connect->setChecked(false); //Uncheck the button + } + else //Rig connected + { + rigCom.connected = 1; + guiInit(); + if (rigCap.onoff == 0 || rigGet.onoff == RIG_POWER_ON) timer->start(rigCom.rigRefresh); + } + } + else if (rigCom.connected) //Button unchecked + { + rigCom.connected = 0; + timer->stop(); + rig_close(my_rig); //Close the communication to the rig + //rig_cleanup(my_rig); //Release rig handle and free associated memory + } +} + +void MainWindow::on_pushButton_Power_toggled(bool checked) +{ + if (checked && !rigGet.onoff) + { + retcode = rig_set_powerstat(my_rig, RIG_POWER_ON); + if (retcode != RIG_OK) + { + ui->pushButton_Power->setChecked(false); //Uncheck the button + ui->statusbar->showMessage(rigerror(retcode)); + } + else timer->start(rigCom.rigRefresh); + } + else if (!checked && rigGet.onoff) + { + retcode = rig_set_powerstat(my_rig, RIG_POWER_OFF); + if (retcode == RIG_OK) + { + ui->pushButton_Power->setChecked(false); //Uncheck the button + timer->stop(); + } + } +} + +void MainWindow::on_pushButton_PTT_toggled(bool checked) +{ + if (checked && !rigGet.ptt) + { + rigSet.ptt = RIG_PTT_ON; + rigCmd.ptt = 1; + } + else if (!checked && rigGet.ptt) + { + rigSet.ptt = RIG_PTT_OFF; + rigCmd.ptt = 1; + } +} + +void MainWindow::on_pushButton_Split_toggled(bool checked) +{ + if (checked && !rigGet.split) + { + rigSet.split = RIG_SPLIT_ON; + rigCmd.split = 1; + } + else if (!checked && rigGet.split) + { + rigSet.split = RIG_SPLIT_OFF; + rigCmd.split = 1; + } +} + +void MainWindow::on_pushButton_QSplit_clicked() +{ + quick_split(); +} + +void MainWindow::on_pushButton_AB_clicked() +{ + rigCmd.vfoXchange = 1; +} + +void MainWindow::on_pushButton_AeqB_clicked() +{ + rigCmd.vfoCopy = 1; +} + +void MainWindow::on_pushButton_Fast_toggled(bool checked) +{ + if (checked) fastDial = 1; + else fastDial = 0; +} + +void MainWindow::on_pushButton_Tune_clicked() +{ + rigCmd.tune = 1; +} + +void MainWindow::on_pushButton_Band160_clicked() +{ + set_band(160); +} + +void MainWindow::on_pushButton_Band80_clicked() +{ + set_band(80); +} + +void MainWindow::on_pushButton_Band60_clicked() +{ + set_band(60); +} + +void MainWindow::on_pushButton_Band40_clicked() +{ + set_band(40); +} + +void MainWindow::on_pushButton_Band30_clicked() +{ + set_band(30); +} + +void MainWindow::on_pushButton_Band20_clicked() +{ + set_band(20); +} + +void MainWindow::on_pushButton_Band17_clicked() +{ + set_band(17); +} + +void MainWindow::on_pushButton_Band15_clicked() +{ + set_band(15); +} + +void MainWindow::on_pushButton_Band12_clicked() +{ + set_band(12); +} + +void MainWindow::on_pushButton_Band10_clicked() +{ + set_band(10); +} + +void MainWindow::on_pushButton_Band6_clicked() +{ + set_band(6); +} + +void MainWindow::on_pushButton_Band2_clicked() +{ + set_band(2); +} + +void MainWindow::on_pushButton_Band70_clicked() +{ + set_band(70); +} + +void MainWindow::on_pushButton_BandGen_clicked() +{ + set_band(1); +} + +void MainWindow::on_pushButton_BandDown_clicked() +{ + rigCmd.bandDown = 1; +} + +void MainWindow::on_pushButton_BandUp_clicked() +{ + rigCmd.bandUp = 1; +} + +//***** CheckBox ***** + +void MainWindow::on_checkBox_NAR_toggled(bool checked) +{ + if (checked && !rigGet.bwNarrow) + { + rigSet.bwidth = rig_passband_narrow(my_rig, rigGet.mode); + rigCmd.bwidth = 1; + } + else if (!checked && rigGet.bwNarrow) + { + rigSet.bwidth = RIG_PASSBAND_NORMAL; + rigCmd.bwidth = 1; + } +} + +void MainWindow::on_checkBox_BKIN_toggled(bool checked) +{ + if (checked && !rigGet.bkin) + { + rigSet.bkin = 1; + rigCmd.bkin = 1; + } + else if (!checked && rigGet.bkin) + { + rigSet.bkin = 0; + rigCmd.bkin = 1; + } +} + +void MainWindow::on_checkBox_NB_toggled(bool checked) +{ + if (checked && !rigGet.noiseBlanker) + { + rigSet.noiseBlanker = 1; + rigCmd.noiseBlanker = 1; + } + else if (!checked && rigGet.noiseBlanker) + { + rigSet.noiseBlanker = 0; + rigCmd.noiseBlanker = 1; + } +} + +void MainWindow::on_checkBox_NR_toggled(bool checked) +{ + if (checked && !rigGet.noiseReduction) + { + rigSet.noiseReduction = 1; + rigCmd.noiseReduction = 1; + } + else if (!checked && rigGet.noiseReduction) + { + rigSet.noiseReduction = 0; + rigCmd.noiseReduction = 1; + } +} + +void MainWindow::on_checkBox_NF_toggled(bool checked) +{ + if (checked && !rigGet.notchFilter) + { + rigSet.notchFilter = 1; + rigCmd.notchFilter = 1; + } + else if (!checked && rigGet.notchFilter) + { + rigSet.notchFilter = 0; + rigCmd.notchFilter = 1; + } +} + +void MainWindow::on_checkBox_APF_toggled(bool checked) +{ + if (checked && !rigGet.apf) + { + rigSet.apf = 1; + rigCmd.apf = 1; + } + else if (!checked && rigGet.apf) + { + rigSet.apf = 0; + rigCmd.apf = 1; + } +} + + +//***** RadioButton ***** + +void MainWindow::on_radioButton_Tuner_toggled(bool checked) +{ + if (checked && !rigGet.tuner) + { + rigSet.tuner = 1; + rigCmd.tuner = 1; + } + else if (!checked && rigGet.tuner) + { + rigSet.tuner = 0; + rigCmd.tuner = 1; + } +} + +void MainWindow::on_radioButton_RPTshiftSimplex_toggled(bool checked) +{ + if (checked) + { + rigSet.rptShift = RIG_RPT_SHIFT_NONE; + rigCmd.rptShift = 1; + } +} + +void MainWindow::on_radioButton_RPTshiftMinus_toggled(bool checked) +{ + if (checked) + { + rigSet.rptShift = RIG_RPT_SHIFT_MINUS; + rigCmd.rptShift = 1; + } +} + + +void MainWindow::on_radioButton_RPTshiftPlus_toggled(bool checked) +{ + if (checked) + { + rigSet.rptShift = RIG_RPT_SHIFT_PLUS; + rigCmd.rptShift = 1; + } +} + + +//***** Dial ***** + +void MainWindow::on_dial_valueChanged(int value) +{ + int step; + + step = value - prevDial; + if (step<=99 && step>50) step = value - 100 - prevDial; + if (step>=-99 && step<-50) step = value + 100 - prevDial; + prevDial = value; + + if (ui->radioButton_VFOSub->isChecked()) //dial VFO Sub + { + rigSet.freqSub = rigGet.freqSub + step*(!fastDial*10+fastDial*100); + rigCmd.freqSub = 1; + } + else //dial VFO Main + { + rigSet.freqMain = rigGet.freqMain + step*(!fastDial*10+fastDial*100); + rigCmd.freqMain = 1; + } +} + +void MainWindow::on_vfoDisplayValueChanged(int value) +{ + rigSet.freqMain = value; + rigCmd.freqMain = 1; +} + +//***** ComboBox ***** + +void MainWindow::on_comboBox_Mode_activated(int index) +{ + rigSet.mode = rig_parse_mode(ui->comboBox_Mode->itemText(index).toLatin1()); + rigCmd.mode = 1; +} + +void MainWindow::on_comboBox_ModeSub_activated(int index) +{ + rigSet.modeSub = rig_parse_mode(ui->comboBox_ModeSub->itemText(index).toLatin1()); + rigCmd.modeSub = 1; +} + +void MainWindow::on_comboBox_BW_activated(int index) +{ + rigSet.bwidth = ui->comboBox_BW->itemText(index).toInt(); + rigCmd.bwidth = 1; +} + +void MainWindow::on_comboBox_AGC_activated(int index) +{ + rigSet.agc = levelagcstr(ui->comboBox_AGC->itemText(index)); + rigCmd.agc = 1; +} + +void MainWindow::on_comboBox_Att_activated(int index) +{ + rigSet.att = ui->comboBox_Att->itemText(index).toInt(); + rigCmd.att = 1; +} + +void MainWindow::on_comboBox_Preamp_activated(int index) +{ + rigSet.pre = ui->comboBox_Preamp->itemText(index).toInt(); + rigCmd.pre = 1; +} + +void MainWindow::on_comboBox_Ant_activated(int index) +{ + rigSet.ant = antstr(ui->comboBox_Ant->itemText(index)); + rigCmd.ant = 1; +} + +void MainWindow::on_comboBox_Meter_activated(int index) +{ + rigSet.meter = levelmeterstr (ui->comboBox_Meter->itemText(index)); + setSubMeter(); +} + +void MainWindow::on_comboBox_toneType_activated(int index) +{ + rigSet.toneType = index; + rigCmd.toneList = 1; //update tone list + rigCmd.tone = 1; +} + +void MainWindow::on_comboBox_toneFreq_activated(int index) +{ + QString arg = ui->comboBox_toneFreq->itemText(index); + arg = arg.remove("."); //Remove '.' from CTCSS (as for hamlib CTCSS tone list) + + if (rigGet.toneType == 2 || rigGet.toneType == 3) rigSet.tone = arg.toUInt(); + rigCmd.tone = 1; +} + + +//***** Spin Box ***** + +void MainWindow::on_spinBox_NR_valueChanged(int arg1) +{ + rigSet.noiseReductionLevel = arg1; + rigCmd.noiseReductionLevel = 1; +} + +void MainWindow::on_spinBox_WPM_valueChanged(int arg1) +{ + rigSet.wpm = arg1; + rigCmd.wpm = 1; +} + + +//***** Slider ***** + +void MainWindow::on_verticalSlider_RFpower_valueChanged(int value) +{ + if (!rigCmd.rfPower) + { + if (value < 5) value = 5; + rigSet.rfPower = (float)(value)/100; + if (rigSet.rfPower != rigGet.rfPower) rigCmd.rfPower = 1; + } +} + +void MainWindow::on_verticalSlider_RFgain_valueChanged(int value) +{ + if (!rigCmd.rfGain) + { + rigSet.rfGain = (float)(value)/100; + if (rigSet.rfGain != rigGet.rfGain) rigCmd.rfGain = 1; + } +} + +void MainWindow::on_verticalSlider_AFGain_valueChanged(int value) +{ + if (!rigCmd.afGain) + { + rigSet.afGain = (float)(value)/100; + if (rigSet.afGain != rigGet.afGain) rigCmd.afGain = 1; + } +} + + +void MainWindow::on_verticalSlider_Squelch_valueChanged(int value) +{ + if (!rigCmd.squelch) + { + rigSet.squelch = (float)(value)/100; + if (rigSet.squelch != rigGet.squelch) rigCmd.squelch = 1; + } +} + +void MainWindow::on_horizontalSlider_IFshift_valueChanged(int value) +{ + if (!rigCmd.ifShift) + { + rigSet.ifShift = value; + if (rigSet.ifShift != rigGet.ifShift) rigCmd.ifShift = 1; + } +} + + +//***** Menu ***** + +void MainWindow::on_action_Connection_triggered() +{ + DialogConfig config; + config.setModal(true); + config.exec(); +} + +void MainWindow::on_action_Setup_triggered() +{ + DialogSetup setup; + setup.setModal(true); + setup.exec(); +} + +void MainWindow::on_action_AboutCatRadio_triggered() +{ + QMessageBox msgBox; + msgBox.setWindowTitle("About"); + msgBox.setTextFormat(Qt::RichText); + QString version = QString::number(VERSION_MAJ)+"."+QString::number(VERSION_MIN)+"."+QString::number(VERSION_MIC); + msgBox.setText("CatRadio Radio control software
version "+version+" "+RELEASE_DATE); + msgBox.setInformativeText("Copyright (C) 2022 Gianfranco Sordetti IZ8EWD
" + "www.pianetaradio.it

" + "

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
" + "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
" + "You should have received a copy of the GNU General Public License along with this program. If not, see www.gnu.org/licenses."); + msgBox.setIcon(QMessageBox::NoIcon); + msgBox.setStandardButtons(QMessageBox::Ok); + + QPixmap icon("catradio.png"); + msgBox.setIconPixmap(icon); + + msgBox.exec(); +} + +void MainWindow::on_action_AboutQT_triggered() +{ + QMessageBox::aboutQt(this); +} + +void MainWindow::on_action_AboutHamLib_triggered() +{ + QMessageBox msgBox; + msgBox.setWindowTitle("About Hamlib"); + msgBox.setText(rig_version()); + msgBox.setInformativeText(rig_copyright()); + //msgBox.setDetailedText(rig_license()); + msgBox.setIcon(QMessageBox::Information); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); +} + +void MainWindow::on_action_CatRadioHomepage_triggered() +{ + QUrl homepage("https://www.pianetaradio.it/blog/catradio/"); + QDesktopServices::openUrl(homepage); +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..8708b56 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,167 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include + +#define RELEASE_DATE __DATE__ +#define VERSION_MAJ 1 +#define VERSION_MIN 1 +#define VERSION_MIC 0 + + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +public slots: + void guiUpdate(); + void on_rigDaemonResultReady(); //Slot for rigDaemon resultReady + void on_vfoDisplayValueChanged(int value); //Slot for vfoDisplay valueChanged + +signals: + +private slots: + void on_pushButton_Connect_toggled(bool checked); + void on_pushButton_Power_toggled(bool checked); + void on_pushButton_PTT_toggled(bool checked); + void on_pushButton_Split_toggled(bool checked); + void on_pushButton_AB_clicked(); + void on_pushButton_AeqB_clicked(); + + void on_dial_valueChanged(int value); + + void on_comboBox_Mode_activated(int index); + void on_comboBox_ModeSub_activated(int index); + + void on_pushButton_Fast_toggled(bool checked); + + void on_pushButton_Band160_clicked(); + + void on_pushButton_Band80_clicked(); + + void on_pushButton_Band60_clicked(); + + void on_pushButton_Band40_clicked(); + + void on_pushButton_Band30_clicked(); + + void on_pushButton_Band20_clicked(); + + void on_pushButton_Band17_clicked(); + + void on_pushButton_Band15_clicked(); + + void on_pushButton_Band12_clicked(); + + void on_pushButton_Band10_clicked(); + + void on_pushButton_Band6_clicked(); + + void on_pushButton_Tune_clicked(); + + void on_radioButton_Tuner_toggled(bool checked); + + void on_pushButton_BandDown_clicked(); + + void on_pushButton_BandUp_clicked(); + + void on_pushButton_QSplit_clicked(); + + void on_action_Connection_triggered(); + + void on_comboBox_BW_activated(int index); + + void on_checkBox_NAR_toggled(bool checked); + + void on_checkBox_BKIN_toggled(bool checked); + + void on_comboBox_AGC_activated(int index); + + void on_comboBox_Att_activated(int index); + + void on_comboBox_Preamp_activated(int index); + + void on_comboBox_Ant_activated(int index); + + void on_action_AboutCatRadio_triggered(); + + void on_checkBox_NB_toggled(bool checked); + + void on_checkBox_NR_toggled(bool checked); + + void on_checkBox_NF_toggled(bool checked); + + void on_comboBox_Meter_activated(int index); + + void on_spinBox_NR_valueChanged(int arg1); + + void on_horizontalSlider_IFshift_valueChanged(int value); + + void on_pushButton_Band2_clicked(); + + void on_pushButton_Band70_clicked(); + + void on_pushButton_BandGen_clicked(); + + void on_action_Setup_triggered(); + void on_action_CatRadioHomepage_triggered(); + void on_action_AboutQT_triggered(); + void on_action_AboutHamLib_triggered(); + + void on_verticalSlider_AFGain_valueChanged(int value); + void on_verticalSlider_Squelch_valueChanged(int value); + void on_verticalSlider_RFpower_valueChanged(int value); + void on_verticalSlider_RFgain_valueChanged(int value); + + void on_spinBox_WPM_valueChanged(int arg1); + + void on_checkBox_APF_toggled(bool checked); + + void on_radioButton_RPTshiftSimplex_toggled(bool checked); + + void on_radioButton_RPTshiftMinus_toggled(bool checked); + + void on_radioButton_RPTshiftPlus_toggled(bool checked); + + void on_comboBox_toneType_activated(int index); + + void on_comboBox_toneFreq_activated(int index); + +private: + Ui::MainWindow *ui; + QTimer *timer; + + void guiInit(); + void setSubMeter(); +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..cdf498e --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,1580 @@ + + + MainWindow + + + true + + + + 0 + 0 + 610 + 604 + + + + CatRadio + + + + catradio.icocatradio.ico + + + + + + 10 + 10 + 91 + 401 + + + + + + + Connect + + + true + + + + + + + Power + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Tuner + + + + + + + Tune + + + + + + + Antenna + + + comboBox_Ant + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + AGC + + + comboBox_AGC + + + + + + + + + + Attenuator + + + comboBox_Att + + + + + + + + + + Preamp + + + comboBox_Preamp + + + + + + + + + + + true + + + + 110 + 80 + 491 + 131 + + + + QFrame::Box + + + QFrame::Raised + + + 0 + + + + + 200 + 10 + 40 + 16 + + + + VFO + + + + + + 430 + 10 + 40 + 16 + + + + VFO + + + + + true + + + + 10 + 60 + 91 + 24 + + + + + + + 110 + 60 + 81 + 24 + + + + + + + 200 + 30 + 51 + 16 + + + + RX TX + + + + + + 430 + 30 + 51 + 16 + + + + RX TX + + + + + true + + + + 280 + 10 + 140 + 40 + + + + + 0 + 0 + + + + + 18 + + + + Qt::RightToLeft + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + true + + + + 280 + 60 + 91 + 24 + + + + false + + + + + + 10 + 9 + 181 + 41 + + + + + + + 10 + 100 + 381 + 27 + + + + + + + A / B + + + + + + + A = B + + + + + + + Split + + + true + + + + + + + Q Split + + + + + + + + + + 110 + 220 + 161 + 191 + + + + Band + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 1.8 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 3.5 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 5.3 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 7 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 10 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 14 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 18 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 21 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 24 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 28 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + Gen + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 50 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + << + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 144 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + 430 + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 16 + 16 + + + + >> + + + + + + + + + 480 + 220 + 121 + 191 + + + + Filter + + + + + 10 + 30 + 51 + 22 + + + + Noise Blanking + + + NB + + + + + + 10 + 60 + 51 + 22 + + + + Noise Reduction + + + NR + + + + + + 10 + 90 + 51 + 22 + + + + Notch Filter + + + NF + + + + + + 70 + 60 + 46 + 25 + + + + 1 + + + 15 + + + + + + 10 + 120 + 61 + 22 + + + + BW Narrow + + + NAR + + + + + + 10 + 170 + 101 + 18 + + + + -1200 + + + 1200 + + + 10 + + + 100 + + + false + + + Qt::Horizontal + + + + + + 10 + 150 + 55 + 16 + + + + IF-Shift + + + horizontalSlider_IFshift + + + + + true + + + + 70 + 150 + 41 + 16 + + + + 0 + + + Qt::AlignCenter + + + + + + + 280 + 220 + 191 + 191 + + + + QFrame::NoFrame + + + QFrame::Raised + + + 1 + + + + + 10 + 150 + 171 + 31 + + + + PTT + + + \ + + + true + + + + + + 25 + 10 + 140 + 140 + + + + false + + + 100 + + + true + + + true + + + 10.000000000000000 + + + false + + + + + + 10 + 120 + 41 + 25 + + + + Fast + + + true + + + + + + 10 + 0 + 61 + 22 + + + + Main + + + true + + + + + + 120 + 0 + 61 + 22 + + + + Qt::RightToLeft + + + Sub + + + + + + + 110 + 9 + 491 + 61 + + + + QFrame::NoFrame + + + QFrame::Raised + + + 0 + + + + + 0 + 0 + 201 + 61 + + + + + + + 250 + 0 + 161 + 61 + + + + + + + 410 + 20 + 75 + 24 + + + + + + + + 0 + 420 + 271 + 131 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + 20 + 20 + 20 + 80 + + + + 100 + + + 100 + + + Qt::Vertical + + + QSlider::TicksBothSides + + + 25 + + + + + + 90 + 20 + 18 + 80 + + + + 100 + + + 100 + + + Qt::Vertical + + + QSlider::TicksBothSides + + + 25 + + + + + + 160 + 20 + 18 + 80 + + + + 100 + + + Qt::Vertical + + + QSlider::TicksBothSides + + + 25 + + + + + + 230 + 20 + 18 + 80 + + + + 100 + + + Qt::Vertical + + + QSlider::TicksBothSides + + + 25 + + + + + + 0 + 100 + 61 + 16 + + + + RF Gain + + + Qt::AlignCenter + + + + + true + + + + 15 + 0 + 30 + 16 + + + + + 0 + 0 + + + + 100 + + + Qt::AlignCenter + + + + + + 65 + 100 + 71 + 16 + + + + RF Power + + + Qt::AlignCenter + + + + + true + + + + 85 + 0 + 30 + 16 + + + + + 0 + 0 + + + + 100 + + + Qt::AlignCenter + + + + + true + + + + 155 + 0 + 30 + 16 + + + + + 0 + 0 + + + + 0 + + + Qt::AlignCenter + + + + + + 140 + 100 + 61 + 16 + + + + AF Gain + + + Qt::AlignCenter + + + + + + 210 + 100 + 61 + 16 + + + + Squelch + + + Qt::AlignCenter + + + + + true + + + + 225 + 0 + 30 + 16 + + + + + 0 + 0 + + + + 0 + + + Qt::AlignCenter + + + + + + + 280 + 419 + 321 + 131 + + + + false + + + 0 + + + + true + + + CW + + + + + + Break-In + + + BK IN + + + + + + + + + WPM + + + + + + + 4 + + + 60 + + + 20 + + + + + + + + + Audio Peak Filter + + + APF + + + + + + + + true + + + FM + + + + + + + + RPT Shift + + + + + + + Simplex + + + true + + + + + + + - + + + + + + + + + + + + + + + + + + + Tone + + + + + + + + + + + + + + + frame_2 + frame + verticalLayoutWidget + groupBox_Band + groupBox_filter + frame_3 + frame_4 + tabWidget + + + + + 0 + 0 + 610 + 20 + + + + + Config + + + + + + + Help + + + + + + + + + + + + + + + Connection + + + + + About CatRadio + + + + + About HamLib + + + + + About QT + + + + + Setup + + + + + CatRadio homepage + + + + + + SMeter + QWidget +

smeter.h
+ 1 + + + SubMeter + QWidget +
submeter.h
+ 1 +
+ + vfoDisplay + QWidget +
vfodisplay.h
+ 1 +
+ + + + diff --git a/rigcommand.cpp b/rigcommand.cpp new file mode 100644 index 0000000..a56a9c5 --- /dev/null +++ b/rigcommand.cpp @@ -0,0 +1,153 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#include "rigcommand.h" +#include "rigdata.h" + +#include //Hamlib + +#include + +extern rigSettings rigGet; +extern rigSettings rigSet; +extern rigCommand rigCmd; +extern rigCommand rigCap; + +void set_band (int band) +{ + freq_t freq; + + switch (band) + { + case 160: freq = 1840000; break; + case 80: freq = 3600000; break; + case 60: freq = 5355000; break; + case 40: freq = 7100000; break; + case 30: freq = 10130000; break; + case 20: freq = 14100000; break; + case 17: freq = 18120000; break; + case 15: freq = 21150000; break; + case 12: freq = 24940000; break; + case 10: freq = 28320000; break; + case 6: freq = 50150000; break; + case 2: freq = 144300000; break; + case 70: freq = 432200000; break; + default: freq = rigSet.freqMain; break; + } + + rigSet.freqMain = freq; + rigCmd.freqMain = 1; + rigCmd.bandChange = 1; +} + +void quick_split () +{ + if (rigGet.vfoMain == RIG_VFO_A) + { + rigSet.freqSub = rigGet.freqMain + 5000; + //rigSet.modeSub = rigGet.modeMain; + rigCmd.freqSub = 1; + //rigCmd.modeSub = 1; + } + else + { + rigSet.freqMain = rigGet.freqSub + 5000; + rigCmd.freqMain = 1; + } + rigCmd.split = 1; +} + +agc_level_e levelagcvalue (int agcValue) +{ + agc_level_e agcLevel; + + switch (agcValue) + { + case 0: agcLevel = RIG_AGC_OFF; break; + case 1: agcLevel = RIG_AGC_SUPERFAST; break; + case 2: agcLevel = RIG_AGC_FAST; break; + case 3: agcLevel = RIG_AGC_SLOW; break; + case 4: agcLevel = RIG_AGC_USER; break; + case 5: agcLevel = RIG_AGC_MEDIUM; break; + case 6: agcLevel = RIG_AGC_AUTO; break; + default: agcLevel = RIG_AGC_AUTO; break; + } + + return agcLevel; +} + +agc_level_e levelagcstr (QString agcString) +{ + agc_level_e agcLevel; + + if (agcString == "OFF") agcLevel = RIG_AGC_OFF; + else if (agcString == "SUPERFAST") agcLevel = RIG_AGC_SUPERFAST; + else if (agcString == "FAST") agcLevel = RIG_AGC_FAST; + else if (agcString == "SLOW") agcLevel = RIG_AGC_SLOW; + else if (agcString == "USER") agcLevel = RIG_AGC_USER; + else if (agcString == "MEDIUM") agcLevel = RIG_AGC_MEDIUM; + else agcLevel = RIG_AGC_AUTO; + + return agcLevel; +} + +value_t valueagclevel (agc_level_e agcLevel) +{ + value_t value; + + if (agcLevel == RIG_AGC_OFF) value.i = 0; + else if (agcLevel == RIG_AGC_SUPERFAST) value.i = 1; + else if (agcLevel == RIG_AGC_FAST) value.i = 2; + else if (agcLevel == RIG_AGC_SLOW) value.i = 3; + else if (agcLevel == RIG_AGC_USER) value.i = 4; + else if (agcLevel == RIG_AGC_MEDIUM) value.i = 5; + else value.i = 6; //RIG_AGC_AUTO + + return value; +} + +ant_t antstr (QString antString) +{ + ant_t ant; + + if (antString == "NONE") ant = RIG_ANT_NONE; + else if (antString == "ANT1") ant = RIG_ANT_1; + else if (antString == "ANT2") ant = RIG_ANT_2; + else if (antString == "ANT3") ant = RIG_ANT_3; + else if (antString == "ANT4") ant = RIG_ANT_4; + else if (antString == "ANT5") ant = RIG_ANT_5; + else if (antString == "UNK") ant = RIG_ANT_UNKNOWN; + else if (antString == "CURR") ant = RIG_ANT_CURR; + else ant = RIG_ANT_UNKNOWN; + + return ant; +} + +unsigned levelmeterstr (QString meterString) +{ + unsigned levelMeter; + + if (meterString == "SWR") levelMeter = RIG_LEVEL_SWR; + else if (meterString == "COMP") levelMeter = RIG_LEVEL_COMP; + else if (meterString == "ALC") levelMeter = RIG_LEVEL_ALC; + //... + else levelMeter = RIG_METER_NONE; + + return levelMeter; +} diff --git a/rigcommand.h b/rigcommand.h new file mode 100644 index 0000000..7c76aeb --- /dev/null +++ b/rigcommand.h @@ -0,0 +1,36 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#ifndef RIGCOMMAND_H +#define RIGCOMMAND_H + +#endif // RIGCOMMAND_H + +#include + +#include + + +void set_band (int band); +void quick_split (); +agc_level_e levelagcvalue (int agcValue); +agc_level_e levelagcstr (QString agcString); +value_t valueagclevel (agc_level_e agcLevel); +ant_t antstr (QString antString); +unsigned levelmeterstr (QString meterString); diff --git a/rigdaemon.cpp b/rigdaemon.cpp new file mode 100644 index 0000000..e376179 --- /dev/null +++ b/rigdaemon.cpp @@ -0,0 +1,593 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#include "rigdaemon.h" +#include "rigdata.h" +#include "rigcommand.h" + +#include +#include +#include + +#include + + +RIG *my_rig; + +extern rigConnect rigCom; +extern rigSettings rigGet; +extern rigSettings rigSet; +extern rigCommand rigCmd; +extern rigCommand rigCap; + +int commandPriority = 0; + + +RigDaemon::RigDaemon(QObject *parent) : QObject(parent) +{ + +} + +int RigDaemon::rigConnect() +{ + int retcode; + + my_rig = rig_init(rigCom.rigModel); //Allocate rig handle + + if (!my_rig) //Wrong Rig number + { + QMessageBox msgBox; //Show error MessageBox + msgBox.setWindowTitle("Warning"); + msgBox.setText("Rig model error"); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + + return -1; //RIG_EINVAL, Invalid parameter + } + else + { + if (rigCom.rigModel == 2) //Rigctld + { + //myport.type.rig = RIG_PORT_NETWORK; + strncpy(my_rig->state.rigport.pathname, rigCom.rigPort.toLatin1(), HAMLIB_FILPATHLEN - 1); + //strncpy(my_rig->state.rigport.pathname, RIG_FILE, HAMLIB_FILPATHLEN - 1); + } + else + { + //myport.type.rig = RIG_PORT_SERIAL; + strncpy(my_rig->state.rigport.pathname, rigCom.rigPort.toLatin1(), HAMLIB_FILPATHLEN - 1); + my_rig->state.rigport.parm.serial.rate = rigCom.serialSpeed; + if (rigCom.civAddr) //CI-V address Icom + { + std::string civaddrS = std::to_string(rigCom.civAddr); //Convert int to string + char const *civaddr = civaddrS.c_str(); //Convert string to char* + rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr); + } + } + + retcode = rig_open(my_rig); + + if (retcode != RIG_OK) return retcode; //Rig not connected + else //Rig connected + { + rig_get_powerstat(my_rig, &rigGet.onoff); + return 0; + } + + } +} + +void RigDaemon::rigUpdate() +{ + int retcode; + value_t retvalue; + + //***** Priority Command execution ***** + //* PTT + if (rigCmd.ptt) + { + retcode = rig_set_ptt(my_rig, RIG_VFO_CURR, rigSet.ptt); + if (retcode == RIG_OK) rigGet.ptt = rigSet.ptt; + rigCmd.ptt = 0; + } + + //* VFO + if (rigCmd.freqMain) //VFO Main + { + retcode = rig_set_freq(my_rig, RIG_VFO_CURR, rigSet.freqMain); + if (retcode == RIG_OK) rigGet.freqMain = rigSet.freqMain; + rigCmd.freqMain = 0; + rigCmd.rangeList = 1; + } + + else if (rigCmd.freqSub) //VFO Sub + { + retcode = rig_set_freq(my_rig, rigGet.vfoSub, rigSet.freqSub); + if (retcode == RIG_OK) rigGet.freqSub = rigSet.freqSub; + rigCmd.freqSub = 0; + } + + //***** Priority Poll execution ***** + else + { + freq_t retfreq; + retcode = rig_get_freq(my_rig, RIG_VFO_CURR, &retfreq); //get VFO Main + if (retcode == RIG_OK) rigGet.freqMain = retfreq; + //if (my_rig->caps->targetable_vfo) //get VFO Sub if targetable + //{ + retcode = rig_get_freq(my_rig, rigGet.vfoSub, &retfreq); + if (retcode == RIG_OK) rigGet.freqSub = retfreq; + //} + + //* PTT + ptt_t retptt; + retcode = rig_get_ptt(my_rig, RIG_VFO_CURR, &retptt); + if (retcode == RIG_OK) rigGet.ptt = retptt; + + //* Meter + if (rigGet.ptt==1) + { + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER_METER, &rigGet.powerMeter); + rig_get_level(my_rig, RIG_VFO_CURR, rigSet.meter, &rigGet.subMeter); + } + else + { + retcode = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_STRENGTH, &retvalue); + if (retcode == RIG_OK) rigGet.sMeter = retvalue; + } + + //***** Command execution ***** + if (!rigGet.ptt) + { + //* Mode + if (rigCmd.mode && rigSet.mode != RIG_MODE_NONE) //VFO Main + { + retcode = rig_set_mode(my_rig, RIG_VFO_CURR, rigSet.mode, RIG_PASSBAND_NOCHANGE); + if (retcode == RIG_OK) + { + rigCmd.bwidthList = 1; //Update BWidth list + commandPriority = 0; + //rig_get_mode(my_rig, RIG_VFO_CURR, &rigGet.mode, &rigGet.bwidth); //Get BW + } + rigCmd.mode = 0; + } + if (rigCmd.modeSub && rigCap.modeSub && rigSet.modeSub != RIG_MODE_NONE) //VFO Sub + { + retcode = rig_set_mode(my_rig, rigGet.vfoSub, rigSet.mode, RIG_PASSBAND_NOCHANGE); + if (retcode == RIG_OK) + { + } + rigCmd.modeSub = 0; + } + + //* BandWidth + if (rigCmd.bwidth) + { + retcode = rig_set_mode(my_rig, RIG_VFO_CURR, rigGet.mode, rigSet.bwidth); + if (retcode == RIG_OK) rigGet.bwidth = rigSet.bwidth; + rigCmd.bwidth = 0; + } + + //* Split + if (rigCmd.split) + { + retcode = rig_set_split_vfo(my_rig, RIG_VFO_RX, rigSet.split, RIG_VFO_TX); + if (retcode == RIG_OK) rigGet.split = rigSet.split; + rigCmd.split = 0; + } + + //* VFO Exchange + if (rigCmd.vfoXchange) + { + int tempMode = rigGet.mode; + retcode = rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_XCHG); + if (retcode == RIG_OK) + { + if (rigCap.modeSub == 0) rigGet.modeSub = tempMode; + commandPriority = 0; + } + rigCmd.vfoXchange = 0; + rigCmd.bwidthList = 1; + } + + //* VFO Copy + if (rigCmd.vfoCopy) + { + rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_CPY); + rigCmd.vfoCopy = 0; + if (rigCap.modeSub == 0) rigGet.modeSub = rigGet.mode; + } + + //* Band Up + if (rigCmd.bandUp) + { + retcode = rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_BAND_UP); + if (retcode == RIG_OK) commandPriority = 0; + rigCmd.bandUp = 0; + rigCmd.bwidthList = 1; + } + + //* Band Down + if (rigCmd.bandDown) + { + retcode = rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_BAND_DOWN); + if (retcode == RIG_OK) commandPriority = 0; + rigCmd.bandDown = 0; + rigCmd.bwidthList = 1; + } + + //* Band change + if (rigCmd.bandChange) + { + commandPriority = 0; + rigCmd.bwidthList = 1; + } + + //* Tune + if (rigCmd.tune) + { + rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_TUNE); + rigCmd.tune = 0; + } + + //* Antenna + if (rigCmd.ant) + { + retcode = rig_set_ant(my_rig, RIG_VFO_CURR, rigSet.ant, retvalue); + if (retcode == RIG_OK) rigGet.ant = rigSet.ant; + rigCmd.ant = 0; + } + + //* AGC + if (rigCmd.agc) + { + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AGC, valueagclevel(rigSet.agc)); + if (retcode == RIG_OK) rigGet.agc = rigSet.agc; + rigCmd.agc = 0; + } + + //* Attenuator + if (rigCmd.att) + { + retvalue.i = rigSet.att; + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_ATT, retvalue); + if (retcode == RIG_OK) rigGet.att = rigSet.att; + rigCmd.att = 0; + } + + //* Preamp + if (rigCmd.pre) + { + retvalue.i = rigSet.pre; + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_PREAMP, retvalue); + if (retcode == RIG_OK) rigGet.pre = rigSet.pre; + rigCmd.pre = 0; + } + + //* RF gain + if (rigCmd.rfGain) + { + retvalue.f = rigSet.rfGain; + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RF, retvalue); + if (retcode == RIG_OK) rigGet.rfGain = rigSet.rfGain; + rigCmd.rfGain = 0; + } + + //* AF Gain + if (rigCmd.afGain) + { + retvalue.f = rigSet.afGain; + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AF, retvalue); + if (retcode == RIG_OK) rigGet.afGain = rigSet.afGain; + rigCmd.afGain = 0; + } + + //* Squelch + if (rigCmd.squelch) + { + retvalue.f = rigSet.squelch; + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_SQL, retvalue); + if (retcode == RIG_OK) rigGet.squelch = rigSet.squelch; + rigCmd.squelch = 0; + } + + //* NB noise blanker + if (rigCmd.noiseBlanker) + { + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_NB, rigSet.noiseBlanker); + if (retcode == RIG_OK) rigGet.noiseBlanker = rigSet.noiseBlanker; + rigCmd.noiseBlanker = 0; + } + + //* NR noise reduction + if (rigCmd.noiseReduction) + { + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_NR, rigSet.noiseReduction); + if (retcode == RIG_OK) rigGet.noiseReduction = rigSet.noiseReduction; + rigCmd.noiseReduction = 0; + } + + if (rigCmd.noiseReductionLevel) + { + retvalue.i = rigSet.noiseReductionLevel; + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_NR, retvalue); + if (retcode == RIG_OK) rigGet.noiseReductionLevel = rigSet.noiseReductionLevel; + rigCmd.noiseReductionLevel = 0; + } + + //* NF notch filter + if (rigCmd.notchFilter) + { + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_ANF, rigSet.notchFilter); + if (retcode == RIG_OK) rigGet.notchFilter = rigSet.notchFilter; + rigCmd.notchFilter = 0; + } + + //* IF Shift + if (rigCmd.ifShift) + { + retvalue.i = rigSet.ifShift; + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_IF, retvalue); + if (retcode == RIG_OK) rigGet.ifShift = rigSet.ifShift; + rigCmd.ifShift = 0; + } + + //** CW + //* CW break-in + if (rigCmd.bkin) + { + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_FBKIN, rigSet.bkin); + if (retcode == RIG_OK) rigGet.bkin = rigSet.bkin; + rigCmd.bkin = 0; + } + //* CW Auto Peak Filter + if (rigCmd.apf) + { + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_APF, rigSet.apf); + if (retcode == RIG_OK) rigGet.apf = rigSet.apf; + rigCmd.apf = 0; + } + //* CW keyer speed + if (rigCmd.wpm) + { + retvalue.i = rigSet.wpm; + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_KEYSPD, retvalue); + if (retcode == RIG_OK) rigGet.wpm = rigSet.wpm; + rigCmd.wpm = 0; + } + + //** FM + //* Repeater shift + if (rigCmd.rptShift) + { + retcode = rig_set_rptr_shift(my_rig, RIG_VFO_CURR, rigSet.rptShift); + if (retcode == RIG_OK) rigGet.rptShift = rigSet.rptShift; + rigCmd.rptShift = 0; + } + //* Tone + if (rigCmd.tone) + { + switch (rigSet.toneType) + { + case 1: + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TBURST, true); + break; + case 2: + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TONE, true); + if (rigSet.tone) rig_set_ctcss_tone(my_rig, RIG_VFO_CURR, rigSet.tone); + else rig_get_ctcss_tone(my_rig, RIG_VFO_CURR, &rigSet.tone); + break; + case 3: + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TSQL, true); + if (rigSet.tone) rig_set_ctcss_tone(my_rig, RIG_VFO_CURR, rigSet.tone); + else rig_get_ctcss_tone(my_rig, RIG_VFO_CURR, &rigSet.tone); + break; + default: + rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TBURST, false); + rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TONE, false); + rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TSQL, false); + retcode = RIG_OK; + break; + } + if (retcode == RIG_OK) + { + rigGet.toneType = rigSet.toneType; + rigGet.tone = rigSet.tone; + } + rigCmd.tone = 0; + rigCmd.toneList = 1; + } + + } //end if (!rigGet.ptt) + + //* Tuner + if (rigCmd.tuner) + { + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TUNER, rigSet.tuner); + if (retcode == RIG_OK) rigGet.tuner = rigSet.tuner; + rigCmd.tune = 0; + } + + //* RF power + if (rigCmd.rfPower) + { + retvalue.f = rigSet.rfPower; + retcode = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER, retvalue); + if (retcode == RIG_OK) rigGet.rfPower = rigSet.rfPower; + rigCmd.rfPower = 0; + } + + //***** Poll execution ***** + //* Mode and BW + if ((commandPriority == 1 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_mode(my_rig, RIG_VFO_CURR, &rigGet.mode, &rigGet.bwidth); + if (rigGet.bwidth == rig_passband_narrow(my_rig, rigGet.mode)) rigGet.bwNarrow = 1; + else rigGet.bwNarrow = 0; + + if (rigCap.modeSub) + { + retcode = rig_get_mode(my_rig, rigGet.vfoSub, &rigGet.modeSub, &rigGet.bwidthSub); + if (retcode != RIG_OK) + { + rigCap.modeSub = 0; //mode not targetable + rigGet.modeSub = RIG_MODE_NONE; + } + } + } + + //* Split + if ((commandPriority == 2 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_split_vfo(my_rig, RIG_VFO_CURR, &rigGet.split, &rigGet.vfoTx); + //else rig_get_split(my_rig, RIG_VFO_CURR, &rigGet.split); + + rig_get_vfo(my_rig, &rigGet.vfoMain); + } + + //* Tuner + if ((commandPriority == 3 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TUNER, &rigGet.tuner); + + //* Antenna + if ((commandPriority == 4 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) rig_get_ant(my_rig, RIG_VFO_CURR, RIG_ANT_CURR, &retvalue, &rigGet.ant, &rigGet.antTx, &rigGet.antRx); + + //* AGC + if ((commandPriority == 5 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AGC, &retvalue); + rigGet.agc = levelagcvalue(retvalue.i); + } + + //* Attenuator + if ((commandPriority == 6 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_ATT, &retvalue); + rigGet.att = retvalue.i; + } + + //* Preamp + if ((commandPriority == 7 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_PREAMP, &retvalue); + rigGet.pre = retvalue.i; + } + + //* RF power + if ((commandPriority == 8 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER, &retvalue); + rigGet.rfPower = retvalue.f; + } + + //* RF gain + if ((commandPriority == 9 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RF, &retvalue); + rigGet.rfGain = retvalue.f; + } + + //* AF gain + if ((commandPriority == 10 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AF, &retvalue); + rigGet.afGain = retvalue.f; + } + + //* Squelch + if ((commandPriority == 11 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_SQL, &retvalue); + rigGet.squelch = retvalue.f; + } + + //* NB noise blanker + if ((commandPriority == 12 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_NB, &rigGet.noiseBlanker); + + //* NR noise reduction + if ((commandPriority == 13 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_NR, &rigGet.noiseReduction); + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_NR, &retvalue); + rigGet.noiseReductionLevel = retvalue.i; + } + + //* NF notch filter + if ((commandPriority == 14 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_ANF, &rigGet.notchFilter); + + //* IF Shift + if ((commandPriority == 15 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_IF, &retvalue); + rigGet.ifShift = retvalue.i; + } + + //* CW + if ((commandPriority == 16 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) //&& mode=CW + { + rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_FBKIN, &rigGet.bkin); //Break-in + rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_APF, &rigGet.apf); //Audio Peak Filter + rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_KEYSPD, &retvalue); //Keyer speed WPM + rigGet.wpm = retvalue.i; + } + + //* FM + if ((commandPriority == 17 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) //&& mode=FM + { + rig_get_rptr_shift(my_rig, RIG_VFO_CURR, &rigGet.rptShift); //Repeater Shift + + int status = false; + if (!status) + { + rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TBURST, &status); //1750 Hz Tone burst + if (status) rigGet.toneType = 1; + } + if (!status) + { + rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TONE, &status); //CTCSS Tone Tx + if (status) rigGet.toneType = 2; + } + if (!status) + { + rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TSQL, &status); //CTCSS Tone Tx and Rx Squelch + if (status) rigGet.toneType = 3; + } + if (!status) rigGet.toneType = 0; + + if (rigGet.toneType == 2 || rigGet.toneType == 3) rig_get_ctcss_tone(my_rig, RIG_VFO_CURR, &rigGet.tone); + else if (rigGet.toneType == 4 || rigGet.toneType == 5) rig_get_dcs_code(my_rig, RIG_VFO_CURR, &rigGet.tone); + + if (rigGet.toneType && rigGet.tone == 0) + { + rigSet.toneType = 0; + rigCmd.tone = 1; + } + + if (rigGet.toneType != rigSet.toneType) rigCmd.toneList = 1; //update tone list + + //rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_CSQL, &status); + //rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_DSQL, &status); + } + + commandPriority ++; + if (commandPriority == 18) commandPriority = 1; + } + + emit resultReady(); +} diff --git a/rigdaemon.h b/rigdaemon.h new file mode 100644 index 0000000..4020535 --- /dev/null +++ b/rigdaemon.h @@ -0,0 +1,42 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#ifndef RIGDAEMON_H +#define RIGDAEMON_H + +#include +#include + +class RigDaemon : public QObject +{ + Q_OBJECT + +public: + explicit RigDaemon(QObject *parent = nullptr); + int rigConnect(); + +public slots: + void rigUpdate(); + +signals: + void resultReady(); + +}; + +#endif // RIGDAEMON_H diff --git a/rigdata.cpp b/rigdata.cpp new file mode 100644 index 0000000..84560e7 --- /dev/null +++ b/rigdata.cpp @@ -0,0 +1,26 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#include "rigdata.h" + +rigConnect rigCom; +rigSettings rigGet; +rigSettings rigSet; +rigCommand rigCmd; +rigCommand rigCap; diff --git a/rigdata.h b/rigdata.h new file mode 100644 index 0000000..e38ecbc --- /dev/null +++ b/rigdata.h @@ -0,0 +1,111 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#ifndef RIGDATA_H +#define RIGDATA_H + +#endif // RIGDATA_H + +#include //Hamlib + +#include + +typedef struct { + unsigned rigModel; //Hamlib rig model + QString rigPort; //COM port or IP address + unsigned serialSpeed; //Serial port baud rate + int civAddr; //CI-V address (decimal, Icom radio) + unsigned rigRefresh; //GUI refresh interval (ms) + int connected; //connected flag + bool fullPoll; //full polling flag +} rigConnect; + +typedef struct { + powerstat_t onoff; //on/off status + freq_t freqMain, freqSub; //Frequency + rmode_t mode, modeSub; //Mode + pbwidth_t bwidth, bwidthSub; //IF filter bandwidth + int bwNarrow; //IF narrow filter + vfo_t vfoMain, vfoSub; //VFO + vfo_t vfoTx; + split_t split; //Split + ptt_t ptt; //PTT + value_t sMeter; //Smeter signal strenght + value_t powerMeter; //RF power meter + value_t subMeter; //secondary meter + unsigned meter; //secondary meter type + float rfPower; //RF power output level + float rfGain; //RF gain rx + float afGain; //AF gain level + float squelch; //Squelch level + agc_level_e agc; //AGC level + int att; //Attenuator + int pre; //Preamplifier + ant_t ant, antTx, antRx; //Antenna + int rangeListTxIndex, rangeListRxIndex; + int tuner; //Tuner + int bkin; //CW Break-in + int wpm; //CW Keyer speed WPM + int apf; //Audio Peak Filter + int noiseBlanker; + int noiseReduction, noiseReductionLevel; + int notchFilter; + int ifShift; + rptr_shift_t rptShift; //Repeater shift + int toneType; //0 none, 1 burst 1750, 2 CTCSS, 3 CTCSS SQL, 4 DCS, 5 DCS SQL + tone_t tone; //CTCSS or DCS tone +} rigSettings; + +typedef struct { + int onoff; + int freqMain, freqSub; + int mode, modeSub; + int bwidth; + int bwidthList; + int vfo; + int split; + int vfoXchange; + int vfoCopy; + int ptt; + int rfPower; + int rfGain; + int afGain; + int squelch; + int agc; + int att; + int pre; + int ant; + int tuner; + int tune; + int bandUp; + int bandDown; + int bandChange; + int bkin; + int wpm; + int apf; + int noiseBlanker; + int noiseReduction, noiseReductionLevel; + int notchFilter; + int ifShift; + int rptShift; + int tone; + int antList; + int rangeList; + int toneList; +} rigCommand; diff --git a/smeter.cpp b/smeter.cpp new file mode 100644 index 0000000..d23bfd8 --- /dev/null +++ b/smeter.cpp @@ -0,0 +1,319 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#include "smeter.h" +#include +#include + +SMeter::SMeter(QWidget *parent) : QWidget(parent) +{ + lineColor = QColor(Qt::black); + bgColor = QColor(Qt::white); + progressColor = QColor(Qt::green); + + //Default value + minValue = 0; + maxValue = 100; + gateValue = 80; + longStep = 20; + shortStep = 10; + precision = 0; + + meterTx = 0; + + currentValue = -54; +} + +void SMeter::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); + + QFont font; + font = painter.font(); + font.setPointSize(font.pointSize() - 2); + painter.setFont(font); + + drawMeter(&painter); + drawProgress(&painter); + drawScaleSMeter(&painter); + drawScalePWRMeter(&painter); +} + +void SMeter::drawMeter(QPainter *painter) +{ + painter->save(); + + QPen pen(lineColor, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + painter->setPen(pen); + painter->setBrush(bgColor); + painter->drawRect(0, height()/3+2, width()-12, height()/3-4); + painter->restore(); +} + +void SMeter::drawProgress(QPainter *painter) +{ + double max, min; + double gate; + + painter->save(); + painter->setPen(Qt::NoPen); + painter->setBrush(progressColor); + + if (meterTx) //RF power meter + { + max = maxValue; + min = minValue; + gate = gateValue; + } + else //SMeter + { + max = 60; + min = -54; + gate = 0; + } + + double length = width()-14; + double increment = length / (max - min); + double initX, initXX; + + if (currentValue>gate) + { + initX = (gate - min) * increment; + QRect rect(1, height()/3+2+1, initX, height()/3-4-2); + painter->drawRect(rect); + + //Red bar + initXX = (currentValue - gate) * increment; + QRect rect2(initX+1, height()/3+2+1, initXX, height()/3-4-2); + painter->setBrush(Qt::red); + painter->drawRect(rect2); + } + else + { + initX = (currentValue - min) * increment; + QRect rect(1, height()/3+2+1, initX, height()/3-4-2); + painter->drawRect(rect); + } + + painter->restore(); +} + +void SMeter::drawScalePWRMeter(QPainter *painter) +{ + painter->save(); + painter->setPen(lineColor); + + double initX = 0; + double initTopY = height()*2/3-2; + double length = width()-12; + double increment = length / (maxValue - minValue); + + int longLineLen = 6; + int shortLineLen = 3; + + QFontMetrics meterFont(painter->font()); + double textHeight = meterFont.height(); + + //Draw scale and scale values based on range values Long lines + int stepNumber = (maxValue - minValue) / shortStep; + for (int i = 0; i <= stepNumber; i++) + { + double j = i * shortStep + minValue; + if (fmod(j,longStep) == 0) + { + if (j == minValue) //Do not draw the first value + { + QPointF textPot = QPointF(initX, initTopY + textHeight); + painter->drawText(textPot, "PO"); + + initX += increment * shortStep; + continue; + } + + QPointF topPot = QPointF(initX, initTopY); + QPointF bottomPot = QPointF(initX, initTopY + longLineLen); + painter->drawLine(topPot, bottomPot); + + QString strValue = QString("%1").arg(j, 0, 'f', precision); + double textWidth = fontMetrics().horizontalAdvance(strValue); + + QPointF textPot = QPointF(initX - textWidth / 2, initTopY + textHeight + longLineLen - 2); + painter->drawText(textPot, strValue); + } + else + { + + QPointF topPot = QPointF(initX, initTopY); + QPointF bottomPot = QPointF(initX, initTopY + shortLineLen); + painter->drawLine(topPot, bottomPot); + } + + initX += increment * shortStep; + } + + painter->restore(); +} + +void SMeter::drawScaleSMeter(QPainter *painter) +{ + int minValue = -54; //Set min and max value according to Hamlib SMeter definition + int maxValue = 60; + + int longLineLen = 6; + int shortLineLen = 3; + + double initX = 0; + int sUnit = 0; + + double initBottomY = height()/3+2; + double length = width()-12; + double increment = length / (maxValue - minValue); + + QFontMetrics meterFont(painter->font()); + double textHeight = meterFont.height(); + + painter->save(); + painter->setPen(lineColor); + + //Draw scale and scale values based on range values + int longStep = 12; + int shortStep = 6; + + for (int i = minValue; i <= 0; i = i + shortStep) //S0 to S9 + { + if (i == minValue) + { + QPointF textPot = QPointF(initX, initBottomY - 2); + painter->drawText(textPot, "S"); + + initX += increment * shortStep; + sUnit = sUnit + 1; + continue; + } + + if (i % longStep == 0) + { + QPointF topPot = QPointF(initX, initBottomY); + QPointF bottomPot = QPointF(initX, initBottomY - longLineLen); + painter->drawLine(topPot, bottomPot); + + QString strValue = QString::number(sUnit); + double textWidth = fontMetrics().horizontalAdvance(strValue); + QPointF textPot = QPointF(initX - textWidth / 2, initBottomY - textHeight / 2 - longLineLen + 2); + painter->drawText(textPot, strValue); + } + else + { + QPointF topPot = QPointF(initX, initBottomY); + QPointF bottomPot = QPointF(initX, initBottomY - shortLineLen); + painter->drawLine(topPot, bottomPot); + } + + sUnit = sUnit + 1; + initX += increment * shortStep; + } + initX -= increment * shortStep; + + shortStep = 10; + longStep = 20; + + for (int i = 0; i <= maxValue; i = i + shortStep) //S9+ to S9+60 + { + if (i % longStep == 0) + { + QPointF topPot = QPointF(initX, initBottomY); + QPointF bottomPot = QPointF(initX, initBottomY - longLineLen); + painter->drawLine(topPot, bottomPot); + + if (i == 0) //Do not draw the first value + { + initX += increment * shortStep; + continue; + } + + QString strValue = "+" + QString::number(i); + double textWidth = fontMetrics().horizontalAdvance(strValue); + + QPointF textPot = QPointF(initX - textWidth / 2, initBottomY - textHeight / 2 - longLineLen + 2); + painter->drawText(textPot, strValue); + } + else + { + QPointF topPot = QPointF(initX, initBottomY); + QPointF bottomPot = QPointF(initX, initBottomY - shortLineLen); + painter->drawLine(topPot, bottomPot); + } + + initX += increment * shortStep; + } + + painter->restore(); +} + +void SMeter::setMinValue(double value) +{ + minValue = value; + update(); +} + +void SMeter::setMaxValue(double value) +{ + maxValue = value; + update(); +} + +void SMeter::setGateValue(double value) +{ + gateValue = value; +} + +void SMeter::setLongStep(double value) +{ + longStep = value; + update(); +} + +void SMeter::setShortStep(double value) +{ + shortStep = value; + update(); +} + +void SMeter::setPrecision(int value) +{ + precision = value; + update(); +} + +void SMeter::setValue(double value) +{ + currentValue = value; + update(); +} + +void SMeter::setValue(int value) +{ + setValue(double(value)); +} + +void SMeter::setTx(bool Tx) +{ + meterTx = Tx; +} diff --git a/smeter.h b/smeter.h new file mode 100644 index 0000000..f35c0f3 --- /dev/null +++ b/smeter.h @@ -0,0 +1,73 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#ifndef SMETER_H +#define SMETER_H + +#include + +class SMeter : public QWidget +{ + Q_OBJECT + +public: + explicit SMeter(QWidget *parent = nullptr); + +public slots: + void setMinValue(double value); + void setMaxValue(double value); + void setGateValue(double value); + void setLongStep(double value); + void setShortStep(double value); + void setPrecision(int value); + + void setValue(double value); + void setValue(int value); + + void setTx(bool Tx); + +protected: + void paintEvent(QPaintEvent *); + void drawMeter(QPainter *painter); + void drawProgress(QPainter *painter); + void drawScaleSMeter(QPainter *painter); + void drawScalePWRMeter(QPainter *painter); + +private: + double minValue; //Minimum scale value + double maxValue; //Maximum scale value + double gateValue; //Gate value to bar color change + double longStep; //Long lines with equal steps + double shortStep; //Short lines with equal steps + int precision; //Precision, the last few decimal places + + double value; //target value + double currentValue; //current value + + bool meterTx; //Switch between SMeter or PowerMeter + + QColor bgColor; //background color + QColor lineColor; //line color + QColor progressColor; //progress color + +signals: + +}; + +#endif // SMETER_H diff --git a/submeter.cpp b/submeter.cpp new file mode 100644 index 0000000..e37a886 --- /dev/null +++ b/submeter.cpp @@ -0,0 +1,257 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#include "submeter.h" +#include +#include +#include + +SubMeter::SubMeter(QWidget *parent) : QWidget(parent) +{ + lineColor = QColor(Qt::black); + bgColor = QColor(Qt::white); + progressColor = QColor(Qt::green); + + //Default value + minValue = 0; + maxValue = 10; + gateValue = 10; + longStep = 5; + shortStep = 1; + precision = 0; + + meterSWR = 0; + + currentValue = 0; +} + +void SubMeter::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); + + QFont font; + font = painter.font(); + font.setPointSize(font.pointSize() - 2); + painter.setFont(font); + + drawMeter(&painter); + drawProgress(&painter); + drawScale(&painter); +} + +void SubMeter::drawMeter(QPainter *painter) +{ + painter->save(); + QPen pen(lineColor, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + painter->setPen(pen); + painter->setBrush(bgColor); + painter->drawRect(0, height()/3+2, width()-12, height()/3-4); + painter->restore(); +} + +void SubMeter::drawProgress(QPainter *painter) +{ + painter->save(); + painter->setPen(Qt::NoPen); + painter->setBrush(progressColor); + + double length = width()-14; + double increment; + + double initX, initXX; + + if (meterSWR) increment = length / (10 * log10(maxValue)); + else increment = length / (maxValue - minValue); + + if (currentValue>gateValue) + { + if (currentValue > maxValue) currentValue = maxValue; //Trim value if overload scale + + if (meterSWR) initX = 10 * log10(gateValue) * increment; + else initX = (gateValue - minValue) * increment; + QRect rect(1, height()/3+2+1, initX, height()/3-4-2); + painter->drawRect(rect); + + //Red bar + if (meterSWR) + { + if (currentValue > maxValue) currentValue = maxValue; //Trim value if overload scale + initXX = 10 * (log10(currentValue) - log10(gateValue)) * increment; + } + else + { + if (currentValue > maxValue) currentValue = maxValue; //Trim value if overload scale + initXX = (currentValue - gateValue) * increment; + } + QRect rect2(initX+1, height()/3+2+1, initXX+1, height()/3-4-2); + painter->setBrush(Qt::red); + painter->drawRect(rect2); + } + else + { + if (meterSWR) initX = 10 * log10(currentValue) * increment; + else initX = (currentValue - minValue) * increment; + QRect rect(1, height()/3+2+1, initX, height()/3-4-2); + painter->drawRect(rect); + } + + painter->restore(); +} + +void SubMeter::drawScale(QPainter *painter) +{ + painter->save(); + painter->setPen(lineColor); + + double initX = 0; + double initTopY = height()*2/3-2; + double length = width()-12; + double increment; + + int longLineLen = 6; + int shortLineLen = 3; + + QFontMetrics meterFont(painter->font()); + double textHeight = meterFont.height(); + + if (meterSWR) increment = length / (10 * log10(maxValue)); + else increment = length / (maxValue - minValue); + + if (meterSWR) //Draw SWR meter with log scale + { + double j = 1.0; + for (int i = 0; i <= 10; i++) //1.0 to 2.0 + { + QPointF topPot = QPointF(initX, initTopY); + QPointF bottomPot; + if (abs(j - 1.5) < 0.01 || abs(j - 2.0) < 0.01) + { + bottomPot = QPointF(initX, initTopY + longLineLen); + QString strValue = QString::number(j, 'f', 1); + double textWidth = fontMetrics().horizontalAdvance(strValue); + QPointF textPot = QPointF(initX - textWidth / 2, initTopY + textHeight + longLineLen - 2); + painter->drawText(textPot, strValue); + } + else bottomPot = QPointF(initX, initTopY + shortLineLen); + painter->drawLine(topPot, bottomPot); + j +=0.1; + initX = 10 * log10(j) * increment; + } + for (int i = 11; i <= 25; i++) //2.1 to 3.5 + { + QPointF topPot = QPointF(initX, initTopY); + QPointF bottomPot; + if (abs(j - 2.5) < 0.01 || abs(j - 3.0) < 0.01 || abs(j - 3.5) < 0.01) + { + bottomPot = QPointF(initX, initTopY + longLineLen); + QString strValue = QString::number(j, 'f', 1); + double textWidth = fontMetrics().horizontalAdvance(strValue); + QPointF textPot = QPointF(initX - textWidth / 2, initTopY + textHeight + longLineLen - 2); + painter->drawText(textPot, strValue); + painter->drawLine(topPot, bottomPot); + } + j +=0.1; + initX = 10 * log10(j) * increment; + } + } + else //Draw scale and scale values based on range values + { + int stepNumber = (maxValue - minValue) / shortStep; + for (int i = 0; i <= stepNumber; i++) + { + double j = i * shortStep + minValue; + if (fmod(j,longStep) == 0) + { + if (j == minValue) //Do not draw the first value + { + initX += increment * shortStep; + continue; + } + QPointF topPot = QPointF(initX, initTopY); + QPointF bottomPot = QPointF(initX, initTopY + longLineLen); + painter->drawLine(topPot, bottomPot); + + QString strValue = QString("%1").arg(j, 0, 'f', precision); + double textWidth = fontMetrics().horizontalAdvance(strValue); + QPointF textPot = QPointF(initX - textWidth / 2, initTopY + textHeight + longLineLen - 2); + painter->drawText(textPot, strValue); + } + else + { + QPointF topPot = QPointF(initX, initTopY); + QPointF bottomPot = QPointF(initX, initTopY + shortLineLen); + painter->drawLine(topPot, bottomPot); + } + initX += increment * shortStep; + } + } + painter->restore(); +} + +void SubMeter::setMinValue(double value) +{ + minValue = value; + update(); +} + +void SubMeter::setMaxValue(double value) +{ + maxValue = value; + update(); +} + +void SubMeter::setGateValue(double value) +{ + gateValue = value; +} + +void SubMeter::setLongStep(double value) +{ + longStep = value; + update(); +} + +void SubMeter::setShortStep(double value) +{ + shortStep = value; + update(); +} + +void SubMeter::setPrecision(int value) +{ + precision = value; + update(); +} + +void SubMeter::setValue(double value) +{ + currentValue = value; + update(); +} + +void SubMeter::setValue(int value) +{ + setValue(double(value)); +} + +void SubMeter::setMeterSWR(bool swr) +{ + meterSWR = swr; +} diff --git a/submeter.h b/submeter.h new file mode 100644 index 0000000..a4e1b29 --- /dev/null +++ b/submeter.h @@ -0,0 +1,71 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#ifndef SUBMETER_H +#define SUBMETER_H + +#include + +class SubMeter : public QWidget +{ + Q_OBJECT +public: + explicit SubMeter(QWidget *parent = nullptr); + +public slots: + void setMinValue(double value); + void setMaxValue(double value); + void setGateValue(double value); + void setLongStep(double value); + void setShortStep(double value); + void setPrecision(int value); + + void setValue(double value); + void setValue(int value); + + void setMeterSWR(bool swr); + +protected: + void paintEvent(QPaintEvent *); + void drawMeter(QPainter *painter); + void drawProgress(QPainter *painter); + void drawScale(QPainter *painter); + +private: + double minValue; //Minimum scale value + double maxValue; //Maximum scale value + double gateValue; //Gate value to bar color change + double longStep; //Long lines with equal steps + double shortStep; //Short lines with equal steps + int precision; //Precision, the last few decimal places + + int meterSWR; //set for SWR meter + + double value; //target value + double currentValue; //current value + + QColor bgColor; //background color + QColor lineColor; //line color + QColor progressColor; //progress color + +signals: + +}; + +#endif // SUBMETER_H diff --git a/vfodisplay.cpp b/vfodisplay.cpp new file mode 100644 index 0000000..c71ab03 --- /dev/null +++ b/vfodisplay.cpp @@ -0,0 +1,154 @@ +/** + ** This file is part of the CatRadio project. + ** Copyright 2022 Gianfranco Sordetti IZ8EWD . + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + **/ + + +#include "vfodisplay.h" +#include "guidata.h" + +#include +#include +#include +#include +#include + + +extern guiConfig guiConf; + + +vfoDisplay::vfoDisplay(QWidget *parent) : QWidget(parent) +{ + lineColor = QColor(Qt::black); + bgColor = QColor(Qt::white); + textColor = QColor(Qt::black); +} + +void vfoDisplay::paintEvent(QPaintEvent *) +{ + //setMouseTracking(true); + + QPainter painter(this); + painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); + + QFont font; + font = painter.font(); + font.setPointSize(height() - 18); + painter.setFont(font); + + drawDisplay(&painter); + drawText(&painter); +} + +void vfoDisplay::drawDisplay(QPainter *painter) +{ + painter->save(); + + QPen pen(lineColor, 1, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin); + painter->setPen(pen); + painter->setBrush(bgColor); + painter->drawRect(1, 1, width()-3, height()-2); + painter->restore(); +} + +void vfoDisplay::drawText(QPainter *painter) +{ + painter->save(); + painter->setPen(textColor); + + QFontMetrics meterFont(painter->font()); + double textHeight = meterFont.ascent(); + textWidth = meterFont.horizontalAdvance("0",-1); + + QPointF textPot; + + long val = currentValue; + + for (int i = 1; i < 10; i++) + { + val = qFloor(val/10); + int d = val % 10; + + if (i==2) + { + textPot = QPointF(width()-3-(textWidth+2)*i-4, textHeight); + painter->drawText(textPot, "."); + } + + textPot = QPointF(width()-3-(textWidth+2)*i, textHeight); + + if (val==0 && d==0) painter->drawText(textPot, " "); + else painter->drawText(textPot, QString::number(d)); + } + + painter->restore(); +} + +void vfoDisplay::setValue(unsigned long value) +{ + currentValue = value; + update(); +} + +//* Tuning using mouse buttons +void vfoDisplay::mousePressEvent(QMouseEvent *event) +{ + event->accept(); + + QPoint pointerPos = event->pos(); + + for (int i = 1; i < 10; i ++) + { + if (pointerPos.x() > (width()-3-(textWidth+2)*i+1) && pointerPos.x() < (width()-3-(textWidth+2)*(i-1)-1)) + { + if (guiConf.vfoDisplayMode && event->button() == Qt::LeftButton) //Up/Down mode + { + if (pointerPos.y() < height()/2) currentValue = currentValue + pow(10,i); //Up + else if (currentValue - pow(10,i) > 0) currentValue = currentValue - pow(10,i); //Down + } + else if (!guiConf.vfoDisplayMode) //Left/Right mode + { + if (event->button() == Qt::LeftButton) currentValue = currentValue + pow(10,i); //LeftButton + else if (currentValue - pow(10,i) > 0) currentValue = currentValue - pow(10,i); //RightButton + } + + break; + } + } + + update(); + emit on_valueChanged(currentValue); +} + +//* Tuning using mouse wheel +void vfoDisplay::wheelEvent(QWheelEvent *event) +{ + event->accept(); + + QPointF pointerPos = event->position(); + + for (int i = 1; i < 10; i ++) + { + if (pointerPos.x() > (width()-3-(textWidth+2)*i+1) && pointerPos.x() < (width()-3-(textWidth+2)*(i-1)-1)) + { + if (event->angleDelta().y() > 0) currentValue = currentValue + pow(10,i); //Wheel up + else if (currentValue - pow(10,i) > 0) currentValue = currentValue - pow(10,i); //Wheel down + } + } + + update(); + emit on_valueChanged(currentValue); +} diff --git a/vfodisplay.h b/vfodisplay.h new file mode 100644 index 0000000..9dee447 --- /dev/null +++ b/vfodisplay.h @@ -0,0 +1,37 @@ +#ifndef VFODISPLAY_H +#define VFODISPLAY_H + +#include + +class vfoDisplay : public QWidget +{ + Q_OBJECT + +public: + explicit vfoDisplay(QWidget *parent = nullptr); + +public slots: + void setValue(unsigned long value); + +signals: + void on_valueChanged(int value); + +protected: + void paintEvent(QPaintEvent *); + void drawDisplay(QPainter *painter); + void drawText(QPainter *painter); + void mousePressEvent(QMouseEvent *event); //Mouse buttons + void wheelEvent(QWheelEvent *event); //Mouse wheel + +private: + QColor bgColor; //background color + QColor lineColor; //line color + QColor textColor; //text color + + unsigned long currentValue; //current frequency value (Hz) + unsigned long value; //target value + + int textWidth; //number width +}; + +#endif // VFODISPLAY_H