From 10d83aeeb15e24212fbeb06af9650be49e39c574 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 9 Jul 2013 22:41:15 +0000 Subject: [PATCH] Fix another bug in setting frequencies through Commander. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3474 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- mainwindow.cpp | 4 +++- rigclass.cpp | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index c74ea30eb..2df1d3b63 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -2988,7 +2988,9 @@ void MainWindow::setXIT(int n) msgBox(rt); } } - if(m_bSplit) ret=rig->setSplitFreq(MHz(m_dialFreq)+xit,RIG_VFO_B); + if(m_bSplit) { + ret=rig->setSplitFreq(MHz(m_dialFreq)+xit,RIG_VFO_B); + } } if(m_bSplit) soundOutThread.setXIT(xit); if(!m_bSplit) soundOutThread.setXIT(0); diff --git a/rigclass.cpp b/rigclass.cpp index 6ce774b84..aa2a5c390 100644 --- a/rigclass.cpp +++ b/rigclass.cpp @@ -101,10 +101,15 @@ int Rig::open(int n) { } } if(n==9998) { -// qDebug() << "A" << socket->state(); - socket->connectToHost(QHostAddress::LocalHost, 52002); - if(!socket->waitForConnected(1000)) { - return -1; + if(socket->state()==QAbstractSocket::ConnectedState) { + socket->abort(); + } + + if(socket->state()==QAbstractSocket::UnconnectedState) { + socket->connectToHost(QHostAddress::LocalHost, 52002); + if(!socket->waitForConnected(1000)) { + return -1; + } } QString t; // qint32 nkHz=14076; @@ -112,12 +117,10 @@ int Rig::open(int n) { t="CmdGetFreq"; QByteArray ba = t.toLocal8Bit(); const char* buf=ba.data(); - socket->write(buf); - socket->waitForReadyRead(1000); + int n=socket->write(buf); + bool bret=socket->waitForReadyRead(1000); QByteArray reply=socket->read(128); - if(reply.indexOf("")==0) { -// qDebug() << "Freq:" << reply; -// qDebug() << "Connected to Commander"; + if(reply.indexOf("CmdSetTxFreq%5d",nkHz); + t.sprintf("CmdSetTxFreq%6d",nkHz); QByteArray ba = t.toLocal8Bit(); const char* buf=ba.data(); socket->write(buf);