kopia lustrzana https://gitlab.com/eliggett/wfview
Initial commit of rigctld (doesn't currently do anything useful!)
rodzic
3f2a66f8f8
commit
c78ad19210
|
@ -7,3 +7,4 @@ Q_LOGGING_CATEGORY(logRig, "rig")
|
|||
Q_LOGGING_CATEGORY(logAudio, "audio")
|
||||
Q_LOGGING_CATEGORY(logUdp, "udp")
|
||||
Q_LOGGING_CATEGORY(logUdpServer, "udp.server")
|
||||
Q_LOGGING_CATEGORY(logRigCtlD, "rigctld")
|
||||
|
|
|
@ -10,5 +10,6 @@ Q_DECLARE_LOGGING_CATEGORY(logRig)
|
|||
Q_DECLARE_LOGGING_CATEGORY(logAudio)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logUdp)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logUdpServer)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logRigCtlD)
|
||||
|
||||
#endif // LOGCATEGORIES_H
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
#include "rigctld.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
|
||||
|
||||
rigCtlD::rigCtlD(QObject* parent) :
|
||||
QTcpServer(parent)
|
||||
{
|
||||
}
|
||||
|
||||
rigCtlD::~rigCtlD()
|
||||
{
|
||||
}
|
||||
|
||||
int rigCtlD::startServer(qint16 port)
|
||||
{
|
||||
if (!this->listen(QHostAddress::Any, port)) {
|
||||
qDebug(logRigCtlD()) << "could not start on port " << port;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug(logRigCtlD()) << "started on port " << port;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rigCtlD::incomingConnection(qintptr socket) {
|
||||
rigCtlClient* client = new rigCtlClient(socket, rigCaps, this);
|
||||
connect(this, SIGNAL(onStopped()), client, SLOT(closeSocket()));
|
||||
}
|
||||
|
||||
|
||||
void rigCtlD::stopServer()
|
||||
{
|
||||
qDebug(logRigCtlD()) << "stopping server";
|
||||
emit onStopped();
|
||||
}
|
||||
|
||||
void rigCtlD::receiveRigCaps(rigCapabilities caps)
|
||||
{
|
||||
qDebug(logRigCtlD()) << "Got rigcaps for:" << caps.modelName;
|
||||
this->rigCaps = caps;
|
||||
}
|
||||
|
||||
rigCtlClient::rigCtlClient(int socketId, rigCapabilities caps, rigCtlD *parent) : QObject(parent)
|
||||
{
|
||||
commandBuffer.clear();
|
||||
sessionId = socketId;
|
||||
rigCaps = caps;
|
||||
socket = new QTcpSocket(this);
|
||||
if (!socket->setSocketDescriptor(sessionId))
|
||||
{
|
||||
qDebug(logRigCtlD()) << " error binding socket: " << sessionId;
|
||||
return;
|
||||
}
|
||||
connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()), Qt::DirectConnection);
|
||||
connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()), Qt::DirectConnection);
|
||||
connect(parent, SIGNAL(sendData(QString)), this, SLOT(sendData(QString)), Qt::DirectConnection);
|
||||
qDebug(logRigCtlD()) << " session connected: " << sessionId;
|
||||
}
|
||||
|
||||
void rigCtlClient::socketReadyRead()
|
||||
{
|
||||
QByteArray data = socket->readAll();
|
||||
commandBuffer.append(data);
|
||||
if (commandBuffer.endsWith('\n'))
|
||||
{
|
||||
// Process command
|
||||
qDebug(logRigCtlD()) << sessionId << "command received" << commandBuffer;
|
||||
QString cmd = commandBuffer[0];
|
||||
|
||||
if (cmd.toLower() == "q")
|
||||
{
|
||||
closeSocket();
|
||||
}
|
||||
else if (cmd == "1")
|
||||
{
|
||||
dumpCaps();
|
||||
}
|
||||
commandBuffer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void rigCtlClient::socketDisconnected()
|
||||
{
|
||||
qDebug(logRigCtlD()) << sessionId << "disconnected";
|
||||
socket->deleteLater();
|
||||
this->deleteLater();
|
||||
}
|
||||
|
||||
void rigCtlClient::closeSocket()
|
||||
{
|
||||
socket->close();
|
||||
}
|
||||
|
||||
void rigCtlClient::sendData(QString data)
|
||||
{
|
||||
if (socket != Q_NULLPTR && socket->isValid() && socket->isOpen())
|
||||
{
|
||||
socket->write(data.toLatin1());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void rigCtlClient::dumpCaps()
|
||||
{
|
||||
sendData(QString("Caps dump for model: %1\n").arg(rigCaps.modelID));
|
||||
sendData(QString("Model Name:\t%1\n").arg(rigCaps.modelName));
|
||||
sendData(QString("Mfg Name:\tIcom\n"));
|
||||
sendData(QString("Backend version:\t0.1\n"));
|
||||
sendData(QString("Backend copyright:\t2021\n"));
|
||||
sendData(QString("Rig type:\tTransceiver\n"));
|
||||
sendData(QString("PTT type:\tRig capable\n"));
|
||||
sendData(QString("DCD type:\tRig capable\n"));
|
||||
sendData(QString("Port type:\tNetwork link\n"));
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
#ifndef RIGCTLD_H
|
||||
#define RIGCTLD_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
#include <QSet>
|
||||
#include <QDataStream>
|
||||
|
||||
#include "rigcommander.h"
|
||||
|
||||
|
||||
class rigCtlD : public QTcpServer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit rigCtlD(QObject *parent=Q_NULLPTR);
|
||||
virtual ~rigCtlD();
|
||||
|
||||
int startServer(qint16 port);
|
||||
void stopServer();
|
||||
rigCapabilities rigCaps;
|
||||
|
||||
signals:
|
||||
void onStarted();
|
||||
void onStopped();
|
||||
void sendData(QString data);
|
||||
|
||||
public slots:
|
||||
virtual void incomingConnection(qintptr socketDescriptor);
|
||||
void receiveRigCaps(rigCapabilities caps);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class rigCtlClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit rigCtlClient(int socket, rigCapabilities caps, rigCtlD* parent = Q_NULLPTR);
|
||||
int getSocketId();
|
||||
|
||||
|
||||
public slots:
|
||||
void socketReadyRead();
|
||||
void socketDisconnected();
|
||||
void closeSocket();
|
||||
void sendData(QString data);
|
||||
|
||||
protected:
|
||||
int sessionId;
|
||||
QTcpSocket* socket = Q_NULLPTR;
|
||||
QString commandBuffer;
|
||||
|
||||
private:
|
||||
void dumpCaps();
|
||||
rigCapabilities rigCaps;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
21
wfmain.cpp
21
wfmain.cpp
|
@ -203,6 +203,13 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
|||
|
||||
}
|
||||
|
||||
// Start rigctld
|
||||
if (prefs.enableRigCtlD) {
|
||||
rigCtl = new rigCtlD(this);
|
||||
|
||||
rigCtl->startServer(prefs.rigCtlPort);
|
||||
connect(this, SIGNAL(sendRigCaps(rigCapabilities)), rigCtl, SLOT(receiveRigCaps(rigCapabilities)));
|
||||
}
|
||||
plot = ui->plot; // rename it waterfall.
|
||||
wf = ui->waterfall;
|
||||
tracer = new QCPItemTracer(plot);
|
||||
|
@ -569,6 +576,9 @@ wfmain::~wfmain()
|
|||
serverThread->quit();
|
||||
serverThread->wait();
|
||||
}
|
||||
if (rigCtl != Q_NULLPTR) {
|
||||
delete rigCtl;
|
||||
}
|
||||
delete rpt;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -754,6 +764,8 @@ void wfmain::setDefPrefs()
|
|||
defPrefs.serialPortBaud = 115200;
|
||||
defPrefs.enablePTT = false;
|
||||
defPrefs.niceTS = true;
|
||||
defPrefs.enableRigCtlD = false;
|
||||
defPrefs.rigCtlPort = 4533;
|
||||
|
||||
udpDefPrefs.ipAddress = QString("");
|
||||
udpDefPrefs.controlLANPort = 50001;
|
||||
|
@ -811,7 +823,10 @@ void wfmain::loadSettings()
|
|||
prefs.enableLAN = settings.value("EnableLAN", defPrefs.enableLAN).toBool();
|
||||
ui->lanEnableBtn->setChecked(prefs.enableLAN);
|
||||
ui->connectBtn->setEnabled(prefs.enableLAN);
|
||||
|
||||
|
||||
prefs.enableRigCtlD = settings.value("EnableRigCtlD", defPrefs.enableRigCtlD).toBool();
|
||||
prefs.rigCtlPort = settings.value("RigCtlPort", defPrefs.rigCtlPort).toInt();
|
||||
|
||||
udpPrefs.ipAddress = settings.value("IPAddress", udpDefPrefs.ipAddress).toString();
|
||||
ui->ipAddressTxt->setEnabled(ui->lanEnableBtn->isChecked());
|
||||
ui->ipAddressTxt->setText(udpPrefs.ipAddress);
|
||||
|
@ -983,6 +998,8 @@ void wfmain::saveSettings()
|
|||
|
||||
settings.beginGroup("LAN");
|
||||
settings.setValue("EnableLAN", prefs.enableLAN);
|
||||
settings.setValue("EnableRigCtlD", prefs.enableRigCtlD);
|
||||
settings.setValue("RigCtlPort", prefs.rigCtlPort);
|
||||
settings.setValue("IPAddress", udpPrefs.ipAddress);
|
||||
settings.setValue("ControlLANPort", udpPrefs.controlLANPort);
|
||||
settings.setValue("SerialLANPort", udpPrefs.serialLANPort);
|
||||
|
@ -998,7 +1015,7 @@ void wfmain::saveSettings()
|
|||
settings.setValue("AudioOutput", udpPrefs.audioOutput);
|
||||
settings.setValue("AudioInput", udpPrefs.audioInput);
|
||||
settings.setValue("ResampleQuality", udpPrefs.resampleQuality);
|
||||
settings.setValue("clientName", udpPrefs.clientName);
|
||||
settings.setValue("ClientName", udpPrefs.clientName);
|
||||
settings.endGroup();
|
||||
|
||||
// Memory channels
|
||||
|
|
4
wfmain.h
4
wfmain.h
|
@ -23,6 +23,7 @@
|
|||
#include "udpserversetup.h"
|
||||
#include "udpserver.h"
|
||||
#include "qledlabel.h"
|
||||
#include "rigctld.h"
|
||||
|
||||
#include <qcustomplot.h>
|
||||
#include <qserialportinfo.h>
|
||||
|
@ -550,6 +551,8 @@ private:
|
|||
bool enablePTT;
|
||||
bool niceTS;
|
||||
bool enableLAN;
|
||||
bool enableRigCtlD;
|
||||
quint16 rigCtlPort;
|
||||
} prefs;
|
||||
|
||||
preferences defPrefs;
|
||||
|
@ -618,6 +621,7 @@ private:
|
|||
udpServerSetup *srv;
|
||||
|
||||
udpServer* udp = Q_NULLPTR;
|
||||
rigCtlD* rigCtl = Q_NULLPTR;
|
||||
QThread* serverThread = Q_NULLPTR;
|
||||
|
||||
void bandStackBtnClick();
|
||||
|
|
|
@ -100,7 +100,8 @@ SOURCES += main.cpp\
|
|||
qledlabel.cpp \
|
||||
pttyhandler.cpp \
|
||||
resampler/resample.c \
|
||||
repeatersetup.cpp
|
||||
repeatersetup.cpp \
|
||||
rigctld.cpp
|
||||
|
||||
HEADERS += wfmain.h \
|
||||
commhandler.h \
|
||||
|
@ -122,7 +123,8 @@ HEADERS += wfmain.h \
|
|||
resampler/arch.h \
|
||||
resampler/resample_sse.h \
|
||||
repeatersetup.h \
|
||||
repeaterattributes.h
|
||||
repeaterattributes.h \
|
||||
rigctld.h
|
||||
|
||||
|
||||
FORMS += wfmain.ui \
|
||||
|
|
|
@ -213,6 +213,7 @@
|
|||
<ClCompile Include="repeatersetup.cpp" />
|
||||
<ClCompile Include="resampler\resample.c" />
|
||||
<ClCompile Include="rigcommander.cpp" />
|
||||
<ClCompile Include="rigctld.cpp" />
|
||||
<ClCompile Include="rigidentities.cpp" />
|
||||
<ClCompile Include="audiohandler.cpp" />
|
||||
<ClCompile Include="satellitesetup.cpp" />
|
||||
|
@ -241,6 +242,7 @@
|
|||
<QtMoc Include="pttyhandler.h" />
|
||||
<QtMoc Include="repeatersetup.h" />
|
||||
<ClInclude Include="resampler\speex_resampler.h" />
|
||||
<QtMoc Include="rigctld.h" />
|
||||
<ClInclude Include="rigidentities.h" />
|
||||
<QtMoc Include="udphandler.h">
|
||||
</QtMoc>
|
||||
|
|
|
@ -114,6 +114,9 @@
|
|||
<ClCompile Include="repeatersetup.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rigctld.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="commhandler.h">
|
||||
|
@ -167,6 +170,9 @@
|
|||
<QtMoc Include="repeatersetup.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="rigctld.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="debug\moc_predefs.h.cbt">
|
||||
|
@ -341,6 +347,7 @@
|
|||
<None Include="resources\wfview.png" />
|
||||
<None Include="resources\wfview.png" />
|
||||
<None Include="resources\wfview.png" />
|
||||
<None Include="resources\wfview.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="resources\install.sh">
|
||||
|
|
Ładowanie…
Reference in New Issue