Skip to content

Commit

Permalink
Merge pull request #575 from drowe67/ms-omnirig-support
Browse files Browse the repository at this point in the history
Add OmniRig support to FreeDV and fix several other bugs discovered during testing.
  • Loading branch information
tmiw authored Oct 25, 2023
2 parents f0ea16b + 9e60e1b commit 60a50f3
Show file tree
Hide file tree
Showing 19 changed files with 2,193 additions and 98 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ endif(APPLE)

# Adds a tag to the end of the version string. Leave empty
# for official release builds.
set(FREEDV_VERSION_TAG "devel")
set(FREEDV_VERSION_TAG "")

# Prevent in-source builds to protect automake/autoconf config.
# If an in-source build is attempted, you will still need to clean up a few
Expand Down
7 changes: 6 additions & 1 deletion USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -909,12 +909,17 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes

# Release Notes

## V1.9.4 TBD 2023
## V1.9.4 October 2023

1. Bugfixes:
* Fix issue causing hanging while testing serial port PTT. (PR #577)
* Fix issue causing improper RX Only reporting when hamlib is disabled. (PR #579)
* Fix compiler error on some Linux installations. (PR #578)
* Fix issue causing error on startup after testing setup with Easy Setup. (PR #575)
* Fix issue preventing PSK Reporter from being enabled by default. (PR #575)
2. Enhancements:
* Add experimental support for OmniRig to FreeDV. (PR #575)
* *Note: This is only available on Windows.*

## V1.9.3 October 2023

Expand Down
2 changes: 1 addition & 1 deletion src/config/ReportingConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ReportingConfiguration::ReportingConfiguration()

, manualFrequencyReporting("/Reporting/ManualFrequencyReporting", false)

, pskReporterEnabled("/Reporting/PSKReporter/Enable", false)
, pskReporterEnabled("/Reporting/PSKReporter/Enable", true)

, freedvReporterEnabled("/Reporting/FreeDV/Enable", true)
, freedvReporterHostname("/Reporting/FreeDV/Hostname", wxT(FREEDV_REPORTER_DEFAULT_HOSTNAME))
Expand Down
17 changes: 16 additions & 1 deletion src/config/RigControlConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ RigControlConfiguration::RigControlConfiguration()
, serialPTTPolarityRTS("/Rig/RTSPolarity", true)
, serialPTTUseDTR("/Rig/UseDTR", false)
, serialPTTPolarityDTR("/Rig/DTRPolarity", false)


#if defined(WIN32)
, useOmniRig("/Rig/UseOmniRig", false)
, omniRigRigId("/Rig/OmniRigRigId", 0)
#endif // defined(WIN32)

, useSerialPTTInput("/Rig/UseSerialPTTInput", false)
, serialPTTInputPort("/Rig/PttInPort", "")
, serialPTTInputPolarityCTS("/Rig/CTSPolarity", false)
Expand Down Expand Up @@ -72,6 +77,11 @@ void RigControlConfiguration::load(wxConfigBase* config)
load_(config, serialPTTUseDTR);
load_(config, serialPTTPolarityDTR);

#if defined(WIN32)
load_(config, useOmniRig);
load_(config, omniRigRigId);
#endif // defined(WIN32)

load_(config, useSerialPTTInput);
load_(config, serialPTTInputPort);
load_(config, serialPTTInputPolarityCTS);
Expand All @@ -98,6 +108,11 @@ void RigControlConfiguration::save(wxConfigBase* config)
save_(config, serialPTTUseDTR);
save_(config, serialPTTPolarityDTR);

#if defined(WIN32)
save_(config, useOmniRig);
save_(config, omniRigRigId);
#endif // defined(WIN32)

save_(config, useSerialPTTInput);
save_(config, serialPTTInputPort);
save_(config, serialPTTInputPolarityCTS);
Expand Down
5 changes: 5 additions & 0 deletions src/config/RigControlConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class RigControlConfiguration : public WxWidgetsConfigStore
ConfigurationDataElement<bool> serialPTTUseDTR;
ConfigurationDataElement<bool> serialPTTPolarityDTR;

#if defined(WIN32)
ConfigurationDataElement<bool> useOmniRig;
ConfigurationDataElement<unsigned int> omniRigRigId;
#endif // defined(WIN32)

ConfigurationDataElement<bool> useSerialPTTInput;
ConfigurationDataElement<wxString> serialPTTInputPort;
ConfigurationDataElement<bool> serialPTTInputPolarityCTS;
Expand Down
3 changes: 3 additions & 0 deletions src/dlg_easy_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ void EasySetupDialog::OnTest(wxCommandEvent& event)
{
txTestAudioDevice_->stop();
txTestAudioDevice_ = nullptr;

auto audioEngine = AudioEngineFactory::GetAudioEngine();
audioEngine->stop();
}

if (hamlibTestObject_ != nullptr && hamlibTestObject_->isConnected())
Expand Down
2 changes: 1 addition & 1 deletion src/dlg_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c
sizerRigControl->Add(sbSizer_ptt,0, wxALL | wxEXPAND, 5);

wxStaticBoxSizer* sbSizer_hamlib;
wxStaticBox *sb_hamlib = new wxStaticBox(m_rigControlTab, wxID_ANY, _("Hamlib Options"));
wxStaticBox *sb_hamlib = new wxStaticBox(m_rigControlTab, wxID_ANY, _("Frequency/Mode Control Options"));
sbSizer_hamlib = new wxStaticBoxSizer(sb_hamlib, wxVERTICAL);

m_ckboxEnableFreqModeChanges = new wxCheckBox(m_rigControlTab, wxID_ANY, _("Enable frequency and mode changes"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
Expand Down
136 changes: 130 additions & 6 deletions src/dlg_ptt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
#include <sstream>
#include <chrono>

#include "rig_control/HamlibRigController.h"
#include "rig_control/SerialPortOutRigController.h"

#if defined(WIN32)
#include "rig_control/omnirig/OmniRigController.h"
#endif // defined(WIN32)

using namespace std::chrono_literals;

extern wxConfigBase *pConfig;
Expand Down Expand Up @@ -217,6 +224,34 @@ ComPortsDlg::ComPortsDlg(wxWindow* parent, wxWindowID id, const wxString& title,

pttInBoxSizer->Add(gridSizerPttIn, 1, wxEXPAND, 5);

#if defined(WIN32)

//----------------------------------------------------------------------
// OmniRig for PTT/frequency control
//----------------------------------------------------------------------

wxStaticBox* omniRigBox = new wxStaticBox(panel, wxID_ANY, _("OmniRig Settings"));
wxStaticBoxSizer* omniRigBoxSizer = new wxStaticBoxSizer( omniRigBox, wxHORIZONTAL);

/* Use OmniRig checkbox. */

m_ckUseOmniRig = new wxCheckBox(omniRigBox, wxID_ANY, _("Enable CAT control via OmniRig"), wxDefaultPosition, wxSize(-1, -1), 0);
m_ckUseOmniRig->SetValue(false);
omniRigBoxSizer->Add(m_ckUseOmniRig, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);

/* OmniRig Rig ID combobox. */

omniRigBoxSizer->Add(new wxStaticText(omniRigBox, wxID_ANY, _("Rig ID:"), wxDefaultPosition, wxDefaultSize, 0),
0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
m_cbOmniRigRigId = new wxComboBox(omniRigBox, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);

m_cbOmniRigRigId->Append("1");
m_cbOmniRigRigId->Append("2");
omniRigBoxSizer->Add(m_cbOmniRigRigId, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
mainSizer->Add(omniRigBoxSizer, 0, wxEXPAND, 5);

#endif // defined(WIN32)

//----------------------------------------------------------------------
// OK - Cancel - Apply
//----------------------------------------------------------------------
Expand Down Expand Up @@ -250,6 +285,11 @@ ComPortsDlg::ComPortsDlg(wxWindow* parent, wxWindowID id, const wxString& title,
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(ComPortsDlg::OnInitDialog), NULL, this);
m_ckUseHamlibPTT->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(ComPortsDlg::PTTUseHamLibClicked), NULL, this);
m_ckUseSerialPTT->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(ComPortsDlg::PTTUseSerialClicked), NULL, this);

#if defined(WIN32)
m_ckUseOmniRig->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(ComPortsDlg::PTTUseOmniRigClicked), NULL, this);
#endif // defined(WIN32)

m_ckUsePTTInput->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(ComPortsDlg::PTTUseSerialInputClicked), NULL, this);
m_cbRigName->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(ComPortsDlg::HamlibRigNameChanged), NULL, this);
m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(ComPortsDlg::OnOK), NULL, this);
Expand Down Expand Up @@ -486,11 +526,18 @@ void ComPortsDlg::ExchangeData(int inout)
m_rbUseDTR->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.serialPTTUseDTR);
m_ckDTRPos->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.serialPTTPolarityDTR);

/* PTT Input */
m_ckUsePTTInput->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.useSerialPTTInput);
str = wxGetApp().appConfiguration.rigControlConfiguration.serialPTTInputPort;
m_cbCtlDevicePathPttIn->SetValue(str);
m_ckCTSPos->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.serialPTTInputPolarityCTS);

#if defined(WIN32)
/* OmniRig */
m_ckUseOmniRig->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.useOmniRig);
m_cbOmniRigRigId->SetSelection(wxGetApp().appConfiguration.rigControlConfiguration.omniRigRigId);
#endif // defined(WIN32)

updateControlState();
}

Expand Down Expand Up @@ -537,6 +584,12 @@ void ComPortsDlg::ExchangeData(int inout)
wxGetApp().appConfiguration.rigControlConfiguration.serialPTTInputPort = m_cbCtlDevicePathPttIn->GetValue();
wxGetApp().appConfiguration.rigControlConfiguration.serialPTTInputPolarityCTS = m_ckCTSPos->IsChecked();

#if defined(WIN32)
/* OmniRig */
wxGetApp().appConfiguration.rigControlConfiguration.useOmniRig = m_ckUseOmniRig->GetValue();
wxGetApp().appConfiguration.rigControlConfiguration.omniRigRigId = m_cbOmniRigRigId->GetCurrentSelection();
#endif // defined(WIN32)

wxGetApp().appConfiguration.save(pConfig);
}
}
Expand All @@ -547,6 +600,11 @@ void ComPortsDlg::ExchangeData(int inout)
void ComPortsDlg::PTTUseHamLibClicked(wxCommandEvent& event)
{
m_ckUseSerialPTT->SetValue(false);

#if defined(WIN32)
m_ckUseOmniRig->SetValue(false);
#endif // defined(WIN32)

updateControlState();
}

Expand Down Expand Up @@ -635,16 +693,15 @@ void ComPortsDlg::OnTest(wxCommandEvent& event) {
hamlib->disconnect();
}
}

/* Serial PTT */

if (m_ckUseSerialPTT->IsChecked()) {
else if (m_ckUseSerialPTT->IsChecked())
{
/* Serial PTT */
wxString ctrlport;
ctrlport = m_cbCtlDevicePath->GetValue();
if (g_verbose) fprintf(stderr, "opening serial port: ");
fputs(ctrlport.c_str(), stderr); // don't escape crazy Microsoft bakslash-ified comm port names
if (g_verbose) fprintf(stderr,"\n");

if (wxGetApp().CanAccessSerialPort((const char*)ctrlport.ToUTF8()))
{
std::shared_ptr<SerialPortOutRigController> serialPort = std::make_shared<SerialPortOutRigController>(
Expand Down Expand Up @@ -691,15 +748,74 @@ void ComPortsDlg::OnTest(wxCommandEvent& event) {
}
}

#if defined(WIN32)
else if (m_ckUseOmniRig->IsChecked())
{
// try to open rig
std::shared_ptr<OmniRigController> rig =
std::make_shared<OmniRigController>(
m_cbOmniRigRigId->GetCurrentSelection());

std::mutex mtx;
std::condition_variable cv;

rig->onRigError += [&](IRigController*, std::string error) {
CallAfter([&]() {
wxMessageBox("Couldn't connect to Radio with OmniRig. Make sure the rig ID and OmniRig configuration is correct.",
wxT("Error"), wxOK | wxICON_ERROR, this);

cv.notify_one();
});
};

rig->onRigConnected += [&](IRigController*) {
rig->ptt(true);
};

rig->onPttChange += [&](IRigController*, bool state) {
if (state)
{
std::this_thread::sleep_for(1s);
rig->ptt(false);
}
else
{
cv.notify_one();
}
};

rig->connect();

std::unique_lock<std::mutex> lk(mtx);
cv.wait(lk);

rig->disconnect();
}
#endif // defined(WIN32)
}

#if defined(WIN32)
//-------------------------------------------------------------------------
// PTTUseSerialClicked()
//-------------------------------------------------------------------------
void ComPortsDlg::PTTUseOmniRigClicked(wxCommandEvent& event)
{
m_ckUseHamlibPTT->SetValue(false);
m_ckUseSerialPTT->SetValue(false);
updateControlState();
}
#endif // defined(WIN32)

//-------------------------------------------------------------------------
// PTTUseSerialClicked()
//-------------------------------------------------------------------------
void ComPortsDlg::PTTUseSerialClicked(wxCommandEvent& event)
{
m_ckUseHamlibPTT->SetValue(false);
#if defined(WIN32)
m_ckUseOmniRig->SetValue(false);
#endif // defined(WIN32)

updateControlState();
}

Expand Down Expand Up @@ -787,7 +903,15 @@ void ComPortsDlg::updateControlState()
m_cbCtlDevicePathPttIn->Enable(m_ckUsePTTInput->GetValue());
m_ckCTSPos->Enable(m_ckUsePTTInput->GetValue());

m_buttonTest->Enable(m_ckUseHamlibPTT->GetValue() || m_ckUseSerialPTT->GetValue());
#if defined(WIN32)
m_cbOmniRigRigId->Enable(m_ckUseOmniRig->GetValue());
#endif // defined(WIN32)

m_buttonTest->Enable(m_ckUseHamlibPTT->GetValue() || m_ckUseSerialPTT->GetValue()
#if defined(WIN32)
|| m_ckUseOmniRig->GetValue()
#endif // defined(WIN32)
);

if (m_cbPttMethod->GetValue() == _("CAT") || m_cbPttMethod->GetValue() == _("None (RX Only)"))
{
Expand Down
12 changes: 10 additions & 2 deletions src/dlg_ptt.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#define __COMPORTS_DIALOG__

#include "main.h"
#include "rig_control/HamlibRigController.h"
#include <wx/settings.h>
#include <wx/xrc/xmlres.h>
#include <wx/xrc/xh_bmp.h>
Expand Down Expand Up @@ -62,7 +61,6 @@ class ComPortsDlg : public wxDialog
wxStaticText *m_stIcomCIVHex;
wxTextCtrl *m_tcIcomCIVHex;
wxComboBox *m_cbPttMethod;
std::shared_ptr<HamlibRigController> m_hamlib;

/* Serial Settings */

Expand All @@ -80,6 +78,11 @@ class ComPortsDlg : public wxDialog
wxCheckBox *m_ckCTSPos;
wxComboBox *m_cbCtlDevicePathPttIn;

#if defined(WIN32)
wxCheckBox *m_ckUseOmniRig;
wxComboBox *m_cbOmniRigRigId;
#endif // defined(WIN32)

/* Test - Ok - Cancel - Apply */

wxButton* m_buttonTest;
Expand All @@ -93,6 +96,11 @@ class ComPortsDlg : public wxDialog

void PTTUseHamLibClicked(wxCommandEvent& event);
void PTTUseSerialClicked(wxCommandEvent& event);

#if defined(WIN32)
void PTTUseOmniRigClicked(wxCommandEvent& event);
#endif // deinfed(WIN32)

void PTTUseSerialInputClicked(wxCommandEvent& event);
void HamlibRigNameChanged(wxCommandEvent& event);
void OnHamlibSerialPortChanged(wxCommandEvent& event);
Expand Down
Loading

0 comments on commit 60a50f3

Please sign in to comment.