Starting to implement CAT control. Not finished yet, and there may be bugs!

PTT control not yet done...


git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3078 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2013-03-24 12:55:13 +00:00
parent 82936270dc
commit b752c8c517
5 changed files with 1191 additions and 238 deletions

View File

@ -113,9 +113,19 @@ void DevSetup::initDlg()
}
}
connect(&p4, SIGNAL(readyReadStandardOutput()),
this, SLOT(p4ReadFromStdout()));
connect(&p4, SIGNAL(readyReadStandardError()),
this, SLOT(p4ReadFromStderr()));
connect(&p4, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(p4Error()));
p4.start("rigctl -l");
p4.waitForFinished(1000);
ui.myCallEntry->setText(m_myCall);
ui.myGridEntry->setText(m_myGrid);
ui.idIntSpinBox->setValue(m_idInt);
ui.pttMethodComboBox->setCurrentIndex(m_pttMethodIndex);
ui.pttComboBox->setCurrentIndex(m_pttPort);
ui.saveDirEntry->setText(m_saveDir);
ui.comboBoxSndIn->setCurrentIndex(m_nDevIn);
@ -123,6 +133,20 @@ void DevSetup::initDlg()
ui.cbPSKReporter->setChecked(m_pskReporter);
m_paInDevice=m_inDevList[m_nDevIn];
m_paOutDevice=m_outDevList[m_nDevOut];
ui.cbEnableCAT->setChecked(m_catEnabled);
ui.catPortComboBox->setEnabled(m_catEnabled);
ui.rigComboBox->setEnabled(m_catEnabled);
ui.serialRateComboBox->setEnabled(m_catEnabled);
ui.dataBitsComboBox->setEnabled(m_catEnabled);
ui.stopBitsComboBox->setEnabled(m_catEnabled);
ui.handshakeComboBox->setEnabled(m_catEnabled);
ui.rigComboBox->setCurrentIndex(m_rigIndex);
ui.catPortComboBox->setCurrentIndex(m_catPortIndex);
ui.serialRateComboBox->setCurrentIndex(m_serialRateIndex);
ui.dataBitsComboBox->setCurrentIndex(m_dataBitsIndex);
ui.stopBitsComboBox->setCurrentIndex(m_stopBitsIndex);
ui.handshakeComboBox->setCurrentIndex(m_handshakeIndex);
ui.macro1->setText(m_macro[0].toUpper());
ui.macro2->setText(m_macro[1].toUpper());
@ -153,6 +177,7 @@ void DevSetup::accept()
m_myCall=ui.myCallEntry->text();
m_myGrid=ui.myGridEntry->text();
m_idInt=ui.idIntSpinBox->value();
m_pttMethodIndex=ui.pttMethodComboBox->currentIndex();
m_pttPort=ui.pttComboBox->currentIndex();
m_saveDir=ui.saveDirEntry->text();
m_nDevIn=ui.comboBoxSndIn->currentIndex();
@ -175,6 +200,39 @@ void DevSetup::accept()
QDialog::accept();
}
void DevSetup::p4ReadFromStdout() //p4readFromStdout
{
while(p4.canReadLine()) {
QString t(p4.readLine());
QString t1,t2,t3;
if(t.mid(0,6)!=" Rig #") {
t1=t.mid(0,6);
t2=t.mid(8,22).trimmed();
t3=t.mid(31,23).trimmed();
t=t1 + " " + t2 + " " + t3;
ui.rigComboBox->addItem(t);
}
}
}
void DevSetup::p4ReadFromStderr() //p4readFromStderr
{
QByteArray t=p4.readAllStandardError();
if(t.length()>0) {
msgBox(t);
}
}
void DevSetup::p4Error() //p4rror
{
msgBox("Error running 'rigctl -l'.");
}
void DevSetup::msgBox(QString t) //msgBox
{
msgBox0.setText(t);
msgBox0.exec();
}
void DevSetup::on_myCallEntry_editingFinished()
{
@ -193,3 +251,56 @@ void DevSetup::on_cbPSKReporter_clicked(bool b)
{
m_pskReporter=b;
}
void DevSetup::on_pttMethodComboBox_activated(int index)
{
m_pttMethodIndex=index;
}
void DevSetup::on_catPortComboBox_activated(int index)
{
m_catPortIndex=index;
m_catPort=ui.catPortComboBox->itemText(index);
}
void DevSetup::on_cbEnableCAT_toggled(bool b)
{
m_catEnabled=b;
ui.catPortComboBox->setEnabled(b);
ui.rigComboBox->setEnabled(b);
ui.serialRateComboBox->setEnabled(b);
ui.dataBitsComboBox->setEnabled(b);
ui.stopBitsComboBox->setEnabled(b);
ui.handshakeComboBox->setEnabled(b);
}
void DevSetup::on_serialRateComboBox_activated(int index)
{
m_serialRateIndex=index;
m_serialRate=ui.serialRateComboBox->itemText(index).toInt();
}
void DevSetup::on_handshakeComboBox_activated(int index)
{
m_handshakeIndex=index;
m_handshake=ui.handshakeComboBox->itemText(index);
}
void DevSetup::on_dataBitsComboBox_activated(int index)
{
m_dataBitsIndex=index;
m_dataBits=ui.dataBitsComboBox->itemText(index).toInt();
}
void DevSetup::on_stopBitsComboBox_activated(int index)
{
m_stopBitsIndex=index;
m_stopBits=ui.stopBitsComboBox->itemText(index).toInt();
}
void DevSetup::on_rigComboBox_activated(int index)
{
m_rigIndex=index;
QString t=ui.rigComboBox->itemText(index);
m_rig=t.mid(0,7).toInt();
}

View File

@ -2,6 +2,8 @@
#define DEVSETUP_H
#include <QDialog>
#include <QProcess>
#include <QMessageBox>
#include "ui_devsetup.h"
class DevSetup : public QDialog
@ -13,6 +15,7 @@ public:
void initDlg();
qint32 m_idInt;
qint32 m_pttMethodIndex;
qint32 m_pttPort;
qint32 m_nDevIn;
qint32 m_nDevOut;
@ -20,28 +23,60 @@ public:
qint32 m_outDevList[100];
qint32 m_paInDevice;
qint32 m_paOutDevice;
qint32 m_catPortIndex;
qint32 m_rig;
qint32 m_rigIndex;
qint32 m_serialRate;
qint32 m_serialRateIndex;
qint32 m_dataBits;
qint32 m_dataBitsIndex;
qint32 m_stopBits;
qint32 m_stopBitsIndex;
qint32 m_handshakeIndex;
bool m_restartSoundIn;
bool m_restartSoundOut;
bool m_pskReporter;
bool m_firstCall;
bool m_catEnabled;
QString m_myCall;
QString m_myGrid;
QString m_saveDir;
QString m_azelDir;
QString m_catPort;
QString m_handshake;
QStringList m_macro;
QProcess p4;
QMessageBox msgBox0;
public slots:
void accept();
void p4ReadFromStdout();
void p4ReadFromStderr();
void p4Error();
private slots:
void on_myCallEntry_editingFinished();
void on_myGridEntry_editingFinished();
void on_cbPSKReporter_clicked(bool checked);
void on_pttMethodComboBox_activated(int index);
void on_catPortComboBox_activated(int index);
void on_cbEnableCAT_toggled(bool checked);
void on_serialRateComboBox_activated(int index);
void on_handshakeComboBox_activated(int index);
void on_dataBitsComboBox_activated(int index);
void on_stopBitsComboBox_activated(int index);
void on_rigComboBox_activated(int index);
private:
void msgBox(QString t);
Ui::DialogSndCard ui;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
//--------------------------------------------------------------- MainWindow
//---------------------------------------------------------------- MainWindow
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "devsetup.h"
@ -281,6 +281,7 @@ void MainWindow::writeSettings()
settings.setValue("MyCall",m_myCall);
settings.setValue("MyGrid",m_myGrid);
settings.setValue("IDint",m_idInt);
settings.setValue("PTTmethod",m_pttMethodIndex);
settings.setValue("PTTport",m_pttPort);
settings.setValue("SaveDir",m_saveDir);
settings.setValue("SoundInIndex",m_nDevIn);
@ -309,6 +310,19 @@ void MainWindow::writeSettings()
settings.setValue("toRTTY",m_toRTTY);
settings.setValue("NoSuffix",m_noSuffix);
settings.setValue("dBtoComments",m_dBtoComments);
settings.setValue("catEnabled",m_catEnabled);
settings.setValue("Rig",m_rig);
settings.setValue("RigIndex",m_rigIndex);
settings.setValue("CATport",m_catPort);
settings.setValue("CATportIndex",m_catPortIndex);
settings.setValue("SerialRate",m_serialRate);
settings.setValue("SerialRateIndex",m_serialRateIndex);
settings.setValue("DataBits",m_dataBits);
settings.setValue("DataBitsIndex",m_dataBitsIndex);
settings.setValue("StopBits",m_stopBits);
settings.setValue("StopBitsIndex",m_stopBitsIndex);
settings.setValue("Handshake",m_handshake);
settings.setValue("HandshakeIndex",m_handshakeIndex);
settings.endGroup();
}
@ -332,6 +346,7 @@ void MainWindow::readSettings()
m_myCall=settings.value("MyCall","").toString();
m_myGrid=settings.value("MyGrid","").toString();
m_idInt=settings.value("IDint",0).toInt();
m_pttMethodIndex=settings.value("PTTmethod",1).toInt();
m_pttPort=settings.value("PTTport",0).toInt();
m_saveDir=settings.value("SaveDir",m_appDir + "/save").toString();
m_nDevIn = settings.value("SoundInIndex", 0).toInt();
@ -379,6 +394,20 @@ void MainWindow::readSettings()
ui->actionLog_JT9_without_submode->setChecked(m_noSuffix);
m_dBtoComments=settings.value("dBtoComments",false).toBool();
ui->actionLog_dB_reports_to_Comments->setChecked(m_dBtoComments);
m_catEnabled=settings.value("catEnabled",false).toBool();
m_rig=settings.value("Rig",214).toInt();
m_rigIndex=settings.value("RigIndex",100).toInt();
m_catPort=settings.value("CATport","None").toString();
m_catPortIndex=settings.value("CATportIndex",0).toInt();
m_serialRate=settings.value("SerialRate",4800).toInt();
m_serialRateIndex=settings.value("SerialRateIndex",1).toInt();
m_dataBits=settings.value("DataBits",8).toInt();
m_dataBitsIndex=settings.value("DataBitsIndex",1).toInt();
m_stopBits=settings.value("StopBits",8).toInt();
m_stopBitsIndex=settings.value("StopBitsIndex",1).toInt();
m_handshake=settings.value("Handshake","None").toString();
m_handshakeIndex=settings.value("HandshakeIndex",0).toInt();
settings.endGroup();
if(!ui->actionLinrad->isChecked() && !ui->actionCuteSDR->isChecked() &&
@ -464,18 +493,32 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
dlg.m_myCall=m_myCall;
dlg.m_myGrid=m_myGrid;
dlg.m_idInt=m_idInt;
dlg.m_pttMethodIndex=m_pttMethodIndex;
dlg.m_pttPort=m_pttPort;
dlg.m_saveDir=m_saveDir;
dlg.m_nDevIn=m_nDevIn;
dlg.m_nDevOut=m_nDevOut;
dlg.m_pskReporter=m_pskReporter;
dlg.m_macro=m_macro;
dlg.m_catEnabled=m_catEnabled;
dlg.m_rig=m_rig;
dlg.m_rigIndex=m_rigIndex;
dlg.m_catPort=m_catPort;
dlg.m_catPortIndex=m_catPortIndex;
dlg.m_serialRate=m_serialRate;
dlg.m_serialRateIndex=m_serialRateIndex;
dlg.m_dataBits=m_dataBits;
dlg.m_dataBitsIndex=m_dataBitsIndex;
dlg.m_stopBits=m_stopBits;
dlg.m_stopBitsIndex=m_stopBitsIndex;
dlg.m_handshake=m_handshake;
dlg.m_handshakeIndex=m_handshakeIndex;
dlg.initDlg();
if(dlg.exec() == QDialog::Accepted) {
m_myCall=dlg.m_myCall;
m_myGrid=dlg.m_myGrid;
m_idInt=dlg.m_idInt;
m_pttMethodIndex=dlg.m_pttMethodIndex;
m_pttPort=dlg.m_pttPort;
m_saveDir=dlg.m_saveDir;
m_nDevIn=dlg.m_nDevIn;
@ -483,6 +526,19 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
m_nDevOut=dlg.m_nDevOut;
m_paOutDevice=dlg.m_paOutDevice;
m_macro=dlg.m_macro;
m_catEnabled=dlg.m_catEnabled;
m_rig=dlg.m_rig;
m_rigIndex=dlg.m_rigIndex;
m_catPort=dlg.m_catPort;
m_catPortIndex=dlg.m_catPortIndex;
m_serialRate=dlg.m_serialRate;
m_serialRateIndex=dlg.m_serialRateIndex;
m_dataBits=dlg.m_dataBits;
m_dataBitsIndex=dlg.m_dataBitsIndex;
m_stopBits=dlg.m_stopBits;
m_stopBitsIndex=dlg.m_stopBitsIndex;
m_handshake=dlg.m_handshake;
m_handshakeIndex=dlg.m_handshakeIndex;
#ifdef WIN32
if(dlg.m_pskReporter!=m_pskReporter) {
@ -1167,16 +1223,22 @@ void MainWindow::guiUpdate()
bTxTime=true;
if(bTxTime and iptt==0 and !btxMute) {
int itx=1;
int ierr = ptt(m_pttPort,itx,&iptt); // Raise PTT
/*
if(ierr<0) {
on_stopTxButton_clicked();
char s[18];
sprintf(s,"PTT Error %d",ierr);
msgBox(s);
}
*/
/*
//Raise PTT
if(m_pttMethodIndex==0) {
m_cmnd=rig_command() + " T 1";
p3.start(m_cmnd);
p3.waitForFinished();
}
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) {
// ptt(m_pttPort,1,&m_iptt,&m_COMportOpen);
ptt(m_pttPort,1,&m_iptt);
}
*/
if(!soundOutThread.isRunning()) {
QString t=ui->tx6->text();
double snr=t.mid(1,5).toDouble();
@ -1266,13 +1328,20 @@ void MainWindow::guiUpdate()
if(nc0 == 0) {
int itx=0;
int ierr=ptt(m_pttPort,itx,&iptt); // Lower PTT
/*
if(ierr<0) {
char s[18];
sprintf(s,"PTT Error %d",ierr);
msgBox(s);
}
*/
/*
//Lower PTT
if(m_pttMethodIndex==0) {
m_cmnd=rig_command() + " T 0";
p3.start(m_cmnd);
p3.waitForFinished();
}
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) {
// ptt(m_pttPort,0,&m_iptt,&m_COMportOpen);
ptt(m_pttPort,0,&m_iptt);
}
*/
if(!btxMute) soundOutThread.quitExecution=true;
m_transmitting=false;
if(m_auto) {
@ -1348,6 +1417,17 @@ void MainWindow::guiUpdate()
btxok0=btxok;
}
QString MainWindow::rig_command()
{
QString cmnd1,cmnd2;
cmnd1.sprintf("rigctl -m %d -r ",m_rig);
cmnd1+=m_catPort;
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::ba2msg(QByteArray ba, char message[]) //ba2msg()
{
bool eom;
@ -1627,7 +1707,6 @@ void MainWindow::msgtype(QString t, QLineEdit* tx) //msgtype()
char message[23];
char msgsent[23];
int len1=22;
int jtone[85];
t=t.toUpper();
QByteArray s=t.toUpper().toLocal8Bit();

View File

@ -139,6 +139,7 @@ private:
qint32 m_nDevOut;
qint32 m_idInt;
qint32 m_waterfallAvg;
qint32 m_pttMethodIndex;
qint32 m_tol;
qint32 m_QSOfreq0;
qint32 m_ntx;
@ -161,6 +162,20 @@ private:
qint32 m_len1;
qint32 m_inGain;
qint32 m_nsave;
qint32 m_catPortIndex;
qint32 m_rig;
qint32 m_rigIndex;
qint32 m_serialRate;
qint32 m_serialRateIndex;
qint32 m_dataBits;
qint32 m_dataBitsIndex;
qint32 m_stopBits;
qint32 m_stopBitsIndex;
qint32 m_handshakeIndex;
qint32 m_ncw;
qint32 m_secID;
qint32 m_COMportOpen;
qint32 m_iptt;
bool m_monitoring;
bool m_transmitting;
@ -188,6 +203,7 @@ private:
bool m_noSuffix;
bool m_toRTTY;
bool m_dBtoComments;
bool m_catEnabled;
char m_decoded[80];
@ -212,6 +228,7 @@ private:
QFutureWatcher<void>* watcher3;
QProcess proc_jt9;
QProcess p3;
QString m_path;
QString m_pbdecoding_style1;
@ -232,8 +249,10 @@ private:
QString m_rptRcvd;
QString m_qsoStart;
QString m_qsoStop;
QString m_catPort;
QString m_handshake;
QStringList m_macro;
QString m_cmnd;
SoundInThread soundInThread; //Instantiate the audio threads
SoundOutThread soundOutThread;
@ -250,8 +269,8 @@ private:
void msgtype(QString t, QLineEdit* tx);
void stub();
void statusChanged();
bool gridOK(QString g);
QString rig_command();
};
extern void getfile(QString fname, int ntrperiod);