kopia lustrzana https://gitlab.com/eliggett/wfview
Add logging categories
rodzic
05c54ed349
commit
ef79801081
|
@ -3,6 +3,7 @@
|
|||
but as the setup/handling if output (RX) and input (TX) devices is so similar I have combined them.
|
||||
*/
|
||||
#include "audiohandler.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
#define MULAW_BIAS 33
|
||||
#define MULAW_MAX 0x1fff
|
||||
|
@ -138,30 +139,30 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16
|
|||
|
||||
bool audioHandler::setDevice(QAudioDeviceInfo deviceInfo)
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": setDevice() running :" << deviceInfo.deviceName();
|
||||
qDebug(logAudio()) << this->metaObject()->className() << ": setDevice() running :" << deviceInfo.deviceName();
|
||||
if (!deviceInfo.isFormatSupported(format)) {
|
||||
if (deviceInfo.isNull())
|
||||
{
|
||||
qDebug() << "No audio device was found. You probably need to install libqt5multimedia-plugins.";
|
||||
qDebug(logAudio()) << "No audio device was found. You probably need to install libqt5multimedia-plugins.";
|
||||
}
|
||||
else {
|
||||
qDebug() << "Audio Devices found: ";
|
||||
qDebug(logAudio()) << "Audio Devices found: ";
|
||||
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
for (const QAudioDeviceInfo& deviceInfo : deviceInfos)
|
||||
{
|
||||
qDebug() << "Device name: " << deviceInfo.deviceName();
|
||||
qDebug() << "is null (probably not good):" << deviceInfo.isNull();
|
||||
qDebug() << "channel count:" << deviceInfo.supportedChannelCounts();
|
||||
qDebug() << "byte order:" << deviceInfo.supportedByteOrders();
|
||||
qDebug() << "supported codecs:" << deviceInfo.supportedCodecs();
|
||||
qDebug() << "sample rates:" << deviceInfo.supportedSampleRates();
|
||||
qDebug() << "sample sizes:" << deviceInfo.supportedSampleSizes();
|
||||
qDebug() << "sample types:" << deviceInfo.supportedSampleTypes();
|
||||
qDebug(logAudio()) << "Device name: " << deviceInfo.deviceName();
|
||||
qDebug(logAudio()) << "is null (probably not good):" << deviceInfo.isNull();
|
||||
qDebug(logAudio()) << "channel count:" << deviceInfo.supportedChannelCounts();
|
||||
qDebug(logAudio()) << "byte order:" << deviceInfo.supportedByteOrders();
|
||||
qDebug(logAudio()) << "supported codecs:" << deviceInfo.supportedCodecs();
|
||||
qDebug(logAudio()) << "sample rates:" << deviceInfo.supportedSampleRates();
|
||||
qDebug(logAudio()) << "sample sizes:" << deviceInfo.supportedSampleSizes();
|
||||
qDebug(logAudio()) << "sample types:" << deviceInfo.supportedSampleTypes();
|
||||
}
|
||||
qDebug() << "----- done with audio info -----";
|
||||
qDebug(logAudio()) << "----- done with audio info -----";
|
||||
}
|
||||
|
||||
qDebug() << "Format not supported, choosing nearest supported format - which may not work!";
|
||||
qDebug(logAudio()) << "Format not supported, choosing nearest supported format - which may not work!";
|
||||
deviceInfo.nearestFormat(format);
|
||||
}
|
||||
this->deviceInfo = deviceInfo;
|
||||
|
@ -171,7 +172,7 @@ bool audioHandler::setDevice(QAudioDeviceInfo deviceInfo)
|
|||
|
||||
void audioHandler::reinit()
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": reinit() running";
|
||||
qDebug(logAudio()) << this->metaObject()->className() << ": reinit() running";
|
||||
if (audioOutput && audioOutput->state() != QAudio::StoppedState) {
|
||||
this->stop();
|
||||
}
|
||||
|
@ -211,7 +212,7 @@ void audioHandler::reinit()
|
|||
|
||||
void audioHandler::start()
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": start() running";
|
||||
qDebug(logAudio()) << this->metaObject()->className() << ": start() running";
|
||||
|
||||
if ((audioOutput == Q_NULLPTR || audioOutput->state() != QAudio::StoppedState) &&
|
||||
(audioInput == Q_NULLPTR || audioInput->state() != QAudio::StoppedState) ) {
|
||||
|
@ -236,7 +237,7 @@ void audioHandler::setVolume(float volume)
|
|||
|
||||
void audioHandler::flush()
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": flush() running";
|
||||
qDebug(logAudio()) << this->metaObject()->className() << ": flush() running";
|
||||
this->stop();
|
||||
if (isInput) {
|
||||
audioInput->reset();
|
||||
|
@ -298,7 +299,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen)
|
|||
buffer.remove(0, outlen);
|
||||
}
|
||||
else {
|
||||
qDebug() << "Sample bits MUST be 8 or 16 - got: " << radioSampleBits; // Should never happen?
|
||||
qDebug(logAudio()) << "Sample bits MUST be 8 or 16 - got: " << radioSampleBits; // Should never happen?
|
||||
}
|
||||
return outlen;
|
||||
}
|
||||
|
@ -357,25 +358,25 @@ void audioHandler::notified()
|
|||
void audioHandler::stateChanged(QAudio::State state)
|
||||
{
|
||||
if (state == QAudio::IdleState && audioOutput->error() == QAudio::UnderrunError) {
|
||||
qDebug() << this->metaObject()->className() << "RX:Buffer underrun";
|
||||
qDebug(logAudio()) << this->metaObject()->className() << "RX:Buffer underrun";
|
||||
//if (buffer.length() < bufferSize) {
|
||||
// audioOutput->suspend();
|
||||
//}
|
||||
}
|
||||
//qDebug() << this->metaObject()->className() << ": state = " << state;
|
||||
//qDebug(logAudio()) << this->metaObject()->className() << ": state = " << state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void audioHandler::incomingAudio(const QByteArray& data)
|
||||
{
|
||||
//qDebug() << "Got " << data.length() << " samples";
|
||||
//qDebug(logAudio()) << "Got " << data.length() << " samples";
|
||||
if (audioOutput != Q_NULLPTR && audioOutput->state() != QAudio::StoppedState) {
|
||||
QMutexLocker locker(&mutex);
|
||||
buffer.append(data);
|
||||
|
||||
if (audioOutput->state() == QAudio::SuspendedState) {
|
||||
qDebug() << "RX Audio Suspended, Resuming...";
|
||||
qDebug(logAudio()) << "RX Audio Suspended, Resuming...";
|
||||
audioOutput->resume();
|
||||
}
|
||||
}
|
||||
|
@ -384,7 +385,7 @@ void audioHandler::incomingAudio(const QByteArray& data)
|
|||
void audioHandler::changeBufferSize(const quint16 newSize)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
qDebug() << this->metaObject()->className() << ": Changing buffer size to: " << newSize << " from " << bufferSize;
|
||||
qDebug(logAudio()) << this->metaObject()->className() << ": Changing buffer size to: " << newSize << " from " << bufferSize;
|
||||
bufferSize = newSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "calibrationwindow.h"
|
||||
#include "ui_calibrationwindow.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
calibrationWindow::calibrationWindow(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "commhandler.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -22,9 +23,9 @@ commHandler::commHandler()
|
|||
|
||||
setupComm(); // basic parameters
|
||||
openPort();
|
||||
//qDebug() << "Serial buffer size: " << port->readBufferSize();
|
||||
//qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||
//port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why...
|
||||
//qDebug() << "Serial buffer size: " << port->readBufferSize();
|
||||
//qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||
|
||||
initializePt();
|
||||
|
||||
|
@ -50,9 +51,9 @@ commHandler::commHandler(QString portName, quint32 baudRate)
|
|||
|
||||
setupComm(); // basic parameters
|
||||
openPort();
|
||||
// qDebug() << "Serial buffer size: " << port->readBufferSize();
|
||||
// qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||
//port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why...
|
||||
//qDebug() << "Serial buffer size: " << port->readBufferSize();
|
||||
//qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize();
|
||||
|
||||
|
||||
initializePt();
|
||||
|
@ -64,7 +65,7 @@ commHandler::commHandler(QString portName, quint32 baudRate)
|
|||
|
||||
void commHandler::initializePt()
|
||||
{
|
||||
// qDebug() << "init pt";
|
||||
// qDebug(logSerial()) << "init pt";
|
||||
pseudoterm = new QSerialPort();
|
||||
setupPtComm();
|
||||
openPtPort();
|
||||
|
@ -72,7 +73,7 @@ void commHandler::initializePt()
|
|||
|
||||
void commHandler::setupPtComm()
|
||||
{
|
||||
qDebug() << "Setting up Pseudo Term";
|
||||
qDebug(logSerial()) << "Setting up Pseudo Term";
|
||||
pseudoterm->setPortName("/dev/ptmx");
|
||||
// pseudoterm->setBaudRate(baudrate);
|
||||
// pseudoterm->setStopBits(QSerialPort::OneStop);
|
||||
|
@ -80,7 +81,7 @@ void commHandler::setupPtComm()
|
|||
|
||||
void commHandler::openPtPort()
|
||||
{
|
||||
// qDebug() << "opening pt port";
|
||||
// qDebug(logSerial()) << "opening pt port";
|
||||
bool success;
|
||||
#ifndef Q_OS_WIN
|
||||
char ptname[128];
|
||||
|
@ -93,22 +94,22 @@ void commHandler::openPtPort()
|
|||
|
||||
#ifndef Q_OS_WIN
|
||||
|
||||
qDebug() << "Opened pt device, attempting to grant pt status";
|
||||
qDebug(logSerial()) << "Opened pt device, attempting to grant pt status";
|
||||
ptfd = pseudoterm->handle();
|
||||
qDebug() << "ptfd: " << ptfd;
|
||||
qDebug(logSerial()) << "ptfd: " << ptfd;
|
||||
if(grantpt(ptfd))
|
||||
{
|
||||
qDebug() << "Failed to grantpt";
|
||||
qDebug(logSerial()) << "Failed to grantpt";
|
||||
return;
|
||||
}
|
||||
if(unlockpt(ptfd))
|
||||
{
|
||||
qDebug() << "Failed to unlock pt";
|
||||
qDebug(logSerial()) << "Failed to unlock pt";
|
||||
return;
|
||||
}
|
||||
// we're good!
|
||||
qDebug() << "Opened pseudoterminal.";
|
||||
qDebug() << "Slave name: " << ptsname(ptfd);
|
||||
qDebug(logSerial()) << "Opened pseudoterminal.";
|
||||
qDebug(logSerial()) << "Slave name: " << ptsname(ptfd);
|
||||
|
||||
ptsname_r(ptfd, ptname, 128);
|
||||
ptDevSlave = QString::fromLocal8Bit(ptname);
|
||||
|
@ -118,13 +119,13 @@ void commHandler::openPtPort()
|
|||
sysResult = system(ptLinkCmd.toStdString().c_str());
|
||||
if(sysResult)
|
||||
{
|
||||
qDebug() << "Received error from pseudo-terminal symlink command: code: [" << sysResult << "]" << " command: [" << ptLinkCmd << "]";
|
||||
qDebug(logSerial()) << "Received error from pseudo-terminal symlink command: code: [" << sysResult << "]" << " command: [" << ptLinkCmd << "]";
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
ptfd = 0;
|
||||
qDebug() << "Could not open pseudo-terminal.";
|
||||
qDebug(logSerial()) << "Could not open pseudo-terminal.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +158,7 @@ void commHandler::sendDataOut(const QByteArray &writeData)
|
|||
qint64 bytesWritten;
|
||||
|
||||
bytesWritten = port->write(writeData);
|
||||
qDebug() << "bytesWritten: " << bytesWritten << " length of byte array: " << writeData.length()\
|
||||
qDebug(logSerial()) << "bytesWritten: " << bytesWritten << " length of byte array: " << writeData.length()\
|
||||
<< " size of byte array: " << writeData.size()\
|
||||
<< " Wrote all bytes? " << (bool) (bytesWritten == (qint64)writeData.size());
|
||||
|
||||
|
@ -176,7 +177,7 @@ void commHandler::sendDataOutPt(const QByteArray &writeData)
|
|||
#ifdef QT_DEBUG
|
||||
qint64 bytesWritten;
|
||||
bytesWritten = port->write(writeData);
|
||||
qDebug() << "pseudo-term bytesWritten: " << bytesWritten << " length of byte array: " << \
|
||||
qDebug(logSerial()) << "pseudo-term bytesWritten: " << bytesWritten << " length of byte array: " << \
|
||||
writeData.length() << " size of byte array: " << writeData.size()\
|
||||
<< ", wrote all: " << (bool)(bytesWritten == (qint64)writeData.size());
|
||||
#else
|
||||
|
@ -189,14 +190,14 @@ void commHandler::sendDataOutPt(const QByteArray &writeData)
|
|||
void commHandler::receiveDataInPt()
|
||||
{
|
||||
// We received data from the pseudo-term.
|
||||
//qDebug() << "Sending data from pseudo-terminal to radio";
|
||||
//qDebug(logSerial()) << "Sending data from pseudo-terminal to radio";
|
||||
// Send this data to the radio:
|
||||
//QByteArray ptdata = pseudoterm->readAll();
|
||||
// should check the data and rollback
|
||||
// for now though...
|
||||
//sendDataOut(ptdata);
|
||||
sendDataOut(pseudoterm->readAll());
|
||||
//qDebug() << "Returned from sendDataOut with pseudo-terminal send data.";
|
||||
//qDebug(logSerial()) << "Returned from sendDataOut with pseudo-terminal send data.";
|
||||
}
|
||||
|
||||
void commHandler::receiveDataIn()
|
||||
|
@ -224,27 +225,27 @@ void commHandler::receiveDataIn()
|
|||
// 0xE1 = wfview
|
||||
// 0xE0 = pseudo-term host
|
||||
// 0x00 = broadcast to all
|
||||
//qDebug() << "Sending data from radio to pseudo-terminal";
|
||||
//qDebug(logSerial()) << "Sending data from radio to pseudo-terminal";
|
||||
sendDataOutPt(inPortData);
|
||||
}
|
||||
|
||||
if(rolledBack)
|
||||
{
|
||||
// qDebug() << "Rolled back and was successfull. Length: " << inPortData.length();
|
||||
// qDebug(logSerial()) << "Rolled back and was successfull. Length: " << inPortData.length();
|
||||
//printHex(inPortData, false, true);
|
||||
rolledBack = false;
|
||||
}
|
||||
} else {
|
||||
// did not receive the entire thing so roll back:
|
||||
// qDebug() << "Rolling back transaction. End not detected. Lenth: " << inPortData.length();
|
||||
// qDebug(logSerial()) << "Rolling back transaction. End not detected. Lenth: " << inPortData.length();
|
||||
//printHex(inPortData, false, true);
|
||||
port->rollbackTransaction();
|
||||
rolledBack = true;
|
||||
}
|
||||
} else {
|
||||
port->commitTransaction(); // do not emit data, do not keep data.
|
||||
//qDebug() << "Warning: received data with invalid start. Dropping data.";
|
||||
//qDebug() << "THIS SHOULD ONLY HAPPEN ONCE!!";
|
||||
//qDebug(logSerial()) << "Warning: received data with invalid start. Dropping data.";
|
||||
//qDebug(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!";
|
||||
// THIS SHOULD ONLY HAPPEN ONCE!
|
||||
|
||||
// unrecoverable. We did not receive the start and must
|
||||
|
@ -264,11 +265,11 @@ void commHandler::openPort()
|
|||
if(success)
|
||||
{
|
||||
isConnected = true;
|
||||
//qDebug() << "Opened port!";
|
||||
//qDebug(logSerial()) << "Opened port!";
|
||||
return;
|
||||
} else {
|
||||
// debug?
|
||||
qDebug() << "Could not open serial port " << portName << " , please restart.";
|
||||
qDebug(logSerial()) << "Could not open serial port " << portName << " , please restart.";
|
||||
isConnected = false;
|
||||
serialError = true;
|
||||
emit haveSerialPortError(portName, "Could not open port. Please restart.");
|
||||
|
@ -287,7 +288,7 @@ void commHandler::closePort()
|
|||
void commHandler::debugThis()
|
||||
{
|
||||
// Do not use, function is for debug only and subject to change.
|
||||
qDebug() << "comm debug called.";
|
||||
qDebug(logSerial()) << "comm debug called.";
|
||||
|
||||
inPortData = port->readAll();
|
||||
emit haveDataFromPort(inPortData);
|
||||
|
@ -297,7 +298,7 @@ void commHandler::debugThis()
|
|||
|
||||
void commHandler::printHex(const QByteArray &pdata, bool printVert, bool printHoriz)
|
||||
{
|
||||
qDebug() << "---- Begin hex dump -----:";
|
||||
qDebug(logSerial()) << "---- Begin hex dump -----:";
|
||||
QString sdata("DATA: ");
|
||||
QString index("INDEX: ");
|
||||
QStringList strings;
|
||||
|
@ -314,16 +315,16 @@ void commHandler::printHex(const QByteArray &pdata, bool printVert, bool printHo
|
|||
for(int i=0; i < strings.length(); i++)
|
||||
{
|
||||
//sdata = QString(strings.at(i));
|
||||
qDebug() << strings.at(i);
|
||||
qDebug(logSerial()) << strings.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(printHoriz)
|
||||
{
|
||||
qDebug() << index;
|
||||
qDebug() << sdata;
|
||||
qDebug(logSerial()) << index;
|
||||
qDebug(logSerial()) << sdata;
|
||||
}
|
||||
qDebug() << "----- End hex dump -----";
|
||||
qDebug(logSerial()) << "----- End hex dump -----";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "freqmemory.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
// Copytight 2017-2020 Elliott H. Liggett
|
||||
|
||||
|
@ -60,6 +61,6 @@ void freqMemory::dumpMemory()
|
|||
{
|
||||
for(unsigned int p=0; p < numPresets; p++)
|
||||
{
|
||||
qDebug() << "Index: " << p << " freq: " << presets[p].frequency << " Mode: " << presets[p].mode << " isSet: " << presets[p].isSet;
|
||||
qDebug(logSystem()) << "Index: " << p << " freq: " << presets[p].frequency << " Mode: " << presets[p].mode << " isSet: " << presets[p].isSet;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(logDebug)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logInfo)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logWarning)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logCritical)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logSystem)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logSerial)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logGui)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logRig)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logAudio)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logUdp)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logUdpServer)
|
||||
|
||||
#endif // LOGCATEGORIES_H
|
||||
|
|
11
main.cpp
11
main.cpp
|
@ -1,6 +1,7 @@
|
|||
#include <QApplication>
|
||||
#include <iostream>
|
||||
#include "wfmain.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
// Copytight 2017-2021 Elliott H. Liggett
|
||||
|
||||
|
@ -86,13 +87,13 @@ int main(int argc, char *argv[])
|
|||
// Set handler
|
||||
qInstallMessageHandler(messageHandler);
|
||||
|
||||
qDebug(logInfo()) << "Starting wfview";
|
||||
qInfo(logSystem()) << "Starting wfview";
|
||||
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
qDebug(logDebug()) << "SerialPortCL as set by parser: " << serialPortCL;
|
||||
qDebug(logDebug()) << "remote host as set by parser: " << hostCL;
|
||||
qDebug(logDebug()) << "CIV as set by parser: " << civCL;
|
||||
qInfo(logSystem()) << "SerialPortCL as set by parser: " << serialPortCL;
|
||||
qInfo(logSystem()) << "remote host as set by parser: " << hostCL;
|
||||
qInfo(logSystem()) << "CIV as set by parser: " << civCL;
|
||||
#endif
|
||||
a.setWheelScrollLines(1); // one line per wheel click
|
||||
wfmain w( serialPortCL, hostCL);
|
||||
|
@ -102,7 +103,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
|
||||
return a.exec();
|
||||
qDebug(logInfo()) << "wfview is finished";
|
||||
qInfo(logSystem()) << "wfview is finished";
|
||||
|
||||
}
|
||||
|
||||
|
|
117
rigcommander.cpp
117
rigcommander.cpp
|
@ -2,6 +2,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include "rigidentities.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
// Copytight 2017-2020 Elliott H. Liggett
|
||||
|
||||
|
@ -164,7 +165,7 @@ void rigCommander::process()
|
|||
|
||||
void rigCommander::handleSerialPortError(const QString port, const QString errorText)
|
||||
{
|
||||
qDebug() << "Error using port " << port << " message: " << errorText;
|
||||
qDebug(logRig()) << "Error using port " << port << " message: " << errorText;
|
||||
emit haveSerialPortError(port, errorText);
|
||||
}
|
||||
|
||||
|
@ -190,7 +191,7 @@ void rigCommander::findRigs()
|
|||
|
||||
//check this:
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "About to request list of radios connected, using this command: ";
|
||||
qDebug(logRig()) << "About to request list of radios connected, using this command: ";
|
||||
printHex(data, false, true);
|
||||
#endif
|
||||
|
||||
|
@ -204,7 +205,7 @@ void rigCommander::prepDataAndSend(QByteArray data)
|
|||
//printHex(data, false, true);
|
||||
data.append(payloadSuffix);
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "Final payload in rig commander to be sent to rig: ";
|
||||
qDebug(logRig()) << "Final payload in rig commander to be sent to rig: ";
|
||||
printHex(data, false, true);
|
||||
#endif
|
||||
emit dataForComm(data);
|
||||
|
@ -435,7 +436,7 @@ void rigCommander::getSpectrumRefLevel(unsigned char mainSub)
|
|||
|
||||
void rigCommander::setSpectrumRefLevel(int level)
|
||||
{
|
||||
//qDebug() << __func__ << ": Setting scope to level " << level;
|
||||
//qDebug(logRig()) << __func__ << ": Setting scope to level " << level;
|
||||
QByteArray setting;
|
||||
QByteArray number;
|
||||
QByteArray pn;
|
||||
|
@ -453,7 +454,7 @@ void rigCommander::setSpectrumRefLevel(int level)
|
|||
setting.append(number);
|
||||
setting.append(pn);
|
||||
|
||||
//qDebug() << __func__ << ": scope reference number: " << number << ", PN to: " << pn;
|
||||
//qDebug(logRig()) << __func__ << ": scope reference number: " << number << ", PN to: " << pn;
|
||||
//printHex(setting, false, true);
|
||||
|
||||
prepDataAndSend(setting);
|
||||
|
@ -497,7 +498,7 @@ QByteArray rigCommander::makeFreqPayload(double freq)
|
|||
result.append(a);
|
||||
//printHex(result, false, true);
|
||||
}
|
||||
//qDebug() << "encoded frequency for " << freq << " as int " << freqInt;
|
||||
//qDebug(logRig()) << "encoded frequency for " << freq << " as int " << freqInt;
|
||||
//printHex(result, false, true);
|
||||
return result;
|
||||
|
||||
|
@ -648,7 +649,7 @@ void rigCommander::parseData(QByteArray dataInput)
|
|||
// use this:
|
||||
QList <QByteArray> dataList = dataInput.split('\xFD');
|
||||
QByteArray data;
|
||||
// qDebug() << "data list has this many elements: " << dataList.size();
|
||||
// qDebug(logRig()) << "data list has this many elements: " << dataList.size();
|
||||
if (dataList.last().isEmpty())
|
||||
{
|
||||
dataList.removeLast(); // if the original ended in FD, then there is a blank entry at the end.
|
||||
|
@ -672,14 +673,14 @@ void rigCommander::parseData(QByteArray dataInput)
|
|||
// Data from the rig that was not asked for is sent to controller 0x00:
|
||||
// fe fe 00 94 ...... fd (for example, user rotates the tune control or changes the mode)
|
||||
|
||||
//qDebug() << "Data received: ";
|
||||
//qDebug(logRig()) << "Data received: ";
|
||||
//printHex(data, false, true);
|
||||
if(data.length() < 4)
|
||||
{
|
||||
if(data.length())
|
||||
{
|
||||
// Finally this almost never happens
|
||||
// qDebug() << "Data length too short: " << data.length() << " bytes. Data:";
|
||||
// qDebug(logRig()) << "Data length too short: " << data.length() << " bytes. Data:";
|
||||
//printHex(data, false, true);
|
||||
}
|
||||
// no
|
||||
|
@ -690,18 +691,18 @@ void rigCommander::parseData(QByteArray dataInput)
|
|||
|
||||
if(!data.startsWith("\xFE\xFE"))
|
||||
{
|
||||
// qDebug() << "Warning: Invalid data received, did not start with FE FE.";
|
||||
// qDebug(logRig()) << "Warning: Invalid data received, did not start with FE FE.";
|
||||
// find 94 e0 and shift over,
|
||||
// or look inside for a second FE FE
|
||||
// Often a local echo will miss a few bytes at the beginning.
|
||||
if(data.startsWith('\xFE'))
|
||||
{
|
||||
data.prepend('\xFE');
|
||||
// qDebug() << "Warning: Working with prepended data stream.";
|
||||
// qDebug(logRig()) << "Warning: Working with prepended data stream.";
|
||||
parseData(payloadIn);
|
||||
return;
|
||||
} else {
|
||||
//qDebug() << "Error: Could not reconstruct corrupted data: ";
|
||||
//qDebug(logRig()) << "Error: Could not reconstruct corrupted data: ";
|
||||
//printHex(data, false, true);
|
||||
// data.right(data.length() - data.find('\xFE\xFE'));
|
||||
// if found do not return and keep going.
|
||||
|
@ -714,7 +715,7 @@ void rigCommander::parseData(QByteArray dataInput)
|
|||
// data is or begins with an echoback from what we sent
|
||||
// find the first 'fd' and cut it. Then continue.
|
||||
//payloadIn = data.right(data.length() - data.indexOf('\xfd')-1);
|
||||
// qDebug() << "[FOUND] Trimmed off echo:";
|
||||
// qDebug(logRig()) << "[FOUND] Trimmed off echo:";
|
||||
//printHex(payloadIn, false, true);
|
||||
//parseData(payloadIn);
|
||||
//return;
|
||||
|
@ -728,7 +729,7 @@ void rigCommander::parseData(QByteArray dataInput)
|
|||
// // data is or begins with an echoback from what we sent
|
||||
// // find the first 'fd' and cut it. Then continue.
|
||||
// payloadIn = data.right(data.length() - data.indexOf('\xfd')-1);
|
||||
// //qDebug() << "Trimmed off echo:";
|
||||
// //qDebug(logRig()) << "Trimmed off echo:";
|
||||
// //printHex(payloadIn, false, true);
|
||||
// parseData(payloadIn);
|
||||
// break;
|
||||
|
@ -752,7 +753,7 @@ void rigCommander::parseData(QByteArray dataInput)
|
|||
// The data are "to 00" and "from E1"
|
||||
// Don't use it!
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "Caught it! Found the echo'd broadcast request from us!";
|
||||
qDebug(logRig()) << "Caught it! Found the echo'd broadcast request from us!";
|
||||
#endif
|
||||
} else {
|
||||
payloadIn = data.right(data.length() - 4);
|
||||
|
@ -769,7 +770,7 @@ void rigCommander::parseData(QByteArray dataInput)
|
|||
/*
|
||||
if(dataList.length() > 1)
|
||||
{
|
||||
qDebug() << "Recovered " << count << " frames from single data with size" << dataList.count();
|
||||
qDebug(logRig()) << "Recovered " << count << " frames from single data with size" << dataList.count();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -803,19 +804,19 @@ void rigCommander::parseCommand()
|
|||
}
|
||||
break;
|
||||
case '\x01':
|
||||
//qDebug() << "Have mode data";
|
||||
//qDebug(logRig()) << "Have mode data";
|
||||
this->parseMode();
|
||||
break;
|
||||
case '\x04':
|
||||
//qDebug() << "Have mode data";
|
||||
//qDebug(logRig()) << "Have mode data";
|
||||
this->parseMode();
|
||||
break;
|
||||
case '\x05':
|
||||
//qDebug() << "Have frequency data";
|
||||
//qDebug(logRig()) << "Have frequency data";
|
||||
this->parseFrequency();
|
||||
break;
|
||||
case '\x06':
|
||||
//qDebug() << "Have mode data";
|
||||
//qDebug(logRig()) << "Have mode data";
|
||||
this->parseMode();
|
||||
break;
|
||||
case '\x0F':
|
||||
|
@ -830,11 +831,11 @@ void rigCommander::parseCommand()
|
|||
parseLevels();
|
||||
break;
|
||||
case '\x19':
|
||||
// qDebug() << "Have rig ID: " << (unsigned int)payloadIn[2];
|
||||
// qDebug(logRig()) << "Have rig ID: " << (unsigned int)payloadIn[2];
|
||||
// printHex(payloadIn, false, true);
|
||||
model = determineRadioModel(payloadIn[2]); // verify this is the model not the CIV
|
||||
determineRigCaps();
|
||||
qDebug() << "Have rig ID: decimal: " << (unsigned int)model;
|
||||
qDebug(logRig()) << "Have rig ID: decimal: " << (unsigned int)model;
|
||||
|
||||
|
||||
break;
|
||||
|
@ -849,7 +850,7 @@ void rigCommander::parseCommand()
|
|||
break;
|
||||
case '\x27':
|
||||
// scope data
|
||||
//qDebug() << "Have scope data";
|
||||
//qDebug(logRig()) << "Have scope data";
|
||||
//printHex(payloadIn, false, true);
|
||||
parseWFData();
|
||||
//parseSpectrum();
|
||||
|
@ -871,7 +872,7 @@ void rigCommander::parseCommand()
|
|||
case '\xFA':
|
||||
// error
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "Error (FA) received from rig.";
|
||||
qDebug(logRig()) << "Error (FA) received from rig.";
|
||||
printHex(payloadIn, false ,true);
|
||||
#endif
|
||||
break;
|
||||
|
@ -879,7 +880,7 @@ void rigCommander::parseCommand()
|
|||
default:
|
||||
// This gets hit a lot when the pseudo-term is
|
||||
// using commands wfview doesn't know yet.
|
||||
// qDebug() << "Have other data with cmd: " << std::hex << payloadIn[00];
|
||||
// qDebug(logRig()) << "Have other data with cmd: " << std::hex << payloadIn[00];
|
||||
// printHex(payloadIn, false, true);
|
||||
break;
|
||||
}
|
||||
|
@ -889,7 +890,7 @@ void rigCommander::parseCommand()
|
|||
|
||||
void rigCommander::parseLevels()
|
||||
{
|
||||
//qDebug() << "Received a level status readout: ";
|
||||
//qDebug(logRig()) << "Received a level status readout: ";
|
||||
// printHex(payloadIn, false, true);
|
||||
|
||||
// wrong: unsigned char level = (payloadIn[2] * 100) + payloadIn[03];
|
||||
|
@ -899,7 +900,7 @@ void rigCommander::parseLevels()
|
|||
|
||||
unsigned char level = (100*hundreds) + (10*tens) + units;
|
||||
|
||||
//qDebug() << "Level is: " << (int)level << " or " << 100.0*level/255.0 << "%";
|
||||
//qDebug(logRig()) << "Level is: " << (int)level << " or " << 100.0*level/255.0 << "%";
|
||||
|
||||
// Typical RF gain response (rather low setting):
|
||||
// "INDEX: 00 01 02 03 04 "
|
||||
|
@ -948,7 +949,7 @@ void rigCommander::parseLevels()
|
|||
break;
|
||||
|
||||
default:
|
||||
qDebug() << "Unknown control level (0x14) received at register " << payloadIn[1] << " with level " << level;
|
||||
qDebug(logRig()) << "Unknown control level (0x14) received at register " << payloadIn[1] << " with level " << level;
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -989,7 +990,7 @@ void rigCommander::parseLevels()
|
|||
break;
|
||||
|
||||
default:
|
||||
qDebug() << "Unknown meter level (0x15) received at register " << payloadIn[1] << " with level " << level;
|
||||
qDebug(logRig()) << "Unknown meter level (0x15) received at register " << payloadIn[1] << " with level " << level;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1538,7 +1539,7 @@ void rigCommander::setRefAdjustCourse(unsigned char level)
|
|||
|
||||
void rigCommander::setRefAdjustFine(unsigned char level)
|
||||
{
|
||||
qDebug() << __FUNCTION__ << " level: " << level;
|
||||
qDebug(logRig()) << __FUNCTION__ << " level: " << level;
|
||||
// 1A 05 00 73 0000-0255
|
||||
QByteArray payload;
|
||||
payload.setRawData("\x1A\x05\x00\x73", 4);
|
||||
|
@ -1601,7 +1602,7 @@ void rigCommander::parseRegisters1C()
|
|||
|
||||
void rigCommander::parseATU()
|
||||
{
|
||||
// qDebug() << "Have ATU status from radio. Emitting.";
|
||||
// qDebug(logRig()) << "Have ATU status from radio. Emitting.";
|
||||
// Expect:
|
||||
// [0]: 0x1c
|
||||
// [1]: 0x01
|
||||
|
@ -1634,7 +1635,7 @@ void rigCommander::parseRegisters1A()
|
|||
// 01: band stacking memory contents (last freq used is stored here per-band)
|
||||
// 03: filter width
|
||||
// 04: AGC rate
|
||||
// qDebug() << "Looking at register 1A :";
|
||||
// qDebug(logRig()) << "Looking at register 1A :";
|
||||
// printHex(payloadIn, false, true);
|
||||
|
||||
// "INDEX: 00 01 02 03 04 "
|
||||
|
@ -1670,7 +1671,7 @@ void rigCommander::parseRegisters1A()
|
|||
|
||||
void rigCommander::parseBandStackReg()
|
||||
{
|
||||
// qDebug() << "Band stacking register response received: ";
|
||||
// qDebug(logRig()) << "Band stacking register response received: ";
|
||||
// printHex(payloadIn, false, true);
|
||||
// Reference output, 20 meters, regCode 01 (latest):
|
||||
// "INDEX: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 "
|
||||
|
@ -1689,8 +1690,8 @@ void rigCommander::parseBandStackReg()
|
|||
// 14, 15 tone squelch freq setting
|
||||
// if more, memory name (label) ascii
|
||||
|
||||
// qDebug() << "band: " << QString("%1").arg(band) << " regCode: " << (QString)regCode << " freq: " << freq;
|
||||
// qDebug() << "mode: " << (QString)mode << " dataOn: " << dataOn;
|
||||
// qDebug(logRig()) << "band: " << QString("%1").arg(band) << " regCode: " << (QString)regCode << " freq: " << freq;
|
||||
// qDebug(logRig()) << "mode: " << (QString)mode << " dataOn: " << dataOn;
|
||||
emit haveBandStackReg(freq, mode, dataOn);
|
||||
}
|
||||
|
||||
|
@ -1960,7 +1961,7 @@ void rigCommander::parseWFData()
|
|||
case 0x14:
|
||||
// fixed or center
|
||||
emit haveSpectrumFixedMode((bool)payloadIn[2]);
|
||||
qDebug() << "received 0x14 command fix/center";
|
||||
qDebug(logRig()) << "received 0x14 command fix/center";
|
||||
printHex(payloadIn, false, true);
|
||||
// [1] 0x14
|
||||
// [2] 0x00 (center), 0x01 (fixed)
|
||||
|
@ -1970,20 +1971,20 @@ void rigCommander::parseWFData()
|
|||
// [1] 0x15
|
||||
// [2] to [8] is span encoded as a frequency
|
||||
freqSpan = parseFrequency(payloadIn, 8);
|
||||
qDebug() << "Received 0x15 center span data: for frequency " << freqSpan;
|
||||
qDebug(logRig()) << "Received 0x15 center span data: for frequency " << freqSpan;
|
||||
printHex(payloadIn, false, true);
|
||||
break;
|
||||
case 0x16:
|
||||
// read edge mode center in edge mode
|
||||
emit haveScopeEdge((char)payloadIn[2]);
|
||||
qDebug() << "Received 0x16 edge in center mode:";
|
||||
qDebug(logRig()) << "Received 0x16 edge in center mode:";
|
||||
printHex(payloadIn, false, true);
|
||||
// [1] 0x16
|
||||
// [2] 0x01, 0x02, 0x03: Edge 1,2,3
|
||||
break;
|
||||
case 0x17:
|
||||
// Hold status (only 9700?)
|
||||
qDebug() << "Received 0x17 hold status - need to deal with this!";
|
||||
qDebug(logRig()) << "Received 0x17 hold status - need to deal with this!";
|
||||
printHex(payloadIn, false, true);
|
||||
break;
|
||||
case 0x19:
|
||||
|
@ -1996,7 +1997,7 @@ void rigCommander::parseWFData()
|
|||
parseSpectrumRefLevel();
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Unknown waveform data received: ";
|
||||
qDebug(logRig()) << "Unknown waveform data received: ";
|
||||
printHex(payloadIn, false, true);
|
||||
break;
|
||||
}
|
||||
|
@ -2137,7 +2138,7 @@ void rigCommander::determineRigCaps()
|
|||
rigCaps.hasLan = false;
|
||||
rigCaps.hasEthernet = false;
|
||||
rigCaps.hasWiFi = false;
|
||||
qDebug() << "Found unknown rig: " << rigCaps.modelName;
|
||||
qDebug(logRig()) << "Found unknown rig: " << rigCaps.modelName;
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -2147,14 +2148,14 @@ void rigCommander::determineRigCaps()
|
|||
lookingForRig = false;
|
||||
foundRig = true;
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "---Rig FOUND from broadcast query:";
|
||||
qDebug(logRig()) << "---Rig FOUND from broadcast query:";
|
||||
#endif
|
||||
this->civAddr = incomingCIVAddr; // Override and use immediately.
|
||||
payloadPrefix = QByteArray("\xFE\xFE");
|
||||
payloadPrefix.append(civAddr);
|
||||
payloadPrefix.append((char)compCivAddr);
|
||||
// if there is a compile-time error, remove the following line, the "hex" part is the issue:
|
||||
qDebug() << "Using incomingCIVAddr: (int): " << this->civAddr << " hex: " << hex << this->civAddr;
|
||||
qDebug(logRig()) << "Using incomingCIVAddr: (int): " << this->civAddr << " hex: " << hex << this->civAddr;
|
||||
emit discoveredRigID(rigCaps);
|
||||
} else {
|
||||
emit haveRigID(rigCaps);
|
||||
|
@ -2166,14 +2167,14 @@ void rigCommander::parseSpectrum()
|
|||
if(!haveRigCaps)
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "Spectrum received in rigCommander, but rigID is incomplete.";
|
||||
qDebug(logRig()) << "Spectrum received in rigCommander, but rigID is incomplete.";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if(rigCaps.spectSeqMax == 0)
|
||||
{
|
||||
// there is a chance this will happen with rigs that support spectrum. Once our RigID query returns, we will parse correctly.
|
||||
qDebug() << "Warning: Spectrum sequence max was zero, yet spectrum was received.";
|
||||
qDebug(logRig()) << "Warning: Spectrum sequence max was zero, yet spectrum was received.";
|
||||
return;
|
||||
}
|
||||
// Here is what to expect:
|
||||
|
@ -2213,7 +2214,7 @@ void rigCommander::parseSpectrum()
|
|||
|
||||
|
||||
// unsigned char waveInfo = payloadIn[06]; // really just one byte?
|
||||
//qDebug() << "Spectrum Data received: " << sequence << "/" << sequenceMax << " mode: " << scopeMode << " waveInfo: " << waveInfo << " length: " << payloadIn.length();
|
||||
//qDebug(logRig()) << "Spectrum Data received: " << sequence << "/" << sequenceMax << " mode: " << scopeMode << " waveInfo: " << waveInfo << " length: " << payloadIn.length();
|
||||
|
||||
// Sequnce 2, index 05 is the start of data
|
||||
// Sequence 11. index 05, is the last chunk
|
||||
|
@ -2259,13 +2260,13 @@ void rigCommander::parseSpectrum()
|
|||
// sequence numbers 2 through 10, 50 pixels each. Total after sequence 10 is 450 pixels.
|
||||
payloadIn.chop(1);
|
||||
spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5)); // write over the FD, last one doesn't, oh well.
|
||||
//qDebug() << "sequence: " << sequence << "spec index: " << (sequence-2)*55 << " payloadPosition: " << payloadIn.length() - 5 << " payload length: " << payloadIn.length();
|
||||
//qDebug(logRig()) << "sequence: " << sequence << "spec index: " << (sequence-2)*55 << " payloadPosition: " << payloadIn.length() - 5 << " payload length: " << payloadIn.length();
|
||||
} else if (sequence == rigCaps.spectSeqMax)
|
||||
{
|
||||
// last spectrum, a little bit different (last 25 pixels). Total at end is 475 pixels (7300).
|
||||
payloadIn.chop(1);
|
||||
spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5));
|
||||
//qDebug() << "sequence: " << sequence << " spec index: " << (sequence-2)*55 << " payloadPosition: " << payloadIn.length() - 5 << " payload length: " << payloadIn.length();
|
||||
//qDebug(logRig()) << "sequence: " << sequence << " spec index: " << (sequence-2)*55 << " payloadPosition: " << payloadIn.length() - 5 << " payload length: " << payloadIn.length();
|
||||
emit haveSpectrumData(spectrumLine, spectrumStartFreq, spectrumEndFreq);
|
||||
}
|
||||
}
|
||||
|
@ -2333,7 +2334,7 @@ QByteArray rigCommander::bcdEncodeInt(unsigned int num)
|
|||
{
|
||||
if(num > 9999)
|
||||
{
|
||||
qDebug() << __FUNCTION__ << "Error, number is too big for four-digit conversion: " << num;
|
||||
qDebug(logRig()) << __FUNCTION__ << "Error, number is too big for four-digit conversion: " << num;
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
|
@ -2345,14 +2346,14 @@ QByteArray rigCommander::bcdEncodeInt(unsigned int num)
|
|||
char b0 = hundreds | (thousands << 4);
|
||||
char b1 = units | (tens << 4);
|
||||
|
||||
//qDebug() << __FUNCTION__ << " encoding value " << num << " as hex:";
|
||||
//qDebug(logRig()) << __FUNCTION__ << " encoding value " << num << " as hex:";
|
||||
//printHex(QByteArray(b0), false, true);
|
||||
//printHex(QByteArray(b1), false, true);
|
||||
|
||||
|
||||
QByteArray result;
|
||||
result.append(b0).append(b1);
|
||||
qDebug() << "Result: " << result;
|
||||
qDebug(logRig()) << "Result: " << result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2457,7 +2458,7 @@ void rigCommander::setATU(bool enabled)
|
|||
|
||||
void rigCommander::getATUStatus()
|
||||
{
|
||||
//qDebug() << "Sending out for ATU status in RC.";
|
||||
//qDebug(logRig()) << "Sending out for ATU status in RC.";
|
||||
QByteArray payload("\x1C\x01");
|
||||
prepDataAndSend(payload);
|
||||
}
|
||||
|
@ -2522,7 +2523,7 @@ void rigCommander::printHex(const QByteArray &pdata)
|
|||
|
||||
void rigCommander::printHex(const QByteArray &pdata, bool printVert, bool printHoriz)
|
||||
{
|
||||
qDebug() << "---- Begin hex dump -----:";
|
||||
qDebug(logRig()) << "---- Begin hex dump -----:";
|
||||
QString sdata("DATA: ");
|
||||
QString index("INDEX: ");
|
||||
QStringList strings;
|
||||
|
@ -2539,21 +2540,21 @@ void rigCommander::printHex(const QByteArray &pdata, bool printVert, bool printH
|
|||
for(int i=0; i < strings.length(); i++)
|
||||
{
|
||||
//sdata = QString(strings.at(i));
|
||||
qDebug() << strings.at(i);
|
||||
qDebug(logRig()) << strings.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(printHoriz)
|
||||
{
|
||||
qDebug() << index;
|
||||
qDebug() << sdata;
|
||||
qDebug(logRig()) << index;
|
||||
qDebug(logRig()) << sdata;
|
||||
}
|
||||
qDebug() << "----- End hex dump -----";
|
||||
qDebug(logRig()) << "----- End hex dump -----";
|
||||
}
|
||||
|
||||
void rigCommander::dataFromServer(QByteArray data)
|
||||
{
|
||||
//qDebug() << "emit dataForComm()";
|
||||
//qDebug(logRig()) << "emit dataForComm()";
|
||||
emit dataForComm(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "rigidentities.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
// Copytight 2017-2021 Elliott H. Liggett
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "satellitesetup.h"
|
||||
#include "ui_satellitesetup.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
satelliteSetup::satelliteSetup(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// This code is heavily based on "Kappanhang" by HA2NON, ES1AKOS and W6EL!
|
||||
|
||||
#include "udphandler.h"
|
||||
|
||||
#include "logcategories.h"
|
||||
udpHandler::udpHandler(QString ip, quint16 controlPort, quint16 civPort, quint16 audioPort, QString username, QString password,
|
||||
quint16 buffer, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec) :
|
||||
controlPort(controlPort),
|
||||
|
@ -19,7 +19,7 @@ udpHandler::udpHandler(QString ip, quint16 controlPort, quint16 civPort, quint16
|
|||
this->rxCodec = rxcodec;
|
||||
this->txCodec = txcodec;
|
||||
|
||||
qDebug() << "Starting udpHandler user:" << username << " buffer:" << buffer << " rx sample rate: " << rxsample <<
|
||||
qDebug(logUdp()) << "Starting udpHandler user:" << username << " buffer:" << buffer << " rx sample rate: " << rxsample <<
|
||||
" rx codec: " << rxcodec << " tx sample rate: " << txsample << " tx codec: " << txcodec;
|
||||
|
||||
// Try to set the IP address, if it is a hostname then perform a DNS lookup.
|
||||
|
@ -30,13 +30,13 @@ udpHandler::udpHandler(QString ip, quint16 controlPort, quint16 civPort, quint16
|
|||
{
|
||||
if (addr.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||
radioIP = addr;
|
||||
qDebug() << "Got IP Address :" << ip << ": " << addr.toString();
|
||||
qDebug(logUdp()) << "Got IP Address :" << ip << ": " << addr.toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (radioIP.isNull())
|
||||
{
|
||||
qDebug() << "Error obtaining IP Address for :" << ip << ": " << remote.errorString();
|
||||
qDebug(logUdp()) << "Error obtaining IP Address for :" << ip << ": " << remote.errorString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ udpHandler::~udpHandler()
|
|||
if (civ != Q_NULLPTR) {
|
||||
delete civ;
|
||||
}
|
||||
qDebug() << "Sending token removal packet";
|
||||
qDebug(logUdp()) << "Sending token removal packet";
|
||||
sendToken(0x01);
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ void udpHandler::dataReceived()
|
|||
// This is "I am ready" in response to "Are you ready" so send login.
|
||||
else if (in->type == 0x06)
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": Received I am ready";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Received I am ready";
|
||||
sendLogin(); // send login packet
|
||||
}
|
||||
break;
|
||||
|
@ -175,7 +175,7 @@ void udpHandler::dataReceived()
|
|||
{
|
||||
if (in->response == 0x0000)
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": Token renewal successful";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Token renewal successful";
|
||||
tokenTimer->start(TOKEN_RENEWAL);
|
||||
gotAuthOK = true;
|
||||
if (!streamOpened)
|
||||
|
@ -206,12 +206,12 @@ void udpHandler::dataReceived()
|
|||
if (in->error == 0x00ffffff && !streamOpened)
|
||||
{
|
||||
emit haveNetworkError(radioIP.toString(), "Auth failed, try rebooting the radio.");
|
||||
qDebug() << this->metaObject()->className() << ": Auth failed, try rebooting the radio.";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Auth failed, try rebooting the radio.";
|
||||
}
|
||||
else if (in->error == 0x00000000 && in->disc == 0x01)
|
||||
{
|
||||
emit haveNetworkError(radioIP.toString(), "Got radio disconnected.");
|
||||
qDebug() << this->metaObject()->className() << ": Got radio disconnected.";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Got radio disconnected.";
|
||||
if (streamOpened) {
|
||||
// Close stream connections but keep connection open to the radio.
|
||||
if (audio != Q_NULLPTR) {
|
||||
|
@ -232,7 +232,7 @@ void udpHandler::dataReceived()
|
|||
if (in->error == 0xfeffffff)
|
||||
{
|
||||
emit haveNetworkStatus("Invalid Username/Password");
|
||||
qDebug() << this->metaObject()->className() << ": Invalid Username/Password";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Invalid Username/Password";
|
||||
}
|
||||
else if (!isAuthenticated)
|
||||
{
|
||||
|
@ -240,7 +240,7 @@ void udpHandler::dataReceived()
|
|||
if (in->tokrequest == tokRequest)
|
||||
{
|
||||
emit haveNetworkStatus("Radio Login OK!");
|
||||
qDebug() << this->metaObject()->className() << ": Received matching token response to our request";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Received matching token response to our request";
|
||||
token = in->token;
|
||||
sendToken(0x02);
|
||||
tokenTimer->start(TOKEN_RENEWAL); // Start token request timer
|
||||
|
@ -248,7 +248,7 @@ void udpHandler::dataReceived()
|
|||
}
|
||||
else
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": Token response did not match, sent:" << tokRequest << " got " << in->tokrequest;
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Token response did not match, sent:" << tokRequest << " got " << in->tokrequest;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ void udpHandler::dataReceived()
|
|||
highBandwidthConnection = true;
|
||||
}
|
||||
|
||||
qDebug() << this->metaObject()->className() << ": Detected connection speed " << in->connection;
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Detected connection speed " << in->connection;
|
||||
break;
|
||||
}
|
||||
case (CONNINFO_SIZE):
|
||||
|
@ -285,7 +285,7 @@ void udpHandler::dataReceived()
|
|||
|
||||
emit haveNetworkStatus(devName);
|
||||
|
||||
qDebug() << this->metaObject()->className() << "Got serial and audio request success, device name: " << devName;
|
||||
qDebug(logUdp()) << this->metaObject()->className() << "Got serial and audio request success, device name: " << devName;
|
||||
|
||||
// Stuff can change in the meantime because of a previous login...
|
||||
remoteId = in->sentid;
|
||||
|
@ -312,7 +312,7 @@ void udpHandler::dataReceived()
|
|||
audioType = in->audio;
|
||||
devName = in->name;
|
||||
//replyId = r.mid(0x42, 16);
|
||||
qDebug() << this->metaObject()->className() << "Received radio capabilities, Name:" <<
|
||||
qDebug(logUdp()) << this->metaObject()->className() << "Received radio capabilities, Name:" <<
|
||||
devName << " Audio:" <<
|
||||
audioType;
|
||||
|
||||
|
@ -371,10 +371,10 @@ void udpHandler::sendAreYouThere()
|
|||
{
|
||||
if (areYouThereCounter == 20)
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": Radio not responding.";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Radio not responding.";
|
||||
emit haveNetworkStatus("Radio not responding!");
|
||||
}
|
||||
qDebug() << this->metaObject()->className() << ": Sending Are You There...";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Sending Are You There...";
|
||||
|
||||
areYouThereCounter++;
|
||||
udpBase::sendControl(false,0x03,0x00);
|
||||
|
@ -383,7 +383,7 @@ void udpHandler::sendAreYouThere()
|
|||
void udpHandler::sendLogin() // Only used on control stream.
|
||||
{
|
||||
|
||||
qDebug() << this->metaObject()->className() << ": Sending login packet";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Sending login packet";
|
||||
|
||||
tokRequest = static_cast<quint16>(rand() | rand() << 8); // Generate random token request.
|
||||
|
||||
|
@ -411,7 +411,7 @@ void udpHandler::sendLogin() // Only used on control stream.
|
|||
|
||||
void udpHandler::sendToken(uint8_t magic)
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << "Sending Token request: " << magic;
|
||||
qDebug(logUdp()) << this->metaObject()->className() << "Sending Token request: " << magic;
|
||||
|
||||
token_packet p;
|
||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||
|
@ -434,7 +434,7 @@ void udpHandler::sendToken(uint8_t magic)
|
|||
// Class that manages all Civ Data to/from the rig
|
||||
udpCivData::udpCivData(QHostAddress local, QHostAddress ip, quint16 civPort)
|
||||
{
|
||||
qDebug() << "Starting udpCivData";
|
||||
qDebug(logUdp()) << "Starting udpCivData";
|
||||
localIP = local;
|
||||
port = civPort;
|
||||
radioIP = ip;
|
||||
|
@ -466,7 +466,7 @@ udpCivData::~udpCivData() {
|
|||
|
||||
void udpCivData::send(QByteArray d)
|
||||
{
|
||||
// qDebug() << "Sending: (" << d.length() << ") " << d;
|
||||
// qDebug(logUdp()) << "Sending: (" << d.length() << ") " << d;
|
||||
data_packet p;
|
||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||
p.len = sizeof(p);
|
||||
|
@ -515,7 +515,7 @@ void udpCivData::dataReceived()
|
|||
while (udp->hasPendingDatagrams())
|
||||
{
|
||||
QNetworkDatagram datagram = udp->receiveDatagram();
|
||||
//qDebug() << "Received: " << datagram.data();
|
||||
//qDebug(logUdp()) << "Received: " << datagram.data();
|
||||
QByteArray r = datagram.data();
|
||||
|
||||
switch (r.length())
|
||||
|
@ -557,7 +557,7 @@ void udpCivData::dataReceived()
|
|||
// Audio stream
|
||||
udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, quint16 buffer, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec)
|
||||
{
|
||||
qDebug() << "Starting udpAudio";
|
||||
qDebug(logUdp()) << "Starting udpAudio";
|
||||
this->localIP = local;
|
||||
this->port = audioPort;
|
||||
this->radioIP = ip;
|
||||
|
@ -680,7 +680,7 @@ void udpAudio::sendTxAudio()
|
|||
QByteArray tx = QByteArray::fromRawData((const char*)p.packet, sizeof(p));
|
||||
tx.append(partial);
|
||||
len = len + partial.length();
|
||||
//qDebug() << "Sending audio packet length: " << tx.length();
|
||||
//qDebug(logUdp()) << "Sending audio packet length: " << tx.length();
|
||||
sendTrackedPacket(tx);
|
||||
sendAudioSeq++;
|
||||
counter++;
|
||||
|
@ -699,7 +699,7 @@ void udpAudio::dataReceived()
|
|||
{
|
||||
while (udp->hasPendingDatagrams()) {
|
||||
QNetworkDatagram datagram = udp->receiveDatagram();
|
||||
//qDebug() << "Received: " << datagram.data();
|
||||
//qDebug(logUdp()) << "Received: " << datagram.data();
|
||||
QByteArray r = datagram.data();
|
||||
|
||||
switch (r.length())
|
||||
|
@ -743,14 +743,14 @@ void udpBase::init()
|
|||
udp = new QUdpSocket(this);
|
||||
udp->bind(); // Bind to random port.
|
||||
localPort = udp->localPort();
|
||||
qDebug() << "UDP Stream bound to local port:" << localPort << " remote port:" << port;
|
||||
qDebug(logUdp()) << "UDP Stream bound to local port:" << localPort << " remote port:" << port;
|
||||
uint32_t addr = localIP.toIPv4Address();
|
||||
myId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (localPort & 0xffff);
|
||||
}
|
||||
|
||||
udpBase::~udpBase()
|
||||
{
|
||||
qDebug() << "Closing UDP stream :" << radioIP.toString() << ":" << port;
|
||||
qDebug(logUdp()) << "Closing UDP stream :" << radioIP.toString() << ":" << port;
|
||||
if (udp != Q_NULLPTR) {
|
||||
sendControl(false, 0x05, 0x00); // Send disconnect
|
||||
udp->close();
|
||||
|
@ -787,7 +787,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
control_packet_t in = (control_packet_t)r.constData();
|
||||
|
||||
if (in->type == 0x04) {
|
||||
qDebug() << this->metaObject()->className() << ": Received I am here";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Received I am here";
|
||||
areYouThereCounter = 0;
|
||||
// I don't think that we will ever receive an "I am here" other than in response to "Are you there?"
|
||||
remoteId = in->sentid;
|
||||
|
@ -813,7 +813,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
// Don't constantly retransmit the same packet, give-up eventually
|
||||
if (match->retransmitCount < 4) {
|
||||
QMutexLocker locker(&mutex);
|
||||
qDebug() << this->metaObject()->className() << ": Sending retransmit of " << match->seqNum;
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Sending retransmit of " << match->seqNum;
|
||||
match->retransmitCount++;
|
||||
udp->writeDatagram(match->data, radioIP, port);
|
||||
}
|
||||
|
@ -824,7 +824,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
}
|
||||
else {
|
||||
// Packet was not found in buffer
|
||||
qDebug() << this->metaObject()->className() << ": Could not find requested packet " << in->seq << ", sending idle.";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Could not find requested packet " << in->seq << ", sending idle.";
|
||||
sendControl(false, 0, in->seq);
|
||||
}
|
||||
}
|
||||
|
@ -858,11 +858,11 @@ void udpBase::dataReceived(QByteArray r)
|
|||
}
|
||||
else {
|
||||
// Not sure what to do here, need to spend more time with the protocol but will try sending ping with same seq next time.
|
||||
qDebug() << "Received out-of-sequence ping response. Sent:" << pingSendSeq << " received " << in->seq;
|
||||
qDebug(logUdp()) << "Received out-of-sequence ping response. Sent:" << pingSendSeq << " received " << in->seq;
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "Unhandled response to ping. I have never seen this! 0x10=" << r[16];
|
||||
qDebug(logUdp()) << "Unhandled response to ping. I have never seen this! 0x10=" << r[16];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -874,14 +874,14 @@ void udpBase::dataReceived(QByteArray r)
|
|||
|
||||
if (in->type==0x01)
|
||||
{ // retransmit range request
|
||||
qDebug() << this->metaObject()->className() << ": Retransmit range request for:" << in->first << ", " << in->second << ", " << in->third << ", " << in->fourth << ", ";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Retransmit range request for:" << in->first << ", " << in->second << ", " << in->third << ", " << in->fourth << ", ";
|
||||
|
||||
auto match = std::find_if(txSeqBuf.begin(), txSeqBuf.end(), [&ca = in->first, &cb = in->second, &cc = in->third, &cd = in->fourth](SEQBUFENTRY& s) {
|
||||
return s.seqNum == ca || s.seqNum == cb || s.seqNum == cc || s.seqNum == cd;
|
||||
});
|
||||
|
||||
if (match == txSeqBuf.end()) {
|
||||
qDebug() << this->metaObject()->className() << ": Could not find requested packet " << in->seq << ", sending idle.";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Could not find requested packet " << in->seq << ", sending idle.";
|
||||
sendControl(false, 0, in->seq);
|
||||
}
|
||||
else {
|
||||
|
@ -889,7 +889,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
// Found matching entry?
|
||||
// Send "untracked" as it has already been sent once.
|
||||
if (match->retransmitCount <4) {
|
||||
qDebug() << this->metaObject()->className() << ": Sending retransmit of " << match->seqNum;
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Sending retransmit of " << match->seqNum;
|
||||
QMutexLocker locker(&mutex);
|
||||
udp->writeDatagram(match->data, radioIP, port);
|
||||
udp->writeDatagram(match->data, radioIP, port);
|
||||
|
@ -922,7 +922,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
|
||||
if (in->seq < lastReceivedSeq)
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": ******* seq number may have rolled over ****** previous highest: " << rxSeqBuf.back() << " current: " << in->seq;
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": ******* seq number may have rolled over ****** previous highest: " << rxSeqBuf.back() << " current: " << in->seq;
|
||||
|
||||
// Looks like it has rolled over so clear buffer and start again.
|
||||
rxSeqBuf.clear();
|
||||
|
@ -957,7 +957,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
|
||||
if (count > 6) // Something bad happened, clear the buffer.
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": Excessive lost incoming packets, clearing buffer: " << count << " packets lost!";
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Excessive lost incoming packets, clearing buffer: " << count << " packets lost!";
|
||||
|
||||
rxSeqBuf.clear();
|
||||
rxSeqBuf.append(in->seq);
|
||||
|
@ -965,7 +965,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
}
|
||||
else if (count == 1)
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": Requesting retransmit of: " << first;
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Requesting retransmit of: " << first;
|
||||
rxSeqBuf.append(first);
|
||||
sendControl(false, 0x01, first);
|
||||
}
|
||||
|
@ -976,7 +976,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
|
||||
if (count == 3)
|
||||
{
|
||||
qDebug() << this->metaObject()->className() << ": Requesting retransmit of: " << first << ", " << second << ", " << third;
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Requesting retransmit of: " << first << ", " << second << ", " << third;
|
||||
rxSeqBuf.append(first);
|
||||
rxSeqBuf.append(second);
|
||||
if (second != third)
|
||||
|
@ -1083,7 +1083,7 @@ void udpBase::purgeOldEntries()
|
|||
std::sort(rxSeqBuf.begin(), rxSeqBuf.end());
|
||||
rxSeqBuf.remove(0,1024);
|
||||
lastReceivedSeq = *rxSeqBuf.begin();
|
||||
qDebug() << this->metaObject()->className() << ": Purged buffer of old rx packets, new buffer: " << rxSeqBuf.first() << " - " << rxSeqBuf.last();
|
||||
qDebug(logUdp()) << this->metaObject()->className() << ": Purged buffer of old rx packets, new buffer: " << rxSeqBuf.first() << " - " << rxSeqBuf.last();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "udpserver.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
#define STALE_CONNECTION 15
|
||||
|
||||
udpServer::udpServer(SERVERCONFIG config) :
|
||||
config(config)
|
||||
{
|
||||
qDebug() << "Starting udp server";
|
||||
qDebug(logUdpServer()) << "Starting udp server";
|
||||
}
|
||||
|
||||
void udpServer::init()
|
||||
|
@ -26,7 +27,7 @@ void udpServer::init()
|
|||
|
||||
uint32_t addr = localIP.toIPv4Address();
|
||||
|
||||
qDebug() << " Got: " << QHostAddress(addr).toString();
|
||||
qDebug(logUdpServer()) << " Got: " << QHostAddress(addr).toString();
|
||||
|
||||
|
||||
controlId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (config.controlPort & 0xffff);
|
||||
|
@ -42,9 +43,9 @@ void udpServer::init()
|
|||
udpAudio->bind(config.audioPort);
|
||||
udpCiv->bind(config.civPort);
|
||||
|
||||
qDebug() << "Server Binding Control to: " << config.controlPort;
|
||||
qDebug() << "Server Binding CIV to: " << config.civPort;
|
||||
qDebug() << "Server Binding Audio to: " << config.audioPort;
|
||||
qDebug(logUdpServer()) << "Server Binding Control to: " << config.controlPort;
|
||||
qDebug(logUdpServer()) << "Server Binding CIV to: " << config.civPort;
|
||||
qDebug(logUdpServer()) << "Server Binding Audio to: " << config.audioPort;
|
||||
|
||||
|
||||
QUdpSocket::connect(udpControl, &QUdpSocket::readyRead, this, &udpServer::controlReceived);
|
||||
|
@ -55,7 +56,7 @@ void udpServer::init()
|
|||
|
||||
udpServer::~udpServer()
|
||||
{
|
||||
qDebug() << "Closing udpServer";
|
||||
qDebug(logUdpServer()) << "Closing udpServer";
|
||||
|
||||
|
||||
foreach(CLIENT * client, controlClients)
|
||||
|
@ -169,7 +170,7 @@ void udpServer::controlReceived()
|
|||
current->idleTimer->start(100);
|
||||
current->wdTimer->start(10000);
|
||||
current->commonCap = 0x8010;
|
||||
qDebug() << "New Control connection created from :" << current->ipAddress.toString() << ":" << QString::number(current->port);
|
||||
qDebug(logUdpServer()) << "New Control connection created from :" << current->ipAddress.toString() << ":" << QString::number(current->port);
|
||||
controlClients.append(current);
|
||||
}
|
||||
|
||||
|
@ -182,26 +183,26 @@ void udpServer::controlReceived()
|
|||
control_packet_t in = (control_packet_t)r.constData();
|
||||
if (in->type == 0x03)
|
||||
{
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'are you there'";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'are you there'";
|
||||
current->remoteId = in->sentid;
|
||||
sendControl(current,0x04,in->seq);
|
||||
} // This is This is "Are you ready" in response to "I am here".
|
||||
else if (in->type == 0x06)
|
||||
{
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'Are you ready'";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'Are you ready'";
|
||||
current->remoteId = in->sentid;
|
||||
sendControl(current,0x06,in->seq);
|
||||
} // This is a retransmit request
|
||||
else if (in->type == 0x01)
|
||||
{
|
||||
// Just send an idle for now!
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'retransmit' request for " << in->seq;
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'retransmit' request for " << in->seq;
|
||||
sendControl(current,0x00, in->seq);
|
||||
|
||||
} // This is a disconnect request
|
||||
else if (in->type == 0x05)
|
||||
{
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'disconnect' request";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'disconnect' request";
|
||||
sendControl(current, 0x00, in->seq);
|
||||
//current->wdTimer->stop(); // Keep watchdog running to delete stale connection.
|
||||
deleteConnection(&controlClients, current);
|
||||
|
@ -232,7 +233,7 @@ void udpServer::controlReceived()
|
|||
current->pingSeq++;
|
||||
}
|
||||
else {
|
||||
qDebug() << current->ipAddress.toString() << ": Server got out of sequence ping reply. Got: " << in->seq << " expecting: " << current->pingSeq;
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Server got out of sequence ping reply. Got: " << in->seq << " expecting: " << current->pingSeq;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,17 +247,17 @@ void udpServer::controlReceived()
|
|||
current->authInnerSeq = in->innerseq;
|
||||
if (in->res == 0x02) {
|
||||
// Request for new token
|
||||
qDebug() << current->ipAddress.toString() << ": Received create token request";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received create token request";
|
||||
sendCapabilities(current);
|
||||
sendConnectionInfo(current);
|
||||
}
|
||||
else if (in->res == 0x01) {
|
||||
// Token disconnect
|
||||
qDebug() << current->ipAddress.toString() << ": Received token disconnect request";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received token disconnect request";
|
||||
sendTokenResponse(current, in->res);
|
||||
}
|
||||
else {
|
||||
qDebug() << current->ipAddress.toString() << ": Received token request";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received token request";
|
||||
sendTokenResponse(current, in->res);
|
||||
}
|
||||
break;
|
||||
|
@ -264,7 +265,7 @@ void udpServer::controlReceived()
|
|||
case (LOGIN_SIZE):
|
||||
{
|
||||
login_packet_t in = (login_packet_t)r.constData();
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'login'";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'login'";
|
||||
bool userOk = false;
|
||||
foreach(SERVERUSER user, config.users)
|
||||
{
|
||||
|
@ -289,11 +290,11 @@ void udpServer::controlReceived()
|
|||
current->tokenTx =(quint8)rand() | (quint8)rand() << 8 | (quint8)rand() << 16 | (quint8)rand() << 24;
|
||||
|
||||
if (userOk) {
|
||||
qDebug() << current->ipAddress.toString() << ": User " << current->user.username << " login OK";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": User " << current->user.username << " login OK";
|
||||
sendLoginResponse(current, in->seq, true);
|
||||
}
|
||||
else {
|
||||
qDebug() << current->ipAddress.toString() << ": Incorrect username/password";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Incorrect username/password";
|
||||
|
||||
sendLoginResponse(current, in->seq, false);
|
||||
}
|
||||
|
@ -302,7 +303,7 @@ void udpServer::controlReceived()
|
|||
case (CONNINFO_SIZE):
|
||||
{
|
||||
conninfo_packet_t in = (conninfo_packet_t)r.constData();
|
||||
qDebug() << current->ipAddress.toString() << ": Received request for radio connection";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received request for radio connection";
|
||||
// Request to start audio and civ!
|
||||
current->isStreaming = true;
|
||||
current->rxSeq = in->seq;
|
||||
|
@ -321,7 +322,7 @@ void udpServer::controlReceived()
|
|||
}
|
||||
default:
|
||||
{
|
||||
qDebug() << "Unknown length packet received: " << r.length();
|
||||
qDebug(logUdpServer()) << "Unknown length packet received: " << r.length();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +338,7 @@ void udpServer::civReceived()
|
|||
|
||||
CLIENT* current = Q_NULLPTR;
|
||||
|
||||
qDebug() << "Got CIV data";
|
||||
qDebug(logUdpServer()) << "Got CIV data";
|
||||
if (datagram.senderAddress().isNull() || datagram.senderPort() == 65535 || datagram.senderPort() == 0)
|
||||
return;
|
||||
|
||||
|
@ -373,7 +374,7 @@ void udpServer::civReceived()
|
|||
connect(current->idleTimer, &QTimer::timeout, this, std::bind(&udpServer::sendControl, this, current,0x00, (quint16)0x00));
|
||||
current->pingTimer->start(100);
|
||||
current->idleTimer->start(100);
|
||||
qDebug() << "New CIV connection created from :" << current->ipAddress.toString() << ":" << QString::number(current->port);
|
||||
qDebug(logUdpServer()) << "New CIV connection created from :" << current->ipAddress.toString() << ":" << QString::number(current->port);
|
||||
civClients.append(current);
|
||||
}
|
||||
|
||||
|
@ -387,26 +388,26 @@ void udpServer::civReceived()
|
|||
control_packet_t in = (control_packet_t)r.constData();
|
||||
|
||||
if (in->type == 0x03) {
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'are you there'";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'are you there'";
|
||||
current->remoteId = qFromLittleEndian<quint32>(r.mid(8, 4));
|
||||
sendControl(current, 0x04, gotSeq);
|
||||
} // This is This is "Are you ready" in response to "I am here".
|
||||
else if (in->type == 0x06)
|
||||
{
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'Are you ready'";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'Are you ready'";
|
||||
current->remoteId = qFromLittleEndian<quint32>(r.mid(8, 4));
|
||||
sendControl(current, 0x06, gotSeq);
|
||||
} // This is a retransmit request
|
||||
else if (in->type == 0x01)
|
||||
{
|
||||
// Just send an idle for now, we need to be able to retransmit missing packets.
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'retransmit' request for " << gotSeq;
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'retransmit' request for " << gotSeq;
|
||||
sendControl(current, 0x00, gotSeq);
|
||||
|
||||
} // This is a disconnect request
|
||||
else if (in->type == 0x05)
|
||||
{
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'disconnect' request";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'disconnect' request";
|
||||
sendControl(current, 0x00, gotSeq);
|
||||
deleteConnection(&civClients, current);
|
||||
|
||||
|
@ -436,7 +437,7 @@ void udpServer::civReceived()
|
|||
current->pingSeq++;
|
||||
}
|
||||
else {
|
||||
qDebug() << current->ipAddress.toString() << ": Civ got out of sequence ping reply. Got: " << gotSeq << " expecting: " << current->pingSeq;
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Civ got out of sequence ping reply. Got: " << gotSeq << " expecting: " << current->pingSeq;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +450,7 @@ void udpServer::civReceived()
|
|||
quint8 temp = r[0] - 0x15;
|
||||
if ((quint8)r[16] == 0xc1 && (quint8)r[17] == temp)
|
||||
{
|
||||
//qDebug() << "Got CIV from server: " << r.mid(21);
|
||||
//qDebug(logUdpServer()) << "Got CIV from server: " << r.mid(21);
|
||||
emit haveDataFromServer(r.mid(21));
|
||||
}
|
||||
}
|
||||
|
@ -498,7 +499,7 @@ void udpServer::audioReceived()
|
|||
current->pingTimer = new QTimer();
|
||||
connect(current->pingTimer, &QTimer::timeout, this, std::bind(&udpServer::sendPing, this, &audioClients, current, (quint16)0x00, false));
|
||||
current->pingTimer->start(100);
|
||||
qDebug() << "New Audio connection created from :" << current->ipAddress.toString() << ":" << QString::number(current->port);
|
||||
qDebug(logUdpServer()) << "New Audio connection created from :" << current->ipAddress.toString() << ":" << QString::number(current->port);
|
||||
audioClients.append(current);
|
||||
}
|
||||
|
||||
|
@ -511,26 +512,26 @@ void udpServer::audioReceived()
|
|||
{
|
||||
control_packet_t in = (control_packet_t)r.constData();
|
||||
if (in->type == 0x03) {
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'are you there'";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'are you there'";
|
||||
current->remoteId = qFromLittleEndian<quint32>(r.mid(8, 4));
|
||||
sendControl(current, 0x04, gotSeq);
|
||||
} // This is This is "Are you ready" in response to "I am here".
|
||||
else if (in->type == 0x06)
|
||||
{
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'Are you ready'";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'Are you ready'";
|
||||
current->remoteId = qFromLittleEndian<quint32>(r.mid(8, 4));
|
||||
sendControl(current, 0x06, gotSeq);
|
||||
} // This is a retransmit request
|
||||
else if (in->type == 0x01)
|
||||
{
|
||||
// Just send an idle for now!
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'retransmit' request for " << gotSeq;
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'retransmit' request for " << gotSeq;
|
||||
sendControl(current, 0x00, gotSeq);
|
||||
|
||||
} // This is a disconnect request
|
||||
else if (in->type == 0x05)
|
||||
{
|
||||
qDebug() << current->ipAddress.toString() << ": Received 'disconnect' request";
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'disconnect' request";
|
||||
sendControl(current, 0x00, gotSeq);
|
||||
deleteConnection(&audioClients, current);
|
||||
}
|
||||
|
@ -561,7 +562,7 @@ void udpServer::audioReceived()
|
|||
current->pingSeq++;
|
||||
}
|
||||
else {
|
||||
qDebug() << current->ipAddress.toString() << ": Civ got out of sequence ping reply. Got: " << gotSeq << " expecting: " << current->pingSeq;
|
||||
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Civ got out of sequence ping reply. Got: " << gotSeq << " expecting: " << current->pingSeq;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -588,7 +589,7 @@ void udpServer::sendControl(CLIENT* c, quint8 type, quint16 seq)
|
|||
c->txSeq++;
|
||||
}
|
||||
|
||||
//qDebug() << c->ipAddress.toString() << ": Sending control packet: " << type;
|
||||
//qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending control packet: " << type;
|
||||
control_packet p;
|
||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||
p.len = sizeof(p);
|
||||
|
@ -612,13 +613,13 @@ void udpServer::sendPing(QList<CLIENT*> *l,CLIENT* c, quint16 seq, bool reply)
|
|||
|
||||
if (c->lastHeard.secsTo(now) > STALE_CONNECTION)
|
||||
{
|
||||
qDebug() << "Deleting stale connection " << c->ipAddress.toString();
|
||||
qDebug(logUdpServer()) << "Deleting stale connection " << c->ipAddress.toString();
|
||||
deleteConnection(l, c);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//qDebug() << c->ipAddress.toString() << ": Sending Ping";
|
||||
//qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending Ping";
|
||||
|
||||
quint32 pingTime = 0;
|
||||
quint8 pingReply = 0;
|
||||
|
@ -650,7 +651,7 @@ void udpServer::sendPing(QList<CLIENT*> *l,CLIENT* c, quint16 seq, bool reply)
|
|||
|
||||
void udpServer::sendLoginResponse(CLIENT* c,quint16 seq, bool allowed)
|
||||
{
|
||||
qDebug() << c->ipAddress.toString() << ": Sending Login response: " << c->txSeq;
|
||||
qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending Login response: " << c->txSeq;
|
||||
|
||||
login_response_packet p;
|
||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||
|
@ -682,7 +683,7 @@ void udpServer::sendLoginResponse(CLIENT* c,quint16 seq, bool allowed)
|
|||
|
||||
void udpServer::sendCapabilities(CLIENT* c)
|
||||
{
|
||||
qDebug() << c->ipAddress.toString() << ": Sending Capabilities :" << c->txSeq;
|
||||
qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending Capabilities :" << c->txSeq;
|
||||
|
||||
capabilities_packet p;
|
||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||
|
@ -719,7 +720,7 @@ void udpServer::sendCapabilities(CLIENT* c)
|
|||
// Also used to display currently connected used information.
|
||||
void udpServer::sendConnectionInfo(CLIENT* c)
|
||||
{
|
||||
qDebug() << c->ipAddress.toString() << ": Sending ConnectionInfo :" << c->txSeq;
|
||||
qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending ConnectionInfo :" << c->txSeq;
|
||||
conninfo_packet p;
|
||||
memset(p.packet, 0x0, sizeof(p));
|
||||
p.len = sizeof(p);
|
||||
|
@ -755,7 +756,7 @@ void udpServer::sendConnectionInfo(CLIENT* c)
|
|||
|
||||
void udpServer::sendTokenResponse(CLIENT* c, quint8 type)
|
||||
{
|
||||
qDebug() << c->ipAddress.toString() << ": Sending Token response for type: " << type;
|
||||
qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending Token response for type: " << type;
|
||||
|
||||
token_packet p;
|
||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||
|
@ -805,7 +806,7 @@ void udpServer::sendStatus(CLIENT* c)
|
|||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
qDebug() << c->ipAddress.toString() << ": Sending Status";
|
||||
qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending Status";
|
||||
|
||||
status_packet p;
|
||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||
|
@ -842,7 +843,7 @@ void udpServer::sendStatus(CLIENT* c)
|
|||
void udpServer::dataForServer(QByteArray d)
|
||||
{
|
||||
|
||||
//qDebug() << "Server got:" << d;
|
||||
//qDebug(logUdpServer()) << "Server got:" << d;
|
||||
foreach(CLIENT * client, civClients)
|
||||
{
|
||||
if (client != Q_NULLPTR && client->connected) {
|
||||
|
@ -873,7 +874,7 @@ void udpServer::dataForServer(QByteArray d)
|
|||
// Needs to stop and delete all timers, remove the connection from the list and delete the connection.
|
||||
void udpServer::deleteConnection(QList<CLIENT*> *l, CLIENT* c)
|
||||
{
|
||||
qDebug() << "Deleting connection to: " << c->ipAddress.toString() << ":" << QString::number(c->port);
|
||||
qDebug(logUdpServer()) << "Deleting connection to: " << c->ipAddress.toString() << ":" << QString::number(c->port);
|
||||
if (c->idleTimer != Q_NULLPTR) {
|
||||
c->idleTimer->stop();
|
||||
delete c->idleTimer;
|
||||
|
@ -899,5 +900,5 @@ void udpServer::deleteConnection(QList<CLIENT*> *l, CLIENT* c)
|
|||
}
|
||||
delete c; // Is this needed or will the erase have done it?
|
||||
c = Q_NULLPTR;
|
||||
qDebug() << "Current Number of clients connected: " << l->length();
|
||||
qDebug(logUdpServer()) << "Current Number of clients connected: " << l->length();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "udpserversetup.h"
|
||||
#include "ui_udpserversetup.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
udpServerSetup::udpServerSetup(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
|
|
113
wfmain.cpp
113
wfmain.cpp
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "commhandler.h"
|
||||
#include "rigidentities.h"
|
||||
#include "logcategories.h"
|
||||
|
||||
// This code is copyright 2017-2020 Elliott H. Liggett
|
||||
// All rights reserved
|
||||
|
@ -174,17 +175,17 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
|||
// if(prefs.serialPortRadio == QString("auto"))
|
||||
// {
|
||||
// // Find the ICOM IC-7300.
|
||||
// qDebug() << "Searching for serial port...";
|
||||
// qDebug(logSystem()) << "Searching for serial port...";
|
||||
// QDirIterator it("/dev/serial", QStringList() << "*IC-7300*", QDir::Files, QDirIterator::Subdirectories);
|
||||
|
||||
// while (it.hasNext())
|
||||
// qDebug() << it.next();
|
||||
// qDebug(logSystem()) << it.next();
|
||||
// // if (it.isEmpty()) // fail or default to ttyUSB0 if present
|
||||
// // iterator might not make sense
|
||||
// serialPortRig = it.filePath(); // first? last?
|
||||
// if(serialPortRig.isEmpty())
|
||||
// {
|
||||
// qDebug() << "Cannot find IC-7300 serial port. Trying /dev/ttyUSB0";
|
||||
// qDebug(logSystem()) << "Cannot find IC-7300 serial port. Trying /dev/ttyUSB0";
|
||||
// serialPortRig = QString("/dev/ttyUSB0");
|
||||
// }
|
||||
// // end finding the 7300 code
|
||||
|
@ -447,7 +448,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
|||
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "Running with debugging options enabled.";
|
||||
qDebug(logSystem()) << "Running with debugging options enabled.";
|
||||
ui->debugBtn->setVisible(true);
|
||||
#else
|
||||
ui->debugBtn->setVisible(false);
|
||||
|
@ -504,14 +505,14 @@ void wfmain::openRig()
|
|||
#ifdef QT_DEBUG
|
||||
if(!serialPortCL.isEmpty())
|
||||
{
|
||||
qDebug() << "Serial port specified by user: " << serialPortCL;
|
||||
qDebug(logSystem()) << "Serial port specified by user: " << serialPortCL;
|
||||
} else {
|
||||
qDebug() << "Serial port not specified. ";
|
||||
qDebug(logSystem()) << "Serial port not specified. ";
|
||||
}
|
||||
|
||||
if(!hostCL.isEmpty())
|
||||
{
|
||||
qDebug() << "Remote host name specified by user: " << hostCL;
|
||||
qDebug(logSystem()) << "Remote host name specified by user: " << hostCL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -547,7 +548,7 @@ void wfmain::openRig()
|
|||
if( (prefs.serialPortRadio == QString("auto")) && (serialPortCL.isEmpty()))
|
||||
{
|
||||
// Find the ICOM
|
||||
// qDebug() << "Searching for serial port...";
|
||||
// qDebug(logSystem()) << "Searching for serial port...";
|
||||
QDirIterator it73("/dev/serial", QStringList() << "*IC-7300*", QDir::Files, QDirIterator::Subdirectories);
|
||||
QDirIterator it97("/dev/serial", QStringList() << "*IC-9700*A*", QDir::Files, QDirIterator::Subdirectories);
|
||||
QDirIterator it785x("/dev/serial", QStringList() << "*IC-785*A*", QDir::Files, QDirIterator::Subdirectories);
|
||||
|
@ -572,7 +573,7 @@ void wfmain::openRig()
|
|||
serialPortRig = it705.filePath();
|
||||
} else {
|
||||
//fall back:
|
||||
qDebug() << "Could not find Icom serial port. Falling back to OS default. Use --port to specify, or modify preferences.";
|
||||
qDebug(logSystem()) << "Could not find Icom serial port. Falling back to OS default. Use --port to specify, or modify preferences.";
|
||||
#ifdef Q_OS_MAC
|
||||
serialPortRig = QString("/dev/tty.SLAB_USBtoUART");
|
||||
#endif
|
||||
|
@ -605,7 +606,7 @@ void wfmain::openRig()
|
|||
if(prefs.radioCIVAddr == 0)
|
||||
{
|
||||
// tell rigCommander to broadcast a request for all rig IDs.
|
||||
// qDebug() << "Beginning search from wfview for rigCIV (auto-detection broadcast)";
|
||||
// qDebug(logSystem()) << "Beginning search from wfview for rigCIV (auto-detection broadcast)";
|
||||
ui->statusBar->showMessage(QString("Searching CIV bus for connected radios."), 1000);
|
||||
emit getRigCIV();
|
||||
cmdOutQue.append(cmdGetRigCIV);
|
||||
|
@ -613,7 +614,7 @@ void wfmain::openRig()
|
|||
} else {
|
||||
// don't bother, they told us the CIV they want, stick with it.
|
||||
// We still query the rigID to find the model, but at least we know the CIV.
|
||||
qDebug() << "Skipping automatic CIV, using user-supplied value of " << prefs.radioCIVAddr;
|
||||
qDebug(logSystem()) << "Skipping automatic CIV, using user-supplied value of " << prefs.radioCIVAddr;
|
||||
getInitialRigState();
|
||||
}
|
||||
*/
|
||||
|
@ -622,12 +623,12 @@ void wfmain::openRig()
|
|||
|
||||
void wfmain::receiveCommReady()
|
||||
{
|
||||
qDebug() << "Received CommReady!! ";
|
||||
qDebug(logSystem()) << "Received CommReady!! ";
|
||||
// taken from above:
|
||||
if(prefs.radioCIVAddr == 0)
|
||||
{
|
||||
// tell rigCommander to broadcast a request for all rig IDs.
|
||||
// qDebug() << "Beginning search from wfview for rigCIV (auto-detection broadcast)";
|
||||
// qDebug(logSystem()) << "Beginning search from wfview for rigCIV (auto-detection broadcast)";
|
||||
ui->statusBar->showMessage(QString("Searching CIV bus for connected radios."), 1000);
|
||||
emit getRigCIV();
|
||||
cmdOutQue.append(cmdGetRigCIV);
|
||||
|
@ -635,7 +636,7 @@ void wfmain::receiveCommReady()
|
|||
} else {
|
||||
// don't bother, they told us the CIV they want, stick with it.
|
||||
// We still query the rigID to find the model, but at least we know the CIV.
|
||||
qDebug() << "Skipping automatic CIV, using user-supplied value of " << prefs.radioCIVAddr;
|
||||
qDebug(logSystem()) << "Skipping automatic CIV, using user-supplied value of " << prefs.radioCIVAddr;
|
||||
getInitialRigState();
|
||||
}
|
||||
|
||||
|
@ -646,7 +647,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
|
|||
{
|
||||
// Entry point for unknown rig being identified at the start of the program.
|
||||
//now we know what the rig ID is:
|
||||
//qDebug() << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST.";
|
||||
//qDebug(logSystem()) << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST.";
|
||||
|
||||
delayedCommand->setInterval(100); // faster polling is ok now.
|
||||
receiveRigID(rigCaps);
|
||||
|
@ -661,7 +662,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
|
|||
|
||||
void wfmain::receiveSerialPortError(QString port, QString errorText)
|
||||
{
|
||||
qDebug() << "wfmain: received serial port error for port: " << port << " with message: " << errorText;
|
||||
qDebug(logSystem()) << "wfmain: received serial port error for port: " << port << " with message: " << errorText;
|
||||
ui->statusBar->showMessage(QString("ERROR: using port ").append(port).append(": ").append(errorText), 10000);
|
||||
|
||||
// TODO: Dialog box, exit, etc
|
||||
|
@ -705,7 +706,7 @@ void wfmain::setDefPrefs()
|
|||
|
||||
void wfmain::loadSettings()
|
||||
{
|
||||
qDebug() << "Loading settings from " << settings.fileName();
|
||||
qDebug(logSystem()) << "Loading settings from " << settings.fileName();
|
||||
|
||||
// Basic things to load:
|
||||
// UI: (full screen, dark theme, draw peaks, colors, etc)
|
||||
|
@ -876,7 +877,7 @@ void wfmain::loadSettings()
|
|||
|
||||
void wfmain::saveSettings()
|
||||
{
|
||||
qDebug() << "Saving settings to " << settings.fileName();
|
||||
qDebug(logSystem()) << "Saving settings to " << settings.fileName();
|
||||
// Basic things to load:
|
||||
|
||||
// UI: (full screen, dark theme, draw peaks, colors, etc)
|
||||
|
@ -1041,7 +1042,7 @@ void wfmain::prepareWf()
|
|||
wf->xAxis->setVisible(false);
|
||||
|
||||
} else {
|
||||
qDebug() << "Cannot prepare WF view without rigCaps. Waiting on this.";
|
||||
qDebug(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1132,7 +1133,7 @@ void wfmain::shortcutF12()
|
|||
void wfmain::shortcutControlT()
|
||||
{
|
||||
// Transmit
|
||||
qDebug() << "Activated Control-T shortcut";
|
||||
qDebug(logSystem()) << "Activated Control-T shortcut";
|
||||
showStatusBarText(QString("Transmitting. Press Control-R to receive."));
|
||||
ui->pttOnBtn->click();
|
||||
}
|
||||
|
@ -1494,7 +1495,7 @@ void wfmain::runPeriodicCommands()
|
|||
emit getMode();
|
||||
break;
|
||||
case cmdGetDataMode:
|
||||
// qDebug() << "Sending query for data mode";
|
||||
// qDebug(logSystem()) << "Sending query for data mode";
|
||||
emit getDataMode();
|
||||
break;
|
||||
case cmdSetDataModeOff:
|
||||
|
@ -1596,7 +1597,7 @@ void wfmain::runDelayedCommand()
|
|||
switch(qdCmd)
|
||||
{
|
||||
case cmdNone:
|
||||
//qDebug() << "NOOP";
|
||||
//qDebug(logSystem()) << "NOOP";
|
||||
break;
|
||||
case cmdGetRigID:
|
||||
emit getRigID();
|
||||
|
@ -1616,7 +1617,7 @@ void wfmain::runDelayedCommand()
|
|||
emit getMode();
|
||||
break;
|
||||
case cmdGetDataMode:
|
||||
// qDebug() << "Sending query for data mode";
|
||||
// qDebug(logSystem()) << "Sending query for data mode";
|
||||
emit getDataMode();
|
||||
break;
|
||||
case cmdSetDataModeOff:
|
||||
|
@ -1724,12 +1725,12 @@ void wfmain::receiveRigID(rigCapabilities rigCaps)
|
|||
return;
|
||||
} else {
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "Rig name: " << rigCaps.modelName;
|
||||
qDebug() << "Has LAN capabilities: " << rigCaps.hasLan;
|
||||
qDebug() << "Rig ID received into wfmain: spectLenMax: " << rigCaps.spectLenMax;
|
||||
qDebug() << "Rig ID received into wfmain: spectAmpMax: " << rigCaps.spectAmpMax;
|
||||
qDebug() << "Rig ID received into wfmain: spectSeqMax: " << rigCaps.spectSeqMax;
|
||||
qDebug() << "Rig ID received into wfmain: hasSpectrum: " << rigCaps.hasSpectrum;
|
||||
qDebug(logSystem()) << "Rig name: " << rigCaps.modelName;
|
||||
qDebug(logSystem()) << "Has LAN capabilities: " << rigCaps.hasLan;
|
||||
qDebug(logSystem()) << "Rig ID received into wfmain: spectLenMax: " << rigCaps.spectLenMax;
|
||||
qDebug(logSystem()) << "Rig ID received into wfmain: spectAmpMax: " << rigCaps.spectAmpMax;
|
||||
qDebug(logSystem()) << "Rig ID received into wfmain: spectSeqMax: " << rigCaps.spectSeqMax;
|
||||
qDebug(logSystem()) << "Rig ID received into wfmain: hasSpectrum: " << rigCaps.hasSpectrum;
|
||||
#endif
|
||||
this->rigCaps = rigCaps;
|
||||
this->spectWidth = rigCaps.spectLenMax; // used once haveRigCaps is true.
|
||||
|
@ -1832,7 +1833,7 @@ void wfmain::insertPeriodicCommand(cmds cmd, unsigned char priority)
|
|||
|
||||
void wfmain::receiveFreq(double freqMhz)
|
||||
{
|
||||
//qDebug() << "HEY WE GOT A Frequency: " << freqMhz;
|
||||
//qDebug(logSystem()) << "HEY WE GOT A Frequency: " << freqMhz;
|
||||
ui->freqLabel->setText(QString("%1").arg(freqMhz, 0, 'f'));
|
||||
this->freqMhz = freqMhz;
|
||||
this->knobFreqMhz = freqMhz;
|
||||
|
@ -1842,7 +1843,7 @@ void wfmain::receiveFreq(double freqMhz)
|
|||
void wfmain::receivePTTstatus(bool pttOn)
|
||||
{
|
||||
// This is the only place where amTransmitting and the transmit button text should be changed:
|
||||
qDebug() << "PTT status: " << pttOn;
|
||||
qDebug(logSystem()) << "PTT status: " << pttOn;
|
||||
amTransmitting = pttOn;
|
||||
changeTxBtn();
|
||||
}
|
||||
|
@ -1863,7 +1864,7 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
|
|||
if(!haveRigCaps)
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "Spectrum received, but RigID incomplete.";
|
||||
qDebug(logSystem()) << "Spectrum received, but RigID incomplete.";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -1882,18 +1883,18 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
|
|||
oldLowerFreq = startFreq;
|
||||
oldUpperFreq = endFreq;
|
||||
|
||||
//qDebug() << "start: " << startFreq << " end: " << endFreq;
|
||||
//qDebug(logSystem()) << "start: " << startFreq << " end: " << endFreq;
|
||||
quint16 specLen = spectrum.length();
|
||||
//qDebug() << "Spectrum data received at UI! Length: " << specLen;
|
||||
//qDebug(logSystem()) << "Spectrum data received at UI! Length: " << specLen;
|
||||
//if( (specLen != 475) || (specLen!=689) )
|
||||
|
||||
if( specLen != rigCaps.spectLenMax )
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "-------------------------------------------";
|
||||
qDebug() << "------ Unusual spectrum received, length: " << specLen;
|
||||
qDebug() << "------ Expected spectrum length: " << rigCaps.spectLenMax;
|
||||
qDebug() << "------ This should happen once at most. ";
|
||||
qDebug(logSystem()) << "-------------------------------------------";
|
||||
qDebug(logSystem()) << "------ Unusual spectrum received, length: " << specLen;
|
||||
qDebug(logSystem()) << "------ Expected spectrum length: " << rigCaps.spectLenMax;
|
||||
qDebug(logSystem()) << "------ This should happen once at most. ";
|
||||
#endif
|
||||
return; // safe. Using these unusual length things is a problem.
|
||||
}
|
||||
|
@ -1962,7 +1963,7 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
|
|||
wf->xAxis->setRange(0, spectWidth-1);
|
||||
wf->replot();
|
||||
spectRowCurrent = (spectRowCurrent + 1) % wfLength;
|
||||
//qDebug() << "updating spectrum, new row is: " << spectRowCurrent;
|
||||
//qDebug(logSystem()) << "updating spectrum, new row is: " << spectRowCurrent;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2066,7 +2067,7 @@ void wfmain::on_scopeEnableWFBtn_clicked(bool checked)
|
|||
|
||||
void wfmain::receiveMode(unsigned char mode, unsigned char filter)
|
||||
{
|
||||
//qDebug() << __func__ << "Received mode " << mode << " current mode: " << currentModeIndex;
|
||||
//qDebug(logSystem()) << __func__ << "Received mode " << mode << " current mode: " << currentModeIndex;
|
||||
|
||||
bool found=false;
|
||||
|
||||
|
@ -2085,12 +2086,12 @@ void wfmain::receiveMode(unsigned char mode, unsigned char filter)
|
|||
}
|
||||
currentModeIndex = mode;
|
||||
} else {
|
||||
qDebug() << __func__ << "Invalid mode " << mode << " received. ";
|
||||
qDebug(logSystem()) << __func__ << "Invalid mode " << mode << " received. ";
|
||||
}
|
||||
|
||||
if(!found)
|
||||
{
|
||||
qDebug() << __func__ << "Received mode " << mode << " but could not match to any index within the modeSelectCombo. ";
|
||||
qDebug(logSystem()) << __func__ << "Received mode " << mode << " but could not match to any index within the modeSelectCombo. ";
|
||||
}
|
||||
|
||||
if( (filter) && (filter < 4)){
|
||||
|
@ -2330,7 +2331,7 @@ void wfmain::on_modeSelectCombo_activated(int index)
|
|||
{
|
||||
// oops, we forgot to reset the combo box
|
||||
} else {
|
||||
qDebug() << __func__ << " at index " << index << " has newMode: " << newMode;
|
||||
qDebug(logSystem()) << __func__ << " at index " << index << " has newMode: " << newMode;
|
||||
|
||||
emit setMode(newMode, filterSelection);
|
||||
}
|
||||
|
@ -2357,7 +2358,7 @@ void wfmain::on_freqDial_valueChanged(int value)
|
|||
return;
|
||||
}
|
||||
|
||||
// qDebug() << "Old value: " << oldFreqDialVal << " New value: " << value ;
|
||||
// qDebug(logSystem()) << "Old value: " << oldFreqDialVal << " New value: " << value ;
|
||||
|
||||
|
||||
if(value == 0)
|
||||
|
@ -2409,7 +2410,7 @@ void wfmain::on_freqDial_valueChanged(int value)
|
|||
|
||||
newFreqMhz = knobFreqMhz + (delta * stepSize);
|
||||
|
||||
// qDebug() << "old freq: " << knobFreqMhz << " new freq: " << newFreqMhz << "knobDelta: " << delta << " freq delta: " << newFreqMhz - knobFreqMhz;
|
||||
// qDebug(logSystem()) << "old freq: " << knobFreqMhz << " new freq: " << newFreqMhz << "knobDelta: " << delta << " freq delta: " << newFreqMhz - knobFreqMhz;
|
||||
|
||||
if(ui->tuningFloorZerosChk->isChecked())
|
||||
{
|
||||
|
@ -2618,7 +2619,7 @@ void wfmain::on_fRclBtn_clicked()
|
|||
ui->goFreqBtn->click();
|
||||
|
||||
} else {
|
||||
qDebug() << "Could not recall preset. Valid presets are 0 through 99.";
|
||||
qDebug(logSystem()) << "Could not recall preset. Valid presets are 0 through 99.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2630,13 +2631,13 @@ void wfmain::on_rfGainSlider_valueChanged(int value)
|
|||
|
||||
void wfmain::on_afGainSlider_valueChanged(int value)
|
||||
{
|
||||
// qDebug() << "Setting AF gain to " << value;
|
||||
// qDebug(logSystem()) << "Setting AF gain to " << value;
|
||||
emit setAfGain((unsigned char) value);
|
||||
}
|
||||
|
||||
void wfmain::receiveRfGain(unsigned char level)
|
||||
{
|
||||
// qDebug() << "Receive RF level of" << (int)level << " = " << 100*level/255.0 << "%";
|
||||
// qDebug(logSystem()) << "Receive RF level of" << (int)level << " = " << 100*level/255.0 << "%";
|
||||
ui->rfGainSlider->blockSignals(true);
|
||||
ui->rfGainSlider->setValue(level);
|
||||
ui->rfGainSlider->blockSignals(false);
|
||||
|
@ -2644,7 +2645,7 @@ void wfmain::receiveRfGain(unsigned char level)
|
|||
|
||||
void wfmain::receiveAfGain(unsigned char level)
|
||||
{
|
||||
// qDebug() << "Receive AF level of" << (int)level << " = " << 100*level/255.0 << "%";
|
||||
// qDebug(logSystem()) << "Receive AF level of" << (int)level << " = " << 100*level/255.0 << "%";
|
||||
ui->afGainSlider->blockSignals(true);
|
||||
ui->afGainSlider->setValue(level);
|
||||
ui->afGainSlider->blockSignals(false);
|
||||
|
@ -2731,7 +2732,7 @@ void wfmain::on_saveSettingsBtn_clicked()
|
|||
|
||||
void wfmain::receiveATUStatus(unsigned char atustatus)
|
||||
{
|
||||
// qDebug() << "Received ATU status update: " << (unsigned int) atustatus;
|
||||
// qDebug(logSystem()) << "Received ATU status update: " << (unsigned int) atustatus;
|
||||
switch(atustatus)
|
||||
{
|
||||
case 0x00:
|
||||
|
@ -2751,14 +2752,14 @@ void wfmain::receiveATUStatus(unsigned char atustatus)
|
|||
case 0x02:
|
||||
// ATU tuning in-progress.
|
||||
// Add command queue to check again and update status bar
|
||||
// qDebug() << "Received ATU status update that *tuning* is taking place";
|
||||
// qDebug(logSystem()) << "Received ATU status update that *tuning* is taking place";
|
||||
showStatusBarText("ATU is Tuning...");
|
||||
cmdOutQue.append(cmdGetATUStatus); // Sometimes the first hit seems to be missed.
|
||||
cmdOutQue.append(cmdGetATUStatus);
|
||||
delayedCommand->start();
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Did not understand ATU status: " << (unsigned int) atustatus;
|
||||
qDebug(logSystem()) << "Did not understand ATU status: " << (unsigned int) atustatus;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3050,7 +3051,7 @@ void wfmain::receiveModInput(rigInput input, bool dataOn)
|
|||
changeModLabel(input);
|
||||
}
|
||||
if(!found)
|
||||
qDebug() << "Could not find modulation input: " << (int)input;
|
||||
qDebug(logSystem()) << "Could not find modulation input: " << (int)input;
|
||||
}
|
||||
|
||||
void wfmain::receiveDuplexMode(duplexMode dm)
|
||||
|
@ -3178,7 +3179,7 @@ void wfmain::serverConfigRequested(SERVERCONFIG conf, bool store)
|
|||
}
|
||||
else {
|
||||
// Store config in file!
|
||||
qDebug() << "Storing server config";
|
||||
qDebug(logSystem()) << "Storing server config";
|
||||
serverConfig = conf;
|
||||
}
|
||||
|
||||
|
@ -3302,7 +3303,7 @@ void wfmain::processChangingCurrentModLevel(unsigned char level)
|
|||
} else {
|
||||
currentIn = currentModSrc;
|
||||
}
|
||||
//qDebug() << __func__ << ": setting current level: " << level;
|
||||
//qDebug(logSystem()) << __func__ << ": setting current level: " << level;
|
||||
|
||||
emit setModLevel(currentIn, level);
|
||||
}
|
||||
|
@ -3315,7 +3316,7 @@ void wfmain::on_tuneLockChk_clicked(bool checked)
|
|||
// --- DEBUG FUNCTION ---
|
||||
void wfmain::on_debugBtn_clicked()
|
||||
{
|
||||
qDebug() << "Debug button pressed.";
|
||||
qDebug(logSystem()) << "Debug button pressed.";
|
||||
|
||||
// TODO: Why don't these commands work?!
|
||||
//emit getScopeMode();
|
||||
|
|
Ładowanie…
Reference in New Issue