Add logging categories

merge-requests/2/head
Phil Taylor 2021-02-23 21:21:22 +00:00
rodzic 05c54ed349
commit ef79801081
13 zmienionych plików z 277 dodań i 263 usunięć

Wyświetl plik

@ -3,6 +3,7 @@
but as the setup/handling if output (RX) and input (TX) devices is so similar I have combined them. but as the setup/handling if output (RX) and input (TX) devices is so similar I have combined them.
*/ */
#include "audiohandler.h" #include "audiohandler.h"
#include "logcategories.h"
#define MULAW_BIAS 33 #define MULAW_BIAS 33
#define MULAW_MAX 0x1fff #define MULAW_MAX 0x1fff
@ -138,30 +139,30 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16
bool audioHandler::setDevice(QAudioDeviceInfo deviceInfo) 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.isFormatSupported(format)) {
if (deviceInfo.isNull()) 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 { else {
qDebug() << "Audio Devices found: "; qDebug(logAudio()) << "Audio Devices found: ";
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
for (const QAudioDeviceInfo& deviceInfo : deviceInfos) for (const QAudioDeviceInfo& deviceInfo : deviceInfos)
{ {
qDebug() << "Device name: " << deviceInfo.deviceName(); qDebug(logAudio()) << "Device name: " << deviceInfo.deviceName();
qDebug() << "is null (probably not good):" << deviceInfo.isNull(); qDebug(logAudio()) << "is null (probably not good):" << deviceInfo.isNull();
qDebug() << "channel count:" << deviceInfo.supportedChannelCounts(); qDebug(logAudio()) << "channel count:" << deviceInfo.supportedChannelCounts();
qDebug() << "byte order:" << deviceInfo.supportedByteOrders(); qDebug(logAudio()) << "byte order:" << deviceInfo.supportedByteOrders();
qDebug() << "supported codecs:" << deviceInfo.supportedCodecs(); qDebug(logAudio()) << "supported codecs:" << deviceInfo.supportedCodecs();
qDebug() << "sample rates:" << deviceInfo.supportedSampleRates(); qDebug(logAudio()) << "sample rates:" << deviceInfo.supportedSampleRates();
qDebug() << "sample sizes:" << deviceInfo.supportedSampleSizes(); qDebug(logAudio()) << "sample sizes:" << deviceInfo.supportedSampleSizes();
qDebug() << "sample types:" << deviceInfo.supportedSampleTypes(); 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); deviceInfo.nearestFormat(format);
} }
this->deviceInfo = deviceInfo; this->deviceInfo = deviceInfo;
@ -171,7 +172,7 @@ bool audioHandler::setDevice(QAudioDeviceInfo deviceInfo)
void audioHandler::reinit() void audioHandler::reinit()
{ {
qDebug() << this->metaObject()->className() << ": reinit() running"; qDebug(logAudio()) << this->metaObject()->className() << ": reinit() running";
if (audioOutput && audioOutput->state() != QAudio::StoppedState) { if (audioOutput && audioOutput->state() != QAudio::StoppedState) {
this->stop(); this->stop();
} }
@ -211,7 +212,7 @@ void audioHandler::reinit()
void audioHandler::start() void audioHandler::start()
{ {
qDebug() << this->metaObject()->className() << ": start() running"; qDebug(logAudio()) << this->metaObject()->className() << ": start() running";
if ((audioOutput == Q_NULLPTR || audioOutput->state() != QAudio::StoppedState) && if ((audioOutput == Q_NULLPTR || audioOutput->state() != QAudio::StoppedState) &&
(audioInput == Q_NULLPTR || audioInput->state() != QAudio::StoppedState) ) { (audioInput == Q_NULLPTR || audioInput->state() != QAudio::StoppedState) ) {
@ -236,7 +237,7 @@ void audioHandler::setVolume(float volume)
void audioHandler::flush() void audioHandler::flush()
{ {
qDebug() << this->metaObject()->className() << ": flush() running"; qDebug(logAudio()) << this->metaObject()->className() << ": flush() running";
this->stop(); this->stop();
if (isInput) { if (isInput) {
audioInput->reset(); audioInput->reset();
@ -298,7 +299,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen)
buffer.remove(0, outlen); buffer.remove(0, outlen);
} }
else { 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; return outlen;
} }
@ -357,25 +358,25 @@ void audioHandler::notified()
void audioHandler::stateChanged(QAudio::State state) void audioHandler::stateChanged(QAudio::State state)
{ {
if (state == QAudio::IdleState && audioOutput->error() == QAudio::UnderrunError) { 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) { //if (buffer.length() < bufferSize) {
// audioOutput->suspend(); // audioOutput->suspend();
//} //}
} }
//qDebug() << this->metaObject()->className() << ": state = " << state; //qDebug(logAudio()) << this->metaObject()->className() << ": state = " << state;
} }
void audioHandler::incomingAudio(const QByteArray& data) 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) { if (audioOutput != Q_NULLPTR && audioOutput->state() != QAudio::StoppedState) {
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
buffer.append(data); buffer.append(data);
if (audioOutput->state() == QAudio::SuspendedState) { if (audioOutput->state() == QAudio::SuspendedState) {
qDebug() << "RX Audio Suspended, Resuming..."; qDebug(logAudio()) << "RX Audio Suspended, Resuming...";
audioOutput->resume(); audioOutput->resume();
} }
} }
@ -384,7 +385,7 @@ void audioHandler::incomingAudio(const QByteArray& data)
void audioHandler::changeBufferSize(const quint16 newSize) void audioHandler::changeBufferSize(const quint16 newSize)
{ {
QMutexLocker locker(&mutex); 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; bufferSize = newSize;
} }

Wyświetl plik

@ -1,5 +1,6 @@
#include "calibrationwindow.h" #include "calibrationwindow.h"
#include "ui_calibrationwindow.h" #include "ui_calibrationwindow.h"
#include "logcategories.h"
calibrationWindow::calibrationWindow(QWidget *parent) : calibrationWindow::calibrationWindow(QWidget *parent) :
QDialog(parent), QDialog(parent),

Wyświetl plik

@ -1,4 +1,5 @@
#include "commhandler.h" #include "commhandler.h"
#include "logcategories.h"
#include <QDebug> #include <QDebug>
@ -22,9 +23,9 @@ commHandler::commHandler()
setupComm(); // basic parameters setupComm(); // basic parameters
openPort(); 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... //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(); initializePt();
@ -50,9 +51,9 @@ commHandler::commHandler(QString portName, quint32 baudRate)
setupComm(); // basic parameters setupComm(); // basic parameters
openPort(); 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... //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(); initializePt();
@ -64,7 +65,7 @@ commHandler::commHandler(QString portName, quint32 baudRate)
void commHandler::initializePt() void commHandler::initializePt()
{ {
// qDebug() << "init pt"; // qDebug(logSerial()) << "init pt";
pseudoterm = new QSerialPort(); pseudoterm = new QSerialPort();
setupPtComm(); setupPtComm();
openPtPort(); openPtPort();
@ -72,7 +73,7 @@ void commHandler::initializePt()
void commHandler::setupPtComm() void commHandler::setupPtComm()
{ {
qDebug() << "Setting up Pseudo Term"; qDebug(logSerial()) << "Setting up Pseudo Term";
pseudoterm->setPortName("/dev/ptmx"); pseudoterm->setPortName("/dev/ptmx");
// pseudoterm->setBaudRate(baudrate); // pseudoterm->setBaudRate(baudrate);
// pseudoterm->setStopBits(QSerialPort::OneStop); // pseudoterm->setStopBits(QSerialPort::OneStop);
@ -80,7 +81,7 @@ void commHandler::setupPtComm()
void commHandler::openPtPort() void commHandler::openPtPort()
{ {
// qDebug() << "opening pt port"; // qDebug(logSerial()) << "opening pt port";
bool success; bool success;
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
char ptname[128]; char ptname[128];
@ -93,22 +94,22 @@ void commHandler::openPtPort()
#ifndef Q_OS_WIN #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(); ptfd = pseudoterm->handle();
qDebug() << "ptfd: " << ptfd; qDebug(logSerial()) << "ptfd: " << ptfd;
if(grantpt(ptfd)) if(grantpt(ptfd))
{ {
qDebug() << "Failed to grantpt"; qDebug(logSerial()) << "Failed to grantpt";
return; return;
} }
if(unlockpt(ptfd)) if(unlockpt(ptfd))
{ {
qDebug() << "Failed to unlock pt"; qDebug(logSerial()) << "Failed to unlock pt";
return; return;
} }
// we're good! // we're good!
qDebug() << "Opened pseudoterminal."; qDebug(logSerial()) << "Opened pseudoterminal.";
qDebug() << "Slave name: " << ptsname(ptfd); qDebug(logSerial()) << "Slave name: " << ptsname(ptfd);
ptsname_r(ptfd, ptname, 128); ptsname_r(ptfd, ptname, 128);
ptDevSlave = QString::fromLocal8Bit(ptname); ptDevSlave = QString::fromLocal8Bit(ptname);
@ -118,13 +119,13 @@ void commHandler::openPtPort()
sysResult = system(ptLinkCmd.toStdString().c_str()); sysResult = system(ptLinkCmd.toStdString().c_str());
if(sysResult) 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 #endif
} else { } else {
ptfd = 0; 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; qint64 bytesWritten;
bytesWritten = port->write(writeData); 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()\ << " size of byte array: " << writeData.size()\
<< " Wrote all bytes? " << (bool) (bytesWritten == (qint64)writeData.size()); << " Wrote all bytes? " << (bool) (bytesWritten == (qint64)writeData.size());
@ -176,7 +177,7 @@ void commHandler::sendDataOutPt(const QByteArray &writeData)
#ifdef QT_DEBUG #ifdef QT_DEBUG
qint64 bytesWritten; qint64 bytesWritten;
bytesWritten = port->write(writeData); 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()\ writeData.length() << " size of byte array: " << writeData.size()\
<< ", wrote all: " << (bool)(bytesWritten == (qint64)writeData.size()); << ", wrote all: " << (bool)(bytesWritten == (qint64)writeData.size());
#else #else
@ -189,14 +190,14 @@ void commHandler::sendDataOutPt(const QByteArray &writeData)
void commHandler::receiveDataInPt() void commHandler::receiveDataInPt()
{ {
// We received data from the pseudo-term. // 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: // Send this data to the radio:
//QByteArray ptdata = pseudoterm->readAll(); //QByteArray ptdata = pseudoterm->readAll();
// should check the data and rollback // should check the data and rollback
// for now though... // for now though...
//sendDataOut(ptdata); //sendDataOut(ptdata);
sendDataOut(pseudoterm->readAll()); 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() void commHandler::receiveDataIn()
@ -224,27 +225,27 @@ void commHandler::receiveDataIn()
// 0xE1 = wfview // 0xE1 = wfview
// 0xE0 = pseudo-term host // 0xE0 = pseudo-term host
// 0x00 = broadcast to all // 0x00 = broadcast to all
//qDebug() << "Sending data from radio to pseudo-terminal"; //qDebug(logSerial()) << "Sending data from radio to pseudo-terminal";
sendDataOutPt(inPortData); sendDataOutPt(inPortData);
} }
if(rolledBack) 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); //printHex(inPortData, false, true);
rolledBack = false; rolledBack = false;
} }
} else { } else {
// did not receive the entire thing so roll back: // 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); //printHex(inPortData, false, true);
port->rollbackTransaction(); port->rollbackTransaction();
rolledBack = true; rolledBack = true;
} }
} else { } else {
port->commitTransaction(); // do not emit data, do not keep data. port->commitTransaction(); // do not emit data, do not keep data.
//qDebug() << "Warning: received data with invalid start. Dropping data."; //qDebug(logSerial()) << "Warning: received data with invalid start. Dropping data.";
//qDebug() << "THIS SHOULD ONLY HAPPEN ONCE!!"; //qDebug(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!";
// THIS SHOULD ONLY HAPPEN ONCE! // THIS SHOULD ONLY HAPPEN ONCE!
// unrecoverable. We did not receive the start and must // unrecoverable. We did not receive the start and must
@ -264,11 +265,11 @@ void commHandler::openPort()
if(success) if(success)
{ {
isConnected = true; isConnected = true;
//qDebug() << "Opened port!"; //qDebug(logSerial()) << "Opened port!";
return; return;
} else { } else {
// debug? // debug?
qDebug() << "Could not open serial port " << portName << " , please restart."; qDebug(logSerial()) << "Could not open serial port " << portName << " , please restart.";
isConnected = false; isConnected = false;
serialError = true; serialError = true;
emit haveSerialPortError(portName, "Could not open port. Please restart."); emit haveSerialPortError(portName, "Could not open port. Please restart.");
@ -287,7 +288,7 @@ void commHandler::closePort()
void commHandler::debugThis() void commHandler::debugThis()
{ {
// Do not use, function is for debug only and subject to change. // Do not use, function is for debug only and subject to change.
qDebug() << "comm debug called."; qDebug(logSerial()) << "comm debug called.";
inPortData = port->readAll(); inPortData = port->readAll();
emit haveDataFromPort(inPortData); emit haveDataFromPort(inPortData);
@ -297,7 +298,7 @@ void commHandler::debugThis()
void commHandler::printHex(const QByteArray &pdata, bool printVert, bool printHoriz) void commHandler::printHex(const QByteArray &pdata, bool printVert, bool printHoriz)
{ {
qDebug() << "---- Begin hex dump -----:"; qDebug(logSerial()) << "---- Begin hex dump -----:";
QString sdata("DATA: "); QString sdata("DATA: ");
QString index("INDEX: "); QString index("INDEX: ");
QStringList strings; QStringList strings;
@ -314,16 +315,16 @@ void commHandler::printHex(const QByteArray &pdata, bool printVert, bool printHo
for(int i=0; i < strings.length(); i++) for(int i=0; i < strings.length(); i++)
{ {
//sdata = QString(strings.at(i)); //sdata = QString(strings.at(i));
qDebug() << strings.at(i); qDebug(logSerial()) << strings.at(i);
} }
} }
if(printHoriz) if(printHoriz)
{ {
qDebug() << index; qDebug(logSerial()) << index;
qDebug() << sdata; qDebug(logSerial()) << sdata;
} }
qDebug() << "----- End hex dump -----"; qDebug(logSerial()) << "----- End hex dump -----";
} }

Wyświetl plik

@ -1,4 +1,5 @@
#include "freqmemory.h" #include "freqmemory.h"
#include "logcategories.h"
// Copytight 2017-2020 Elliott H. Liggett // Copytight 2017-2020 Elliott H. Liggett
@ -60,6 +61,6 @@ void freqMemory::dumpMemory()
{ {
for(unsigned int p=0; p < numPresets; p++) 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;
} }
} }

Wyświetl plik

@ -3,9 +3,12 @@
#include <QLoggingCategory> #include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(logDebug) Q_DECLARE_LOGGING_CATEGORY(logSystem)
Q_DECLARE_LOGGING_CATEGORY(logInfo) Q_DECLARE_LOGGING_CATEGORY(logSerial)
Q_DECLARE_LOGGING_CATEGORY(logWarning) Q_DECLARE_LOGGING_CATEGORY(logGui)
Q_DECLARE_LOGGING_CATEGORY(logCritical) Q_DECLARE_LOGGING_CATEGORY(logRig)
Q_DECLARE_LOGGING_CATEGORY(logAudio)
Q_DECLARE_LOGGING_CATEGORY(logUdp)
Q_DECLARE_LOGGING_CATEGORY(logUdpServer)
#endif // LOGCATEGORIES_H #endif // LOGCATEGORIES_H

Wyświetl plik

@ -1,6 +1,7 @@
#include <QApplication> #include <QApplication>
#include <iostream> #include <iostream>
#include "wfmain.h" #include "wfmain.h"
#include "logcategories.h"
// Copytight 2017-2021 Elliott H. Liggett // Copytight 2017-2021 Elliott H. Liggett
@ -86,13 +87,13 @@ int main(int argc, char *argv[])
// Set handler // Set handler
qInstallMessageHandler(messageHandler); qInstallMessageHandler(messageHandler);
qDebug(logInfo()) << "Starting wfview"; qInfo(logSystem()) << "Starting wfview";
#ifdef QT_DEBUG #ifdef QT_DEBUG
qDebug(logDebug()) << "SerialPortCL as set by parser: " << serialPortCL; qInfo(logSystem()) << "SerialPortCL as set by parser: " << serialPortCL;
qDebug(logDebug()) << "remote host as set by parser: " << hostCL; qInfo(logSystem()) << "remote host as set by parser: " << hostCL;
qDebug(logDebug()) << "CIV as set by parser: " << civCL; qInfo(logSystem()) << "CIV as set by parser: " << civCL;
#endif #endif
a.setWheelScrollLines(1); // one line per wheel click a.setWheelScrollLines(1); // one line per wheel click
wfmain w( serialPortCL, hostCL); wfmain w( serialPortCL, hostCL);
@ -102,7 +103,7 @@ int main(int argc, char *argv[])
return a.exec(); return a.exec();
qDebug(logInfo()) << "wfview is finished"; qInfo(logSystem()) << "wfview is finished";
} }

Wyświetl plik

@ -2,6 +2,7 @@
#include <QDebug> #include <QDebug>
#include "rigidentities.h" #include "rigidentities.h"
#include "logcategories.h"
// Copytight 2017-2020 Elliott H. Liggett // Copytight 2017-2020 Elliott H. Liggett
@ -164,7 +165,7 @@ void rigCommander::process()
void rigCommander::handleSerialPortError(const QString port, const QString errorText) 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); emit haveSerialPortError(port, errorText);
} }
@ -190,7 +191,7 @@ void rigCommander::findRigs()
//check this: //check this:
#ifdef QT_DEBUG #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); printHex(data, false, true);
#endif #endif
@ -204,7 +205,7 @@ void rigCommander::prepDataAndSend(QByteArray data)
//printHex(data, false, true); //printHex(data, false, true);
data.append(payloadSuffix); data.append(payloadSuffix);
#ifdef QT_DEBUG #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); printHex(data, false, true);
#endif #endif
emit dataForComm(data); emit dataForComm(data);
@ -435,7 +436,7 @@ void rigCommander::getSpectrumRefLevel(unsigned char mainSub)
void rigCommander::setSpectrumRefLevel(int level) void rigCommander::setSpectrumRefLevel(int level)
{ {
//qDebug() << __func__ << ": Setting scope to level " << level; //qDebug(logRig()) << __func__ << ": Setting scope to level " << level;
QByteArray setting; QByteArray setting;
QByteArray number; QByteArray number;
QByteArray pn; QByteArray pn;
@ -453,7 +454,7 @@ void rigCommander::setSpectrumRefLevel(int level)
setting.append(number); setting.append(number);
setting.append(pn); 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); //printHex(setting, false, true);
prepDataAndSend(setting); prepDataAndSend(setting);
@ -497,7 +498,7 @@ QByteArray rigCommander::makeFreqPayload(double freq)
result.append(a); result.append(a);
//printHex(result, false, true); //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); //printHex(result, false, true);
return result; return result;
@ -648,7 +649,7 @@ void rigCommander::parseData(QByteArray dataInput)
// use this: // use this:
QList <QByteArray> dataList = dataInput.split('\xFD'); QList <QByteArray> dataList = dataInput.split('\xFD');
QByteArray data; 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()) if (dataList.last().isEmpty())
{ {
dataList.removeLast(); // if the original ended in FD, then there is a blank entry at the end. 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: // 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) // 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); //printHex(data, false, true);
if(data.length() < 4) if(data.length() < 4)
{ {
if(data.length()) if(data.length())
{ {
// Finally this almost never happens // 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); //printHex(data, false, true);
} }
// no // no
@ -690,18 +691,18 @@ void rigCommander::parseData(QByteArray dataInput)
if(!data.startsWith("\xFE\xFE")) 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, // find 94 e0 and shift over,
// or look inside for a second FE FE // or look inside for a second FE FE
// Often a local echo will miss a few bytes at the beginning. // Often a local echo will miss a few bytes at the beginning.
if(data.startsWith('\xFE')) if(data.startsWith('\xFE'))
{ {
data.prepend('\xFE'); data.prepend('\xFE');
// qDebug() << "Warning: Working with prepended data stream."; // qDebug(logRig()) << "Warning: Working with prepended data stream.";
parseData(payloadIn); parseData(payloadIn);
return; return;
} else { } else {
//qDebug() << "Error: Could not reconstruct corrupted data: "; //qDebug(logRig()) << "Error: Could not reconstruct corrupted data: ";
//printHex(data, false, true); //printHex(data, false, true);
// data.right(data.length() - data.find('\xFE\xFE')); // data.right(data.length() - data.find('\xFE\xFE'));
// if found do not return and keep going. // 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 // data is or begins with an echoback from what we sent
// find the first 'fd' and cut it. Then continue. // find the first 'fd' and cut it. Then continue.
//payloadIn = data.right(data.length() - data.indexOf('\xfd')-1); //payloadIn = data.right(data.length() - data.indexOf('\xfd')-1);
// qDebug() << "[FOUND] Trimmed off echo:"; // qDebug(logRig()) << "[FOUND] Trimmed off echo:";
//printHex(payloadIn, false, true); //printHex(payloadIn, false, true);
//parseData(payloadIn); //parseData(payloadIn);
//return; //return;
@ -728,7 +729,7 @@ void rigCommander::parseData(QByteArray dataInput)
// // data is or begins with an echoback from what we sent // // data is or begins with an echoback from what we sent
// // find the first 'fd' and cut it. Then continue. // // find the first 'fd' and cut it. Then continue.
// payloadIn = data.right(data.length() - data.indexOf('\xfd')-1); // payloadIn = data.right(data.length() - data.indexOf('\xfd')-1);
// //qDebug() << "Trimmed off echo:"; // //qDebug(logRig()) << "Trimmed off echo:";
// //printHex(payloadIn, false, true); // //printHex(payloadIn, false, true);
// parseData(payloadIn); // parseData(payloadIn);
// break; // break;
@ -752,7 +753,7 @@ void rigCommander::parseData(QByteArray dataInput)
// The data are "to 00" and "from E1" // The data are "to 00" and "from E1"
// Don't use it! // Don't use it!
#ifdef QT_DEBUG #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 #endif
} else { } else {
payloadIn = data.right(data.length() - 4); payloadIn = data.right(data.length() - 4);
@ -769,7 +770,7 @@ void rigCommander::parseData(QByteArray dataInput)
/* /*
if(dataList.length() > 1) 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; break;
case '\x01': case '\x01':
//qDebug() << "Have mode data"; //qDebug(logRig()) << "Have mode data";
this->parseMode(); this->parseMode();
break; break;
case '\x04': case '\x04':
//qDebug() << "Have mode data"; //qDebug(logRig()) << "Have mode data";
this->parseMode(); this->parseMode();
break; break;
case '\x05': case '\x05':
//qDebug() << "Have frequency data"; //qDebug(logRig()) << "Have frequency data";
this->parseFrequency(); this->parseFrequency();
break; break;
case '\x06': case '\x06':
//qDebug() << "Have mode data"; //qDebug(logRig()) << "Have mode data";
this->parseMode(); this->parseMode();
break; break;
case '\x0F': case '\x0F':
@ -830,11 +831,11 @@ void rigCommander::parseCommand()
parseLevels(); parseLevels();
break; break;
case '\x19': case '\x19':
// qDebug() << "Have rig ID: " << (unsigned int)payloadIn[2]; // qDebug(logRig()) << "Have rig ID: " << (unsigned int)payloadIn[2];
// printHex(payloadIn, false, true); // printHex(payloadIn, false, true);
model = determineRadioModel(payloadIn[2]); // verify this is the model not the CIV model = determineRadioModel(payloadIn[2]); // verify this is the model not the CIV
determineRigCaps(); determineRigCaps();
qDebug() << "Have rig ID: decimal: " << (unsigned int)model; qDebug(logRig()) << "Have rig ID: decimal: " << (unsigned int)model;
break; break;
@ -849,7 +850,7 @@ void rigCommander::parseCommand()
break; break;
case '\x27': case '\x27':
// scope data // scope data
//qDebug() << "Have scope data"; //qDebug(logRig()) << "Have scope data";
//printHex(payloadIn, false, true); //printHex(payloadIn, false, true);
parseWFData(); parseWFData();
//parseSpectrum(); //parseSpectrum();
@ -871,7 +872,7 @@ void rigCommander::parseCommand()
case '\xFA': case '\xFA':
// error // error
#ifdef QT_DEBUG #ifdef QT_DEBUG
qDebug() << "Error (FA) received from rig."; qDebug(logRig()) << "Error (FA) received from rig.";
printHex(payloadIn, false ,true); printHex(payloadIn, false ,true);
#endif #endif
break; break;
@ -879,7 +880,7 @@ void rigCommander::parseCommand()
default: default:
// This gets hit a lot when the pseudo-term is // This gets hit a lot when the pseudo-term is
// using commands wfview doesn't know yet. // 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); // printHex(payloadIn, false, true);
break; break;
} }
@ -889,7 +890,7 @@ void rigCommander::parseCommand()
void rigCommander::parseLevels() void rigCommander::parseLevels()
{ {
//qDebug() << "Received a level status readout: "; //qDebug(logRig()) << "Received a level status readout: ";
// printHex(payloadIn, false, true); // printHex(payloadIn, false, true);
// wrong: unsigned char level = (payloadIn[2] * 100) + payloadIn[03]; // wrong: unsigned char level = (payloadIn[2] * 100) + payloadIn[03];
@ -899,7 +900,7 @@ void rigCommander::parseLevels()
unsigned char level = (100*hundreds) + (10*tens) + units; 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): // Typical RF gain response (rather low setting):
// "INDEX: 00 01 02 03 04 " // "INDEX: 00 01 02 03 04 "
@ -948,7 +949,7 @@ void rigCommander::parseLevels()
break; break;
default: 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; break;
} }
@ -989,7 +990,7 @@ void rigCommander::parseLevels()
break; break;
default: 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; break;
} }
@ -1538,7 +1539,7 @@ void rigCommander::setRefAdjustCourse(unsigned char level)
void rigCommander::setRefAdjustFine(unsigned char level) void rigCommander::setRefAdjustFine(unsigned char level)
{ {
qDebug() << __FUNCTION__ << " level: " << level; qDebug(logRig()) << __FUNCTION__ << " level: " << level;
// 1A 05 00 73 0000-0255 // 1A 05 00 73 0000-0255
QByteArray payload; QByteArray payload;
payload.setRawData("\x1A\x05\x00\x73", 4); payload.setRawData("\x1A\x05\x00\x73", 4);
@ -1601,7 +1602,7 @@ void rigCommander::parseRegisters1C()
void rigCommander::parseATU() void rigCommander::parseATU()
{ {
// qDebug() << "Have ATU status from radio. Emitting."; // qDebug(logRig()) << "Have ATU status from radio. Emitting.";
// Expect: // Expect:
// [0]: 0x1c // [0]: 0x1c
// [1]: 0x01 // [1]: 0x01
@ -1634,7 +1635,7 @@ void rigCommander::parseRegisters1A()
// 01: band stacking memory contents (last freq used is stored here per-band) // 01: band stacking memory contents (last freq used is stored here per-band)
// 03: filter width // 03: filter width
// 04: AGC rate // 04: AGC rate
// qDebug() << "Looking at register 1A :"; // qDebug(logRig()) << "Looking at register 1A :";
// printHex(payloadIn, false, true); // printHex(payloadIn, false, true);
// "INDEX: 00 01 02 03 04 " // "INDEX: 00 01 02 03 04 "
@ -1670,7 +1671,7 @@ void rigCommander::parseRegisters1A()
void rigCommander::parseBandStackReg() void rigCommander::parseBandStackReg()
{ {
// qDebug() << "Band stacking register response received: "; // qDebug(logRig()) << "Band stacking register response received: ";
// printHex(payloadIn, false, true); // printHex(payloadIn, false, true);
// Reference output, 20 meters, regCode 01 (latest): // 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 " // "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 // 14, 15 tone squelch freq setting
// if more, memory name (label) ascii // if more, memory name (label) ascii
// qDebug() << "band: " << QString("%1").arg(band) << " regCode: " << (QString)regCode << " freq: " << freq; // qDebug(logRig()) << "band: " << QString("%1").arg(band) << " regCode: " << (QString)regCode << " freq: " << freq;
// qDebug() << "mode: " << (QString)mode << " dataOn: " << dataOn; // qDebug(logRig()) << "mode: " << (QString)mode << " dataOn: " << dataOn;
emit haveBandStackReg(freq, mode, dataOn); emit haveBandStackReg(freq, mode, dataOn);
} }
@ -1960,7 +1961,7 @@ void rigCommander::parseWFData()
case 0x14: case 0x14:
// fixed or center // fixed or center
emit haveSpectrumFixedMode((bool)payloadIn[2]); emit haveSpectrumFixedMode((bool)payloadIn[2]);
qDebug() << "received 0x14 command fix/center"; qDebug(logRig()) << "received 0x14 command fix/center";
printHex(payloadIn, false, true); printHex(payloadIn, false, true);
// [1] 0x14 // [1] 0x14
// [2] 0x00 (center), 0x01 (fixed) // [2] 0x00 (center), 0x01 (fixed)
@ -1970,20 +1971,20 @@ void rigCommander::parseWFData()
// [1] 0x15 // [1] 0x15
// [2] to [8] is span encoded as a frequency // [2] to [8] is span encoded as a frequency
freqSpan = parseFrequency(payloadIn, 8); 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); printHex(payloadIn, false, true);
break; break;
case 0x16: case 0x16:
// read edge mode center in edge mode // read edge mode center in edge mode
emit haveScopeEdge((char)payloadIn[2]); emit haveScopeEdge((char)payloadIn[2]);
qDebug() << "Received 0x16 edge in center mode:"; qDebug(logRig()) << "Received 0x16 edge in center mode:";
printHex(payloadIn, false, true); printHex(payloadIn, false, true);
// [1] 0x16 // [1] 0x16
// [2] 0x01, 0x02, 0x03: Edge 1,2,3 // [2] 0x01, 0x02, 0x03: Edge 1,2,3
break; break;
case 0x17: case 0x17:
// Hold status (only 9700?) // 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); printHex(payloadIn, false, true);
break; break;
case 0x19: case 0x19:
@ -1996,7 +1997,7 @@ void rigCommander::parseWFData()
parseSpectrumRefLevel(); parseSpectrumRefLevel();
break; break;
default: default:
qDebug() << "Unknown waveform data received: "; qDebug(logRig()) << "Unknown waveform data received: ";
printHex(payloadIn, false, true); printHex(payloadIn, false, true);
break; break;
} }
@ -2137,7 +2138,7 @@ void rigCommander::determineRigCaps()
rigCaps.hasLan = false; rigCaps.hasLan = false;
rigCaps.hasEthernet = false; rigCaps.hasEthernet = false;
rigCaps.hasWiFi = false; rigCaps.hasWiFi = false;
qDebug() << "Found unknown rig: " << rigCaps.modelName; qDebug(logRig()) << "Found unknown rig: " << rigCaps.modelName;
break; break;
} }
@ -2147,14 +2148,14 @@ void rigCommander::determineRigCaps()
lookingForRig = false; lookingForRig = false;
foundRig = true; foundRig = true;
#ifdef QT_DEBUG #ifdef QT_DEBUG
qDebug() << "---Rig FOUND from broadcast query:"; qDebug(logRig()) << "---Rig FOUND from broadcast query:";
#endif #endif
this->civAddr = incomingCIVAddr; // Override and use immediately. this->civAddr = incomingCIVAddr; // Override and use immediately.
payloadPrefix = QByteArray("\xFE\xFE"); payloadPrefix = QByteArray("\xFE\xFE");
payloadPrefix.append(civAddr); payloadPrefix.append(civAddr);
payloadPrefix.append((char)compCivAddr); payloadPrefix.append((char)compCivAddr);
// if there is a compile-time error, remove the following line, the "hex" part is the issue: // 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); emit discoveredRigID(rigCaps);
} else { } else {
emit haveRigID(rigCaps); emit haveRigID(rigCaps);
@ -2166,14 +2167,14 @@ void rigCommander::parseSpectrum()
if(!haveRigCaps) if(!haveRigCaps)
{ {
#ifdef QT_DEBUG #ifdef QT_DEBUG
qDebug() << "Spectrum received in rigCommander, but rigID is incomplete."; qDebug(logRig()) << "Spectrum received in rigCommander, but rigID is incomplete.";
#endif #endif
return; return;
} }
if(rigCaps.spectSeqMax == 0) 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. // 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; return;
} }
// Here is what to expect: // Here is what to expect:
@ -2213,7 +2214,7 @@ void rigCommander::parseSpectrum()
// unsigned char waveInfo = payloadIn[06]; // really just one byte? // 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 // Sequnce 2, index 05 is the start of data
// Sequence 11. index 05, is the last chunk // 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. // sequence numbers 2 through 10, 50 pixels each. Total after sequence 10 is 450 pixels.
payloadIn.chop(1); payloadIn.chop(1);
spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5)); // write over the FD, last one doesn't, oh well. 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) } else if (sequence == rigCaps.spectSeqMax)
{ {
// last spectrum, a little bit different (last 25 pixels). Total at end is 475 pixels (7300). // last spectrum, a little bit different (last 25 pixels). Total at end is 475 pixels (7300).
payloadIn.chop(1); payloadIn.chop(1);
spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5)); 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); emit haveSpectrumData(spectrumLine, spectrumStartFreq, spectrumEndFreq);
} }
} }
@ -2333,7 +2334,7 @@ QByteArray rigCommander::bcdEncodeInt(unsigned int num)
{ {
if(num > 9999) 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(); return QByteArray();
} }
@ -2345,14 +2346,14 @@ QByteArray rigCommander::bcdEncodeInt(unsigned int num)
char b0 = hundreds | (thousands << 4); char b0 = hundreds | (thousands << 4);
char b1 = units | (tens << 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(b0), false, true);
//printHex(QByteArray(b1), false, true); //printHex(QByteArray(b1), false, true);
QByteArray result; QByteArray result;
result.append(b0).append(b1); result.append(b0).append(b1);
qDebug() << "Result: " << result; qDebug(logRig()) << "Result: " << result;
return result; return result;
} }
@ -2457,7 +2458,7 @@ void rigCommander::setATU(bool enabled)
void rigCommander::getATUStatus() void rigCommander::getATUStatus()
{ {
//qDebug() << "Sending out for ATU status in RC."; //qDebug(logRig()) << "Sending out for ATU status in RC.";
QByteArray payload("\x1C\x01"); QByteArray payload("\x1C\x01");
prepDataAndSend(payload); prepDataAndSend(payload);
} }
@ -2522,7 +2523,7 @@ void rigCommander::printHex(const QByteArray &pdata)
void rigCommander::printHex(const QByteArray &pdata, bool printVert, bool printHoriz) void rigCommander::printHex(const QByteArray &pdata, bool printVert, bool printHoriz)
{ {
qDebug() << "---- Begin hex dump -----:"; qDebug(logRig()) << "---- Begin hex dump -----:";
QString sdata("DATA: "); QString sdata("DATA: ");
QString index("INDEX: "); QString index("INDEX: ");
QStringList strings; QStringList strings;
@ -2539,21 +2540,21 @@ void rigCommander::printHex(const QByteArray &pdata, bool printVert, bool printH
for(int i=0; i < strings.length(); i++) for(int i=0; i < strings.length(); i++)
{ {
//sdata = QString(strings.at(i)); //sdata = QString(strings.at(i));
qDebug() << strings.at(i); qDebug(logRig()) << strings.at(i);
} }
} }
if(printHoriz) if(printHoriz)
{ {
qDebug() << index; qDebug(logRig()) << index;
qDebug() << sdata; qDebug(logRig()) << sdata;
} }
qDebug() << "----- End hex dump -----"; qDebug(logRig()) << "----- End hex dump -----";
} }
void rigCommander::dataFromServer(QByteArray data) void rigCommander::dataFromServer(QByteArray data)
{ {
//qDebug() << "emit dataForComm()"; //qDebug(logRig()) << "emit dataForComm()";
emit dataForComm(data); emit dataForComm(data);
} }

Wyświetl plik

@ -1,4 +1,5 @@
#include "rigidentities.h" #include "rigidentities.h"
#include "logcategories.h"
// Copytight 2017-2021 Elliott H. Liggett // Copytight 2017-2021 Elliott H. Liggett

Wyświetl plik

@ -1,5 +1,6 @@
#include "satellitesetup.h" #include "satellitesetup.h"
#include "ui_satellitesetup.h" #include "ui_satellitesetup.h"
#include "logcategories.h"
satelliteSetup::satelliteSetup(QWidget *parent) : satelliteSetup::satelliteSetup(QWidget *parent) :
QDialog(parent), QDialog(parent),

Wyświetl plik

@ -2,7 +2,7 @@
// This code is heavily based on "Kappanhang" by HA2NON, ES1AKOS and W6EL! // This code is heavily based on "Kappanhang" by HA2NON, ES1AKOS and W6EL!
#include "udphandler.h" #include "udphandler.h"
#include "logcategories.h"
udpHandler::udpHandler(QString ip, quint16 controlPort, quint16 civPort, quint16 audioPort, QString username, QString password, udpHandler::udpHandler(QString ip, quint16 controlPort, quint16 civPort, quint16 audioPort, QString username, QString password,
quint16 buffer, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec) : quint16 buffer, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec) :
controlPort(controlPort), controlPort(controlPort),
@ -19,7 +19,7 @@ udpHandler::udpHandler(QString ip, quint16 controlPort, quint16 civPort, quint16
this->rxCodec = rxcodec; this->rxCodec = rxcodec;
this->txCodec = txcodec; 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; " 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. // 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) { if (addr.protocol() == QAbstractSocket::IPv4Protocol) {
radioIP = addr; radioIP = addr;
qDebug() << "Got IP Address :" << ip << ": " << addr.toString(); qDebug(logUdp()) << "Got IP Address :" << ip << ": " << addr.toString();
break; break;
} }
} }
if (radioIP.isNull()) if (radioIP.isNull())
{ {
qDebug() << "Error obtaining IP Address for :" << ip << ": " << remote.errorString(); qDebug(logUdp()) << "Error obtaining IP Address for :" << ip << ": " << remote.errorString();
return; return;
} }
} }
@ -92,7 +92,7 @@ udpHandler::~udpHandler()
if (civ != Q_NULLPTR) { if (civ != Q_NULLPTR) {
delete civ; delete civ;
} }
qDebug() << "Sending token removal packet"; qDebug(logUdp()) << "Sending token removal packet";
sendToken(0x01); sendToken(0x01);
} }
} }
@ -140,7 +140,7 @@ void udpHandler::dataReceived()
// This is "I am ready" in response to "Are you ready" so send login. // This is "I am ready" in response to "Are you ready" so send login.
else if (in->type == 0x06) 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 sendLogin(); // send login packet
} }
break; break;
@ -175,7 +175,7 @@ void udpHandler::dataReceived()
{ {
if (in->response == 0x0000) if (in->response == 0x0000)
{ {
qDebug() << this->metaObject()->className() << ": Token renewal successful"; qDebug(logUdp()) << this->metaObject()->className() << ": Token renewal successful";
tokenTimer->start(TOKEN_RENEWAL); tokenTimer->start(TOKEN_RENEWAL);
gotAuthOK = true; gotAuthOK = true;
if (!streamOpened) if (!streamOpened)
@ -206,12 +206,12 @@ void udpHandler::dataReceived()
if (in->error == 0x00ffffff && !streamOpened) if (in->error == 0x00ffffff && !streamOpened)
{ {
emit haveNetworkError(radioIP.toString(), "Auth failed, try rebooting the radio."); 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) else if (in->error == 0x00000000 && in->disc == 0x01)
{ {
emit haveNetworkError(radioIP.toString(), "Got radio disconnected."); emit haveNetworkError(radioIP.toString(), "Got radio disconnected.");
qDebug() << this->metaObject()->className() << ": Got radio disconnected."; qDebug(logUdp()) << this->metaObject()->className() << ": Got radio disconnected.";
if (streamOpened) { if (streamOpened) {
// Close stream connections but keep connection open to the radio. // Close stream connections but keep connection open to the radio.
if (audio != Q_NULLPTR) { if (audio != Q_NULLPTR) {
@ -232,7 +232,7 @@ void udpHandler::dataReceived()
if (in->error == 0xfeffffff) if (in->error == 0xfeffffff)
{ {
emit haveNetworkStatus("Invalid Username/Password"); emit haveNetworkStatus("Invalid Username/Password");
qDebug() << this->metaObject()->className() << ": Invalid Username/Password"; qDebug(logUdp()) << this->metaObject()->className() << ": Invalid Username/Password";
} }
else if (!isAuthenticated) else if (!isAuthenticated)
{ {
@ -240,7 +240,7 @@ void udpHandler::dataReceived()
if (in->tokrequest == tokRequest) if (in->tokrequest == tokRequest)
{ {
emit haveNetworkStatus("Radio Login OK!"); 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; token = in->token;
sendToken(0x02); sendToken(0x02);
tokenTimer->start(TOKEN_RENEWAL); // Start token request timer tokenTimer->start(TOKEN_RENEWAL); // Start token request timer
@ -248,7 +248,7 @@ void udpHandler::dataReceived()
} }
else 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; highBandwidthConnection = true;
} }
qDebug() << this->metaObject()->className() << ": Detected connection speed " << in->connection; qDebug(logUdp()) << this->metaObject()->className() << ": Detected connection speed " << in->connection;
break; break;
} }
case (CONNINFO_SIZE): case (CONNINFO_SIZE):
@ -285,7 +285,7 @@ void udpHandler::dataReceived()
emit haveNetworkStatus(devName); 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... // Stuff can change in the meantime because of a previous login...
remoteId = in->sentid; remoteId = in->sentid;
@ -312,7 +312,7 @@ void udpHandler::dataReceived()
audioType = in->audio; audioType = in->audio;
devName = in->name; devName = in->name;
//replyId = r.mid(0x42, 16); //replyId = r.mid(0x42, 16);
qDebug() << this->metaObject()->className() << "Received radio capabilities, Name:" << qDebug(logUdp()) << this->metaObject()->className() << "Received radio capabilities, Name:" <<
devName << " Audio:" << devName << " Audio:" <<
audioType; audioType;
@ -371,10 +371,10 @@ void udpHandler::sendAreYouThere()
{ {
if (areYouThereCounter == 20) if (areYouThereCounter == 20)
{ {
qDebug() << this->metaObject()->className() << ": Radio not responding."; qDebug(logUdp()) << this->metaObject()->className() << ": Radio not responding.";
emit haveNetworkStatus("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++; areYouThereCounter++;
udpBase::sendControl(false,0x03,0x00); udpBase::sendControl(false,0x03,0x00);
@ -383,7 +383,7 @@ void udpHandler::sendAreYouThere()
void udpHandler::sendLogin() // Only used on control stream. 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. 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) 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; token_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! 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 // Class that manages all Civ Data to/from the rig
udpCivData::udpCivData(QHostAddress local, QHostAddress ip, quint16 civPort) udpCivData::udpCivData(QHostAddress local, QHostAddress ip, quint16 civPort)
{ {
qDebug() << "Starting udpCivData"; qDebug(logUdp()) << "Starting udpCivData";
localIP = local; localIP = local;
port = civPort; port = civPort;
radioIP = ip; radioIP = ip;
@ -466,7 +466,7 @@ udpCivData::~udpCivData() {
void udpCivData::send(QByteArray d) void udpCivData::send(QByteArray d)
{ {
// qDebug() << "Sending: (" << d.length() << ") " << d; // qDebug(logUdp()) << "Sending: (" << d.length() << ") " << d;
data_packet p; data_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
p.len = sizeof(p); p.len = sizeof(p);
@ -515,7 +515,7 @@ void udpCivData::dataReceived()
while (udp->hasPendingDatagrams()) while (udp->hasPendingDatagrams())
{ {
QNetworkDatagram datagram = udp->receiveDatagram(); QNetworkDatagram datagram = udp->receiveDatagram();
//qDebug() << "Received: " << datagram.data(); //qDebug(logUdp()) << "Received: " << datagram.data();
QByteArray r = datagram.data(); QByteArray r = datagram.data();
switch (r.length()) switch (r.length())
@ -557,7 +557,7 @@ void udpCivData::dataReceived()
// Audio stream // Audio stream
udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, quint16 buffer, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec) 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->localIP = local;
this->port = audioPort; this->port = audioPort;
this->radioIP = ip; this->radioIP = ip;
@ -680,7 +680,7 @@ void udpAudio::sendTxAudio()
QByteArray tx = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); QByteArray tx = QByteArray::fromRawData((const char*)p.packet, sizeof(p));
tx.append(partial); tx.append(partial);
len = len + partial.length(); len = len + partial.length();
//qDebug() << "Sending audio packet length: " << tx.length(); //qDebug(logUdp()) << "Sending audio packet length: " << tx.length();
sendTrackedPacket(tx); sendTrackedPacket(tx);
sendAudioSeq++; sendAudioSeq++;
counter++; counter++;
@ -699,7 +699,7 @@ void udpAudio::dataReceived()
{ {
while (udp->hasPendingDatagrams()) { while (udp->hasPendingDatagrams()) {
QNetworkDatagram datagram = udp->receiveDatagram(); QNetworkDatagram datagram = udp->receiveDatagram();
//qDebug() << "Received: " << datagram.data(); //qDebug(logUdp()) << "Received: " << datagram.data();
QByteArray r = datagram.data(); QByteArray r = datagram.data();
switch (r.length()) switch (r.length())
@ -743,14 +743,14 @@ void udpBase::init()
udp = new QUdpSocket(this); udp = new QUdpSocket(this);
udp->bind(); // Bind to random port. udp->bind(); // Bind to random port.
localPort = udp->localPort(); 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(); uint32_t addr = localIP.toIPv4Address();
myId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (localPort & 0xffff); myId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (localPort & 0xffff);
} }
udpBase::~udpBase() udpBase::~udpBase()
{ {
qDebug() << "Closing UDP stream :" << radioIP.toString() << ":" << port; qDebug(logUdp()) << "Closing UDP stream :" << radioIP.toString() << ":" << port;
if (udp != Q_NULLPTR) { if (udp != Q_NULLPTR) {
sendControl(false, 0x05, 0x00); // Send disconnect sendControl(false, 0x05, 0x00); // Send disconnect
udp->close(); udp->close();
@ -787,7 +787,7 @@ void udpBase::dataReceived(QByteArray r)
control_packet_t in = (control_packet_t)r.constData(); control_packet_t in = (control_packet_t)r.constData();
if (in->type == 0x04) { if (in->type == 0x04) {
qDebug() << this->metaObject()->className() << ": Received I am here"; qDebug(logUdp()) << this->metaObject()->className() << ": Received I am here";
areYouThereCounter = 0; areYouThereCounter = 0;
// I don't think that we will ever receive an "I am here" other than in response to "Are you there?" // I don't think that we will ever receive an "I am here" other than in response to "Are you there?"
remoteId = in->sentid; remoteId = in->sentid;
@ -813,7 +813,7 @@ void udpBase::dataReceived(QByteArray r)
// Don't constantly retransmit the same packet, give-up eventually // Don't constantly retransmit the same packet, give-up eventually
if (match->retransmitCount < 4) { if (match->retransmitCount < 4) {
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
qDebug() << this->metaObject()->className() << ": Sending retransmit of " << match->seqNum; qDebug(logUdp()) << this->metaObject()->className() << ": Sending retransmit of " << match->seqNum;
match->retransmitCount++; match->retransmitCount++;
udp->writeDatagram(match->data, radioIP, port); udp->writeDatagram(match->data, radioIP, port);
} }
@ -824,7 +824,7 @@ void udpBase::dataReceived(QByteArray r)
} }
else { else {
// Packet was not found in buffer // 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); sendControl(false, 0, in->seq);
} }
} }
@ -858,11 +858,11 @@ void udpBase::dataReceived(QByteArray r)
} }
else { 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. // 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 { 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) if (in->type==0x01)
{ // retransmit range request { // 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) { 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; return s.seqNum == ca || s.seqNum == cb || s.seqNum == cc || s.seqNum == cd;
}); });
if (match == txSeqBuf.end()) { 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); sendControl(false, 0, in->seq);
} }
else { else {
@ -889,7 +889,7 @@ void udpBase::dataReceived(QByteArray r)
// Found matching entry? // Found matching entry?
// Send "untracked" as it has already been sent once. // Send "untracked" as it has already been sent once.
if (match->retransmitCount <4) { 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); QMutexLocker locker(&mutex);
udp->writeDatagram(match->data, radioIP, port); udp->writeDatagram(match->data, radioIP, port);
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) 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. // Looks like it has rolled over so clear buffer and start again.
rxSeqBuf.clear(); rxSeqBuf.clear();
@ -957,7 +957,7 @@ void udpBase::dataReceived(QByteArray r)
if (count > 6) // Something bad happened, clear the buffer. 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.clear();
rxSeqBuf.append(in->seq); rxSeqBuf.append(in->seq);
@ -965,7 +965,7 @@ void udpBase::dataReceived(QByteArray r)
} }
else if (count == 1) else if (count == 1)
{ {
qDebug() << this->metaObject()->className() << ": Requesting retransmit of: " << first; qDebug(logUdp()) << this->metaObject()->className() << ": Requesting retransmit of: " << first;
rxSeqBuf.append(first); rxSeqBuf.append(first);
sendControl(false, 0x01, first); sendControl(false, 0x01, first);
} }
@ -976,7 +976,7 @@ void udpBase::dataReceived(QByteArray r)
if (count == 3) 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(first);
rxSeqBuf.append(second); rxSeqBuf.append(second);
if (second != third) if (second != third)
@ -1083,7 +1083,7 @@ void udpBase::purgeOldEntries()
std::sort(rxSeqBuf.begin(), rxSeqBuf.end()); std::sort(rxSeqBuf.begin(), rxSeqBuf.end());
rxSeqBuf.remove(0,1024); rxSeqBuf.remove(0,1024);
lastReceivedSeq = *rxSeqBuf.begin(); 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();
} }
} }

Wyświetl plik

@ -1,11 +1,12 @@
#include "udpserver.h" #include "udpserver.h"
#include "logcategories.h"
#define STALE_CONNECTION 15 #define STALE_CONNECTION 15
udpServer::udpServer(SERVERCONFIG config) : udpServer::udpServer(SERVERCONFIG config) :
config(config) config(config)
{ {
qDebug() << "Starting udp server"; qDebug(logUdpServer()) << "Starting udp server";
} }
void udpServer::init() void udpServer::init()
@ -26,7 +27,7 @@ void udpServer::init()
uint32_t addr = localIP.toIPv4Address(); 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); controlId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (config.controlPort & 0xffff);
@ -42,9 +43,9 @@ void udpServer::init()
udpAudio->bind(config.audioPort); udpAudio->bind(config.audioPort);
udpCiv->bind(config.civPort); udpCiv->bind(config.civPort);
qDebug() << "Server Binding Control to: " << config.controlPort; qDebug(logUdpServer()) << "Server Binding Control to: " << config.controlPort;
qDebug() << "Server Binding CIV to: " << config.civPort; qDebug(logUdpServer()) << "Server Binding CIV to: " << config.civPort;
qDebug() << "Server Binding Audio to: " << config.audioPort; qDebug(logUdpServer()) << "Server Binding Audio to: " << config.audioPort;
QUdpSocket::connect(udpControl, &QUdpSocket::readyRead, this, &udpServer::controlReceived); QUdpSocket::connect(udpControl, &QUdpSocket::readyRead, this, &udpServer::controlReceived);
@ -55,7 +56,7 @@ void udpServer::init()
udpServer::~udpServer() udpServer::~udpServer()
{ {
qDebug() << "Closing udpServer"; qDebug(logUdpServer()) << "Closing udpServer";
foreach(CLIENT * client, controlClients) foreach(CLIENT * client, controlClients)
@ -169,7 +170,7 @@ void udpServer::controlReceived()
current->idleTimer->start(100); current->idleTimer->start(100);
current->wdTimer->start(10000); current->wdTimer->start(10000);
current->commonCap = 0x8010; 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); controlClients.append(current);
} }
@ -182,26 +183,26 @@ void udpServer::controlReceived()
control_packet_t in = (control_packet_t)r.constData(); control_packet_t in = (control_packet_t)r.constData();
if (in->type == 0x03) 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; current->remoteId = in->sentid;
sendControl(current,0x04,in->seq); sendControl(current,0x04,in->seq);
} // This is This is "Are you ready" in response to "I am here". } // This is This is "Are you ready" in response to "I am here".
else if (in->type == 0x06) 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; current->remoteId = in->sentid;
sendControl(current,0x06,in->seq); sendControl(current,0x06,in->seq);
} // This is a retransmit request } // This is a retransmit request
else if (in->type == 0x01) else if (in->type == 0x01)
{ {
// Just send an idle for now! // 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); sendControl(current,0x00, in->seq);
} // This is a disconnect request } // This is a disconnect request
else if (in->type == 0x05) 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); sendControl(current, 0x00, in->seq);
//current->wdTimer->stop(); // Keep watchdog running to delete stale connection. //current->wdTimer->stop(); // Keep watchdog running to delete stale connection.
deleteConnection(&controlClients, current); deleteConnection(&controlClients, current);
@ -232,7 +233,7 @@ void udpServer::controlReceived()
current->pingSeq++; current->pingSeq++;
} }
else { 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; current->authInnerSeq = in->innerseq;
if (in->res == 0x02) { if (in->res == 0x02) {
// Request for new token // Request for new token
qDebug() << current->ipAddress.toString() << ": Received create token request"; qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received create token request";
sendCapabilities(current); sendCapabilities(current);
sendConnectionInfo(current); sendConnectionInfo(current);
} }
else if (in->res == 0x01) { else if (in->res == 0x01) {
// Token disconnect // Token disconnect
qDebug() << current->ipAddress.toString() << ": Received token disconnect request"; qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received token disconnect request";
sendTokenResponse(current, in->res); sendTokenResponse(current, in->res);
} }
else { else {
qDebug() << current->ipAddress.toString() << ": Received token request"; qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received token request";
sendTokenResponse(current, in->res); sendTokenResponse(current, in->res);
} }
break; break;
@ -264,7 +265,7 @@ void udpServer::controlReceived()
case (LOGIN_SIZE): case (LOGIN_SIZE):
{ {
login_packet_t in = (login_packet_t)r.constData(); 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; bool userOk = false;
foreach(SERVERUSER user, config.users) 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; current->tokenTx =(quint8)rand() | (quint8)rand() << 8 | (quint8)rand() << 16 | (quint8)rand() << 24;
if (userOk) { 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); sendLoginResponse(current, in->seq, true);
} }
else { else {
qDebug() << current->ipAddress.toString() << ": Incorrect username/password"; qDebug(logUdpServer()) << current->ipAddress.toString() << ": Incorrect username/password";
sendLoginResponse(current, in->seq, false); sendLoginResponse(current, in->seq, false);
} }
@ -302,7 +303,7 @@ void udpServer::controlReceived()
case (CONNINFO_SIZE): case (CONNINFO_SIZE):
{ {
conninfo_packet_t in = (conninfo_packet_t)r.constData(); 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! // Request to start audio and civ!
current->isStreaming = true; current->isStreaming = true;
current->rxSeq = in->seq; current->rxSeq = in->seq;
@ -321,7 +322,7 @@ void udpServer::controlReceived()
} }
default: default:
{ {
qDebug() << "Unknown length packet received: " << r.length(); qDebug(logUdpServer()) << "Unknown length packet received: " << r.length();
break; break;
} }
} }
@ -337,7 +338,7 @@ void udpServer::civReceived()
CLIENT* current = Q_NULLPTR; CLIENT* current = Q_NULLPTR;
qDebug() << "Got CIV data"; qDebug(logUdpServer()) << "Got CIV data";
if (datagram.senderAddress().isNull() || datagram.senderPort() == 65535 || datagram.senderPort() == 0) if (datagram.senderAddress().isNull() || datagram.senderPort() == 65535 || datagram.senderPort() == 0)
return; return;
@ -373,7 +374,7 @@ void udpServer::civReceived()
connect(current->idleTimer, &QTimer::timeout, this, std::bind(&udpServer::sendControl, this, current,0x00, (quint16)0x00)); connect(current->idleTimer, &QTimer::timeout, this, std::bind(&udpServer::sendControl, this, current,0x00, (quint16)0x00));
current->pingTimer->start(100); current->pingTimer->start(100);
current->idleTimer->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); civClients.append(current);
} }
@ -387,26 +388,26 @@ void udpServer::civReceived()
control_packet_t in = (control_packet_t)r.constData(); control_packet_t in = (control_packet_t)r.constData();
if (in->type == 0x03) { 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)); current->remoteId = qFromLittleEndian<quint32>(r.mid(8, 4));
sendControl(current, 0x04, gotSeq); sendControl(current, 0x04, gotSeq);
} // This is This is "Are you ready" in response to "I am here". } // This is This is "Are you ready" in response to "I am here".
else if (in->type == 0x06) 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)); current->remoteId = qFromLittleEndian<quint32>(r.mid(8, 4));
sendControl(current, 0x06, gotSeq); sendControl(current, 0x06, gotSeq);
} // This is a retransmit request } // This is a retransmit request
else if (in->type == 0x01) else if (in->type == 0x01)
{ {
// Just send an idle for now, we need to be able to retransmit missing packets. // 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); sendControl(current, 0x00, gotSeq);
} // This is a disconnect request } // This is a disconnect request
else if (in->type == 0x05) else if (in->type == 0x05)
{ {
qDebug() << current->ipAddress.toString() << ": Received 'disconnect' request"; qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'disconnect' request";
sendControl(current, 0x00, gotSeq); sendControl(current, 0x00, gotSeq);
deleteConnection(&civClients, current); deleteConnection(&civClients, current);
@ -436,7 +437,7 @@ void udpServer::civReceived()
current->pingSeq++; current->pingSeq++;
} }
else { 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; quint8 temp = r[0] - 0x15;
if ((quint8)r[16] == 0xc1 && (quint8)r[17] == temp) 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)); emit haveDataFromServer(r.mid(21));
} }
} }
@ -498,7 +499,7 @@ void udpServer::audioReceived()
current->pingTimer = new QTimer(); current->pingTimer = new QTimer();
connect(current->pingTimer, &QTimer::timeout, this, std::bind(&udpServer::sendPing, this, &audioClients, current, (quint16)0x00, false)); connect(current->pingTimer, &QTimer::timeout, this, std::bind(&udpServer::sendPing, this, &audioClients, current, (quint16)0x00, false));
current->pingTimer->start(100); 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); audioClients.append(current);
} }
@ -511,26 +512,26 @@ void udpServer::audioReceived()
{ {
control_packet_t in = (control_packet_t)r.constData(); control_packet_t in = (control_packet_t)r.constData();
if (in->type == 0x03) { 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)); current->remoteId = qFromLittleEndian<quint32>(r.mid(8, 4));
sendControl(current, 0x04, gotSeq); sendControl(current, 0x04, gotSeq);
} // This is This is "Are you ready" in response to "I am here". } // This is This is "Are you ready" in response to "I am here".
else if (in->type == 0x06) 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)); current->remoteId = qFromLittleEndian<quint32>(r.mid(8, 4));
sendControl(current, 0x06, gotSeq); sendControl(current, 0x06, gotSeq);
} // This is a retransmit request } // This is a retransmit request
else if (in->type == 0x01) else if (in->type == 0x01)
{ {
// Just send an idle for now! // 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); sendControl(current, 0x00, gotSeq);
} // This is a disconnect request } // This is a disconnect request
else if (in->type == 0x05) else if (in->type == 0x05)
{ {
qDebug() << current->ipAddress.toString() << ": Received 'disconnect' request"; qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'disconnect' request";
sendControl(current, 0x00, gotSeq); sendControl(current, 0x00, gotSeq);
deleteConnection(&audioClients, current); deleteConnection(&audioClients, current);
} }
@ -561,7 +562,7 @@ void udpServer::audioReceived()
current->pingSeq++; current->pingSeq++;
} }
else { 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++; c->txSeq++;
} }
//qDebug() << c->ipAddress.toString() << ": Sending control packet: " << type; //qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending control packet: " << type;
control_packet p; control_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
p.len = sizeof(p); 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) 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); deleteConnection(l, c);
return; return;
} }
//qDebug() << c->ipAddress.toString() << ": Sending Ping"; //qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending Ping";
quint32 pingTime = 0; quint32 pingTime = 0;
quint8 pingReply = 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) 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; login_response_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! 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) 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; capabilities_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! 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. // Also used to display currently connected used information.
void udpServer::sendConnectionInfo(CLIENT* c) 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; conninfo_packet p;
memset(p.packet, 0x0, sizeof(p)); memset(p.packet, 0x0, sizeof(p));
p.len = sizeof(p); p.len = sizeof(p);
@ -755,7 +756,7 @@ void udpServer::sendConnectionInfo(CLIENT* c)
void udpServer::sendTokenResponse(CLIENT* c, quint8 type) 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; token_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! 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); QMutexLocker locker(&mutex);
qDebug() << c->ipAddress.toString() << ": Sending Status"; qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending Status";
status_packet p; status_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! 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) void udpServer::dataForServer(QByteArray d)
{ {
//qDebug() << "Server got:" << d; //qDebug(logUdpServer()) << "Server got:" << d;
foreach(CLIENT * client, civClients) foreach(CLIENT * client, civClients)
{ {
if (client != Q_NULLPTR && client->connected) { 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. // 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) 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) { if (c->idleTimer != Q_NULLPTR) {
c->idleTimer->stop(); c->idleTimer->stop();
delete c->idleTimer; 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? delete c; // Is this needed or will the erase have done it?
c = Q_NULLPTR; c = Q_NULLPTR;
qDebug() << "Current Number of clients connected: " << l->length(); qDebug(logUdpServer()) << "Current Number of clients connected: " << l->length();
} }

Wyświetl plik

@ -1,5 +1,6 @@
#include "udpserversetup.h" #include "udpserversetup.h"
#include "ui_udpserversetup.h" #include "ui_udpserversetup.h"
#include "logcategories.h"
udpServerSetup::udpServerSetup(QWidget* parent) : udpServerSetup::udpServerSetup(QWidget* parent) :
QDialog(parent), QDialog(parent),

Wyświetl plik

@ -3,6 +3,7 @@
#include "commhandler.h" #include "commhandler.h"
#include "rigidentities.h" #include "rigidentities.h"
#include "logcategories.h"
// This code is copyright 2017-2020 Elliott H. Liggett // This code is copyright 2017-2020 Elliott H. Liggett
// All rights reserved // All rights reserved
@ -174,17 +175,17 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
// if(prefs.serialPortRadio == QString("auto")) // if(prefs.serialPortRadio == QString("auto"))
// { // {
// // Find the ICOM IC-7300. // // 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); // QDirIterator it("/dev/serial", QStringList() << "*IC-7300*", QDir::Files, QDirIterator::Subdirectories);
// while (it.hasNext()) // while (it.hasNext())
// qDebug() << it.next(); // qDebug(logSystem()) << it.next();
// // if (it.isEmpty()) // fail or default to ttyUSB0 if present // // if (it.isEmpty()) // fail or default to ttyUSB0 if present
// // iterator might not make sense // // iterator might not make sense
// serialPortRig = it.filePath(); // first? last? // serialPortRig = it.filePath(); // first? last?
// if(serialPortRig.isEmpty()) // 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"); // serialPortRig = QString("/dev/ttyUSB0");
// } // }
// // end finding the 7300 code // // end finding the 7300 code
@ -447,7 +448,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
#ifdef QT_DEBUG #ifdef QT_DEBUG
qDebug() << "Running with debugging options enabled."; qDebug(logSystem()) << "Running with debugging options enabled.";
ui->debugBtn->setVisible(true); ui->debugBtn->setVisible(true);
#else #else
ui->debugBtn->setVisible(false); ui->debugBtn->setVisible(false);
@ -504,14 +505,14 @@ void wfmain::openRig()
#ifdef QT_DEBUG #ifdef QT_DEBUG
if(!serialPortCL.isEmpty()) if(!serialPortCL.isEmpty())
{ {
qDebug() << "Serial port specified by user: " << serialPortCL; qDebug(logSystem()) << "Serial port specified by user: " << serialPortCL;
} else { } else {
qDebug() << "Serial port not specified. "; qDebug(logSystem()) << "Serial port not specified. ";
} }
if(!hostCL.isEmpty()) if(!hostCL.isEmpty())
{ {
qDebug() << "Remote host name specified by user: " << hostCL; qDebug(logSystem()) << "Remote host name specified by user: " << hostCL;
} }
#endif #endif
@ -547,7 +548,7 @@ void wfmain::openRig()
if( (prefs.serialPortRadio == QString("auto")) && (serialPortCL.isEmpty())) if( (prefs.serialPortRadio == QString("auto")) && (serialPortCL.isEmpty()))
{ {
// Find the ICOM // 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 it73("/dev/serial", QStringList() << "*IC-7300*", QDir::Files, QDirIterator::Subdirectories);
QDirIterator it97("/dev/serial", QStringList() << "*IC-9700*A*", 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); QDirIterator it785x("/dev/serial", QStringList() << "*IC-785*A*", QDir::Files, QDirIterator::Subdirectories);
@ -572,7 +573,7 @@ void wfmain::openRig()
serialPortRig = it705.filePath(); serialPortRig = it705.filePath();
} else { } else {
//fall back: //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 #ifdef Q_OS_MAC
serialPortRig = QString("/dev/tty.SLAB_USBtoUART"); serialPortRig = QString("/dev/tty.SLAB_USBtoUART");
#endif #endif
@ -605,7 +606,7 @@ void wfmain::openRig()
if(prefs.radioCIVAddr == 0) if(prefs.radioCIVAddr == 0)
{ {
// tell rigCommander to broadcast a request for all rig IDs. // 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); ui->statusBar->showMessage(QString("Searching CIV bus for connected radios."), 1000);
emit getRigCIV(); emit getRigCIV();
cmdOutQue.append(cmdGetRigCIV); cmdOutQue.append(cmdGetRigCIV);
@ -613,7 +614,7 @@ void wfmain::openRig()
} else { } else {
// don't bother, they told us the CIV they want, stick with it. // 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. // 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(); getInitialRigState();
} }
*/ */
@ -622,12 +623,12 @@ void wfmain::openRig()
void wfmain::receiveCommReady() void wfmain::receiveCommReady()
{ {
qDebug() << "Received CommReady!! "; qDebug(logSystem()) << "Received CommReady!! ";
// taken from above: // taken from above:
if(prefs.radioCIVAddr == 0) if(prefs.radioCIVAddr == 0)
{ {
// tell rigCommander to broadcast a request for all rig IDs. // 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); ui->statusBar->showMessage(QString("Searching CIV bus for connected radios."), 1000);
emit getRigCIV(); emit getRigCIV();
cmdOutQue.append(cmdGetRigCIV); cmdOutQue.append(cmdGetRigCIV);
@ -635,7 +636,7 @@ void wfmain::receiveCommReady()
} else { } else {
// don't bother, they told us the CIV they want, stick with it. // 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. // 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(); getInitialRigState();
} }
@ -646,7 +647,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
{ {
// Entry point for unknown rig being identified at the start of the program. // Entry point for unknown rig being identified at the start of the program.
//now we know what the rig ID is: //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. delayedCommand->setInterval(100); // faster polling is ok now.
receiveRigID(rigCaps); receiveRigID(rigCaps);
@ -661,7 +662,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
void wfmain::receiveSerialPortError(QString port, QString errorText) 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); ui->statusBar->showMessage(QString("ERROR: using port ").append(port).append(": ").append(errorText), 10000);
// TODO: Dialog box, exit, etc // TODO: Dialog box, exit, etc
@ -705,7 +706,7 @@ void wfmain::setDefPrefs()
void wfmain::loadSettings() void wfmain::loadSettings()
{ {
qDebug() << "Loading settings from " << settings.fileName(); qDebug(logSystem()) << "Loading settings from " << settings.fileName();
// Basic things to load: // Basic things to load:
// UI: (full screen, dark theme, draw peaks, colors, etc) // UI: (full screen, dark theme, draw peaks, colors, etc)
@ -876,7 +877,7 @@ void wfmain::loadSettings()
void wfmain::saveSettings() void wfmain::saveSettings()
{ {
qDebug() << "Saving settings to " << settings.fileName(); qDebug(logSystem()) << "Saving settings to " << settings.fileName();
// Basic things to load: // Basic things to load:
// UI: (full screen, dark theme, draw peaks, colors, etc) // UI: (full screen, dark theme, draw peaks, colors, etc)
@ -1041,7 +1042,7 @@ void wfmain::prepareWf()
wf->xAxis->setVisible(false); wf->xAxis->setVisible(false);
} else { } else {
qDebug() << "Cannot prepare WF view without rigCaps. Waiting on this."; qDebug(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this.";
return; return;
} }
@ -1132,7 +1133,7 @@ void wfmain::shortcutF12()
void wfmain::shortcutControlT() void wfmain::shortcutControlT()
{ {
// Transmit // Transmit
qDebug() << "Activated Control-T shortcut"; qDebug(logSystem()) << "Activated Control-T shortcut";
showStatusBarText(QString("Transmitting. Press Control-R to receive.")); showStatusBarText(QString("Transmitting. Press Control-R to receive."));
ui->pttOnBtn->click(); ui->pttOnBtn->click();
} }
@ -1494,7 +1495,7 @@ void wfmain::runPeriodicCommands()
emit getMode(); emit getMode();
break; break;
case cmdGetDataMode: case cmdGetDataMode:
// qDebug() << "Sending query for data mode"; // qDebug(logSystem()) << "Sending query for data mode";
emit getDataMode(); emit getDataMode();
break; break;
case cmdSetDataModeOff: case cmdSetDataModeOff:
@ -1596,7 +1597,7 @@ void wfmain::runDelayedCommand()
switch(qdCmd) switch(qdCmd)
{ {
case cmdNone: case cmdNone:
//qDebug() << "NOOP"; //qDebug(logSystem()) << "NOOP";
break; break;
case cmdGetRigID: case cmdGetRigID:
emit getRigID(); emit getRigID();
@ -1616,7 +1617,7 @@ void wfmain::runDelayedCommand()
emit getMode(); emit getMode();
break; break;
case cmdGetDataMode: case cmdGetDataMode:
// qDebug() << "Sending query for data mode"; // qDebug(logSystem()) << "Sending query for data mode";
emit getDataMode(); emit getDataMode();
break; break;
case cmdSetDataModeOff: case cmdSetDataModeOff:
@ -1724,12 +1725,12 @@ void wfmain::receiveRigID(rigCapabilities rigCaps)
return; return;
} else { } else {
#ifdef QT_DEBUG #ifdef QT_DEBUG
qDebug() << "Rig name: " << rigCaps.modelName; qDebug(logSystem()) << "Rig name: " << rigCaps.modelName;
qDebug() << "Has LAN capabilities: " << rigCaps.hasLan; qDebug(logSystem()) << "Has LAN capabilities: " << rigCaps.hasLan;
qDebug() << "Rig ID received into wfmain: spectLenMax: " << rigCaps.spectLenMax; qDebug(logSystem()) << "Rig ID received into wfmain: spectLenMax: " << rigCaps.spectLenMax;
qDebug() << "Rig ID received into wfmain: spectAmpMax: " << rigCaps.spectAmpMax; qDebug(logSystem()) << "Rig ID received into wfmain: spectAmpMax: " << rigCaps.spectAmpMax;
qDebug() << "Rig ID received into wfmain: spectSeqMax: " << rigCaps.spectSeqMax; qDebug(logSystem()) << "Rig ID received into wfmain: spectSeqMax: " << rigCaps.spectSeqMax;
qDebug() << "Rig ID received into wfmain: hasSpectrum: " << rigCaps.hasSpectrum; qDebug(logSystem()) << "Rig ID received into wfmain: hasSpectrum: " << rigCaps.hasSpectrum;
#endif #endif
this->rigCaps = rigCaps; this->rigCaps = rigCaps;
this->spectWidth = rigCaps.spectLenMax; // used once haveRigCaps is true. 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) 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')); ui->freqLabel->setText(QString("%1").arg(freqMhz, 0, 'f'));
this->freqMhz = freqMhz; this->freqMhz = freqMhz;
this->knobFreqMhz = freqMhz; this->knobFreqMhz = freqMhz;
@ -1842,7 +1843,7 @@ void wfmain::receiveFreq(double freqMhz)
void wfmain::receivePTTstatus(bool pttOn) void wfmain::receivePTTstatus(bool pttOn)
{ {
// This is the only place where amTransmitting and the transmit button text should be changed: // 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; amTransmitting = pttOn;
changeTxBtn(); changeTxBtn();
} }
@ -1863,7 +1864,7 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
if(!haveRigCaps) if(!haveRigCaps)
{ {
#ifdef QT_DEBUG #ifdef QT_DEBUG
qDebug() << "Spectrum received, but RigID incomplete."; qDebug(logSystem()) << "Spectrum received, but RigID incomplete.";
#endif #endif
return; return;
} }
@ -1882,18 +1883,18 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
oldLowerFreq = startFreq; oldLowerFreq = startFreq;
oldUpperFreq = endFreq; oldUpperFreq = endFreq;
//qDebug() << "start: " << startFreq << " end: " << endFreq; //qDebug(logSystem()) << "start: " << startFreq << " end: " << endFreq;
quint16 specLen = spectrum.length(); 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 != 475) || (specLen!=689) )
if( specLen != rigCaps.spectLenMax ) if( specLen != rigCaps.spectLenMax )
{ {
#ifdef QT_DEBUG #ifdef QT_DEBUG
qDebug() << "-------------------------------------------"; qDebug(logSystem()) << "-------------------------------------------";
qDebug() << "------ Unusual spectrum received, length: " << specLen; qDebug(logSystem()) << "------ Unusual spectrum received, length: " << specLen;
qDebug() << "------ Expected spectrum length: " << rigCaps.spectLenMax; qDebug(logSystem()) << "------ Expected spectrum length: " << rigCaps.spectLenMax;
qDebug() << "------ This should happen once at most. "; qDebug(logSystem()) << "------ This should happen once at most. ";
#endif #endif
return; // safe. Using these unusual length things is a problem. 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->xAxis->setRange(0, spectWidth-1);
wf->replot(); wf->replot();
spectRowCurrent = (spectRowCurrent + 1) % wfLength; 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) 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; bool found=false;
@ -2085,12 +2086,12 @@ void wfmain::receiveMode(unsigned char mode, unsigned char filter)
} }
currentModeIndex = mode; currentModeIndex = mode;
} else { } else {
qDebug() << __func__ << "Invalid mode " << mode << " received. "; qDebug(logSystem()) << __func__ << "Invalid mode " << mode << " received. ";
} }
if(!found) 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)){ if( (filter) && (filter < 4)){
@ -2330,7 +2331,7 @@ void wfmain::on_modeSelectCombo_activated(int index)
{ {
// oops, we forgot to reset the combo box // oops, we forgot to reset the combo box
} else { } else {
qDebug() << __func__ << " at index " << index << " has newMode: " << newMode; qDebug(logSystem()) << __func__ << " at index " << index << " has newMode: " << newMode;
emit setMode(newMode, filterSelection); emit setMode(newMode, filterSelection);
} }
@ -2357,7 +2358,7 @@ void wfmain::on_freqDial_valueChanged(int value)
return; return;
} }
// qDebug() << "Old value: " << oldFreqDialVal << " New value: " << value ; // qDebug(logSystem()) << "Old value: " << oldFreqDialVal << " New value: " << value ;
if(value == 0) if(value == 0)
@ -2409,7 +2410,7 @@ void wfmain::on_freqDial_valueChanged(int value)
newFreqMhz = knobFreqMhz + (delta * stepSize); 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()) if(ui->tuningFloorZerosChk->isChecked())
{ {
@ -2618,7 +2619,7 @@ void wfmain::on_fRclBtn_clicked()
ui->goFreqBtn->click(); ui->goFreqBtn->click();
} else { } 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) 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); emit setAfGain((unsigned char) value);
} }
void wfmain::receiveRfGain(unsigned char level) 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->blockSignals(true);
ui->rfGainSlider->setValue(level); ui->rfGainSlider->setValue(level);
ui->rfGainSlider->blockSignals(false); ui->rfGainSlider->blockSignals(false);
@ -2644,7 +2645,7 @@ void wfmain::receiveRfGain(unsigned char level)
void wfmain::receiveAfGain(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->blockSignals(true);
ui->afGainSlider->setValue(level); ui->afGainSlider->setValue(level);
ui->afGainSlider->blockSignals(false); ui->afGainSlider->blockSignals(false);
@ -2731,7 +2732,7 @@ void wfmain::on_saveSettingsBtn_clicked()
void wfmain::receiveATUStatus(unsigned char atustatus) 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) switch(atustatus)
{ {
case 0x00: case 0x00:
@ -2751,14 +2752,14 @@ void wfmain::receiveATUStatus(unsigned char atustatus)
case 0x02: case 0x02:
// ATU tuning in-progress. // ATU tuning in-progress.
// Add command queue to check again and update status bar // 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..."); showStatusBarText("ATU is Tuning...");
cmdOutQue.append(cmdGetATUStatus); // Sometimes the first hit seems to be missed. cmdOutQue.append(cmdGetATUStatus); // Sometimes the first hit seems to be missed.
cmdOutQue.append(cmdGetATUStatus); cmdOutQue.append(cmdGetATUStatus);
delayedCommand->start(); delayedCommand->start();
break; break;
default: default:
qDebug() << "Did not understand ATU status: " << (unsigned int) atustatus; qDebug(logSystem()) << "Did not understand ATU status: " << (unsigned int) atustatus;
break; break;
} }
} }
@ -3050,7 +3051,7 @@ void wfmain::receiveModInput(rigInput input, bool dataOn)
changeModLabel(input); changeModLabel(input);
} }
if(!found) if(!found)
qDebug() << "Could not find modulation input: " << (int)input; qDebug(logSystem()) << "Could not find modulation input: " << (int)input;
} }
void wfmain::receiveDuplexMode(duplexMode dm) void wfmain::receiveDuplexMode(duplexMode dm)
@ -3178,7 +3179,7 @@ void wfmain::serverConfigRequested(SERVERCONFIG conf, bool store)
} }
else { else {
// Store config in file! // Store config in file!
qDebug() << "Storing server config"; qDebug(logSystem()) << "Storing server config";
serverConfig = conf; serverConfig = conf;
} }
@ -3302,7 +3303,7 @@ void wfmain::processChangingCurrentModLevel(unsigned char level)
} else { } else {
currentIn = currentModSrc; currentIn = currentModSrc;
} }
//qDebug() << __func__ << ": setting current level: " << level; //qDebug(logSystem()) << __func__ << ": setting current level: " << level;
emit setModLevel(currentIn, level); emit setModLevel(currentIn, level);
} }
@ -3315,7 +3316,7 @@ void wfmain::on_tuneLockChk_clicked(bool checked)
// --- DEBUG FUNCTION --- // --- DEBUG FUNCTION ---
void wfmain::on_debugBtn_clicked() void wfmain::on_debugBtn_clicked()
{ {
qDebug() << "Debug button pressed."; qDebug(logSystem()) << "Debug button pressed.";
// TODO: Why don't these commands work?! // TODO: Why don't these commands work?!
//emit getScopeMode(); //emit getScopeMode();