serial & Hamlib PTT tested OK on Linux
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 2 Jun 2013 00:19:57 +0000 (00:19 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 2 Jun 2013 00:19:57 +0000 (00:19 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1303 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/src/dlg_ptt.cpp
fdmdv2/src/fdmdv2_main.cpp

index 06236ff96098a3dca0d3bf7aaac74c9e8fa9e783..2eb3dbac162d427385aa12b8ad36f8aea58b9896 100644 (file)
@@ -253,7 +253,9 @@ void ComPortsDlg::populatePortList()
     /* TODO(Joel): http://stackoverflow.com/questions/2530096/how-to-find-all-serial-devices-ttys-ttyusb-on-linux-without-opening-them */
     m_cbSerialPort->Clear();
     m_cbSerialPort->Append("/dev/ttyUSB0");
+    m_cbSerialPort->Append("/dev/ttyUSB1");
     m_cbSerialPort->Append("/dev/ttyS0");
+    m_cbSerialPort->Append("/dev/ttyS1");
 #endif
 }
 
@@ -316,6 +318,7 @@ void ComPortsDlg::ExchangeData(int inout)
         wxGetApp().m_boolDTRPos                 = m_ckDTRPos->IsChecked();
         
         pConfig->Write(wxT("/Rig/UseSerialPTT"),    wxGetApp().m_boolUseSerialPTT);
+        pConfig->Write(wxT("/Rig/Port"),            wxGetApp().m_strRigCtrlPort); 
         pConfig->Write(wxT("/Rig/UseRTS"),          wxGetApp().m_boolUseRTS);
         pConfig->Write(wxT("/Rig/RTSPolarity"),     wxGetApp().m_boolRTSPos);
         pConfig->Write(wxT("/Rig/UseDTR"),          wxGetApp().m_boolUseDTR);
index 9baae5b4792c7377160fced1370d8516a7d8f7cf..95aa0d57cd88589ff008d4b61133c352d4d85746 100644 (file)
@@ -969,25 +969,23 @@ void MainFrame::togglePTT(void) {
           0      0        1
           1      0        0
 
-          -> exclusive NOR
+          exclusive NOR
     */
 
     if(wxGetApp().m_boolUseSerialPTT && m_serialPort != NULL) {
         if (wxGetApp().m_boolUseRTS) {
-            bool serialLine = !(g_tx ^ wxGetApp().m_boolRTSPos);
-            printf("g_tx: %d m_boolRTSPos: %d serialLine: %d\n", g_tx, wxGetApp().m_boolRTSPos, serialLine);
-            if (serialLine)
+            printf("g_tx: %d m_boolRTSPos: %d serialLine: %d\n", g_tx, wxGetApp().m_boolRTSPos, g_tx == wxGetApp().m_boolRTSPos);
+            if (g_tx == wxGetApp().m_boolRTSPos)
                 m_serialPort->SetLineState(ctb::LinestateRts);
             else
                 m_serialPort->ClrLineState(ctb::LinestateRts);
         }
         if (wxGetApp().m_boolUseDTR) {
-            bool serialLine = !(g_tx ^ wxGetApp().m_boolRTSPos);
-            printf("g_tx: %d m_boolDTRPos: %d serialLine: %d\n", g_tx, wxGetApp().m_boolDTRPos, serialLine);
-            if (serialLine)
-                m_serialPort->SetLineState(ctb::LinestateCts);
+            printf("g_tx: %d m_boolDTRPos: %d serialLine: %d\n", g_tx, wxGetApp().m_boolDTRPos, g_tx == wxGetApp().m_boolDTRPos);
+            if (g_tx == wxGetApp().m_boolDTRPos)
+                m_serialPort->SetLineState(ctb::LinestateDtr);
             else
-                m_serialPort->ClrLineState(ctb::LinestateCts);
+                m_serialPort->ClrLineState(ctb::LinestateDtr);
         }
  
     }
@@ -1701,8 +1699,9 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event)
         
         if (wxGetApp().m_boolHamlibUseForPTT)
             OpenHamlibRig();
-        if (wxGetApp().m_boolUseSerialPTT)
+        if (wxGetApp().m_boolUseSerialPTT) {
             SetupSerialPort();
+        }
 
         // attempt to start sound cards and tx/rx processing
 
@@ -3094,28 +3093,30 @@ void MainFrame::SetupSerialPort(void)
         {
             m_serialPort = NULL;
             m_device     = NULL;
+            wxMessageBox("Couldn't open Serial Port", wxT("About"), wxOK | wxICON_ERROR, this);
+
         }
     }
 }
 
 void MainFrame::SerialPTTRx(void)
 {
-    if(wxGetApp().m_boolRTSPos) // RTS cleared LOW
-        {
+    printf("m_boolUseRTS: %d m_boolRTSPos: %d m_boolUseDTR: %d m_boolDTRPos: %d\n",
+           wxGetApp().m_boolUseRTS, wxGetApp().m_boolRTSPos, wxGetApp().m_boolUseDTR, wxGetApp().m_boolDTRPos);
+
+    if (wxGetApp().m_boolUseRTS) {
+        if(wxGetApp().m_boolRTSPos) // RTS cleared LOW
             m_serialPort->ClrLineState(ctb::LinestateRts);
-        }
-    else                        // RTS cleared HIGH
-        {
+        else                        // RTS cleared HIGH
             m_serialPort->SetLineState(ctb::LinestateRts);
-        }
-    if(wxGetApp().m_boolDTRPos) // DTR cleared LOW
-        {
+    }
+
+    if (wxGetApp().m_boolUseDTR) {
+        if(wxGetApp().m_boolDTRPos) // DTR cleared LOW
             m_serialPort->ClrLineState(ctb::LinestateDtr);
-        }
-    else                        // DTR cleared HIGH
-        {
+        else                        // DTR cleared HIGH
             m_serialPort->SetLineState(ctb::LinestateDtr);
-        }
+    }
 }
 
 //----------------------------------------------------------------
@@ -3123,14 +3124,15 @@ void MainFrame::SerialPTTRx(void)
 //----------------------------------------------------------------
 void MainFrame::CloseSerialPort(void)
 {
-    // always end with PTT in rx state
+    if (m_serialPort != NULL) {
+        // always end with PTT in rx state
 
-    SerialPTTRx();
+        SerialPTTRx();
 
-    if((m_serialPort != NULL) && m_serialPort->IsOpen())
-    {
-        m_serialPort->Close();
-        m_serialPort = NULL;
-        m_device     = NULL;
+        if((m_serialPort != NULL) && m_serialPort->IsOpen()) {
+            m_serialPort->Close();
+            m_serialPort = NULL;
+            m_device     = NULL;
+        }
     }
 }