kopia lustrzana https://gitlab.com/eliggett/wfview
Initial tcpserver support (needs work)
rodzic
ece5933d55
commit
bfd9ddea52
|
@ -61,13 +61,20 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu
|
|||
comm = new commHandler(rigSerialPort, rigBaudRate);
|
||||
ptty = new pttyHandler(vsp);
|
||||
|
||||
tcp = new tcpServer();
|
||||
|
||||
// data from the comm port to the program:
|
||||
connect(comm, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
|
||||
|
||||
// data from the ptty to the rig:
|
||||
connect(ptty, SIGNAL(haveDataFromPort(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray)));
|
||||
|
||||
// data from the tcp port to the rig:
|
||||
connect(tcp, SIGNAL(readyRead(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray)));
|
||||
|
||||
// data from the program to the comm port:
|
||||
connect(this, SIGNAL(dataForComm(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray)));
|
||||
connect(this, SIGNAL(dataForComm(QByteArray)), tcp, SLOT(dataToPort(QByteArray)));
|
||||
connect(this, SIGNAL(toggleRTS(bool)), comm, SLOT(setRTS(bool)));
|
||||
|
||||
// data from the rig to the ptty:
|
||||
|
@ -100,6 +107,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud
|
|||
setup();
|
||||
// ---
|
||||
|
||||
|
||||
if (udp == Q_NULLPTR) {
|
||||
|
||||
udp = new udpHandler(prefs,rxSetup,txSetup);
|
||||
|
@ -120,12 +128,18 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud
|
|||
|
||||
ptty = new pttyHandler(vsp);
|
||||
|
||||
tcp = new tcpServer(this);
|
||||
|
||||
// Data from UDP to the program
|
||||
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), this, SLOT(handleNewData(QByteArray)));
|
||||
|
||||
// data from the rig to the ptty:
|
||||
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray)));
|
||||
|
||||
// data from the rig to tcp:
|
||||
connect(udp, SIGNAL(haveDataFromPort(QByteArray)), tcp, SLOT(dataToPort(QByteArray)));
|
||||
|
||||
|
||||
// Audio from UDP
|
||||
connect(udp, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket)));
|
||||
|
||||
|
@ -135,6 +149,9 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud
|
|||
// data from the ptty to the rig:
|
||||
connect(ptty, SIGNAL(haveDataFromPort(QByteArray)), udp, SLOT(receiveDataFromUserToRig(QByteArray)));
|
||||
|
||||
// data from the tcp port to the Rig:
|
||||
connect(tcp, SIGNAL(haveDataFromPort(QByteArray)), udp, SLOT(receiveDataFromUserToRig(QByteArray)));
|
||||
|
||||
connect(this, SIGNAL(haveChangeLatency(quint16)), udp, SLOT(changeLatency(quint16)));
|
||||
connect(this, SIGNAL(haveSetVolume(unsigned char)), udp, SLOT(setVolume(unsigned char)));
|
||||
connect(udp, SIGNAL(haveBaudRate(quint32)), this, SLOT(receiveBaudRate(quint32)));
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "rigidentities.h"
|
||||
#include "repeaterattributes.h"
|
||||
#include "freqmemory.h"
|
||||
#include "tcpserver.h"
|
||||
|
||||
#include "rigstate.h"
|
||||
|
||||
|
@ -425,6 +426,7 @@ private:
|
|||
|
||||
commHandler* comm = Q_NULLPTR;
|
||||
pttyHandler* ptty = Q_NULLPTR;
|
||||
tcpServer* tcp = Q_NULLPTR;
|
||||
udpHandler* udp=Q_NULLPTR;
|
||||
QThread* udpHandlerThread = Q_NULLPTR;
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
#include "tcpserver.h"
|
||||
|
||||
#include "logcategories.h"
|
||||
|
||||
tcpServer::tcpServer(QObject* parent) : QObject(parent)
|
||||
{
|
||||
server = new QTcpServer(this);
|
||||
connect(server, SIGNAL(newConnection()), this, SLOT(newConnection()));
|
||||
if (!server->listen(QHostAddress::Any, 5010))
|
||||
{
|
||||
qDebug() << "TCP Server could not start";
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "TCP Server started!";
|
||||
}
|
||||
}
|
||||
|
||||
tcpServer::~tcpServer()
|
||||
{
|
||||
if (socket != Q_NULLPTR)
|
||||
{
|
||||
socket->close();
|
||||
delete socket;
|
||||
}
|
||||
server->close();
|
||||
delete server;
|
||||
|
||||
}
|
||||
|
||||
void tcpServer::newConnection()
|
||||
{
|
||||
qDebug(logSystem()) << QString("Incoming Connection");
|
||||
socket = server->nextPendingConnection();
|
||||
connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
||||
}
|
||||
|
||||
void tcpServer::readyRead() {
|
||||
QByteArray data;
|
||||
if (socket->bytesAvailable()) {
|
||||
data=socket->readAll();
|
||||
emit haveDataFromPort(data);
|
||||
}
|
||||
//qDebug(logSystem()) << QString("Data IN!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void tcpServer::dataToPort(QByteArray data) {
|
||||
//qDebug(logSystem()) << QString("TCP Send");
|
||||
|
||||
if (socket != Q_NULLPTR) {
|
||||
socket->write(data);
|
||||
socket->flush();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef TCPSERVER_H
|
||||
#define TCPSERVER_H
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
#include <qtcpserver.h>
|
||||
class tcpServer :
|
||||
public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit tcpServer(QObject* parent = 0);
|
||||
~tcpServer();
|
||||
public slots:
|
||||
void dataToPort(QByteArray data);
|
||||
void readyRead();
|
||||
void newConnection();
|
||||
signals:
|
||||
void haveDataFromPort(QByteArray data); // emit this when we have data, connect to rigcommander
|
||||
private:
|
||||
QTcpServer* server;
|
||||
QTcpSocket* socket = Q_NULLPTR;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -164,6 +164,7 @@ SOURCES += main.cpp\
|
|||
ring/ring.cpp \
|
||||
transceiveradjustments.cpp \
|
||||
selectradio.cpp \
|
||||
tcpserver.cpp \
|
||||
aboutbox.cpp
|
||||
|
||||
HEADERS += wfmain.h \
|
||||
|
@ -192,6 +193,7 @@ HEADERS += wfmain.h \
|
|||
transceiveradjustments.h \
|
||||
audiotaper.h \
|
||||
selectradio.h \
|
||||
tcpserver.h \
|
||||
aboutbox.h
|
||||
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<ObjectFileName>release\</ObjectFileName>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION="1.2d";BUILD_WFVIEW;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";GITSHORT="41e90bb";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION="1.2d";BUILD_WFVIEW;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";GITSHORT="ece5933";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<ProgramDataBaseFileName></ProgramDataBaseFileName>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
|
@ -85,7 +85,7 @@
|
|||
<WarningLevel>0</WarningLevel>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION=\"1.2d\";BUILD_WFVIEW;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";GITSHORT=\"41e90bb\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION=\"1.2d\";BUILD_WFVIEW;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";GITSHORT=\"ece5933\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<QtMoc><CompilerFlavor>msvc</CompilerFlavor><Include>./$(Configuration)/moc_predefs.h</Include><ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription><DynamicSource>output</DynamicSource><QtMocDir>$(Configuration)</QtMocDir><QtMocFileName>moc_%(Filename).cpp</QtMocFileName></QtMoc><QtRcc><Compression>default</Compression><ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription><QtRccDir>$(Configuration)</QtRccDir><QtRccFileName>qrc_%(Filename).cpp</QtRccFileName></QtRcc><QtUic><ExecutionDescription>Uic'ing %(Identity)...</ExecutionDescription><QtUicDir>$(ProjectDir)</QtUicDir><QtUicFileName>ui_%(Filename).h</QtUicFileName></QtUic></ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
@ -99,7 +99,7 @@
|
|||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<ObjectFileName>debug\</ObjectFileName>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION="1.2d";BUILD_WFVIEW;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";GITSHORT="41e90bb";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION="1.2d";BUILD_WFVIEW;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";GITSHORT="ece5933";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
|
@ -124,7 +124,7 @@
|
|||
<WarningLevel>0</WarningLevel>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION=\"1.2d\";BUILD_WFVIEW;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";GITSHORT=\"41e90bb\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION=\"1.2d\";BUILD_WFVIEW;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";GITSHORT=\"ece5933\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<QtMoc><CompilerFlavor>msvc</CompilerFlavor><Include>./$(Configuration)/moc_predefs.h</Include><ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription><DynamicSource>output</DynamicSource><QtMocDir>$(Configuration)</QtMocDir><QtMocFileName>moc_%(Filename).cpp</QtMocFileName></QtMoc><QtRcc><Compression>default</Compression><ExecutionDescription>Rcc'ing %(Identity)...</ExecutionDescription><QtRccDir>$(Configuration)</QtRccDir><QtRccFileName>qrc_%(Filename).cpp</QtRccFileName></QtRcc><QtUic><ExecutionDescription>Uic'ing %(Identity)...</ExecutionDescription><QtUicDir>$(ProjectDir)</QtUicDir><QtUicFileName>ui_%(Filename).h</QtUicFileName></QtUic></ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
@ -147,6 +147,7 @@
|
|||
<ClCompile Include="ring\ring.cpp" />
|
||||
<ClCompile Include="satellitesetup.cpp" />
|
||||
<ClCompile Include="selectradio.cpp" />
|
||||
<ClCompile Include="tcpserver.cpp" />
|
||||
<ClCompile Include="transceiveradjustments.cpp" />
|
||||
<ClCompile Include="udphandler.cpp" />
|
||||
<ClCompile Include="udpserver.cpp" />
|
||||
|
@ -293,6 +294,16 @@
|
|||
|
||||
</QtMoc>
|
||||
<ClInclude Include="resampler\speex_resampler.h" />
|
||||
<QtMoc Include="tcpserver.h">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</QtMoc>
|
||||
<QtMoc Include="transceiveradjustments.h">
|
||||
|
||||
|
||||
|
@ -394,6 +405,8 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -104,6 +104,9 @@
|
|||
<ClCompile Include="selectradio.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tcpserver.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="transceiveradjustments.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -187,6 +190,9 @@
|
|||
<ClInclude Include="resampler\speex_resampler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<QtMoc Include="tcpserver.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="transceiveradjustments.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
|
@ -252,6 +258,8 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue