Skip to content

Commit

Permalink
Merge branch 'master' into ms-json-reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed May 18, 2023
2 parents 96b19b7 + 7af82bc commit 2f84b53
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 11 deletions.
2 changes: 2 additions & 0 deletions USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
3. Enhancements:
* Add last received SNR to callsign list. (PR #389, #391)
* Add support for FreeDV Reporter web-based tool. (PR #390)
* Defer sound device checking until Start is pushed. (PR #393)
* Add ability for Hamlib to use RTS/DTR instead of CAT for PTT. (PR #394)

## V1.8.9 April 2023

Expand Down
24 changes: 22 additions & 2 deletions src/dlg_easy_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ EasySetupDialog::EasySetupDialog(wxWindow* parent, wxWindowID id, const wxString
m_hamlibBox = new wxStaticBox(setupCatControlBox, wxID_ANY, _("Hamlib CAT Control"));
m_hamlibBox->Hide();
wxStaticBoxSizer* hamlibBoxSizer = new wxStaticBoxSizer(m_hamlibBox, wxVERTICAL);
wxGridSizer* gridSizerhl = new wxGridSizer(4, 2, 0, 0);
wxGridSizer* gridSizerhl = new wxGridSizer(5, 2, 0, 0);
hamlibBoxSizer->Add(gridSizerhl);
setupCatControlBoxSizer->Add(hamlibBoxSizer);

Expand Down Expand Up @@ -152,6 +152,19 @@ EasySetupDialog::EasySetupDialog(wxWindow* parent, wxWindowID id, const wxString
m_cbSerialRate = new wxComboBox(m_hamlibBox, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(140, -1), 0, NULL, wxCB_DROPDOWN);
gridSizerhl->Add(m_cbSerialRate, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);

/* Hamlib PTT Method combobox. */

gridSizerhl->Add(new wxStaticText(m_hamlibBox, wxID_ANY, _("PTT uses:"), wxDefaultPosition, wxDefaultSize, 0),
0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 20);
m_cbPttMethod = new wxComboBox(m_hamlibBox, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);
m_cbPttMethod->SetSize(wxSize(140, -1));
gridSizerhl->Add(m_cbPttMethod, 0, wxALIGN_CENTER_VERTICAL, 0);

// Add valid PTT options to combo box.
m_cbPttMethod->Append(wxT("CAT"));
m_cbPttMethod->Append(wxT("RTS"));
m_cbPttMethod->Append(wxT("DTR"));

/* Serial port box */
m_serialBox = new wxStaticBox(setupCatControlBox, wxID_ANY, _("Serial PTT"));
m_serialBox->Hide();
Expand Down Expand Up @@ -514,6 +527,8 @@ void EasySetupDialog::ExchangePttDeviceData(int inout)
}

m_tcIcomCIVHex->SetValue(wxString::Format(wxT("%02X"), wxGetApp().m_intHamlibIcomCIVHex));

m_cbPttMethod->SetSelection((int)wxGetApp().m_hamlibPttType);
}
else if (wxGetApp().m_boolUseSerialPTT)
{
Expand Down Expand Up @@ -570,6 +585,9 @@ void EasySetupDialog::ExchangePttDeviceData(int inout)
pConfig->Write(wxT("/Hamlib/RigNameStr"), wxGetApp().m_strHamlibRigName);
pConfig->Write(wxT("/Hamlib/SerialPort"), wxGetApp().m_strHamlibSerialPort);
pConfig->Write(wxT("/Hamlib/SerialRate"), wxGetApp().m_intHamlibSerialRate);

wxGetApp().m_hamlibPttType = (Hamlib::PttType)m_cbPttMethod->GetSelection();
pConfig->Write(wxT("/Hamlib/PttType"), (long)wxGetApp().m_hamlibPttType);
}
else if (m_ckUseSerialPTT->GetValue())
{
Expand Down Expand Up @@ -813,7 +831,9 @@ void EasySetupDialog::OnTest(wxCommandEvent& event)
return;
}

if (!hamlibTestObject_->connect(rig, (const char*)serialPort.ToUTF8(), rate, civHexAddress))
auto pttType = (Hamlib::PttType)m_cbPttMethod->GetSelection();

if (!hamlibTestObject_->connect(rig, (const char*)serialPort.ToUTF8(), rate, civHexAddress, pttType))
{
wxMessageBox(
"Couldn't connect to Radio with Hamlib. Make sure the Hamlib serial Device, Rate, and Params match your radio",
Expand Down
1 change: 1 addition & 0 deletions src/dlg_easy_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class EasySetupDialog : public wxDialog
wxStaticText *m_cbSerialParams;
wxStaticText *m_stIcomCIVHex;
wxTextCtrl *m_tcIcomCIVHex;
wxComboBox *m_cbPttMethod;

// Step 2b: Serial PTT
wxStaticBox* m_serialBox;
Expand Down
27 changes: 24 additions & 3 deletions src/dlg_ptt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ComPortsDlg::ComPortsDlg(wxWindow* parent, wxWindowID id, const wxString& title,

wxStaticBox* hamlibBox = new wxStaticBox(panel, wxID_ANY, _("Hamlib Settings"));
wxStaticBoxSizer* staticBoxSizer18 = new wxStaticBoxSizer( hamlibBox, wxHORIZONTAL);
wxGridSizer* gridSizerhl = new wxGridSizer(6, 2, 0, 0);
wxGridSizer* gridSizerhl = new wxGridSizer(7, 2, 0, 0);
staticBoxSizer18->Add(gridSizerhl, 1, wxEXPAND|wxALIGN_LEFT, 5);

/* Use Hamlib for PTT checkbox. */
Expand Down Expand Up @@ -100,7 +100,20 @@ ComPortsDlg::ComPortsDlg(wxWindow* parent, wxWindowID id, const wxString& title,
0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 20);
m_cbSerialRate = new wxComboBox(hamlibBox, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(140, -1), 0, NULL, wxCB_DROPDOWN);
gridSizerhl->Add(m_cbSerialRate, 0, wxALIGN_CENTER_VERTICAL, 0);

/* Hamlib PTT Method combobox. */

gridSizerhl->Add(new wxStaticText(hamlibBox, wxID_ANY, _("PTT uses:"), wxDefaultPosition, wxDefaultSize, 0),
0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 20);
m_cbPttMethod = new wxComboBox(hamlibBox, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);
m_cbPttMethod->SetSize(wxSize(140, -1));
gridSizerhl->Add(m_cbPttMethod, 0, wxALIGN_CENTER_VERTICAL, 0);

// Add valid PTT options to combo box.
m_cbPttMethod->Append(wxT("CAT"));
m_cbPttMethod->Append(wxT("RTS"));
m_cbPttMethod->Append(wxT("DTR"));

gridSizerhl->Add(new wxStaticText(hamlibBox, wxID_ANY, _("Serial Params:"), wxDefaultPosition, wxDefaultSize, 0),
0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 20);
m_cbSerialParams = new wxStaticText(hamlibBox, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, 0);
Expand Down Expand Up @@ -437,6 +450,8 @@ void ComPortsDlg::ExchangeData(int inout)

m_tcIcomCIVHex->SetValue(wxString::Format(wxT("%02X"), wxGetApp().m_intHamlibIcomCIVHex));

m_cbPttMethod->SetSelection((int)wxGetApp().m_hamlibPttType);

/* Serial PTT */

m_ckUseSerialPTT->SetValue(wxGetApp().m_boolUseSerialPTT);
Expand Down Expand Up @@ -484,11 +499,14 @@ void ComPortsDlg::ExchangeData(int inout)
}
if (g_verbose) fprintf(stderr, "serial rate: %d\n", wxGetApp().m_intHamlibSerialRate);

wxGetApp().m_hamlibPttType = (Hamlib::PttType)m_cbPttMethod->GetSelection();

pConfig->Write(wxT("/Hamlib/UseForPTT"), wxGetApp().m_boolHamlibUseForPTT);
pConfig->Write(wxT("/Hamlib/RigNameStr"), wxGetApp().m_strHamlibRigName);
pConfig->Write(wxT("/Hamlib/SerialPort"), wxGetApp().m_strHamlibSerialPort);
pConfig->Write(wxT("/Hamlib/SerialRate"), wxGetApp().m_intHamlibSerialRate);

pConfig->Write(wxT("/Hamlib/PttType"), (long)wxGetApp().m_hamlibPttType);

/* Serial settings */

wxGetApp().m_boolUseSerialPTT = m_ckUseSerialPTT->IsChecked();
Expand Down Expand Up @@ -560,6 +578,8 @@ void ComPortsDlg::OnTest(wxCommandEvent& event) {
long hexAddress = 0;
m_tcIcomCIVHex->GetValue().ToLong(&hexAddress, 16);

auto pttType = (Hamlib::PttType)m_cbPttMethod->GetSelection();

// display serial params

if (g_verbose) fprintf(stderr, "serial rate: %d\n", serial_rate);
Expand All @@ -568,7 +588,7 @@ void ComPortsDlg::OnTest(wxCommandEvent& event) {
{
// try to open rig
Hamlib *hamlib = wxGetApp().m_hamlib;
bool status = hamlib->connect(rig, port.mb_str(wxConvUTF8), serial_rate, hexAddress);
bool status = hamlib->connect(rig, port.mb_str(wxConvUTF8), serial_rate, hexAddress, pttType);
if (status == false) {
wxMessageBox("Couldn't connect to Radio with Hamlib. Make sure the Hamlib serial Device, Rate, and Params match your radio",
wxT("Error"), wxOK | wxICON_ERROR, this);
Expand Down Expand Up @@ -725,6 +745,7 @@ void ComPortsDlg::updateControlState()
m_cbSerialPort->Enable(m_ckUseHamlibPTT->GetValue());
m_cbSerialRate->Enable(m_ckUseHamlibPTT->GetValue());
m_tcIcomCIVHex->Enable(m_ckUseHamlibPTT->GetValue());
m_cbPttMethod->Enable(m_ckUseHamlibPTT->GetValue());

m_cbCtlDevicePath->Enable(m_ckUseSerialPTT->GetValue());
m_rbUseDTR->Enable(m_ckUseSerialPTT->GetValue());
Expand Down
1 change: 1 addition & 0 deletions src/dlg_ptt.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ComPortsDlg : public wxDialog
wxStaticText *m_cbSerialParams;
wxStaticText *m_stIcomCIVHex;
wxTextCtrl *m_tcIcomCIVHex;
wxComboBox *m_cbPttMethod;
Hamlib *m_hamlib;

/* Serial Settings */
Expand Down
16 changes: 15 additions & 1 deletion src/hamlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void Hamlib::populateComboBox(wxComboBox *cb) {
}
}

bool Hamlib::connect(unsigned int rig_index, const char *serial_port, const int serial_rate, const int civ_hex) {
bool Hamlib::connect(unsigned int rig_index, const char *serial_port, const int serial_rate, const int civ_hex, const PttType pttType) {

/* Look up model from index. */

Expand Down Expand Up @@ -187,6 +187,20 @@ bool Hamlib::connect(unsigned int rig_index, const char *serial_port, const int
if (g_verbose) fprintf(stderr, "hamlib: data_bits..: %d\n", get_data_bits());
if (g_verbose) fprintf(stderr, "hamlib: stop_bits..: %d\n", get_stop_bits());

// Set PTT type as needed.
switch(pttType)
{
case PTT_VIA_RTS:
rig_set_conf(m_rig, rig_token_lookup(m_rig, "ptt_type"), "RTS");
break;
case PTT_VIA_DTR:
rig_set_conf(m_rig, rig_token_lookup(m_rig, "ptt_type"), "DTR");
break;
case PTT_VIA_CAT:
default:
break;
}

if (rig_open(m_rig) == RIG_OK) {
if (g_verbose) fprintf(stderr, "hamlib: rig_open() OK\n");

Expand Down
9 changes: 8 additions & 1 deletion src/hamlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ extern "C" {
class Hamlib {

public:
enum PttType
{
PTT_VIA_CAT = 0,
PTT_VIA_RTS,
PTT_VIA_DTR
};

Hamlib();
~Hamlib();

Expand All @@ -23,7 +30,7 @@ class Hamlib {
std::string rigIndexToName(unsigned int rigIndex);

void populateComboBox(wxComboBox *cb);
bool connect(unsigned int rig_index, const char *serial_port, const int serial_rate, const int civ_hex = 0);
bool connect(unsigned int rig_index, const char *serial_port, const int serial_rate, const int civ_hex = 0, const PttType pttType = PTT_VIA_CAT);
bool ptt(bool press, wxString &hamlibError);
void enable_mode_detection(wxStaticText* statusBox, wxTextCtrl* freqBox, bool vhfUhfMode);
void disable_mode_detection();
Expand Down
14 changes: 11 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ void MainFrame::loadConfiguration_()
wxGetApp().m_intHamlibRig = wxGetApp().m_hamlib->rigNameToIndex(std::string(wxGetApp().m_strHamlibRigName.ToUTF8()));
}

wxGetApp().m_hamlibPttType = (Hamlib::PttType)pConfig->ReadLong("/Hamlib/PttType", 0);
wxGetApp().m_strHamlibSerialPort = pConfig->Read("/Hamlib/SerialPort", "");
wxGetApp().m_intHamlibSerialRate = pConfig->ReadLong("/Hamlib/SerialRate", 0);

Expand Down Expand Up @@ -741,8 +742,6 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent, wxID_ANY, _("FreeDV ")
m_panelTestFrameErrorsHist->setBarGraph(1);
m_panelTestFrameErrorsHist->setLogY(1);

validateSoundCardSetup();

// this->Connect(m_menuItemHelpUpdates->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler(TopFrame::OnHelpCheckUpdatesUI));
m_togBtnOnOff->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(MainFrame::OnTogBtnOnOffUI), NULL, this);
m_togBtnAnalog->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(MainFrame::OnTogBtnAnalogClickUI), NULL, this);
Expand Down Expand Up @@ -840,6 +839,15 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent, wxID_ANY, _("FreeDV ")

pConfig->Write(wxT("/FirstTimeUse"), false);

if (wxGetApp().m_firstTimeUse)
{
// Initial setup. Display Easy Setup dialog.
CallAfter([&]() {
EasySetupDialog* dlg = new EasySetupDialog(this);
dlg->ShowModal();
});
}

//#define FTEST
#ifdef FTEST
ftest = fopen("ftest.raw", "wb");
Expand Down Expand Up @@ -934,7 +942,7 @@ MainFrame::~MainFrame()
pConfig->Write("/Hamlib/SerialPort", wxGetApp().m_strHamlibSerialPort);
pConfig->Write("/Hamlib/SerialRate", wxGetApp().m_intHamlibSerialRate);
pConfig->Write("/Hamlib/IcomCIVHex", wxGetApp().m_intHamlibIcomCIVHex);

pConfig->Write("/Hamlib/PttType", (long)wxGetApp().m_hamlibPttType);

pConfig->Write(wxT("/File/playFileToMicInPath"), wxGetApp().m_playFileToMicInPath);
pConfig->Write(wxT("/File/recFileFromRadioPath"), wxGetApp().m_recFileFromRadioPath);
Expand Down
1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class MainApp : public wxApp
unsigned int m_intHamlibSerialRate;
unsigned int m_intHamlibIcomCIVHex;
Hamlib *m_hamlib;
Hamlib::PttType m_hamlibPttType;

bool m_boolUseSerialPTT;
wxString m_strRigCtrlPort;
Expand Down
2 changes: 1 addition & 1 deletion src/ongui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ bool MainFrame::OpenHamlibRig() {
int serial_rate = wxGetApp().m_intHamlibSerialRate;
if (wxGetApp().CanAccessSerialPort((const char*)port.ToUTF8()))
{
bool status = wxGetApp().m_hamlib->connect(rig, port.mb_str(wxConvUTF8), serial_rate, wxGetApp().m_intHamlibIcomCIVHex);
bool status = wxGetApp().m_hamlib->connect(rig, port.mb_str(wxConvUTF8), serial_rate, wxGetApp().m_intHamlibIcomCIVHex, wxGetApp().m_hamlibPttType);
if (status == false)
{
wxMessageBox("Couldn't connect to Radio with hamlib", wxT("Error"), wxOK | wxICON_ERROR, this);
Expand Down

0 comments on commit 2f84b53

Please sign in to comment.