kopia lustrzana https://gitlab.com/eliggett/wfview
Add code to select virtual serial port
rodzic
5bd21ce6fa
commit
e041e6d1c5
|
@ -5,7 +5,7 @@
|
|||
|
||||
// Copyright 2017-2021 Elliott H. Liggett & Phil Taylor
|
||||
|
||||
pttyHandler::pttyHandler()
|
||||
pttyHandler::pttyHandler(QString pty)
|
||||
{
|
||||
//constructor
|
||||
// grab baud rate and other comm port details
|
||||
|
@ -20,17 +20,19 @@ pttyHandler::pttyHandler()
|
|||
stopBits = 1;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
portName = "COM20";
|
||||
portName = pty;
|
||||
#else
|
||||
portName = "/dev/ptmx";
|
||||
#endif
|
||||
setupPtty(); // basic parameters
|
||||
openPort();
|
||||
//qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||
//port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why...
|
||||
//qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||
if (portName != "" && portName != "None") {
|
||||
setupPtty(); // basic parameters
|
||||
openPort();
|
||||
//qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||
//port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why...
|
||||
//qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||
|
||||
connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn()));
|
||||
connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn()));
|
||||
}
|
||||
}
|
||||
|
||||
pttyHandler::pttyHandler(QString portName, quint32 baudRate)
|
||||
|
@ -60,7 +62,7 @@ pttyHandler::pttyHandler(QString portName, quint32 baudRate)
|
|||
|
||||
void pttyHandler::setupPtty()
|
||||
{
|
||||
qDebug(logSerial()) << "Setting up Pseudo Term";
|
||||
qDebug(logSerial()) << "Setting up Pseudo Term: " << portName;
|
||||
serialError = false;
|
||||
port->setPortName(portName);
|
||||
#ifdef Q_OS_WIN
|
||||
|
|
|
@ -15,7 +15,7 @@ class pttyHandler : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
pttyHandler();
|
||||
pttyHandler(QString portName);
|
||||
pttyHandler(QString portName, quint32 baudRate);
|
||||
bool serialError;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ rigCommander::~rigCommander()
|
|||
}
|
||||
|
||||
|
||||
void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate)
|
||||
void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate, QString vsp)
|
||||
{
|
||||
// construct
|
||||
// TODO: Bring this parameter and the comm port from the UI.
|
||||
|
@ -51,7 +51,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu
|
|||
this->rigBaudRate = rigBaudRate;
|
||||
|
||||
comm = new commHandler(rigSerialPort, rigBaudRate);
|
||||
ptty = new pttyHandler();
|
||||
ptty = new pttyHandler(vsp);
|
||||
|
||||
// data from the comm port to the program:
|
||||
connect(comm, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
|
||||
|
@ -74,7 +74,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu
|
|||
|
||||
}
|
||||
|
||||
void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs)
|
||||
void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, QString vsp)
|
||||
{
|
||||
// construct
|
||||
// TODO: Bring this parameter and the comm port from the UI.
|
||||
|
@ -106,7 +106,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs)
|
|||
//this->rigSerialPort = rigSerialPort;
|
||||
//this->rigBaudRate = rigBaudRate;
|
||||
|
||||
ptty = new pttyHandler();
|
||||
ptty = new pttyHandler(vsp);
|
||||
|
||||
// Data from UDP to the program
|
||||
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
|
||||
|
|
|
@ -61,8 +61,8 @@ public:
|
|||
|
||||
public slots:
|
||||
void process();
|
||||
void commSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate);
|
||||
void commSetup(unsigned char rigCivAddr, udpPreferences prefs);
|
||||
void commSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate,QString vsp);
|
||||
void commSetup(unsigned char rigCivAddr, udpPreferences prefs, QString vsp);
|
||||
void closeComm();
|
||||
|
||||
// Power:
|
||||
|
|
82
wfmain.cpp
82
wfmain.cpp
|
@ -167,6 +167,46 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
|||
ui->audioInputCombo->addItem(deviceInfo.deviceName());
|
||||
}
|
||||
|
||||
ui->serialDeviceListCombo->blockSignals(true);
|
||||
ui->serialDeviceListCombo->addItem("Auto", 0);
|
||||
int i = 0;
|
||||
foreach(const QSerialPortInfo & serialPortInfo, QSerialPortInfo::availablePorts())
|
||||
{
|
||||
portList.append(serialPortInfo.portName());
|
||||
ui->serialDeviceListCombo->addItem(serialPortInfo.portName(), i++);
|
||||
}
|
||||
ui->serialDeviceListCombo->addItem("Manual...", 256);
|
||||
ui->serialDeviceListCombo->blockSignals(false);
|
||||
|
||||
// vspe checkbox is Currently disabled as not implemented!
|
||||
ui->vspeCheck->setVisible(false);
|
||||
#ifndef Q_OS_WIN
|
||||
ui->vspCombo->setVisible(false);
|
||||
ui->vspLabel->setVisible(false);
|
||||
ui->vspeCheck->setVisible(false);
|
||||
#else
|
||||
i = 0;
|
||||
ui->vspCombo->blockSignals(true);
|
||||
ui->vspCombo->addItem(QString("None"), i++);
|
||||
if (!ui->vspeCheck->isChecked())
|
||||
{
|
||||
int i = 0;
|
||||
foreach(const QSerialPortInfo & serialPortInfo, QSerialPortInfo::availablePorts())
|
||||
{
|
||||
ui->vspCombo->addItem(serialPortInfo.portName(), i++);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int f = 1; f < 100; f++) {
|
||||
ui->vspCombo->addItem(QString("COM%1").arg(f), f);
|
||||
}
|
||||
}
|
||||
ui->vspCombo->blockSignals(false);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
setDefaultColors(); // set of UI colors with defaults populated
|
||||
setDefPrefs(); // other default options
|
||||
loadSettings(); // Look for saved preferences
|
||||
|
@ -318,18 +358,6 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
|||
periodicPollingTimer->setSingleShot(false);
|
||||
connect(periodicPollingTimer, SIGNAL(timeout()), this, SLOT(runPeriodicCommands()));
|
||||
|
||||
|
||||
ui->serialDeviceListCombo->blockSignals(true);
|
||||
ui->serialDeviceListCombo->addItem("Auto", 0);
|
||||
int i=0;
|
||||
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts())
|
||||
{
|
||||
portList.append(serialPortInfo.portName());
|
||||
ui->serialDeviceListCombo->addItem(serialPortInfo.portName(), i++);
|
||||
}
|
||||
ui->serialDeviceListCombo->addItem("Manual...", 256);
|
||||
ui->serialDeviceListCombo->blockSignals(false);
|
||||
|
||||
freq.MHzDouble = 0.0;
|
||||
freq.Hz = 0;
|
||||
|
||||
|
@ -641,8 +669,8 @@ void wfmain::openRig()
|
|||
connect(rig, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(receiveSerialPortError(QString, QString)));
|
||||
connect(rig, SIGNAL(haveStatusUpdate(QString)), this, SLOT(receiveStatusUpdate(QString)));
|
||||
|
||||
connect(this, SIGNAL(sendCommSetup(unsigned char, udpPreferences)), rig, SLOT(commSetup(unsigned char, udpPreferences)));
|
||||
connect(this, SIGNAL(sendCommSetup(unsigned char, QString, quint32)), rig, SLOT(commSetup(unsigned char, QString, quint32)));
|
||||
connect(this, SIGNAL(sendCommSetup(unsigned char, udpPreferences,QString)), rig, SLOT(commSetup(unsigned char, udpPreferences,QString)));
|
||||
connect(this, SIGNAL(sendCommSetup(unsigned char, QString, quint32,QString)), rig, SLOT(commSetup(unsigned char, QString, quint32,QString)));
|
||||
|
||||
connect(this, SIGNAL(sendCloseComm()), rig, SLOT(closeComm()));
|
||||
connect(this, SIGNAL(sendChangeLatency(quint16)), rig, SLOT(changeLatency(quint16)));
|
||||
|
@ -660,7 +688,7 @@ void wfmain::openRig()
|
|||
if (prefs.enableLAN)
|
||||
{
|
||||
ui->lanEnableBtn->setChecked(true);
|
||||
emit sendCommSetup(prefs.radioCIVAddr, udpPrefs);
|
||||
emit sendCommSetup(prefs.radioCIVAddr, udpPrefs,prefs.virtualSerialPort);
|
||||
} else {
|
||||
ui->serialEnableBtn->setChecked(true);
|
||||
if( (prefs.serialPortRadio == QString("auto")) && (serialPortCL.isEmpty()))
|
||||
|
@ -715,7 +743,7 @@ void wfmain::openRig()
|
|||
// Here, the radioCIVAddr is being set from a default preference, which is for the 7300.
|
||||
// However, we will not use it initially. OTOH, if it is set explicitedly to a value in the prefs,
|
||||
// then we skip auto detection.
|
||||
emit sendCommSetup(prefs.radioCIVAddr, serialPortRig, prefs.serialPortBaud);
|
||||
emit sendCommSetup(prefs.radioCIVAddr, serialPortRig, prefs.serialPortBaud,prefs.virtualSerialPort);
|
||||
}
|
||||
|
||||
ui->statusBar->showMessage(QString("Connecting to rig using serial port ").append(serialPortRig), 1000);
|
||||
|
@ -791,6 +819,8 @@ void wfmain::setDefPrefs()
|
|||
defPrefs.niceTS = true;
|
||||
defPrefs.enableRigCtlD = false;
|
||||
defPrefs.rigCtlPort = 4533;
|
||||
defPrefs.enableVSPE = false;
|
||||
defPrefs.virtualSerialPort = QString("none");
|
||||
|
||||
udpDefPrefs.ipAddress = QString("");
|
||||
udpDefPrefs.controlLANPort = 50001;
|
||||
|
@ -868,6 +898,13 @@ void wfmain::loadSettings()
|
|||
prefs.radioCIVAddr = (unsigned char) settings.value("RigCIVuInt", defPrefs.radioCIVAddr).toInt();
|
||||
prefs.serialPortRadio = settings.value("SerialPortRadio", defPrefs.serialPortRadio).toString();
|
||||
prefs.serialPortBaud = (quint32) settings.value("SerialPortBaud", defPrefs.serialPortBaud).toInt();
|
||||
prefs.enableVSPE = settings.value("EnableVSPE", defPrefs.enableVSPE).toBool();
|
||||
prefs.virtualSerialPort = settings.value("VirtualSerialPort", defPrefs.virtualSerialPort).toString();
|
||||
int vspIndex = ui->vspCombo->findText(prefs.virtualSerialPort);
|
||||
if (vspIndex != -1) {
|
||||
ui->vspCombo->setCurrentIndex(vspIndex);
|
||||
}
|
||||
ui->vspeCheck->setChecked(prefs.enableVSPE);
|
||||
settings.endGroup();
|
||||
|
||||
// Misc. user settings (enable PTT, draw peaks, etc)
|
||||
|
@ -1047,6 +1084,8 @@ void wfmain::saveSettings()
|
|||
settings.setValue("RigCIVuInt", prefs.radioCIVAddr);
|
||||
settings.setValue("SerialPortRadio", prefs.serialPortRadio);
|
||||
settings.setValue("SerialPortBaud", prefs.serialPortBaud);
|
||||
settings.setValue("EnableVSPE", prefs.enableVSPE);
|
||||
settings.setValue("VirtualSerialPort", prefs.virtualSerialPort);
|
||||
settings.endGroup();
|
||||
|
||||
// Misc. user settings (enable PTT, draw peaks, etc)
|
||||
|
@ -3367,6 +3406,17 @@ void wfmain::on_txLatencySlider_valueChanged(int value)
|
|||
ui->txLatencyValue->setText(QString::number(value));
|
||||
}
|
||||
|
||||
void wfmain::on_vspCombo_currentIndexChanged(int value)
|
||||
{
|
||||
Q_UNUSED(value);
|
||||
prefs.virtualSerialPort = ui->vspCombo->currentText();
|
||||
}
|
||||
|
||||
void wfmain::on_vspeCheck_clicked(bool checked)
|
||||
{
|
||||
prefs.enableVSPE = checked;
|
||||
}
|
||||
|
||||
void wfmain::on_toFixedBtn_clicked()
|
||||
{
|
||||
emit setScopeFixedEdge(oldLowerFreq, oldUpperFreq, ui->scopeEdgeCombo->currentIndex()+1);
|
||||
|
|
10
wfmain.h
10
wfmain.h
|
@ -131,8 +131,8 @@ signals:
|
|||
void sayFrequency();
|
||||
void sayMode();
|
||||
void sayAll();
|
||||
void sendCommSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate);
|
||||
void sendCommSetup(unsigned char rigCivAddr, udpPreferences prefs);
|
||||
void sendCommSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate,QString vsp);
|
||||
void sendCommSetup(unsigned char rigCivAddr, udpPreferences prefs, QString vsp);
|
||||
void sendCloseComm();
|
||||
void sendChangeLatency(quint16 latency);
|
||||
void initServer();
|
||||
|
@ -361,6 +361,10 @@ private slots:
|
|||
|
||||
void on_audioSampleRateCombo_currentIndexChanged(QString text);
|
||||
|
||||
void on_vspCombo_currentIndexChanged(int value);
|
||||
|
||||
void on_vspeCheck_clicked(bool checked);
|
||||
|
||||
void on_scopeEnableWFBtn_clicked(bool checked);
|
||||
|
||||
void on_sqlSlider_valueChanged(int value);
|
||||
|
@ -598,6 +602,8 @@ private:
|
|||
bool enableRigCtlD;
|
||||
quint16 rigCtlPort;
|
||||
colors colorScheme;
|
||||
bool enableVSPE;
|
||||
QString virtualSerialPort;
|
||||
} prefs;
|
||||
|
||||
preferences defPrefs;
|
||||
|
|
23
wfmain.ui
23
wfmain.ui
|
@ -18,7 +18,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mainTab">
|
||||
<attribute name="title">
|
||||
|
@ -2064,7 +2064,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<spacer name="horizontalSpacer_10">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -2076,6 +2076,23 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="vspLabel">
|
||||
<property name="text">
|
||||
<string>Virtual Serial Port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="vspCombo"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="vspeCheck">
|
||||
<property name="text">
|
||||
<string>Use VSPE Driver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -2358,7 +2375,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>934</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
Ładowanie…
Reference in New Issue