kopia lustrzana https://gitlab.com/eliggett/wfview
rigctl working (sort of) with WSJT-X
rodzic
a8f70ba51c
commit
6623c2ced0
|
@ -22,7 +22,9 @@
|
||||||
|
|
||||||
rigCommander::rigCommander()
|
rigCommander::rigCommander()
|
||||||
{
|
{
|
||||||
|
rigState.filter = 0;
|
||||||
|
rigState.mode = 0;
|
||||||
|
rigState.ptt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rigCommander::~rigCommander()
|
rigCommander::~rigCommander()
|
||||||
|
@ -136,6 +138,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs)
|
||||||
// data from the comm port to the program:
|
// data from the comm port to the program:
|
||||||
|
|
||||||
emit commReady();
|
emit commReady();
|
||||||
|
emit stateInfo(&rigState);
|
||||||
|
|
||||||
pttAllowed = true; // This is for developing, set to false for "safe" debugging. Set to true for deployment.
|
pttAllowed = true; // This is for developing, set to false for "safe" debugging. Set to true for deployment.
|
||||||
|
|
||||||
|
@ -1890,6 +1893,7 @@ void rigCommander::parsePTT()
|
||||||
// PTT on
|
// PTT on
|
||||||
emit havePTTStatus(true);
|
emit havePTTStatus(true);
|
||||||
}
|
}
|
||||||
|
rigState.ptt = (unsigned char)payloadIn[2];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2805,6 +2809,7 @@ void rigCommander::parseFrequency()
|
||||||
|
|
||||||
freq.MHzDouble = frequencyMhz;
|
freq.MHzDouble = frequencyMhz;
|
||||||
|
|
||||||
|
rigState.vfoAFreq = freq;
|
||||||
emit haveFrequency(freq);
|
emit haveFrequency(freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2862,7 +2867,6 @@ freqt rigCommander::parseFrequency(QByteArray data, unsigned char lastPosition)
|
||||||
freqs.Hz += ((data[lastPosition-3] & 0xf0) >> 4) * 100000;
|
freqs.Hz += ((data[lastPosition-3] & 0xf0) >> 4) * 100000;
|
||||||
|
|
||||||
freqs.MHzDouble = (double)freq;
|
freqs.MHzDouble = (double)freq;
|
||||||
|
|
||||||
return freqs;
|
return freqs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2876,7 +2880,8 @@ void rigCommander::parseMode()
|
||||||
} else {
|
} else {
|
||||||
filter = 0;
|
filter = 0;
|
||||||
}
|
}
|
||||||
|
rigState.mode = (unsigned char)payloadIn[01];
|
||||||
|
rigState.filter = filter;
|
||||||
emit haveMode((unsigned char)payloadIn[01], filter);
|
emit haveMode((unsigned char)payloadIn[01], filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,9 @@ struct freqt {
|
||||||
struct rigStateStruct {
|
struct rigStateStruct {
|
||||||
freqt vfoAFreq;
|
freqt vfoAFreq;
|
||||||
freqt vfoBFreq;
|
freqt vfoBFreq;
|
||||||
|
unsigned char ptt;
|
||||||
|
unsigned char mode;
|
||||||
|
unsigned char filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class rigCommander : public QObject
|
class rigCommander : public QObject
|
||||||
|
@ -283,6 +286,9 @@ signals:
|
||||||
void havePreamp(unsigned char pre);
|
void havePreamp(unsigned char pre);
|
||||||
void haveAntenna(unsigned char ant);
|
void haveAntenna(unsigned char ant);
|
||||||
|
|
||||||
|
// Rig State
|
||||||
|
void stateInfo(rigStateStruct* state);
|
||||||
|
|
||||||
// Housekeeping:
|
// Housekeeping:
|
||||||
void getMoreDebug();
|
void getMoreDebug();
|
||||||
void finished();
|
void finished();
|
||||||
|
|
123
rigctld.cpp
123
rigctld.cpp
|
@ -12,6 +12,16 @@ rigCtlD::~rigCtlD()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rigCtlD::receiveFrequency(freqt freq)
|
||||||
|
{
|
||||||
|
emit setFrequency(freq);
|
||||||
|
}
|
||||||
|
void rigCtlD::receiveStateInfo(rigStateStruct* state)
|
||||||
|
{
|
||||||
|
qDebug("Setting rig state");
|
||||||
|
rigState = state;
|
||||||
|
}
|
||||||
|
|
||||||
int rigCtlD::startServer(qint16 port)
|
int rigCtlD::startServer(qint16 port)
|
||||||
{
|
{
|
||||||
if (!this->listen(QHostAddress::Any, port)) {
|
if (!this->listen(QHostAddress::Any, port)) {
|
||||||
|
@ -26,7 +36,7 @@ int rigCtlD::startServer(qint16 port)
|
||||||
}
|
}
|
||||||
|
|
||||||
void rigCtlD::incomingConnection(qintptr socket) {
|
void rigCtlD::incomingConnection(qintptr socket) {
|
||||||
rigCtlClient* client = new rigCtlClient(socket, rigCaps, this);
|
rigCtlClient* client = new rigCtlClient(socket, rigCaps, rigState, this);
|
||||||
connect(this, SIGNAL(onStopped()), client, SLOT(closeSocket()));
|
connect(this, SIGNAL(onStopped()), client, SLOT(closeSocket()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,12 +53,14 @@ void rigCtlD::receiveRigCaps(rigCapabilities caps)
|
||||||
this->rigCaps = caps;
|
this->rigCaps = caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
rigCtlClient::rigCtlClient(int socketId, rigCapabilities caps, rigCtlD *parent) : QObject(parent)
|
rigCtlClient::rigCtlClient(int socketId, rigCapabilities caps,rigStateStruct *state, rigCtlD *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
commandBuffer.clear();
|
commandBuffer.clear();
|
||||||
sessionId = socketId;
|
sessionId = socketId;
|
||||||
rigCaps = caps;
|
rigCaps = caps;
|
||||||
|
rigState = state;
|
||||||
socket = new QTcpSocket(this);
|
socket = new QTcpSocket(this);
|
||||||
|
this->parent = parent;
|
||||||
if (!socket->setSocketDescriptor(sessionId))
|
if (!socket->setSocketDescriptor(sessionId))
|
||||||
{
|
{
|
||||||
qDebug(logRigCtlD()) << " error binding socket: " << sessionId;
|
qDebug(logRigCtlD()) << " error binding socket: " << sessionId;
|
||||||
|
@ -64,20 +76,92 @@ void rigCtlClient::socketReadyRead()
|
||||||
{
|
{
|
||||||
QByteArray data = socket->readAll();
|
QByteArray data = socket->readAll();
|
||||||
commandBuffer.append(data);
|
commandBuffer.append(data);
|
||||||
|
static QString sep = " ";
|
||||||
|
static int num = 0;
|
||||||
if (commandBuffer.endsWith('\n'))
|
if (commandBuffer.endsWith('\n'))
|
||||||
{
|
{
|
||||||
// Process command
|
// Process command
|
||||||
qDebug(logRigCtlD()) << sessionId << "command received" << commandBuffer;
|
if (rigState == Q_NULLPTR)
|
||||||
|
{
|
||||||
|
qDebug(logRigCtlD()) << "no rigState!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (commandBuffer[0].toLower() == "q")
|
qDebug(logRigCtlD()) << sessionId << "command received" << commandBuffer;
|
||||||
|
if (commandBuffer[num] == ";" || commandBuffer[num] == "|" || commandBuffer[num] == ",")
|
||||||
|
{
|
||||||
|
sep = commandBuffer[num].toLatin1();
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
else if (commandBuffer[num] == "+")
|
||||||
|
{
|
||||||
|
sep = "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commandBuffer[num] == "q")
|
||||||
{
|
{
|
||||||
closeSocket();
|
closeSocket();
|
||||||
}
|
}
|
||||||
else if (commandBuffer[0] == "1")
|
if (commandBuffer.contains("\\chk_vfo"))
|
||||||
{
|
{
|
||||||
dumpCaps();
|
sendData(QString("0\n"));
|
||||||
|
}
|
||||||
|
if (commandBuffer.contains("\\dump_state"))
|
||||||
|
{
|
||||||
|
// Currently send "fake" state information until I can work out what is required!
|
||||||
|
sendData(QString("1\n1\n0\n150000.000000 1500000000.000000 0x1ff -1 -1 0x16000003 0xf\n0 0 0 0 0 0 0\n0 0 0 0 0 0 0\n0x1ff 1\n0x1ff 0\n0 0\n0x1e 2400\n0x2 500\n0x1 8000\n0x1 2400\n0x20 15000\n0x20 8000\n0x40 230000\n0 0\n9990\n9990\n10000\n0\n10\n10 20 30\n0x3effffff\n0x3effffff\n0x7fffffff\n0x7fffffff\n0x7fffffff\n0x7fffffff\ndone\n"));
|
||||||
|
}
|
||||||
|
if (commandBuffer[num] == "f" || commandBuffer.contains("\\get_freq"))
|
||||||
|
{
|
||||||
|
sendData(QString("%1\n").arg(rigState->vfoAFreq.Hz));
|
||||||
|
}
|
||||||
|
else if (commandBuffer[num] == "F" || commandBuffer.contains("\\set_freq"))
|
||||||
|
{
|
||||||
|
const QRegExp rx(QLatin1Literal("[^0-9]+"));
|
||||||
|
auto&& parts = commandBuffer.split(rx);
|
||||||
|
freqt freq;
|
||||||
|
freq.Hz = parts[1].toInt();
|
||||||
|
emit parent->setFrequency(freq);
|
||||||
|
sendData(QString("RPRT 0\n"));
|
||||||
|
}
|
||||||
|
else if (commandBuffer[num] == "1" || commandBuffer.contains("\\dump_caps"))
|
||||||
|
{
|
||||||
|
dumpCaps(sep);
|
||||||
|
}
|
||||||
|
else if (commandBuffer[num] == "t")
|
||||||
|
{
|
||||||
|
sendData(QString("%1\n").arg(rigState->ptt));
|
||||||
|
}
|
||||||
|
else if (commandBuffer[num] == "T")
|
||||||
|
{
|
||||||
|
if (commandBuffer[num + 2] == "0") {
|
||||||
|
emit parent->setPTT(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit parent->setPTT(true);
|
||||||
|
}
|
||||||
|
sendData(QString("RPRT 0\n"));
|
||||||
|
}
|
||||||
|
else if (commandBuffer[num] == "v")
|
||||||
|
{
|
||||||
|
sendData(QString("VFOA\n"));
|
||||||
|
}
|
||||||
|
else if (commandBuffer[num] == "m")
|
||||||
|
{
|
||||||
|
sendData(QString("FM\n15000\n"));
|
||||||
|
}
|
||||||
|
else if (commandBuffer[num] == "M")
|
||||||
|
{
|
||||||
|
// Set mode
|
||||||
|
sendData(QString("RPRT 0\n"));
|
||||||
|
}
|
||||||
|
else if (commandBuffer[num] == "s")
|
||||||
|
{
|
||||||
|
sendData(QString("0\nVFOA\n"));
|
||||||
}
|
}
|
||||||
commandBuffer.clear();
|
commandBuffer.clear();
|
||||||
|
sep = " ";
|
||||||
|
num = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,23 +179,28 @@ void rigCtlClient::closeSocket()
|
||||||
|
|
||||||
void rigCtlClient::sendData(QString data)
|
void rigCtlClient::sendData(QString data)
|
||||||
{
|
{
|
||||||
|
qDebug(logRigCtlD()) << "Sending:" << data;
|
||||||
if (socket != Q_NULLPTR && socket->isValid() && socket->isOpen())
|
if (socket != Q_NULLPTR && socket->isValid() && socket->isOpen())
|
||||||
{
|
{
|
||||||
socket->write(data.toLatin1());
|
socket->write(data.toLatin1());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug(logRigCtlD()) << "socket not open!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void rigCtlClient::dumpCaps()
|
void rigCtlClient::dumpCaps(QString sep)
|
||||||
{
|
{
|
||||||
sendData(QString("Caps dump for model: %1\n").arg(rigCaps.modelID));
|
sendData(QString("Caps dump for model: %1%2").arg(rigCaps.modelID).arg(sep));
|
||||||
sendData(QString("Model Name:\t%1\n").arg(rigCaps.modelName));
|
sendData(QString("Model Name:\t%1%2").arg(rigCaps.modelName).arg(sep));
|
||||||
sendData(QString("Mfg Name:\tIcom\n"));
|
sendData(QString("Mfg Name:\tIcom%1").arg(sep));
|
||||||
sendData(QString("Backend version:\t0.1\n"));
|
sendData(QString("Backend version:\t0.1%1").arg(sep));
|
||||||
sendData(QString("Backend copyright:\t2021\n"));
|
sendData(QString("Backend copyright:\t2021%1").arg(sep));
|
||||||
sendData(QString("Rig type:\tTransceiver\n"));
|
sendData(QString("Rig type:\tTransceiver%1").arg(sep));
|
||||||
sendData(QString("PTT type:\tRig capable\n"));
|
sendData(QString("PTT type:\tRig capable%1").arg(sep));
|
||||||
sendData(QString("DCD type:\tRig capable\n"));
|
sendData(QString("DCD type:\tRig capable%1").arg(sep));
|
||||||
sendData(QString("Port type:\tNetwork link\n"));
|
sendData(QString("Port type:\tNetwork link%1").arg(sep));
|
||||||
|
sendData(QString("\n"));
|
||||||
}
|
}
|
14
rigctld.h
14
rigctld.h
|
@ -27,12 +27,17 @@ signals:
|
||||||
void onStarted();
|
void onStarted();
|
||||||
void onStopped();
|
void onStopped();
|
||||||
void sendData(QString data);
|
void sendData(QString data);
|
||||||
|
void setFrequency(freqt freq);
|
||||||
|
void setPTT(bool state);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void incomingConnection(qintptr socketDescriptor);
|
virtual void incomingConnection(qintptr socketDescriptor);
|
||||||
void receiveRigCaps(rigCapabilities caps);
|
void receiveRigCaps(rigCapabilities caps);
|
||||||
|
void receiveStateInfo(rigStateStruct* state);
|
||||||
|
void receiveFrequency(freqt freq);
|
||||||
|
|
||||||
|
private:
|
||||||
|
rigStateStruct* rigState = Q_NULLPTR;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +47,7 @@ class rigCtlClient : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit rigCtlClient(int socket, rigCapabilities caps, rigCtlD* parent = Q_NULLPTR);
|
explicit rigCtlClient(int socket, rigCapabilities caps, rigStateStruct *state, rigCtlD* parent = Q_NULLPTR);
|
||||||
int getSocketId();
|
int getSocketId();
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,9 +63,10 @@ protected:
|
||||||
QString commandBuffer;
|
QString commandBuffer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void dumpCaps();
|
void dumpCaps(QString sep);
|
||||||
rigCapabilities rigCaps;
|
rigCapabilities rigCaps;
|
||||||
|
rigStateStruct* rigState = Q_NULLPTR;
|
||||||
|
rigCtlD* parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
22
wfmain.cpp
22
wfmain.cpp
|
@ -203,13 +203,6 @@ 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.
|
plot = ui->plot; // rename it waterfall.
|
||||||
wf = ui->waterfall;
|
wf = ui->waterfall;
|
||||||
|
|
||||||
|
@ -462,7 +455,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
||||||
connect(rig, SIGNAL(havePreamp(unsigned char)), this, SLOT(receivePreamp(unsigned char)));
|
connect(rig, SIGNAL(havePreamp(unsigned char)), this, SLOT(receivePreamp(unsigned char)));
|
||||||
connect(this, SIGNAL(getAttenuator()), rig, SLOT(getAttenuator()));
|
connect(this, SIGNAL(getAttenuator()), rig, SLOT(getAttenuator()));
|
||||||
connect(rig, SIGNAL(haveAttenuator(unsigned char)), this, SLOT(receiveAttenuator(unsigned char)));
|
connect(rig, SIGNAL(haveAttenuator(unsigned char)), this, SLOT(receiveAttenuator(unsigned char)));
|
||||||
connect(this, SIGNAL(getAntenna()), rig, SLOT(getAntenna));
|
connect(this, SIGNAL(getAntenna()), rig, SLOT(getAntenna()));
|
||||||
//connect(rig, SIGNAL(haveAntenna(unsigned char)), this, SLOT(receiveAntennaSel(unsigned char)));
|
//connect(rig, SIGNAL(haveAntenna(unsigned char)), this, SLOT(receiveAntennaSel(unsigned char)));
|
||||||
|
|
||||||
|
|
||||||
|
@ -612,6 +605,14 @@ void wfmain::openRig()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Start rigctld
|
||||||
|
if (prefs.enableRigCtlD) {
|
||||||
|
rigCtl = new rigCtlD(this);
|
||||||
|
|
||||||
|
rigCtl->startServer(prefs.rigCtlPort);
|
||||||
|
connect(this, SIGNAL(sendRigCaps(rigCapabilities)), rigCtl, SLOT(receiveRigCaps(rigCapabilities)));
|
||||||
|
}
|
||||||
|
|
||||||
if (rigThread == Q_NULLPTR)
|
if (rigThread == Q_NULLPTR)
|
||||||
{
|
{
|
||||||
rig = new rigCommander();
|
rig = new rigCommander();
|
||||||
|
@ -633,6 +634,11 @@ void wfmain::openRig()
|
||||||
connect(this, SIGNAL(getRigCIV()), rig, SLOT(findRigs()));
|
connect(this, SIGNAL(getRigCIV()), rig, SLOT(findRigs()));
|
||||||
connect(rig, SIGNAL(discoveredRigID(rigCapabilities)), this, SLOT(receiveFoundRigID(rigCapabilities)));
|
connect(rig, SIGNAL(discoveredRigID(rigCapabilities)), this, SLOT(receiveFoundRigID(rigCapabilities)));
|
||||||
connect(rig, SIGNAL(commReady()), this, SLOT(receiveCommReady()));
|
connect(rig, SIGNAL(commReady()), this, SLOT(receiveCommReady()));
|
||||||
|
if (rigCtl != Q_NULLPTR) {
|
||||||
|
connect(rig, SIGNAL(stateInfo(rigStateStruct*)), rigCtl, SLOT(receiveStateInfo(rigStateStruct*)));
|
||||||
|
connect(rigCtl, SIGNAL(setFrequency(freqt)), rig, SLOT(setFrequency(freqt)));
|
||||||
|
connect(rigCtl, SIGNAL(setPTT(bool)), rig, SLOT(setPTT(bool)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs.enableLAN)
|
if (prefs.enableLAN)
|
||||||
|
|
1
wfmain.h
1
wfmain.h
|
@ -649,6 +649,7 @@ private:
|
||||||
Q_DECLARE_METATYPE(struct rigCapabilities)
|
Q_DECLARE_METATYPE(struct rigCapabilities)
|
||||||
Q_DECLARE_METATYPE(struct freqt)
|
Q_DECLARE_METATYPE(struct freqt)
|
||||||
Q_DECLARE_METATYPE(struct udpPreferences)
|
Q_DECLARE_METATYPE(struct udpPreferences)
|
||||||
|
Q_DECLARE_METATYPE(struct rigStateStruct)
|
||||||
Q_DECLARE_METATYPE(enum rigInput)
|
Q_DECLARE_METATYPE(enum rigInput)
|
||||||
Q_DECLARE_METATYPE(enum meterKind)
|
Q_DECLARE_METATYPE(enum meterKind)
|
||||||
Q_DECLARE_METATYPE(enum spectrumMode)
|
Q_DECLARE_METATYPE(enum spectrumMode)
|
||||||
|
|
Ładowanie…
Reference in New Issue