From: drowe67 Date: Mon, 10 Jul 2017 22:13:55 +0000 (+0000) Subject: tested PTT hamlib.serial support on Windows and Linux X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=55b45b1269b083e2c690f218ce5fc4eaaeda8ec6;p=freetel-svn-tracking.git tested PTT hamlib.serial support on Windows and Linux git-svn-id: https://svn.code.sf.net/p/freetel/code@3290 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/freedv-dev/src/dlg_options.cpp b/freedv-dev/src/dlg_options.cpp index fb25de41..499ca565 100644 --- a/freedv-dev/src/dlg_options.cpp +++ b/freedv-dev/src/dlg_options.cpp @@ -260,10 +260,14 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c m_sdbSizer5Apply = new wxButton(this, wxID_APPLY); bSizer31->Add(m_sdbSizer5Apply, 0, wxALL, 2); - bSizer30->Add(bSizer31, 0, wxALIGN_CENTER_HORIZONTAL, 0); + bSizer30->Add(bSizer31, 0, wxALIGN_CENTER, 0); this->SetSizer(bSizer30); - this->Layout(); + if ( GetSizer() ) + { + GetSizer()->Fit(this); + } + this->Layout(); this->Centre(wxBOTH); @@ -540,7 +544,7 @@ void OptionsDlg::OnChooseVoiceKeyerWaveFile(wxCommandEvent& event) { wxGetApp().m_txtVoiceKeyerWaveFilePath, wxEmptyString, wxT("WAV files (*.wav)|*.wav"), - wxFD_SAVE + wxFD_OPEN ); if(openFileDialog.ShowModal() == wxID_CANCEL) { return; // the user changed their mind... diff --git a/freedv-dev/src/dlg_options.h b/freedv-dev/src/dlg_options.h index 7ac5b1f1..081448cb 100644 --- a/freedv-dev/src/dlg_options.h +++ b/freedv-dev/src/dlg_options.h @@ -36,9 +36,9 @@ class OptionsDlg : public wxDialog const wxPoint& pos = wxDefaultPosition, #ifdef __WXMSW__ /* we add debug console check box for windows */ - const wxSize& size = wxSize(600,360), + const wxSize& size = wxSize(600,410), #else - const wxSize& size = wxSize(600,360), + const wxSize& size = wxSize(600,380), #endif long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~OptionsDlg(); diff --git a/freedv-dev/src/dlg_ptt.cpp b/freedv-dev/src/dlg_ptt.cpp index 61bff1d1..1a04c9c4 100644 --- a/freedv-dev/src/dlg_ptt.cpp +++ b/freedv-dev/src/dlg_ptt.cpp @@ -54,45 +54,8 @@ ComPortsDlg::ComPortsDlg(wxWindow* parent, wxWindowID id, const wxString& title, // Hamlib for CAT PTT //---------------------------------------------------------------------- -#ifdef PREV__ wxStaticBoxSizer* staticBoxSizer18 = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Hamlib Settings")), wxHORIZONTAL); - - /* Use Hamlib for PTT checkbox. */ - - m_ckUseHamlibPTT = new wxCheckBox(this, wxID_ANY, _("Use Hamlib PTT"), wxDefaultPosition, wxSize(-1, -1), 0); - m_ckUseHamlibPTT->SetValue(false); - staticBoxSizer18->Add(m_ckUseHamlibPTT, 0, wxALIGN_CENTER_VERTICAL, 0); - - /* Hamlib Rig Type combobox. */ - - staticBoxSizer18->Add(new wxStaticText(this, wxID_ANY, _("Rig Model:"), wxDefaultPosition, wxDefaultSize, 0), - 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 20); - m_cbRigName = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(250, -1), 0, NULL, wxCB_DROPDOWN); - /* TODO(Joel): this is a hack. At the least, need to guarantee that m_hamLib - * exists. */ - wxGetApp().m_hamlib->populateComboBox(m_cbRigName); - m_cbRigName->SetSelection(wxGetApp().m_intHamlibRig); - staticBoxSizer18->Add(m_cbRigName, 0, wxALIGN_CENTER_VERTICAL, 0); - - /* Hamlib Serial Port combobox. */ - - staticBoxSizer18->Add(new wxStaticText(this, wxID_ANY, _("Serial Device:"), wxDefaultPosition, wxDefaultSize, 0), - 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 20); - m_cbSerialPort = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(140, -1), 0, NULL, wxCB_DROPDOWN); - staticBoxSizer18->Add(m_cbSerialPort, 0, wxALIGN_CENTER_VERTICAL, 0); - - /* Hamlib Serial Rate combobox. */ - - staticBoxSizer18->Add(new wxStaticText(this, wxID_ANY, _("Serial Rate:"), wxDefaultPosition, wxDefaultSize, 0), - 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 20); - m_cbSerialRate = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(140, -1), 0, NULL, wxCB_DROPDOWN); - staticBoxSizer18->Add(m_cbSerialRate, 0, wxALIGN_CENTER_VERTICAL, 0); - - mainSizer->Add(staticBoxSizer18, 0, wxEXPAND, 5); -#endif - - wxStaticBoxSizer* staticBoxSizer18 = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Hamlib Settings")), wxHORIZONTAL); - wxGridSizer* gridSizerhl = new wxGridSizer(4, 2, 0, 0); + wxGridSizer* gridSizerhl = new wxGridSizer(5, 2, 0, 0); staticBoxSizer18->Add(gridSizerhl, 1, wxEXPAND|wxALIGN_LEFT, 5); /* Use Hamlib for PTT checkbox. */ @@ -125,6 +88,11 @@ ComPortsDlg::ComPortsDlg(wxWindow* parent, wxWindowID id, const wxString& title, m_cbSerialRate = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(140, -1), 0, NULL, wxCB_DROPDOWN); gridSizerhl->Add(m_cbSerialRate, 0, wxALIGN_CENTER_VERTICAL, 0); + gridSizerhl->Add(new wxStaticText(this, wxID_ANY, _("Serial Params:"), wxDefaultPosition, wxDefaultSize, 0), + 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 20); + m_cbSerialParams = new wxStaticText(this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, 0); + gridSizerhl->Add(m_cbSerialParams, 0, wxALIGN_CENTER_VERTICAL, 0); + mainSizer->Add(staticBoxSizer18, 0, wxEXPAND, 5); //---------------------------------------------------------------------- @@ -506,11 +474,11 @@ void ComPortsDlg::OnTest(wxCommandEvent& event) { } else { wxString hamlib_serial_config; - hamlib_serial_config.sprintf("Serial config: %d, %d, %d", + hamlib_serial_config.sprintf(" %d, %d, %d", hamlib->get_serial_rate(), hamlib->get_data_bits(), hamlib->get_stop_bits()); - wxMessageBox(hamlib_serial_config, wxT("Hamlib Serial Config"), wxOK | wxICON_INFORMATION, this); + m_cbSerialParams->SetLabel(hamlib_serial_config); } // toggle PTT @@ -540,12 +508,16 @@ void ComPortsDlg::OnTest(wxCommandEvent& event) { #if defined(__WXGTK__) || defined(__WXOSX__) ctrlport = m_cbCtlDevicePath->GetValue(); #endif + fprintf(stderr, "opening serial port\n"); + bool success = serialport->openport(ctrlport.c_str(), m_rbUseRTS->GetValue(), m_ckRTSPos->IsChecked(), m_rbUseDTR->GetValue(), m_ckDTRPos->IsChecked()); + fprintf(stderr, "serial port open\n"); + if (!success) { wxMessageBox("Couldn't open serial port", wxT("Error"), wxOK | wxICON_ERROR, this); } @@ -555,6 +527,10 @@ void ComPortsDlg::OnTest(wxCommandEvent& event) { serialport->ptt(true); wxSleep(1); serialport->ptt(false); + + fprintf(stderr, "closing serial port\n"); + serialport->closeport(); + fprintf(stderr, "serial port closed\n"); } } diff --git a/freedv-dev/src/dlg_ptt.h b/freedv-dev/src/dlg_ptt.h index 997d08a1..5a35c3bd 100644 --- a/freedv-dev/src/dlg_ptt.h +++ b/freedv-dev/src/dlg_ptt.h @@ -55,6 +55,7 @@ class ComPortsDlg : public wxDialog wxComboBox *m_cbRigName; wxComboBox *m_cbSerialPort; wxComboBox *m_cbSerialRate; + wxStaticText *m_cbSerialParams; Hamlib *m_hamlib; /* Serial Settings */ diff --git a/freedv-dev/src/fdmdv2_main.cpp b/freedv-dev/src/fdmdv2_main.cpp index 39f8d178..8e1ac046 100644 --- a/freedv-dev/src/fdmdv2_main.cpp +++ b/freedv-dev/src/fdmdv2_main.cpp @@ -248,6 +248,7 @@ bool MainApp::OnInit() //------------------------------------------------------------------------- int MainApp::OnExit() { + fprintf(stderr, "MainApp::OnExit\n"); if (m_plugIn) { #ifdef __WXMSW__ FreeLibrary((HMODULE)m_plugInHandle); @@ -647,6 +648,7 @@ MainFrame::~MainFrame() int w; int h; + fprintf(stderr, "MainFrame::~MainFrame()\n"); //fclose(ftest); #ifdef __WXMSW__ fclose(g_logfile); @@ -664,18 +666,11 @@ MainFrame::~MainFrame() if (wxGetApp().m_hamlib) delete wxGetApp().m_hamlib; if (wxGetApp().m_serialport) delete wxGetApp().m_serialport; - //MainApp *pApp = wxGetApp(); wxConfigBase *pConfig = wxConfigBase::Get(); if(pConfig) { if (!IsIconized()) { GetClientSize(&w, &h); - - // big hack - for some reason height shrinks by this much - // every time FreeDV runs! I have no idea why - - h += 23; - GetPosition(&x, &y); printf("x = %d y = %d w = %d h = %d\n", x,y,w,h); pConfig->Write(wxT("/MainFrame/left"), (long) x); @@ -1288,6 +1283,7 @@ void MainFrame::OnTimer(wxTimerEvent &evt) //------------------------------------------------------------------------- void MainFrame::OnCloseFrame(wxCloseEvent& event) { + fprintf(stderr, "MainFrame::OnCloseFrame()\n"); Pa_Terminate(); Destroy(); } @@ -2049,6 +2045,7 @@ void MainFrame::OnRecFileFromRadio(wxCommandEvent& event) //------------------------------------------------------------------------- void MainFrame::OnExit(wxCommandEvent& event) { + fprintf(stderr, "MainFrame::OnExit\n"); wxUnusedVar(event); #ifdef _USE_TIMER m_plotTimer.Stop(); @@ -2495,10 +2492,10 @@ void MainFrame::stopRxStream() { m_RxRunning = false; - fprintf(g_logfile, "waiting for thread to stop"); + fprintf(stderr, "waiting for thread to stop\n"); m_txRxThread->m_run = 0; m_txRxThread->Wait(); - fprintf(g_logfile, "thread stopped"); + fprintf(stderr, "thread stopped\n"); m_rxInPa->stop(); m_rxInPa->streamClose(); diff --git a/freedv-dev/src/serialport.cpp b/freedv-dev/src/serialport.cpp index ceba8e0d..59dd0c93 100644 --- a/freedv-dev/src/serialport.cpp +++ b/freedv-dev/src/serialport.cpp @@ -101,6 +101,7 @@ bool Serialport::openport(const char name[], bool useRTS, bool RTSPos, bool useD t.c_cflag = ( CS8 /* 8 bits */ | CREAD /* enable receiver */ + /* Fun snippet from the FreeBSD manpage: @@ -111,6 +112,7 @@ bool Serialport::openport(const char name[], bool useRTS, bool RTSPos, bool useD */ | CLOCAL /* ignore modem status lines */ ); + t.c_lflag = 0; /* No local modes */ if(tcsetattr(com_handle, TCSANOW, &t)==-1) { close(com_handle); @@ -124,6 +126,8 @@ bool Serialport::openport(const char name[], bool useRTS, bool RTSPos, bool useD } +// fixme: this takes about one second to close under Linux + void Serialport::closeport() { #ifdef _WIN32