tested PTT hamlib.serial support on Windows and Linux
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 10 Jul 2017 22:13:55 +0000 (22:13 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 10 Jul 2017 22:13:55 +0000 (22:13 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3290 01035d8c-6547-0410-b346-abe4f91aad63

freedv-dev/src/dlg_options.cpp
freedv-dev/src/dlg_options.h
freedv-dev/src/dlg_ptt.cpp
freedv-dev/src/dlg_ptt.h
freedv-dev/src/fdmdv2_main.cpp
freedv-dev/src/serialport.cpp

index fb25de415db2f07f0189fb5990a109a5b467e86b..499ca5659eeceabc97b39513221a0f9ff69c47b4 100644 (file)
@@ -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...
index 7ac5b1f163f4125f068c22af9696b647dc05612e..081448cbba39ff079d5cfbf8284ff15ad7164347 100644 (file)
@@ -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();
index 61bff1d194dc158ec5119e7b5d25023c8fa71ba9..1a04c9c4e5034aaafc545ddd3b5be4451395e60e 100644 (file)
@@ -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");
     }
     
 }
index 997d08a17efa8b760fad621c4b4161fd6add6bb6..5a35c3bd14c0d644e96b050b052e12e4788f7714 100644 (file)
@@ -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 */
index 39f8d1782d6b3097b80bed1f9b9fe3a36573cde2..8e1ac046d745ca7b9f599918f4a00adb1873be3a 100644 (file)
@@ -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();
index ceba8e0d5152acf05e1e76266a56f0ce16ef99af..59dd0c93936fa3a69362a084c9a38c337ab3e54b 100644 (file)
@@ -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