From d95e90063613e47a04babc1350d033a5dd9dc788 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 23 Apr 2013 20:46:04 +0000 Subject: [PATCH] 1. Removed all vestiges of rigctl use. Now using calls to hamlib functions. 2. Restored "Test CAT Control" and "Test PTT" buttons on the Setup | Configuration screen. These features need thorough testing! git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3204 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- devsetup.cpp | 58 +- devsetup.h | 9 + devsetup.ui | 2051 +++++++++++++++++++++++++----------------------- mainwindow.cpp | 65 +- mainwindow.h | 5 +- mainwindow.ui | 30 +- 6 files changed, 1166 insertions(+), 1052 deletions(-) diff --git a/devsetup.cpp b/devsetup.cpp index e03f7adfa..4daa70a8d 100644 --- a/devsetup.cpp +++ b/devsetup.cpp @@ -1,5 +1,4 @@ #include "devsetup.h" -#include "mainwindow.h" #include #include @@ -14,13 +13,14 @@ DevSetup::DevSetup(QWidget *parent) : QDialog(parent) m_restartSoundIn=false; m_restartSoundOut=false; m_firstCall=true; + m_iptt=0; + m_bRigOpen=false; } DevSetup::~DevSetup() { } - void DevSetup::initDlg() { int k,id; @@ -47,7 +47,6 @@ void DevSetup::initDlg() } k=0; -// Needs work to compile for Linux for(id=0; idmaxInputChannels; @@ -257,6 +256,12 @@ void DevSetup::accept() m_dFreq.append(ui.f15->text()); m_dFreq.append(ui.f16->text()); + if(m_bRigOpen) { + rig->close(); + delete rig; + m_bRigOpen=false; + } + QDialog::accept(); } @@ -369,3 +374,50 @@ void DevSetup::on_cbID73_toggled(bool checked) { m_After73=checked; } + +void DevSetup::on_testCATButton_clicked() +{ + + if(!m_catEnabled) return; + if(m_bRigOpen) { + rig->close(); + delete rig; + m_bRigOpen=false; + } + rig = new Rig(m_rig); + try { + rig->setConf("rig_pathname", m_catPort.toAscii().data()); + char buf[80]; + sprintf(buf,"%d",m_serialRate); + rig->setConf("serial_speed",buf); + sprintf(buf,"%d",m_dataBits); + rig->setConf("data_bits",buf); + sprintf(buf,"%d",m_stopBits); + rig->setConf("stop_bits",buf); + rig->setConf("serial_handshake",m_handshake.toAscii().data()); + rig->open(); + m_bRigOpen=true; + } + catch (const RigException &Ex) { + m_bRigOpen=false; + msgBox("Failed to open rig (A)"); + return; + } + double fMHz=rig->getFreq(RIG_VFO_CURR)/1000000.0; + QString t; + t.sprintf("Rig control working.\nDial Frequency: %.6f",fMHz); + msgBox(t); +} + +void DevSetup::on_testPTTButton_clicked() +{ + int iret=0; + m_iptt=1-m_iptt; + if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { + int iptt=m_iptt; + ptt(m_pttPort,iptt,&m_iptt,&m_COMportOpen); + } + if(m_pttMethodIndex==0 and m_bRigOpen) { + rig->setPTT((ptt_t)m_iptt, RIG_VFO_CURR); + } +} diff --git a/devsetup.h b/devsetup.h index 137efdcdb..8df29f5b2 100644 --- a/devsetup.h +++ b/devsetup.h @@ -5,6 +5,7 @@ #include #include #include "ui_devsetup.h" +#include "mainwindow.h" class DevSetup : public QDialog { @@ -34,6 +35,8 @@ public: qint32 m_stopBits; qint32 m_stopBitsIndex; qint32 m_handshakeIndex; + qint32 m_iptt; + qint32 m_COMportOpen; bool m_restartSoundIn; bool m_restartSoundOut; @@ -41,6 +44,7 @@ public: bool m_firstCall; bool m_catEnabled; bool m_After73; + bool m_bRigOpen; QString m_myCall; QString m_myGrid; @@ -52,6 +56,8 @@ public: QStringList m_macro; QStringList m_dFreq; + Rig* rig; + QProcess p4; QMessageBox msgBox0; @@ -74,6 +80,9 @@ private slots: void on_stopBitsComboBox_activated(int index); void on_rigComboBox_activated(int index); void on_cbID73_toggled(bool checked); + void on_testCATButton_clicked(); + + void on_testPTTButton_clicked(); private: void msgBox(QString t); diff --git a/devsetup.ui b/devsetup.ui index bd400cc0d..33119f228 100644 --- a/devsetup.ui +++ b/devsetup.ui @@ -35,1044 +35,1107 @@ Station - + - + - - - - - - 0 - 0 - - - - - 80 - 20 - - - - - 80 - 16777215 - - - - My Call: - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - 90 - 16777215 - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 80 - 20 - - - - - 80 - 16777215 - - - - My Grid: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 60 - 0 - - - - - 60 - 16777215 - - - - - - - - + + + + 0 + 0 + + + + + 80 + 20 + + + + + 80 + 16777215 + + + + My Call: + + - - - - - - 0 - 0 - - - - - 80 - 0 - - - - - 80 - 16777215 - - - - PTT method: - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - 90 - 16777215 - - - - 1 - - - - CAT - - - - - DTR - - - - - RTS - - - - - VOX - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 80 - 0 - - - - - 80 - 16777215 - - - - PTT Port: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 60 - 0 - - - - - 60 - 16777215 - - - - - None - - - - - COM1 - - - - - COM2 - - - - - COM3 - - - - - COM4 - - - - - COM5 - - - - - COM6 - - - - - COM7 - - - - - COM8 - - - - - COM9 - - - - - COM10 - - - - - COM11 - - - - - COM12 - - - - - COM13 - - - - - COM14 - - - - - COM15 - - - - - USB - - - - - + + + + 0 + 0 + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + + + - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 80 + 20 + + + + + 80 + 16777215 + + + + My Grid: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + + + + + + + + + + + + + 0 + 0 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + PTT method: + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + 1 + - + + CAT + + + + + DTR + + + + + RTS + + + + + VOX + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + PTT Port: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + + None + + + + + COM1 + + + + + COM2 + + + + + COM3 + + + + + COM4 + + + + + COM5 + + + + + COM6 + + + + + COM7 + + + + + COM8 + + + + + COM9 + + + + + COM10 + + + + + COM11 + + + + + COM12 + + + + + COM13 + + + + + COM14 + + + + + COM15 + + + + + USB + + + + + + + + + + + + + 0 + 20 + + + + ID Interval (min): + + + + + + + true + + + + 60 + 16777215 + + + + -20 + + + 10 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ID after 73 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 146 + 0 + + + + + 146 + 16777215 + + + + Enable PSK Reporter + + + + + + + + + Qt::Vertical + + + + 20 + 13 + + + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Enable CAT + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + + 20 + 16777215 + + + + Rig: + + + + + + + + 0 + 0 + + + + + 200 + 0 + + + + + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + CAT port: + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + 0 + + + + None + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + Data bits: + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + 1 + + + + 7 + + + + + 8 + + + + + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Serial rate: + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + 1 + + + + 1200 + + + + + 4800 + + + + + 9600 + + + + + 19200 + + + + + 38400 + + + + + 57600 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + Stop bits: + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + 1 + + + + 1 + + + + + 2 + + + + + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Handshake: + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + 2 + + + + None + + + + + XonXoff + + + + + Hardware + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Test CAT Control + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + Test PTT + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 13 + + + + + + + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + Dev Channel + + + + + + + API Name + + + Qt::AlignCenter + + + + + + + + + + + - 0 - 20 + 90 + 0 + + + + + 75 + 16777215 - ID Interval (min): + Audio In: - + true + + + + + + + + + + + 0 + 0 + + + + + 90 + 0 + + - 60 + 75 16777215 - - -20 - - - 10 + + Audio Out: - - - Qt::Horizontal + + + + + + + + + + + 0 + 0 + - + - 40 + 90 20 - - - - - ID after 73 + Save Directory: - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 146 - 0 - - - - - 146 - 16777215 - - + - Enable PSK Reporter + C:\Users\joe\wsjt\map65\save - - - - Qt::Vertical - - - - 20 - 15 - - - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Enable CAT - - - - - - - - 0 - 0 - - - - - 20 - 0 - - - - - 20 - 16777215 - - - - Rig: - - - - - - - - 0 - 0 - - - - - 200 - 0 - - - - - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - CAT port: - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - 90 - 16777215 - - - - 0 - - - - None - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 60 - 0 - - - - - 60 - 16777215 - - - - Data bits: - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - 1 - - - - 7 - - - - - 8 - - - - - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Serial rate: - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - 90 - 16777215 - - - - 1 - - - - 1200 - - - - - 4800 - - - - - 9600 - - - - - 19200 - - - - - 38400 - - - - - 57600 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 60 - 0 - - - - - 60 - 16777215 - - - - Stop bits: - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - 1 - - - - 1 - - - - - 2 - - - - - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Handshake: - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - 90 - 16777215 - - - - 2 - - - - None - - - - - XonXoff - - - - - Hardware - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 15 - - - - - - - - - - - 90 - 0 - - - - - 90 - 16777215 - - - - Dev Channel - - - - - - - API Name - - - Qt::AlignCenter - - - - - - - - - - - - - - 90 - 0 - - - - - 75 - 16777215 - - - - Audio In: - - - - - - - true - - - - - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - 75 - 16777215 - - - - Audio Out: - - - - - - - - - - - - - - - 0 - 0 - - - - - 90 - 20 - - - - Save Directory: - - - - - - - C:\Users\joe\wsjt\map65\save - - - - - - - diff --git a/mainwindow.cpp b/mainwindow.cpp index 7340eaa2b..951c03bae 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -616,6 +616,13 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog dlg.m_handshake=m_handshake; dlg.m_handshakeIndex=m_handshakeIndex; + if(m_bRigOpen) { + rig->close(); + delete rig; + m_bRigOpen=false; + m_catEnabled=false; + } + dlg.initDlg(); if(dlg.exec() == QDialog::Accepted) { m_myCall=dlg.m_myCall; @@ -682,6 +689,10 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog soundOutThread.setOutputDevice(m_paOutDevice); } } + m_catEnabled=dlg.m_catEnabled; + if(m_catEnabled) { + rigOpen(); + } } void MainWindow::on_monitorButton_clicked() //Monitor @@ -1428,16 +1439,14 @@ void MainWindow::guiUpdate() icw[0]=m_ncw; //Raise PTT - if(m_pttMethodIndex==0) { //CAT control for PTT=1 - m_cmnd=rig_command() + " T 1"; - p3.start(m_cmnd); - p3.waitForFinished(); + if(m_catEnabled and m_bRigOpen and m_pttMethodIndex==0) { m_iptt=1; + rig->setPTT((ptt_t)m_iptt, RIG_VFO_CURR); //CAT control for PTT=1 } if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { //DTR or RTS ptt(m_pttPort,1,&m_iptt,&m_COMportOpen); } - if(m_pttMethodIndex==3) { //VOX + if(m_pttMethodIndex==3) { //VOX m_iptt=1; } ptt1Timer->start(200); //Sequencer delay @@ -1556,20 +1565,19 @@ void MainWindow::guiUpdate() if(nc0 <= 0) { nc0++; } - if(nc0 == 0) { + if(nc0 == 0) { //Lower PTT - if(m_pttMethodIndex==0) { //CAT for PTT=0 - m_cmnd=rig_command() + " T 0"; - p3.start(m_cmnd); - p3.waitForFinished(); - } - if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { //DTR-RTS - ptt(m_pttPort,0,&m_iptt,&m_COMportOpen); - } - if(m_pttMethodIndex==3) { //VOX - m_iptt=0; - } + if(m_catEnabled and m_bRigOpen and m_pttMethodIndex==0) { + m_iptt=0; + rig->setPTT((ptt_t)m_iptt, RIG_VFO_CURR); //CAT control for PTT=1 + } + if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { //DTR-RTS + ptt(m_pttPort,0,&m_iptt,&m_COMportOpen); + } + if(m_pttMethodIndex==3) { //VOX + m_iptt=0; + } } if(m_iptt == 0 && !btxok) { @@ -1656,20 +1664,6 @@ void MainWindow::displayTxMsg(QString t) ui->decodedTextBrowser->setTextCursor(cursor); } -QString MainWindow::rig_command() -{ - QString cmnd1,cmnd2; - cmnd1.sprintf("rigctl -m %d -r ",m_rig); - cmnd1+=m_catPort; -// For K2: -// cmnd2.sprintf(" -s %d -C rts_state=OFF -C dtr_state=OFF -C data_bits=%d -C stop_bits=%d -C serial_handshake=", -// m_serialRate,m_dataBits,m_stopBits); - cmnd2.sprintf(" -s %d -C data_bits=%d -C stop_bits=%d -C serial_handshake=", - m_serialRate,m_dataBits,m_stopBits); - cmnd2+=m_handshake; - return cmnd1+cmnd2; -} - void MainWindow::startTx2() { if(!soundOutThread.isRunning()) { @@ -1704,10 +1698,8 @@ void MainWindow::stopTx() void MainWindow::stopTx2() { //Lower PTT - if(m_pttMethodIndex==0) { - m_cmnd=rig_command() + " T 0"; //CAT for PTT=0 - p3.start(m_cmnd); - p3.waitForFinished(); + if(m_catEnabled and m_bRigOpen and m_pttMethodIndex==0) { + rig->setPTT((ptt_t)m_iptt, RIG_VFO_CURR); //CAT control for PTT=0 } if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { ptt(m_pttPort,0,&m_iptt,&m_COMportOpen); @@ -2621,6 +2613,7 @@ void MainWindow::rigOpen() catch (const RigException &Ex) { m_catEnabled=false; m_bRigOpen=false; - msgBox("Failed to open rig"); + msgBox("Failed to open rig (B)"); + delete rig; } } diff --git a/mainwindow.h b/mainwindow.h index 3b0308f69..e94d2c6bf 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -336,7 +336,6 @@ private: void displayTxMsg(QString t); void rigOpen(); bool gridOK(QString g); - QString rig_command(); QString baseCall(QString t); }; @@ -346,9 +345,7 @@ extern int killbyname(const char* progName); extern void getDev(int* numDevices,char hostAPI_DeviceName[][50], int minChan[], int maxChan[], int minSpeed[], int maxSpeed[]); -extern int ptt(int nport, int itx, int* iptt); -//extern int ReporterInitialize(char* hostname, char* port); - +extern int ptt(int nport, int ntx, int* iptt, int* nopen); extern "C" { //----------------------------------------------------- C and Fortran routines diff --git a/mainwindow.ui b/mainwindow.ui index 1f1ff5366..09f68ae0e 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -24,7 +24,7 @@ - 900 + 936 1028 @@ -1389,7 +1389,7 @@ p, li { white-space: pre-wrap; } - buttonGroup + buttonGroup @@ -1420,7 +1420,7 @@ p, li { white-space: pre-wrap; } true - buttonGroup + buttonGroup @@ -1448,7 +1448,7 @@ p, li { white-space: pre-wrap; } - buttonGroup + buttonGroup @@ -1598,7 +1598,7 @@ p, li { white-space: pre-wrap; } - buttonGroup + buttonGroup @@ -1731,7 +1731,7 @@ p, li { white-space: pre-wrap; } - buttonGroup + buttonGroup @@ -1759,7 +1759,7 @@ p, li { white-space: pre-wrap; } - buttonGroup + buttonGroup @@ -1995,7 +1995,7 @@ p, li { white-space: pre-wrap; } - + 0 @@ -2008,19 +2008,19 @@ p, li { white-space: pre-wrap; } 180 - + 1 - + 60.000000000000000 - + 0.000000000000000 - + 8 - + 0.000000000000000 @@ -2037,7 +2037,7 @@ p, li { white-space: pre-wrap; } 0 0 711 - 25 + 21 @@ -2144,7 +2144,7 @@ p, li { white-space: pre-wrap; } - true + false Configuration