diff --git a/audiohandler.cpp b/audiohandler.cpp index 369af93..8bbdff8 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -781,7 +781,7 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16 // chunk size is always relative to Internal Sample Rate. this->chunkSize = (INTERNAL_SAMPLE_RATE / 25) * radioChannels; - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "chunkSize: " << this->chunkSize; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "chunkSize: " << this->chunkSize; int resample_error=0; @@ -791,13 +791,13 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16 const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); for (const QAudioDeviceInfo& deviceInfo : deviceInfos) { if (deviceInfo.deviceName() == port) { - qDebug(logAudio()) << "Input Audio Device name: " << deviceInfo.deviceName(); + qInfo(logAudio()) << "Input Audio Device name: " << deviceInfo.deviceName(); isInitialized = setDevice(deviceInfo); break; } } if (!isInitialized) { - qDebug(logAudio()) << "Input device " << deviceInfo.deviceName() << " not found, using default"; + qInfo(logAudio()) << "Input device " << deviceInfo.deviceName() << " not found, using default"; isInitialized = setDevice(QAudioDeviceInfo::defaultInputDevice()); } } @@ -808,27 +808,27 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16 const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); for (const QAudioDeviceInfo& deviceInfo : deviceInfos) { if (deviceInfo.deviceName() == port) { - qDebug(logAudio()) << "Output Audio Device name: " << deviceInfo.deviceName(); + qInfo(logAudio()) << "Output Audio Device name: " << deviceInfo.deviceName(); isInitialized = setDevice(deviceInfo); break; } } if (!isInitialized) { - qDebug(logAudio()) << "Output device " << deviceInfo.deviceName() << " not found, using default"; + qInfo(logAudio()) << "Output device " << deviceInfo.deviceName() << " not found, using default"; isInitialized = setDevice(QAudioDeviceInfo::defaultOutputDevice()); } } wf_resampler_get_ratio(resampler, &ratioNum, &ratioDen); - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "wf_resampler_init() returned: " << resample_error << " ratioNum" << ratioNum << " ratioDen" << ratioDen; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "wf_resampler_init() returned: " << resample_error << " ratioNum" << ratioNum << " ratioDen" << ratioDen; - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "audio port name: " << port; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "audio port name: " << port; return isInitialized; } void audioHandler::setVolume(unsigned char volume) { - //qDebug(logAudio()) << (isInput ? "Input" : "Output") << "setVolume: " << volume << "(" << (qreal)(volume/255.0) << ")"; + //qInfo(logAudio()) << (isInput ? "Input" : "Output") << "setVolume: " << volume << "(" << (qreal)(volume/255.0) << ")"; if (audioOutput != Q_NULLPTR) { audioOutput->setVolume((qreal)(volume / 255.0)); } @@ -840,34 +840,34 @@ void audioHandler::setVolume(unsigned char volume) bool audioHandler::setDevice(QAudioDeviceInfo deviceInfo) { bool ret = true; - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "setDevice() running :" << deviceInfo.deviceName(); + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "setDevice() running :" << deviceInfo.deviceName(); if (!deviceInfo.isFormatSupported(format)) { if (deviceInfo.isNull()) { - qDebug(logAudio()) << "No audio device was found. You probably need to install libqt5multimedia-plugins."; + qInfo(logAudio()) << "No audio device was found. You probably need to install libqt5multimedia-plugins."; ret = false; } else { /* - qDebug(logAudio()) << "Audio Devices found: "; + qInfo(logAudio()) << "Audio Devices found: "; const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); for (const QAudioDeviceInfo& deviceInfo : deviceInfos) { - qDebug(logAudio()) << "Device name: " << deviceInfo.deviceName(); - qDebug(logAudio()) << "is null (probably not good):" << deviceInfo.isNull(); - qDebug(logAudio()) << "channel count:" << deviceInfo.supportedChannelCounts(); - qDebug(logAudio()) << "byte order:" << deviceInfo.supportedByteOrders(); - qDebug(logAudio()) << "supported codecs:" << deviceInfo.supportedCodecs(); - qDebug(logAudio()) << "sample rates:" << deviceInfo.supportedSampleRates(); - qDebug(logAudio()) << "sample sizes:" << deviceInfo.supportedSampleSizes(); - qDebug(logAudio()) << "sample types:" << deviceInfo.supportedSampleTypes(); + qInfo(logAudio()) << "Device name: " << deviceInfo.deviceName(); + qInfo(logAudio()) << "is null (probably not good):" << deviceInfo.isNull(); + qInfo(logAudio()) << "channel count:" << deviceInfo.supportedChannelCounts(); + qInfo(logAudio()) << "byte order:" << deviceInfo.supportedByteOrders(); + qInfo(logAudio()) << "supported codecs:" << deviceInfo.supportedCodecs(); + qInfo(logAudio()) << "sample rates:" << deviceInfo.supportedSampleRates(); + qInfo(logAudio()) << "sample sizes:" << deviceInfo.supportedSampleSizes(); + qInfo(logAudio()) << "sample types:" << deviceInfo.supportedSampleTypes(); } - qDebug(logAudio()) << "----- done with audio info -----"; + qInfo(logAudio()) << "----- done with audio info -----"; */ ret=false; } - qDebug(logAudio()) << "Format not supported, choosing nearest supported format - which may not work!"; + qInfo(logAudio()) << "Format not supported, choosing nearest supported format - which may not work!"; deviceInfo.nearestFormat(format); } this->deviceInfo = deviceInfo; @@ -877,7 +877,7 @@ bool audioHandler::setDevice(QAudioDeviceInfo deviceInfo) void audioHandler::reinit() { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "reinit() running"; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "reinit() running"; if (audioOutput != Q_NULLPTR && audioOutput->state() != QAudio::StoppedState) { this->stop(); } @@ -913,7 +913,7 @@ void audioHandler::reinit() void audioHandler::start() { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "start() running"; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "start() running"; if ((audioOutput == Q_NULLPTR || audioOutput->state() != QAudio::StoppedState) && (audioInput == Q_NULLPTR || audioInput->state() != QAudio::StoppedState) ) { @@ -933,7 +933,7 @@ void audioHandler::start() void audioHandler::flush() { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "flush() running"; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "flush() running"; this->stop(); if (isInput) { audioInput->reset(); @@ -973,7 +973,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen) // Calculate output length, always full samples int sentlen = 0; - //qDebug(logAudio()) << "Looking for: " << maxlen << " bytes"; + //qInfo(logAudio()) << "Looking for: " << maxlen << " bytes"; // We must lock the mutex for the entire time that the buffer may be modified. // Get next packet from buffer. @@ -989,7 +989,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen) int timediff = packet->time.msecsTo(QTime::currentTime()); if (timediff > (int)latency * 2) { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "Packet " << hex << packet->seq << + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "Packet " << hex << packet->seq << " arrived too late (increase output latency!) " << dec << packet->time.msecsTo(QTime::currentTime()) << "ms"; while (packet !=audioBuffer.end() && timediff > (int)latency) { @@ -1008,7 +1008,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen) { int send = qMin((int)maxlen-sentlen, packet->dataout.length() - packet->sent); lastSeq = packet->seq; - //qDebug(logAudio()) << "Packet " << hex << packet->seq << " arrived on time " << Qt::dec << packet->time.msecsTo(QTime::currentTime()) << "ms"; + //qInfo(logAudio()) << "Packet " << hex << packet->seq << " arrived on time " << Qt::dec << packet->time.msecsTo(QTime::currentTime()) << "ms"; memcpy(data + sentlen, packet->dataout.constData() + packet->sent, send); @@ -1016,7 +1016,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen) if (send == packet->dataout.length() - packet->sent) { - //qDebug(logAudio()) << "Get next packet"; + //qInfo(logAudio()) << "Get next packet"; packet = audioBuffer.erase(packet); // returns next packet } else @@ -1026,7 +1026,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen) break; } } else { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "Missing audio packet(s) from: " << hex << lastSeq + 1 << " to " << hex << packet->seq - 1; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "Missing audio packet(s) from: " << hex << lastSeq + 1 << " to " << hex << packet->seq - 1; lastSeq = packet->seq; } } @@ -1108,31 +1108,31 @@ void audioHandler::stateChanged(QAudio::State state) { case QAudio::IdleState: { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "Audio now in idle state: " << audioBuffer.length() << " packets in buffer"; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "Audio now in idle state: " << audioBuffer.length() << " packets in buffer"; if (audioOutput != Q_NULLPTR && audioOutput->error() == QAudio::UnderrunError) { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "buffer underrun"; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "buffer underrun"; audioOutput->suspend(); } break; } case QAudio::ActiveState: { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "Audio now in active state: " << audioBuffer.length() << " packets in buffer"; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "Audio now in active state: " << audioBuffer.length() << " packets in buffer"; break; } case QAudio::SuspendedState: { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "Audio now in suspended state: " << audioBuffer.length() << " packets in buffer"; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "Audio now in suspended state: " << audioBuffer.length() << " packets in buffer"; break; } case QAudio::StoppedState: { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "Audio now in stopped state: " << audioBuffer.length() << " packets in buffer"; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "Audio now in stopped state: " << audioBuffer.length() << " packets in buffer"; break; } default: { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "Unhandled audio state: " << audioBuffer.length() << " packets in buffer"; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "Unhandled audio state: " << audioBuffer.length() << " packets in buffer"; } } } @@ -1164,7 +1164,7 @@ void audioHandler::incomingAudio(audioPacket data) data.datain = inPacket; // Replace incoming data with converted. } - //qDebug(logAudio()) << "Adding packet to buffer:" << data.seq << ": " << data.datain.length(); + //qInfo(logAudio()) << "Adding packet to buffer:" << data.seq << ": " << data.datain.length(); /* We now have an array of 16bit samples in the NATIVE samplerate of the radio If the radio sample rate is below 48000, we need to resample. @@ -1185,7 +1185,7 @@ void audioHandler::incomingAudio(audioPacket data) err = wf_resampler_process_interleaved_int(resampler, (const qint16*)data.datain.constData(), &inFrames, (qint16*)data.dataout.data(), &outFrames); } if (err) { - qDebug(logAudio()) <<(isInput ? "Input" : "Output") << "Resampler error " << err << " inFrames:" << inFrames << " outFrames:" << outFrames; + qInfo(logAudio()) <<(isInput ? "Input" : "Output") << "Resampler error " << err << " inFrames:" << inFrames << " outFrames:" << outFrames; } } else { @@ -1204,7 +1204,7 @@ void audioHandler::incomingAudio(audioPacket data) // Restart playback if (audioOutput->state() == QAudio::SuspendedState) { - qDebug(logAudio()) << "Output Audio Suspended, Resuming..."; + qInfo(logAudio()) << "Output Audio Suspended, Resuming..."; audioOutput->resume(); } } @@ -1212,7 +1212,7 @@ void audioHandler::incomingAudio(audioPacket data) void audioHandler::changeLatency(const quint16 newSize) { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "Changing latency to: " << newSize << " from " << latency; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "Changing latency to: " << newSize << " from " << latency; latency = newSize; } @@ -1238,7 +1238,7 @@ void audioHandler::getNextAudioChunk(QByteArray& ret) while (packet != audioBuffer.end()) { if (packet->time.msecsTo(QTime::currentTime()) > 100) { - //qDebug(logAudio()) << "TX Packet too old " << dec << packet->time.msecsTo(QTime::currentTime()) << "ms"; + //qInfo(logAudio()) << "TX Packet too old " << dec << packet->time.msecsTo(QTime::currentTime()) << "ms"; packet = audioBuffer.erase(packet); // returns next packet } else { @@ -1265,10 +1265,10 @@ void audioHandler::getNextAudioChunk(QByteArray& ret) err = wf_resampler_process_interleaved_int(resampler, in, &inFrames, out, &outFrames); } if (err) { - qDebug(logAudio()) << (isInput ? "Input" : "Output") << "Resampler error " << err << " inFrames:" << inFrames << " outFrames:" << outFrames; + qInfo(logAudio()) << (isInput ? "Input" : "Output") << "Resampler error " << err << " inFrames:" << inFrames << " outFrames:" << outFrames; } - //qDebug(logAudio()) << "Resampler run " << err << " inFrames:" << inFrames << " outFrames:" << outFrames; - //qDebug(logAudio()) << "Resampler run inLen:" << packet->datain.length() << " outLen:" << packet->dataout.length(); + //qInfo(logAudio()) << "Resampler run " << err << " inFrames:" << inFrames << " outFrames:" << outFrames; + //qInfo(logAudio()) << "Resampler run inLen:" << packet->datain.length() << " outLen:" << packet->dataout.length(); if (radioSampleBits == 8) { packet->datain=packet->dataout; // Copy output packet back to input buffer. diff --git a/commhandler.cpp b/commhandler.cpp index 7a31f2c..4400465 100644 --- a/commhandler.cpp +++ b/commhandler.cpp @@ -23,9 +23,9 @@ commHandler::commHandler() setupComm(); // basic parameters openPort(); - //qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize(); + //qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize(); //port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why... - //qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize(); + //qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize(); connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn())); } @@ -48,9 +48,9 @@ commHandler::commHandler(QString portName, quint32 baudRate) setupComm(); // basic parameters openPort(); - // qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize(); + // qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize(); //port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why... - //qDebug(logSerial()) << "Serial buffer size: " << port->readBufferSize(); + //qInfo(logSerial()) << "Serial buffer size: " << port->readBufferSize(); connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn())); } @@ -79,11 +79,9 @@ void commHandler::sendDataOut(const QByteArray &writeData) mutex.lock(); -#ifdef QT_DEBUG - qint64 bytesWritten; - bytesWritten = port->write(writeData); + if(bytesWritten != (qint64)writeData.size()) { qDebug(logSerial()) << "bytesWritten: " << bytesWritten << " length of byte array: " << writeData.length()\ @@ -91,10 +89,6 @@ void commHandler::sendDataOut(const QByteArray &writeData) << " Wrote all bytes? " << (bool) (bytesWritten == (qint64)writeData.size()); } -#else - port->write(writeData); - -#endif mutex.unlock(); } @@ -118,21 +112,21 @@ void commHandler::receiveDataIn() if(rolledBack) { - // qDebug(logSerial()) << "Rolled back and was successfull. Length: " << inPortData.length(); + // qInfo(logSerial()) << "Rolled back and was successfull. Length: " << inPortData.length(); //printHex(inPortData, false, true); rolledBack = false; } } else { // did not receive the entire thing so roll back: - // qDebug(logSerial()) << "Rolling back transaction. End not detected. Lenth: " << inPortData.length(); + // qInfo(logSerial()) << "Rolling back transaction. End not detected. Lenth: " << inPortData.length(); //printHex(inPortData, false, true); port->rollbackTransaction(); rolledBack = true; } } else { port->commitTransaction(); // do not emit data, do not keep data. - //qDebug(logSerial()) << "Warning: received data with invalid start. Dropping data."; - //qDebug(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!"; + //qInfo(logSerial()) << "Warning: received data with invalid start. Dropping data."; + //qInfo(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!"; // THIS SHOULD ONLY HAPPEN ONCE! // unrecoverable. We did not receive the start and must @@ -154,10 +148,10 @@ void commHandler::openPort() port->setDataTerminalReady(false); port->setRequestToSend(false); isConnected = true; - qDebug(logSerial()) << "Opened port: " << portName; + qInfo(logSerial()) << "Opened port: " << portName; return; } else { - qDebug(logSerial()) << "Could not open serial port " << portName << " , please restart."; + qInfo(logSerial()) << "Could not open serial port " << portName << " , please restart."; isConnected = false; serialError = true; emit haveSerialPortError(portName, "Could not open port. Please restart."); @@ -178,7 +172,7 @@ void commHandler::closePort() void commHandler::debugThis() { // Do not use, function is for debug only and subject to change. - qDebug(logSerial()) << "comm debug called."; + qInfo(logSerial()) << "comm debug called."; inPortData = port->readAll(); emit haveDataFromPort(inPortData); diff --git a/freqmemory.cpp b/freqmemory.cpp index 6934925..9a137c0 100644 --- a/freqmemory.cpp +++ b/freqmemory.cpp @@ -15,7 +15,7 @@ freqMemory::freqMemory() void freqMemory::initializePresets() { - // qDebug() << "Initializing " << numPresets << " memory channels"; + // qInfo() << "Initializing " << numPresets << " memory channels"; for(unsigned int p=0; p < numPresets; p++) { @@ -61,6 +61,6 @@ void freqMemory::dumpMemory() { for(unsigned int p=0; p < numPresets; p++) { - qDebug(logSystem()) << "Index: " << p << " freq: " << presets[p].frequency << " Mode: " << presets[p].mode << " isSet: " << presets[p].isSet; + qInfo(logSystem()) << "Index: " << p << " freq: " << presets[p].frequency << " Mode: " << presets[p].mode << " isSet: " << presets[p].isSet; } } diff --git a/main.cpp b/main.cpp index add5e58..6928b99 100644 --- a/main.cpp +++ b/main.cpp @@ -8,6 +8,7 @@ // Smart pointer to log file QScopedPointer m_logFile; QMutex logMutex; +bool debugMode=false; void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg); @@ -20,7 +21,9 @@ int main(int argc, char *argv[]) a.setOrganizationDomain("wfview.org"); a.setApplicationName("wfview"); - +#ifdef QT_DEBUG + debugMode = true; +#endif QString serialPortCL; QString hostCL; @@ -30,21 +33,26 @@ int main(int argc, char *argv[]) QString currentArg; - const QString helpText = QString("\nUsage: -p --port /dev/port, -h --host remotehostname, -c --civ 0xAddr, -l --logfile filename.log\n"); // TODO... + const QString helpText = QString("\nUsage: -p --port /dev/port, -h --host remotehostname, -c --civ 0xAddr, -l --logfile filename.log, -d --debug\n"); // TODO... for(int c=1; c c) + if (argc > c) { - serialPortCL = argv[c+1]; - c+=1; + serialPortCL = argv[c + 1]; + c += 1; } - } else if ((currentArg == "-h") || (currentArg == "--host")) + } + else if((currentArg == "-d") || (currentArg == "--debug")) + { + debugMode = true; + } + else if ((currentArg == "-h") || (currentArg == "--host")) { if(argc > c) { @@ -90,11 +98,9 @@ int main(int argc, char *argv[]) qInfo(logSystem()) << "Starting wfview"; -#ifdef QT_DEBUG - qInfo(logSystem()) << "SerialPortCL as set by parser: " << serialPortCL; - qInfo(logSystem()) << "remote host as set by parser: " << hostCL; - qInfo(logSystem()) << "CIV as set by parser: " << civCL; -#endif + qDebug(logSystem()) << "SerialPortCL as set by parser: " << serialPortCL; + qDebug(logSystem()) << "remote host as set by parser: " << hostCL; + qDebug(logSystem()) << "CIV as set by parser: " << civCL; a.setWheelScrollLines(1); // one line per wheel click wfmain w( serialPortCL, hostCL); @@ -110,6 +116,10 @@ int main(int argc, char *argv[]) void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) { // Open stream file writes + if (type == QtDebugMsg && !debugMode) + { + return; + } QMutexLocker locker(&logMutex); QTextStream out(m_logFile.data()); @@ -119,11 +129,21 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt switch (type) { - case QtInfoMsg: out << "INF "; break; - case QtDebugMsg: out << "DBG "; break; - case QtWarningMsg: out << "WRN "; break; - case QtCriticalMsg: out << "CRT "; break; - case QtFatalMsg: out << "FTL "; break; + case QtDebugMsg: + out << "DBG "; + break; + case QtInfoMsg: + out << "INF "; + break; + case QtWarningMsg: + out << "WRN "; + break; + case QtCriticalMsg: + out << "CRT "; + break; + case QtFatalMsg: + out << "FTL "; + break; } // Write to the output category of the message and the message itself out << context.category << ": " << msg << "\n"; diff --git a/pttyhandler.cpp b/pttyhandler.cpp index 63b272a..d24f5f0 100644 --- a/pttyhandler.cpp +++ b/pttyhandler.cpp @@ -57,20 +57,20 @@ void pttyHandler::openPort() if (ptfd >=0) { - qDebug(logSerial()) << "Opened pt device: " << ptfd << ", attempting to grant pt status"; + qInfo(logSerial()) << "Opened pt device: " << ptfd << ", attempting to grant pt status"; if (grantpt(ptfd)) { - qDebug(logSerial()) << "Failed to grantpt"; + qInfo(logSerial()) << "Failed to grantpt"; return; } if (unlockpt(ptfd)) { - qDebug(logSerial()) << "Failed to unlock pt"; + qInfo(logSerial()) << "Failed to unlock pt"; return; } // we're good! - qDebug(logSerial()) << "Opened pseudoterminal, slave name :" << ptsname(ptfd); + qInfo(logSerial()) << "Opened pseudoterminal, slave name :" << ptsname(ptfd); ptReader = new QSocketNotifier(ptfd, QSocketNotifier::Read, this); connect(ptReader, &QSocketNotifier::activated, @@ -83,7 +83,7 @@ void pttyHandler::openPort() if (!success) { ptfd = 0; - qDebug(logSerial()) << "Could not open pseudo terminal port, please restart."; + qInfo(logSerial()) << "Could not open pseudo terminal port, please restart."; isConnected = false; serialError = true; emit haveSerialPortError(portName, "Could not open pseudo terminal port. Please restart."); @@ -98,9 +98,9 @@ void pttyHandler::openPort() { if (!QFile::link(ptDevSlave, portName)) { - qDebug(logSerial()) << "Error creating link to" << ptDevSlave << "from" << portName; + qInfo(logSerial()) << "Error creating link to" << ptDevSlave << "from" << portName; } else { - qDebug(logSerial()) << "Created link to" << ptDevSlave << "from" << portName; + qInfo(logSerial()) << "Created link to" << ptDevSlave << "from" << portName; } } #endif @@ -123,7 +123,7 @@ void pttyHandler::receiveDataFromRigToPtty(const QByteArray& data) // 0xE1 = wfview // 0xE0 = pseudo-term host // 0x00 = broadcast to all - //qDebug(logSerial()) << "Sending data from radio to pseudo-terminal"; + //qInfo(logSerial()) << "Sending data from radio to pseudo-terminal"; sendDataOut(data); } } @@ -132,7 +132,7 @@ void pttyHandler::sendDataOut(const QByteArray& writeData) { qint64 bytesWritten = 0; - //qDebug(logSerial()) << "Data to pseudo term:"; + //qInfo(logSerial()) << "Data to pseudo term:"; //printHex(writeData, false, true); if (isConnected) { mutex.lock(); @@ -142,7 +142,7 @@ void pttyHandler::sendDataOut(const QByteArray& writeData) bytesWritten = ::write(ptfd, writeData.constData(), writeData.size()); #endif if (bytesWritten != writeData.length()) { - qDebug(logSerial()) << "bytesWritten: " << bytesWritten << " length of byte array: " << writeData.length()\ + qInfo(logSerial()) << "bytesWritten: " << bytesWritten << " length of byte array: " << writeData.length()\ << " size of byte array: " << writeData.size()\ << " Wrote all bytes? " << (bool)(bytesWritten == (qint64)writeData.size()); } @@ -174,7 +174,7 @@ void pttyHandler::receiveDataIn(int fd) { ssize_t got = ::read(fd, inPortData.data(), available); int err = errno; if (got < 0) { - qDebug(logSerial()) << tr("Read failed: %1").arg(QString::fromLatin1(strerror(err))); + qInfo(logSerial()) << tr("Read failed: %1").arg(QString::fromLatin1(strerror(err))); return; } inPortData.resize(got); @@ -193,18 +193,18 @@ void pttyHandler::receiveDataIn(int fd) { if (civId == 0 && inPortData.length() > lastFE + 2 && (quint8)inPortData[lastFE + 2] > (quint8)0xdf && (quint8)inPortData[lastFE + 2] < (quint8)0xef) { // This is (should be) the remotes CIV id. civId = (quint8)inPortData[lastFE + 2]; - qDebug(logSerial()) << "pty detected remote CI-V:" << hex << civId; + qInfo(logSerial()) << "pty detected remote CI-V:" << hex << civId; } else if (civId != 0 && inPortData.length() > lastFE + 2 && (quint8)inPortData[lastFE + 2] != civId) { civId = (quint8)inPortData[lastFE + 2]; - qDebug(logSerial()) << "pty remote CI-V changed:" << hex << (quint8)civId; + qInfo(logSerial()) << "pty remote CI-V changed:" << hex << (quint8)civId; } // filter 1A 05 01 12/27 = C-IV transceive command before forwarding on. if (inPortData.contains(QByteArrayLiteral("\x1a\x05\x01\x12")) || inPortData.contains(QByteArrayLiteral("\x1a\x05\x01\x27"))) { - //qDebug(logSerial()) << "Filtered transceive command"; + //qInfo(logSerial()) << "Filtered transceive command"; //printHex(inPortData, false, true); QByteArray reply= QByteArrayLiteral("\xfe\xfe\x00\x00\xfb\xfd"); reply[2] = inPortData[3]; @@ -215,20 +215,20 @@ void pttyHandler::receiveDataIn(int fd) { else if (inPortData.length() > lastFE + 2 && ((quint8)inPortData[lastFE + 1] == civId || (quint8)inPortData[lastFE + 2] == civId)) { emit haveDataFromPort(inPortData); - //qDebug(logSerial()) << "Data from pseudo term:"; + //qInfo(logSerial()) << "Data from pseudo term:"; //printHex(inPortData, false, true); } if (rolledBack) { - // qDebug(logSerial()) << "Rolled back and was successfull. Length: " << inPortData.length(); + // qInfo(logSerial()) << "Rolled back and was successfull. Length: " << inPortData.length(); //printHex(inPortData, false, true); rolledBack = false; } } else { // did not receive the entire thing so roll back: - // qDebug(logSerial()) << "Rolling back transaction. End not detected. Lenth: " << inPortData.length(); + // qInfo(logSerial()) << "Rolling back transaction. End not detected. Lenth: " << inPortData.length(); //printHex(inPortData, false, true); rolledBack = true; #ifdef Q_OS_WIN @@ -237,8 +237,8 @@ void pttyHandler::receiveDataIn(int fd) { } else { port->commitTransaction(); // do not emit data, do not keep data. - //qDebug(logSerial()) << "Warning: received data with invalid start. Dropping data."; - //qDebug(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!"; + //qInfo(logSerial()) << "Warning: received data with invalid start. Dropping data."; + //qInfo(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!"; // THIS SHOULD ONLY HAPPEN ONCE! } #else @@ -270,7 +270,7 @@ void pttyHandler::closePort() void pttyHandler::debugThis() { // Do not use, function is for debug only and subject to change. - qDebug(logSerial()) << "comm debug called."; + qInfo(logSerial()) << "comm debug called."; inPortData = port->readAll(); emit haveDataFromPort(inPortData); diff --git a/qledlabel.cpp b/qledlabel.cpp index 2a13395..640b1c4 100644 --- a/qledlabel.cpp +++ b/qledlabel.cpp @@ -17,7 +17,7 @@ QLedLabel::QLedLabel(QWidget* parent) : void QLedLabel::setState(State state) { - qDebug() << "setState" << state; + qInfo() << "setState" << state; switch (state) { case StateOk: setStyleSheet(greenSS); diff --git a/rigcommander.cpp b/rigcommander.cpp index 8719fe7..08b1818 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -192,7 +192,7 @@ void rigCommander::process() void rigCommander::handleSerialPortError(const QString port, const QString errorText) { - qDebug(logRig()) << "Error using port " << port << " message: " << errorText; + qInfo(logRig()) << "Error using port " << port << " message: " << errorText; emit haveSerialPortError(port, errorText); } @@ -230,14 +230,14 @@ void rigCommander::prepDataAndSend(QByteArray data) data.prepend(payloadPrefix); //printHex(data, false, true); data.append(payloadSuffix); -#ifdef QT_DEBUG + if(data[4] != '\x15') { // We don't print out requests for meter levels qDebug(logRig()) << "Final payload in rig commander to be sent to rig: "; printHex(data); } -#endif + emit dataForComm(data); } @@ -254,10 +254,8 @@ void rigCommander::powerOn() payload.append("\x18\x01"); payload.append(payloadSuffix); // FD -#ifdef QT_DEBUG qDebug(logRig()) << "Power ON command in rigcommander to be sent to rig: "; printHex(payload); -#endif emit dataForComm(payload); @@ -497,7 +495,7 @@ void rigCommander::getSpectrumRefLevel(unsigned char mainSub) void rigCommander::setSpectrumRefLevel(int level) { - //qDebug(logRig()) << __func__ << ": Setting scope to level " << level; + //qInfo(logRig()) << __func__ << ": Setting scope to level " << level; QByteArray setting; QByteArray number; QByteArray pn; @@ -515,7 +513,7 @@ void rigCommander::setSpectrumRefLevel(int level) setting.append(number); setting.append(pn); - //qDebug(logRig()) << __func__ << ": scope reference number: " << number << ", PN to: " << pn; + //qInfo(logRig()) << __func__ << ": scope reference number: " << number << ", PN to: " << pn; //printHex(setting, false, true); prepDataAndSend(setting); @@ -590,7 +588,7 @@ QByteArray rigCommander::makeFreqPayload(double freq) result.append(a); //printHex(result, false, true); } - //qDebug(logRig()) << "encoded frequency for " << freq << " as int " << freqInt; + //qInfo(logRig()) << "encoded frequency for " << freq << " as int " << freqInt; //printHex(result, false, true); return result; } @@ -762,7 +760,7 @@ void rigCommander::setTone(quint16 tone) payload.setRawData("\x1B\x00", 2); payload.append(fenc); - //qDebug() << __func__ << "TONE encoded payload: "; + //qInfo() << __func__ << "TONE encoded payload: "; printHex(payload); prepDataAndSend(payload); @@ -776,7 +774,7 @@ void rigCommander::setTSQL(quint16 tsql) payload.setRawData("\x1B\x01", 2); payload.append(fenc); - //qDebug() << __func__ << "TSQL encoded payload: "; + //qInfo() << __func__ << "TSQL encoded payload: "; printHex(payload); prepDataAndSend(payload); @@ -791,7 +789,7 @@ void rigCommander::setDTCS(quint16 dcscode, bool tinv, bool rinv) payload.setRawData("\x1B\x02", 2); payload.append(denc); - //qDebug() << __func__ << "DTCS encoded payload: "; + //qInfo() << __func__ << "DTCS encoded payload: "; printHex(payload); prepDataAndSend(payload); @@ -987,7 +985,7 @@ void rigCommander::parseData(QByteArray dataInput) // use this: QList dataList = dataInput.split('\xFD'); QByteArray data; - // qDebug(logRig()) << "data list has this many elements: " << dataList.size(); + // qInfo(logRig()) << "data list has this many elements: " << dataList.size(); if (dataList.last().isEmpty()) { dataList.removeLast(); // if the original ended in FD, then there is a blank entry at the end. @@ -1011,14 +1009,14 @@ void rigCommander::parseData(QByteArray dataInput) // Data from the rig that was not asked for is sent to controller 0x00: // fe fe 00 94 ...... fd (for example, user rotates the tune control or changes the mode) - //qDebug(logRig()) << "Data received: "; + //qInfo(logRig()) << "Data received: "; //printHex(data, false, true); if(data.length() < 4) { if(data.length()) { // Finally this almost never happens - // qDebug(logRig()) << "Data length too short: " << data.length() << " bytes. Data:"; + // qInfo(logRig()) << "Data length too short: " << data.length() << " bytes. Data:"; //printHex(data, false, true); } // no @@ -1029,18 +1027,18 @@ void rigCommander::parseData(QByteArray dataInput) if(!data.startsWith("\xFE\xFE")) { - // qDebug(logRig()) << "Warning: Invalid data received, did not start with FE FE."; + // qInfo(logRig()) << "Warning: Invalid data received, did not start with FE FE."; // find 94 e0 and shift over, // or look inside for a second FE FE // Often a local echo will miss a few bytes at the beginning. if(data.startsWith('\xFE')) { data.prepend('\xFE'); - // qDebug(logRig()) << "Warning: Working with prepended data stream."; + // qInfo(logRig()) << "Warning: Working with prepended data stream."; parseData(payloadIn); return; } else { - //qDebug(logRig()) << "Error: Could not reconstruct corrupted data: "; + //qInfo(logRig()) << "Error: Could not reconstruct corrupted data: "; //printHex(data, false, true); // data.right(data.length() - data.find('\xFE\xFE')); // if found do not return and keep going. @@ -1053,7 +1051,7 @@ void rigCommander::parseData(QByteArray dataInput) // data is or begins with an echoback from what we sent // find the first 'fd' and cut it. Then continue. //payloadIn = data.right(data.length() - data.indexOf('\xfd')-1); - // qDebug(logRig()) << "[FOUND] Trimmed off echo:"; + // qInfo(logRig()) << "[FOUND] Trimmed off echo:"; //printHex(payloadIn, false, true); //parseData(payloadIn); //return; @@ -1067,7 +1065,7 @@ void rigCommander::parseData(QByteArray dataInput) // // data is or begins with an echoback from what we sent // // find the first 'fd' and cut it. Then continue. // payloadIn = data.right(data.length() - data.indexOf('\xfd')-1); - // //qDebug(logRig()) << "Trimmed off echo:"; + // //qInfo(logRig()) << "Trimmed off echo:"; // //printHex(payloadIn, false, true); // parseData(payloadIn); // break; @@ -1090,9 +1088,7 @@ void rigCommander::parseData(QByteArray dataInput) // This is an echo of our own broadcast request. // The data are "to 00" and "from E1" // Don't use it! -#ifdef QT_DEBUG qDebug(logRig()) << "Caught it! Found the echo'd broadcast request from us!"; -#endif } else { payloadIn = data.right(data.length() - 4); parseCommand(); @@ -1108,7 +1104,7 @@ void rigCommander::parseData(QByteArray dataInput) /* if(dataList.length() > 1) { - qDebug(logRig()) << "Recovered " << count << " frames from single data with size" << dataList.count(); + qInfo(logRig()) << "Recovered " << count << " frames from single data with size" << dataList.count(); } */ } @@ -1117,7 +1113,6 @@ void rigCommander::parseCommand() { // note: data already is trimmed of the beginning FE FE E0 94 stuff. -#ifdef QT_DEBUG bool isSpectrumData = payloadIn.startsWith(QByteArray().setRawData("\x27\x00", 2)); if( (!isSpectrumData) && (payloadIn[00] != '\x15') ) @@ -1126,7 +1121,6 @@ void rigCommander::parseCommand() // as they tend to clog up any useful logging. printHex(payloadIn); } -#endif switch(payloadIn[00]) { @@ -1145,19 +1139,19 @@ void rigCommander::parseCommand() } break; case '\x01': - //qDebug(logRig()) << "Have mode data"; + //qInfo(logRig()) << "Have mode data"; this->parseMode(); break; case '\x04': - //qDebug(logRig()) << "Have mode data"; + //qInfo(logRig()) << "Have mode data"; this->parseMode(); break; case '\x05': - //qDebug(logRig()) << "Have frequency data"; + //qInfo(logRig()) << "Have frequency data"; this->parseFrequency(); break; case '\x06': - //qDebug(logRig()) << "Have mode data"; + //qInfo(logRig()) << "Have mode data"; this->parseMode(); break; case '\x0F': @@ -1178,11 +1172,11 @@ void rigCommander::parseCommand() parseRegister16(); break; case '\x19': - // qDebug(logRig()) << "Have rig ID: " << (unsigned int)payloadIn[2]; + // qInfo(logRig()) << "Have rig ID: " << (unsigned int)payloadIn[2]; // printHex(payloadIn, false, true); model = determineRadioModel(payloadIn[2]); // verify this is the model not the CIV determineRigCaps(); - qDebug(logRig()) << "Have rig ID: decimal: " << (unsigned int)model; + qInfo(logRig()) << "Have rig ID: decimal: " << (unsigned int)model; break; @@ -1201,7 +1195,7 @@ void rigCommander::parseCommand() break; case '\x27': // scope data - //qDebug(logRig()) << "Have scope data"; + //qInfo(logRig()) << "Have scope data"; //printHex(payloadIn, false, true); parseWFData(); //parseSpectrum(); @@ -1225,16 +1219,15 @@ void rigCommander::parseCommand() break; case '\xFA': // error -#ifdef QT_DEBUG + qDebug(logRig()) << "Error (FA) received from rig."; printHex(payloadIn, false ,true); -#endif break; default: // This gets hit a lot when the pseudo-term is // using commands wfview doesn't know yet. - // qDebug(logRig()) << "Have other data with cmd: " << std::hex << payloadIn[00]; + // qInfo(logRig()) << "Have other data with cmd: " << std::hex << payloadIn[00]; // printHex(payloadIn, false, true); break; } @@ -1244,7 +1237,7 @@ void rigCommander::parseCommand() void rigCommander::parseLevels() { - //qDebug(logRig()) << "Received a level status readout: "; + //qInfo(logRig()) << "Received a level status readout: "; // printHex(payloadIn, false, true); // wrong: unsigned char level = (payloadIn[2] * 100) + payloadIn[03]; @@ -1254,7 +1247,7 @@ void rigCommander::parseLevels() unsigned char level = (100*hundreds) + (10*tens) + units; - //qDebug(logRig()) << "Level is: " << (int)level << " or " << 100.0*level/255.0 << "%"; + //qInfo(logRig()) << "Level is: " << (int)level << " or " << 100.0*level/255.0 << "%"; // Typical RF gain response (rather low setting): // "INDEX: 00 01 02 03 04 " @@ -1305,7 +1298,7 @@ void rigCommander::parseLevels() break; default: - qDebug(logRig()) << "Unknown control level (0x14) received at register " << payloadIn[1] << " with level " << level; + qInfo(logRig()) << "Unknown control level (0x14) received at register " << payloadIn[1] << " with level " << level; break; } @@ -1346,7 +1339,7 @@ void rigCommander::parseLevels() break; default: - qDebug(logRig()) << "Unknown meter level (0x15) received at register " << payloadIn[1] << " with level " << level; + qInfo(logRig()) << "Unknown meter level (0x15) received at register " << payloadIn[1] << " with level " << level; break; } @@ -1910,7 +1903,7 @@ void rigCommander::setRefAdjustCourse(unsigned char level) void rigCommander::setRefAdjustFine(unsigned char level) { - qDebug(logRig()) << __FUNCTION__ << " level: " << level; + qInfo(logRig()) << __FUNCTION__ << " level: " << level; // 1A 05 00 73 0000-0255 QByteArray payload; payload.setRawData("\x1A\x05\x00\x73", 4); @@ -2012,7 +2005,7 @@ void rigCommander::parseRegister21() void rigCommander::parseATU() { - // qDebug(logRig()) << "Have ATU status from radio. Emitting."; + // qInfo(logRig()) << "Have ATU status from radio. Emitting."; // Expect: // [0]: 0x1c // [1]: 0x01 @@ -2046,7 +2039,7 @@ void rigCommander::parseRegisters1A() // 01: band stacking memory contents (last freq used is stored here per-band) // 03: filter width // 04: AGC rate - // qDebug(logRig()) << "Looking at register 1A :"; + // qInfo(logRig()) << "Looking at register 1A :"; // printHex(payloadIn, false, true); // "INDEX: 00 01 02 03 04 " @@ -2133,7 +2126,7 @@ void rigCommander::parseRegister16() void rigCommander::parseBandStackReg() { - //qDebug(logRig()) << "Band stacking register response received: "; + //qInfo(logRig()) << "Band stacking register response received: "; //printHex(payloadIn, false, true); // Reference output, 20 meters, regCode 01 (latest): @@ -2156,9 +2149,9 @@ void rigCommander::parseBandStackReg() // 14, 15 tone squelch freq setting // if more, memory name (label) ascii - qDebug(logRig()) << "BSR in rigCommander: band: " << QString("%1").arg(band) << " regCode: " << (QString)regCode << " freq Hz: " << freqs.Hz << ", mode: " << (unsigned int)mode << ", filter: " << (unsigned int)filter << " data: " << dataOn; - //qDebug(logRig()) << "mode: " << (QString)mode << " dataOn: " << dataOn; - //qDebug(logRig()) << "Freq Hz: " << freqs.Hz; + qInfo(logRig()) << "BSR in rigCommander: band: " << QString("%1").arg(band) << " regCode: " << (QString)regCode << " freq Hz: " << freqs.Hz << ", mode: " << (unsigned int)mode << ", filter: " << (unsigned int)filter << " data: " << dataOn; + //qInfo(logRig()) << "mode: " << (QString)mode << " dataOn: " << dataOn; + //qInfo(logRig()) << "Freq Hz: " << freqs.Hz; emit haveBandStackReg(freqs, mode, filter, dataOn); } @@ -2447,20 +2440,20 @@ void rigCommander::parseWFData() isSub = payloadIn.at(2)==0x01; freqSpan = parseFrequency(payloadIn, 6); emit haveScopeSpan(freqSpan, isSub); - qDebug(logRig()) << "Received 0x15 center span data: for frequency " << freqSpan.Hz; + qInfo(logRig()) << "Received 0x15 center span data: for frequency " << freqSpan.Hz; //printHex(payloadIn, false, true); break; case 0x16: // read edge mode center in edge mode emit haveScopeEdge((char)payloadIn[2]); - qDebug(logRig()) << "Received 0x16 edge in center mode:"; + qInfo(logRig()) << "Received 0x16 edge in center mode:"; printHex(payloadIn, false, true); // [1] 0x16 // [2] 0x01, 0x02, 0x03: Edge 1,2,3 break; case 0x17: // Hold status (only 9700?) - qDebug(logRig()) << "Received 0x17 hold status - need to deal with this!"; + qInfo(logRig()) << "Received 0x17 hold status - need to deal with this!"; printHex(payloadIn, false, true); break; case 0x19: @@ -2473,7 +2466,7 @@ void rigCommander::parseWFData() parseSpectrumRefLevel(); break; default: - qDebug(logRig()) << "Unknown waveform data received: "; + qInfo(logRig()) << "Unknown waveform data received: "; printHex(payloadIn, false, true); break; } @@ -2816,7 +2809,7 @@ void rigCommander::determineRigCaps() rigCaps.bands = standardHF; rigCaps.bands.insert(rigCaps.bands.end(), standardVU.begin(), standardVU.end()); rigCaps.bands.insert(rigCaps.bands.end(), {band23cm, band4m, band630m, band2200m, bandGen}); - qDebug(logRig()) << "Found unknown rig: " << rigCaps.modelName; + qInfo(logRig()) << "Found unknown rig: " << rigCaps.modelName; break; } haveRigCaps = true; @@ -2824,15 +2817,14 @@ void rigCommander::determineRigCaps() { lookingForRig = false; foundRig = true; -#ifdef QT_DEBUG + qDebug(logRig()) << "---Rig FOUND from broadcast query:"; -#endif this->civAddr = incomingCIVAddr; // Override and use immediately. payloadPrefix = QByteArray("\xFE\xFE"); payloadPrefix.append(civAddr); payloadPrefix.append((char)compCivAddr); // if there is a compile-time error, remove the following line, the "hex" part is the issue: - qDebug(logRig()) << "Using incomingCIVAddr: (int): " << this->civAddr << " hex: " << hex << this->civAddr; + qInfo(logRig()) << "Using incomingCIVAddr: (int): " << this->civAddr << " hex: " << hex << this->civAddr; emit discoveredRigID(rigCaps); } else { emit haveRigID(rigCaps); @@ -2843,15 +2835,13 @@ void rigCommander::parseSpectrum() { if(!haveRigCaps) { -#ifdef QT_DEBUG qDebug(logRig()) << "Spectrum received in rigCommander, but rigID is incomplete."; -#endif return; } if(rigCaps.spectSeqMax == 0) { // there is a chance this will happen with rigs that support spectrum. Once our RigID query returns, we will parse correctly. - qDebug(logRig()) << "Warning: Spectrum sequence max was zero, yet spectrum was received."; + qInfo(logRig()) << "Warning: Spectrum sequence max was zero, yet spectrum was received."; return; } // Here is what to expect: @@ -2894,7 +2884,7 @@ void rigCommander::parseSpectrum() // unsigned char waveInfo = payloadIn[06]; // really just one byte? - //qDebug(logRig()) << "Spectrum Data received: " << sequence << "/" << sequenceMax << " mode: " << scopeMode << " waveInfo: " << waveInfo << " length: " << payloadIn.length(); + //qInfo(logRig()) << "Spectrum Data received: " << sequence << "/" << sequenceMax << " mode: " << scopeMode << " waveInfo: " << waveInfo << " length: " << payloadIn.length(); // Sequnce 2, index 05 is the start of data // Sequence 11. index 05, is the last chunk @@ -2949,13 +2939,13 @@ void rigCommander::parseSpectrum() // sequence numbers 2 through 10, 50 pixels each. Total after sequence 10 is 450 pixels. payloadIn.chop(1); spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5)); // write over the FD, last one doesn't, oh well. - //qDebug(logRig()) << "sequence: " << sequence << "spec index: " << (sequence-2)*55 << " payloadPosition: " << payloadIn.length() - 5 << " payload length: " << payloadIn.length(); + //qInfo(logRig()) << "sequence: " << sequence << "spec index: " << (sequence-2)*55 << " payloadPosition: " << payloadIn.length() - 5 << " payload length: " << payloadIn.length(); } else if (sequence == rigCaps.spectSeqMax) { // last spectrum, a little bit different (last 25 pixels). Total at end is 475 pixels (7300). payloadIn.chop(1); spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5)); - //qDebug(logRig()) << "sequence: " << sequence << " spec index: " << (sequence-2)*55 << " payloadPosition: " << payloadIn.length() - 5 << " payload length: " << payloadIn.length(); + //qInfo(logRig()) << "sequence: " << sequence << " spec index: " << (sequence-2)*55 << " payloadPosition: " << payloadIn.length() - 5 << " payload length: " << payloadIn.length(); emit haveSpectrumData(spectrumLine, spectrumStartFreq, spectrumEndFreq); } } @@ -3023,7 +3013,7 @@ QByteArray rigCommander::bcdEncodeInt(unsigned int num) { if(num > 9999) { - qDebug(logRig()) << __FUNCTION__ << "Error, number is too big for four-digit conversion: " << num; + qInfo(logRig()) << __FUNCTION__ << "Error, number is too big for four-digit conversion: " << num; return QByteArray(); } @@ -3035,7 +3025,7 @@ QByteArray rigCommander::bcdEncodeInt(unsigned int num) char b0 = hundreds | (thousands << 4); char b1 = units | (tens << 4); - //qDebug(logRig()) << __FUNCTION__ << " encoding value " << num << " as hex:"; + //qInfo(logRig()) << __FUNCTION__ << " encoding value " << num << " as hex:"; //printHex(QByteArray(b0), false, true); //printHex(QByteArray(b1), false, true); @@ -3204,7 +3194,7 @@ void rigCommander::setATU(bool enabled) void rigCommander::getATUStatus() { - //qDebug(logRig()) << "Sending out for ATU status in RC."; + //qInfo(logRig()) << "Sending out for ATU status in RC."; QByteArray payload("\x1C\x01"); prepDataAndSend(payload); } @@ -3343,7 +3333,7 @@ void rigCommander::printHex(const QByteArray &pdata, bool printVert, bool printH void rigCommander::dataFromServer(QByteArray data) { - //qDebug(logRig()) << "emit dataForComm()"; + //qInfo(logRig()) << "emit dataForComm()"; emit dataForComm(data); } diff --git a/rigctld.cpp b/rigctld.cpp index 8fd1991..66fc336 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -18,7 +18,7 @@ void rigCtlD::receiveFrequency(freqt freq) void rigCtlD::receiveStateInfo(rigStateStruct* state) { - qDebug("Setting rig state"); + qInfo("Setting rig state"); rigState = state; } @@ -27,12 +27,12 @@ void rigCtlD::receiveStateInfo(rigStateStruct* state) int rigCtlD::startServer(qint16 port) { if (!this->listen(QHostAddress::Any, port)) { - qDebug(logRigCtlD()) << "could not start on port " << port; + qInfo(logRigCtlD()) << "could not start on port " << port; return -1; } else { - qDebug(logRigCtlD()) << "started on port " << port; + qInfo(logRigCtlD()) << "started on port " << port; } return 0; } @@ -45,13 +45,13 @@ void rigCtlD::incomingConnection(qintptr socket) { void rigCtlD::stopServer() { - qDebug(logRigCtlD()) << "stopping server"; + qInfo(logRigCtlD()) << "stopping server"; emit onStopped(); } void rigCtlD::receiveRigCaps(rigCapabilities caps) { - qDebug(logRigCtlD()) << "Got rigcaps for:" << caps.modelName; + qInfo(logRigCtlD()) << "Got rigcaps for:" << caps.modelName; this->rigCaps = caps; } @@ -66,13 +66,13 @@ rigCtlClient::rigCtlClient(int socketId, rigCapabilities caps, rigStateStruct* s this->parent = parent; if (!socket->setSocketDescriptor(sessionId)) { - qDebug(logRigCtlD()) << " error binding socket: " << sessionId; + qInfo(logRigCtlD()) << " error binding socket: " << sessionId; return; } connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()), Qt::DirectConnection); connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()), Qt::DirectConnection); connect(parent, SIGNAL(sendData(QString)), this, SLOT(sendData(QString)), Qt::DirectConnection); - qDebug(logRigCtlD()) << " session connected: " << sessionId; + qInfo(logRigCtlD()) << " session connected: " << sessionId; } void rigCtlClient::socketReadyRead() @@ -84,7 +84,7 @@ void rigCtlClient::socketReadyRead() bool longReply = false; if (commandBuffer.endsWith('\n')) { - qDebug(logRigCtlD()) << sessionId << "command received" << commandBuffer; + qInfo(logRigCtlD()) << sessionId << "command received" << commandBuffer; commandBuffer.chop(1); // Remove \n character if (commandBuffer.endsWith('\r')) { @@ -95,7 +95,7 @@ void rigCtlClient::socketReadyRead() if (rigState == Q_NULLPTR) { - qDebug(logRigCtlD()) << "no rigState!"; + qInfo(logRigCtlD()) << "no rigState!"; return; } @@ -181,7 +181,7 @@ void rigCtlClient::socketReadyRead() { // Set mode if (command.length() > 1) { - qDebug(logRigCtlD()) << "setting mode: " << getMode(command[1]); + qInfo(logRigCtlD()) << "setting mode: " << getMode(command[1]); emit parent->setMode(getMode(command[1]), 0x06); } sendData(QString("RPRT 0\n")); @@ -198,7 +198,7 @@ void rigCtlClient::socketReadyRead() void rigCtlClient::socketDisconnected() { - qDebug(logRigCtlD()) << sessionId << "disconnected"; + qInfo(logRigCtlD()) << sessionId << "disconnected"; socket->deleteLater(); this->deleteLater(); } @@ -210,14 +210,14 @@ void rigCtlClient::closeSocket() void rigCtlClient::sendData(QString data) { - qDebug(logRigCtlD()) << "Sending:" << data; + qInfo(logRigCtlD()) << "Sending:" << data; if (socket != Q_NULLPTR && socket->isValid() && socket->isOpen()) { socket->write(data.toLatin1()); } else { - qDebug(logRigCtlD()) << "socket not open!"; + qInfo(logRigCtlD()) << "socket not open!"; } } diff --git a/rigctld.h b/rigctld.h index 2501df0..616c89a 100644 --- a/rigctld.h +++ b/rigctld.h @@ -104,7 +104,6 @@ private: unsigned char getMode(QString modeString); QString getFilter(unsigned char mode, unsigned char filter); - //Interface commands; }; diff --git a/udphandler.cpp b/udphandler.cpp index 4622ca4..0db339a 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -24,7 +24,7 @@ udpHandler::udpHandler(udpPreferences prefs) : this->password = prefs.password; this->compName = prefs.clientName.mid(0,8) + "-wfview"; - qDebug(logUdp()) << "Starting udpHandler user:" << username << " rx latency:" << rxLatency << " tx latency:" << txLatency << " rx sample rate: " << rxSampleRate << + qInfo(logUdp()) << "Starting udpHandler user:" << username << " rx latency:" << rxLatency << " tx latency:" << txLatency << " rx sample rate: " << rxSampleRate << " rx codec: " << rxCodec << " tx sample rate: " << txSampleRate << " tx codec: " << txCodec; // Try to set the IP address, if it is a hostname then perform a DNS lookup. @@ -35,13 +35,13 @@ udpHandler::udpHandler(udpPreferences prefs) : { if (addr.protocol() == QAbstractSocket::IPv4Protocol) { radioIP = addr; - qDebug(logUdp()) << "Got IP Address :" << prefs.ipAddress << ": " << addr.toString(); + qInfo(logUdp()) << "Got IP Address :" << prefs.ipAddress << ": " << addr.toString(); break; } } if (radioIP.isNull()) { - qDebug(logUdp()) << "Error obtaining IP Address for :" << prefs.ipAddress << ": " << remote.errorString(); + qInfo(logUdp()) << "Error obtaining IP Address for :" << prefs.ipAddress << ": " << remote.errorString(); return; } } @@ -93,7 +93,7 @@ udpHandler::~udpHandler() if (civ != Q_NULLPTR) { delete civ; } - qDebug(logUdp()) << "Sending token removal packet"; + qInfo(logUdp()) << "Sending token removal packet"; sendToken(0x01); if (tokenTimer != Q_NULLPTR) { @@ -153,7 +153,7 @@ void udpHandler::dataReceived() control_packet_t in = (control_packet_t)r.constData(); if (in->type == 0x04) { // If timer is active, stop it as they are obviously there! - qDebug(logUdp()) << this->metaObject()->className() << ": Received I am here from: " <metaObject()->className() << ": Received I am here from: " <isActive()) { // send ping packets every second @@ -165,7 +165,7 @@ void udpHandler::dataReceived() // This is "I am ready" in response to "Are you ready" so send login. else if (in->type == 0x06) { - qDebug(logUdp()) << this->metaObject()->className() << ": Received I am ready"; + qInfo(logUdp()) << this->metaObject()->className() << ": Received I am ready"; sendLogin(); // send login packet } break; @@ -234,12 +234,12 @@ void udpHandler::dataReceived() if (in->error == 0x00ffffff && !streamOpened) { emit haveNetworkError(radioIP.toString(), "Auth failed, try rebooting the radio."); - qDebug(logUdp()) << this->metaObject()->className() << ": Auth failed, try rebooting the radio."; + qInfo(logUdp()) << this->metaObject()->className() << ": Auth failed, try rebooting the radio."; } else if (in->error == 0x00000000 && in->disc == 0x01) { emit haveNetworkError(radioIP.toString(), "Got radio disconnected."); - qDebug(logUdp()) << this->metaObject()->className() << ": Got radio disconnected."; + qInfo(logUdp()) << this->metaObject()->className() << ": Got radio disconnected."; if (streamOpened) { // Close stream connections but keep connection open to the radio. if (audio != Q_NULLPTR) { @@ -269,7 +269,7 @@ void udpHandler::dataReceived() if (in->error == 0xfeffffff) { emit haveNetworkStatus("Invalid Username/Password"); - qDebug(logUdp()) << this->metaObject()->className() << ": Invalid Username/Password"; + qInfo(logUdp()) << this->metaObject()->className() << ": Invalid Username/Password"; } else if (!isAuthenticated) { @@ -277,7 +277,7 @@ void udpHandler::dataReceived() if (in->tokrequest == tokRequest) { emit haveNetworkStatus("Radio Login OK!"); - qDebug(logUdp()) << this->metaObject()->className() << ": Received matching token response to our request"; + qInfo(logUdp()) << this->metaObject()->className() << ": Received matching token response to our request"; token = in->token; sendToken(0x02); tokenTimer->start(TOKEN_RENEWAL); // Start token request timer @@ -285,7 +285,7 @@ void udpHandler::dataReceived() } else { - qDebug(logUdp()) << this->metaObject()->className() << ": Token response did not match, sent:" << tokRequest << " got " << in->tokrequest; + qInfo(logUdp()) << this->metaObject()->className() << ": Token response did not match, sent:" << tokRequest << " got " << in->tokrequest; } } @@ -294,7 +294,7 @@ void udpHandler::dataReceived() highBandwidthConnection = true; } - qDebug(logUdp()) << this->metaObject()->className() << ": Detected connection speed " << in->connection; + qInfo(logUdp()) << this->metaObject()->className() << ": Detected connection speed " << in->connection; } break; } @@ -324,7 +324,7 @@ void udpHandler::dataReceived() emit haveNetworkStatus(devName); - qDebug(logUdp()) << this->metaObject()->className() << "Got serial and audio request success, device name: " << devName; + qInfo(logUdp()) << this->metaObject()->className() << "Got serial and audio request success, device name: " << devName; // Stuff can change in the meantime because of a previous login... remoteId = in->sentid; @@ -361,7 +361,7 @@ void udpHandler::dataReceived() audioType = in->audio; devName = in->name; //replyId = r.mid(0x42, 16); - qDebug(logUdp()) << this->metaObject()->className() << "Received radio capabilities, Name:" << + qInfo(logUdp()) << this->metaObject()->className() << "Received radio capabilities, Name:" << devName << " Audio:" << audioType; } @@ -417,10 +417,10 @@ void udpHandler::sendAreYouThere() { if (areYouThereCounter == 20) { - qDebug(logUdp()) << this->metaObject()->className() << ": Radio not responding."; + qInfo(logUdp()) << this->metaObject()->className() << ": Radio not responding."; emit haveNetworkStatus("Radio not responding!"); } - qDebug(logUdp()) << this->metaObject()->className() << ": Sending Are You There..."; + qInfo(logUdp()) << this->metaObject()->className() << ": Sending Are You There..."; areYouThereCounter++; udpBase::sendControl(false,0x03,0x00); @@ -429,7 +429,7 @@ void udpHandler::sendAreYouThere() void udpHandler::sendLogin() // Only used on control stream. { - qDebug(logUdp()) << this->metaObject()->className() << ": Sending login packet"; + qInfo(logUdp()) << this->metaObject()->className() << ": Sending login packet"; tokRequest = static_cast(rand() | rand() << 8); // Generate random token request. @@ -479,7 +479,7 @@ void udpHandler::sendToken(uint8_t magic) // Class that manages all Civ Data to/from the rig udpCivData::udpCivData(QHostAddress local, QHostAddress ip, quint16 civPort) { - qDebug(logUdp()) << "Starting udpCivData"; + qInfo(logUdp()) << "Starting udpCivData"; localIP = local; port = civPort; radioIP = ip; @@ -548,7 +548,7 @@ void udpCivData::watchdog() if (lastReceived.msecsTo(QTime::currentTime()) > 500) { if (!alerted) { - qDebug(logUdp()) << " CIV Watchdog: no CIV data received for 500ms, requesting data start."; + qInfo(logUdp()) << " CIV Watchdog: no CIV data received for 500ms, requesting data start."; if (startCivDataTimer != Q_NULLPTR) { startCivDataTimer->start(100); @@ -564,7 +564,7 @@ void udpCivData::watchdog() void udpCivData::send(QByteArray d) { - // qDebug(logUdp()) << "Sending: (" << d.length() << ") " << d; + // qInfo(logUdp()) << "Sending: (" << d.length() << ") " << d; data_packet p; memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! p.len = sizeof(p)+d.length(); @@ -613,7 +613,7 @@ void udpCivData::dataReceived() while (udp->hasPendingDatagrams()) { QNetworkDatagram datagram = udp->receiveDatagram(); - //qDebug(logUdp()) << "Received: " << datagram.data(); + //qInfo(logUdp()) << "Received: " << datagram.data(); QByteArray r = datagram.data(); switch (r.length()) @@ -671,7 +671,7 @@ void udpCivData::dataReceived() // Audio stream udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, quint16 rxlatency, quint16 txlatency, quint16 rxsample, quint8 rxcodec, quint16 txsample, quint8 txcodec, QString outputPort, QString inputPort,quint8 resampleQuality) { - qDebug(logUdp()) << "Starting udpAudio"; + qInfo(logUdp()) << "Starting udpAudio"; this->localIP = local; this->port = audioPort; this->radioIP = ip; @@ -810,7 +810,7 @@ void udpAudio::watchdog() /* Just log it at the moment, maybe try signalling the control channel that it needs to try requesting civ/audio again? */ - qDebug(logUdp()) << " Audio Watchdog: no audio data received for 500ms, restart required"; + qInfo(logUdp()) << " Audio Watchdog: no audio data received for 500ms, restart required"; alerted = true; } } @@ -848,7 +848,7 @@ void udpAudio::sendTxAudio() QByteArray tx = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); tx.append(partial); len = len + partial.length(); - //qDebug(logUdp()) << "Sending audio packet length: " << tx.length(); + //qInfo(logUdp()) << "Sending audio packet length: " << tx.length(); sendTrackedPacket(tx); sendAudioSeq++; counter++; @@ -870,7 +870,7 @@ void udpAudio::dataReceived() { while (udp->hasPendingDatagrams()) { QNetworkDatagram datagram = udp->receiveDatagram(); - //qDebug(logUdp()) << "Received: " << datagram.data(); + //qInfo(logUdp()) << "Received: " << datagram.data(); QByteArray r = datagram.data(); switch (r.length()) @@ -934,7 +934,7 @@ void udpBase::init() udp = new QUdpSocket(this); udp->bind(); // Bind to random port. localPort = udp->localPort(); - qDebug(logUdp()) << "UDP Stream bound to local port:" << localPort << " remote port:" << port; + qInfo(logUdp()) << "UDP Stream bound to local port:" << localPort << " remote port:" << port; uint32_t addr = localIP.toIPv4Address(); myId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (localPort & 0xffff); @@ -946,7 +946,7 @@ void udpBase::init() udpBase::~udpBase() { - qDebug(logUdp()) << "Closing UDP stream :" << radioIP.toString() << ":" << port; + qInfo(logUdp()) << "Closing UDP stream :" << radioIP.toString() << ":" << port; if (udp != Q_NULLPTR) { sendControl(false, 0x05, 0x00); // Send disconnect udp->close(); @@ -1009,14 +1009,14 @@ void udpBase::dataReceived(QByteArray r) // Found matching entry? // Send "untracked" as it has already been sent once. // Don't constantly retransmit the same packet, give-up eventually - //qDebug(logUdp()) << this->metaObject()->className() << ": Sending retransmit of " << hex << match->seqNum; + //qInfo(logUdp()) << this->metaObject()->className() << ": Sending retransmit of " << hex << match->seqNum; match->retransmitCount++; QMutexLocker udplocker(&udpMutex); udp->writeDatagram(match->data, radioIP, port); } } if (in->type == 0x04) { - qDebug(logUdp()) << this->metaObject()->className() << ": Received I am here "; + qInfo(logUdp()) << this->metaObject()->className() << ": Received I am here "; areYouThereCounter = 0; // I don't think that we will ever receive an "I am here" other than in response to "Are you there?" remoteId = in->sentid; @@ -1060,11 +1060,11 @@ void udpBase::dataReceived(QByteArray r) } else { // Not sure what to do here, need to spend more time with the protocol but will try sending ping with same seq next time. - //qDebug(logUdp()) << this->metaObject()->className() << "Received out-of-sequence ping response. Sent:" << pingSendSeq << " received " << in->seq; + //qInfo(logUdp()) << this->metaObject()->className() << "Received out-of-sequence ping response. Sent:" << pingSendSeq << " received " << in->seq; } } else { - qDebug(logUdp()) << this->metaObject()->className() << "Unhandled response to ping. I have never seen this! 0x10=" << r[16]; + qInfo(logUdp()) << this->metaObject()->className() << "Unhandled response to ping. I have never seen this! 0x10=" << r[16]; } } @@ -1097,14 +1097,14 @@ void udpBase::dataReceived(QByteArray r) return s.seqNum == cs; }); if (match == txSeqBuf.end()) { - qDebug(logUdp()) << this->metaObject()->className() << ": Requested packet " << hex << seq << " not found"; + qInfo(logUdp()) << this->metaObject()->className() << ": Requested packet " << hex << seq << " not found"; // Just send idle packet. sendControl(false, 0, match->seqNum); } else { // Found matching entry? // Send "untracked" as it has already been sent once. - //qDebug(logUdp()) << this->metaObject()->className() << ": Sending retransmit (range) of " << hex << match->seqNum; + //qInfo(logUdp()) << this->metaObject()->className() << ": Sending retransmit (range) of " << hex << match->seqNum; match->retransmitCount++; QMutexLocker udplocker(&udpMutex); udp->writeDatagram(match->data, radioIP, port); @@ -1124,7 +1124,7 @@ void udpBase::dataReceived(QByteArray r) std::sort(rxSeqBuf.begin(), rxSeqBuf.end()); if (in->seq < rxSeqBuf.front()) { - qDebug(logUdp()) << this->metaObject()->className() << ": ******* seq number has rolled over ****** previous highest: " << hex << rxSeqBuf.back() << " current: " << hex << in->seq; + qInfo(logUdp()) << this->metaObject()->className() << ": ******* seq number has rolled over ****** previous highest: " << hex << rxSeqBuf.back() << " current: " << hex << in->seq; //seqPrefix++; // Looks like it has rolled over so clear buffer and start again. rxSeqBuf.clear(); @@ -1139,7 +1139,7 @@ void udpBase::dataReceived(QByteArray r) auto s = std::find_if(rxMissing.begin(), rxMissing.end(), [&cs = in->seq](SEQBUFENTRY& s) { return s.seqNum == cs; }); if (s != rxMissing.end()) { - qDebug(logUdp()) << this->metaObject()->className() << ": Missing SEQ has been received! " << hex << in->seq; + qInfo(logUdp()) << this->metaObject()->className() << ": Missing SEQ has been received! " << hex << in->seq; s = rxMissing.erase(s); } } @@ -1168,12 +1168,12 @@ void udpBase::sendRetransmitRequest() { for (quint16 j = *i + 1; j < *(i + 1); j++) { - //qDebug(logUdp()) << this->metaObject()->className() << ": Found missing seq between " << *i << " : " << *(i + 1) << " (" << j << ")"; + //qInfo(logUdp()) << this->metaObject()->className() << ": Found missing seq between " << *i << " : " << *(i + 1) << " (" << j << ")"; auto s = std::find_if(rxMissing.begin(), rxMissing.end(), [&cs = j](SEQBUFENTRY& s) { return s.seqNum == cs; }); if (s == rxMissing.end()) { // We haven't seen this missing packet before - //qDebug(logUdp()) << this->metaObject()->className() << ": Adding to missing buffer (len="<< rxMissing.length() << "): " << j; + //qInfo(logUdp()) << this->metaObject()->className() << ": Adding to missing buffer (len="<< rxMissing.length() << "): " << j; SEQBUFENTRY b; b.seqNum = j; b.retransmitCount = 0; @@ -1193,7 +1193,7 @@ void udpBase::sendRetransmitRequest() } } else { - qDebug(logUdp()) << this->metaObject()->className() << ": Too many missing, flushing buffers"; + qInfo(logUdp()) << this->metaObject()->className() << ": Too many missing, flushing buffers"; rxSeqBuf.clear(); missingSeqs.clear(); break; @@ -1225,13 +1225,13 @@ void udpBase::sendRetransmitRequest() if (missingSeqs.length() == 4) // This is just a single missing packet so send using a control. { p.seq = (missingSeqs[0] & 0xff) | (quint16)(missingSeqs[1] << 8); - qDebug(logUdp()) << this->metaObject()->className() << ": sending request for missing packet : " << hex << p.seq; + qInfo(logUdp()) << this->metaObject()->className() << ": sending request for missing packet : " << hex << p.seq; QMutexLocker udplocker(&udpMutex); udp->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), radioIP, port); } else { - qDebug(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex(); + qInfo(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex(); missingSeqs.insert(0, p.packet, sizeof(p.packet)); QMutexLocker udplocker(&udpMutex); udp->writeDatagram(missingSeqs, radioIP, port); diff --git a/udpserver.cpp b/udpserver.cpp index 1231304..160a6ba 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -6,7 +6,7 @@ udpServer::udpServer(SERVERCONFIG config) : config(config) { - qDebug(logUdpServer()) << "Starting udp server"; + qInfo(logUdpServer()) << "Starting udp server"; } void udpServer::init() @@ -35,24 +35,24 @@ void udpServer::init() uint32_t addr = localIP.toIPv4Address(); - qDebug(logUdpServer()) << " My IP Address: " << QHostAddress(addr).toString() << " My MAC Address: " << macAddress; + qInfo(logUdpServer()) << " My IP Address: " << QHostAddress(addr).toString() << " My MAC Address: " << macAddress; controlId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (config.controlPort & 0xffff); civId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (config.civPort & 0xffff); audioId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (config.audioPort & 0xffff); - qDebug(logUdpServer()) << "Server Binding Control to: " << config.controlPort; + qInfo(logUdpServer()) << "Server Binding Control to: " << config.controlPort; udpControl = new QUdpSocket(this); udpControl->bind(config.controlPort); QUdpSocket::connect(udpControl, &QUdpSocket::readyRead, this, &udpServer::controlReceived); - qDebug(logUdpServer()) << "Server Binding CIV to: " << config.civPort; + qInfo(logUdpServer()) << "Server Binding CIV to: " << config.civPort; udpCiv = new QUdpSocket(this); udpCiv->bind(config.civPort); QUdpSocket::connect(udpCiv, &QUdpSocket::readyRead, this, &udpServer::civReceived); - qDebug(logUdpServer()) << "Server Binding Audio to: " << config.audioPort; + qInfo(logUdpServer()) << "Server Binding Audio to: " << config.audioPort; udpAudio = new QUdpSocket(this); udpAudio->bind(config.audioPort); QUdpSocket::connect(udpAudio, &QUdpSocket::readyRead, this, &udpServer::audioReceived); @@ -60,7 +60,7 @@ void udpServer::init() udpServer::~udpServer() { - qDebug(logUdpServer()) << "Closing udpServer"; + qInfo(logUdpServer()) << "Closing udpServer"; connMutex.lock(); @@ -221,7 +221,7 @@ void udpServer::controlReceived() current->commonCap = 0x8010; - qDebug(logUdpServer()) << current->ipAddress.toString() << ": New Control connection created"; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": New Control connection created"; connMutex.lock(); controlClients.append(current); connMutex.unlock(); @@ -238,7 +238,7 @@ void udpServer::controlReceived() control_packet_t in = (control_packet_t)r.constData(); if (in->type == 0x05) { - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'disconnect' request"; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received 'disconnect' request"; sendControl(current, 0x00, in->seq); //current->wdTimer->stop(); // Keep watchdog running to delete stale connection. deleteConnection(&controlClients, current); @@ -265,7 +265,7 @@ void udpServer::controlReceived() current->pingSeq++; } else { - qDebug(logUdpServer()) << current->ipAddress.toString() << ": got out of sequence ping reply. Got: " << in->seq << " expecting: " << current->pingSeq; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": got out of sequence ping reply. Got: " << in->seq << " expecting: " << current->pingSeq; } } } @@ -282,13 +282,13 @@ void udpServer::controlReceived() current->identb = in->identb; if (in->res == 0x02) { // Request for new token - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received create token request"; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received create token request"; sendCapabilities(current); sendConnectionInfo(current); } else if (in->res == 0x01) { // Token disconnect - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received token disconnect request"; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received token disconnect request"; sendTokenResponse(current, in->res); } else if (in->res == 0x04) { @@ -298,7 +298,7 @@ void udpServer::controlReceived() sendConnectionInfo(current); } else { - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received token request"; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received token request"; sendTokenResponse(current, in->res); } break; @@ -306,7 +306,7 @@ void udpServer::controlReceived() case (LOGIN_SIZE): { login_packet_t in = (login_packet_t)r.constData(); - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'login'"; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received 'login'"; bool userOk = false; foreach(SERVERUSER user, config.users) { @@ -331,11 +331,11 @@ void udpServer::controlReceived() current->tokenTx =(quint8)rand() | (quint8)rand() << 8 | (quint8)rand() << 16 | (quint8)rand() << 24; if (userOk) { - qDebug(logUdpServer()) << current->ipAddress.toString() << ": User " << current->user.username << " login OK"; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": User " << current->user.username << " login OK"; sendLoginResponse(current, true); } else { - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Incorrect username/password"; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Incorrect username/password"; sendLoginResponse(current, false); } @@ -344,7 +344,7 @@ void udpServer::controlReceived() case (CONNINFO_SIZE): { conninfo_packet_t in = (conninfo_packet_t)r.constData(); - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received request for radio connection"; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received request for radio connection"; // Request to start audio and civ! current->isStreaming = true; current->rxSeq = in->seq; @@ -359,7 +359,7 @@ void udpServer::controlReceived() sendStatus(current); current->authInnerSeq = 0x00; sendConnectionInfo(current); - qDebug(logUdpServer()) << current->ipAddress.toString() << ": rxCodec:" << current->rxCodec << " txCodec:" << current->txCodec << + qInfo(logUdpServer()) << current->ipAddress.toString() << ": rxCodec:" << current->rxCodec << " txCodec:" << current->txCodec << " rxSampleRate" << current->rxSampleRate << " txSampleRate" << current->rxSampleRate << " txBufferLen" << current->txBufferLen; @@ -504,7 +504,7 @@ void udpServer::civReceived() connect(current->retransmitTimer, &QTimer::timeout, this, std::bind(&udpServer::sendRetransmitRequest, this, current)); current->retransmitTimer->start(RETRANSMIT_PERIOD); - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): New connection created"; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): New connection created"; connMutex.lock(); civClients.append(current); connMutex.unlock(); @@ -537,7 +537,7 @@ void udpServer::civReceived() current->pingSeq++; } else { - qDebug(logUdpServer()) << current->ipAddress.toString() << ": got out of sequence ping reply. Got: " << in->seq << " expecting: " << current->pingSeq; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": got out of sequence ping reply. Got: " << in->seq << " expecting: " << current->pingSeq; } } } @@ -555,22 +555,22 @@ void udpServer::civReceived() { // Strip all '0xFE' command preambles first: int lastFE = r.lastIndexOf((char)0xfe); - //qDebug(logUdpServer()) << "Got:" << r.mid(lastFE); + //qInfo(logUdpServer()) << "Got:" << r.mid(lastFE); if (current->civId == 0 && r.length() > lastFE + 2 && (quint8)r[lastFE + 2] > (quint8)0xdf && (quint8)r[lastFE + 2] < (quint8)0xef) { // This is (should be) the remotes CIV id. current->civId = (quint8)r[lastFE + 2]; - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Detected remote CI-V:" << hex << current->civId; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Detected remote CI-V:" << hex << current->civId; } else if (current->civId != 0 && r.length() > lastFE + 2 && (quint8)r[lastFE + 2] != current->civId) { current->civId = (quint8)r[lastFE + 2]; - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Detected different remote CI-V:" << hex << current->civId; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Detected different remote CI-V:" << hex << current->civId; } emit haveDataFromServer(r.mid(0x15)); } else { - qDebug(logUdpServer()) << current->ipAddress.toString() << ": Datalen mismatch " << quint16(in->datalen + 0x15) << ":" << (quint16)in->len; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": Datalen mismatch " << quint16(in->datalen + 0x15) << ":" << (quint16)in->len; } } @@ -632,7 +632,7 @@ void udpServer::audioReceived() connect(current->retransmitTimer, &QTimer::timeout, this, std::bind(&udpServer::sendRetransmitRequest, this, current)); current->retransmitTimer->start(RETRANSMIT_PERIOD); current->seqPrefix = 0; - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): New connection created"; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): New connection created"; connMutex.lock(); audioClients.append(current); connMutex.unlock(); @@ -662,7 +662,7 @@ void udpServer::audioReceived() current->pingSeq++; } else { - qDebug(logUdpServer()) << current->ipAddress.toString() << ": got out of sequence ping reply. Got: " << in->seq << " expecting: " << current->pingSeq; + qInfo(logUdpServer()) << current->ipAddress.toString() << ": got out of sequence ping reply. Got: " << in->seq << " expecting: " << current->pingSeq; } } } @@ -695,7 +695,7 @@ void udpServer::audioReceived() tempAudio.time = QTime::currentTime();; tempAudio.sent = 0; tempAudio.datain = r.mid(0x18); - //qDebug(logUdpServer()) << "sending tx audio " << in->seq; + //qInfo(logUdpServer()) << "sending tx audio " << in->seq; emit haveAudioData(tempAudio); } } @@ -718,7 +718,7 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) if (r.length() < 0x10) { // Invalid packet - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Invalid packet received, len: " << r.length(); + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Invalid packet received, len: " << r.length(); return; } @@ -728,13 +728,13 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) { control_packet_t in = (control_packet_t)r.constData(); if (in->type == 0x03) { - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Received 'are you there'"; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Received 'are you there'"; current->remoteId = in->sentid; sendControl(current, 0x04, in->seq); } // This is This is "Are you ready" in response to "I am here". else if (in->type == 0x06) { - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Received 'Are you ready'"; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Received 'Are you ready'"; current->remoteId = in->sentid; sendControl(current, 0x06, in->seq); if (current->idleTimer != Q_NULLPTR && !current->idleTimer->isActive()) { @@ -744,7 +744,7 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) else if (in->type == 0x01) { // Single packet request - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Received 'retransmit' request for " << in->seq; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Received 'retransmit' request for " << in->seq; auto match = std::find_if(current->txSeqBuf.begin(), current->txSeqBuf.end(), [&cs = in->seq](SEQBUFENTRY& s) { return s.seqNum == cs; @@ -753,7 +753,7 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) if (match != current->txSeqBuf.end() && match->retransmitCount < 5) { // Found matching entry? // Don't constantly retransmit the same packet, give-up eventually - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Sending retransmit of " << hex << match->seqNum; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Sending retransmit of " << hex << match->seqNum; match->retransmitCount++; udpMutex.lock(); current->socket->writeDatagram(match->data, current->ipAddress, current->port); @@ -782,7 +782,7 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) return s.seqNum == cs; }); if (match == current->txSeqBuf.end()) { - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Requested packet " << hex << in->seq << " not found"; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Requested packet " << hex << in->seq << " not found"; // Just send idle packet. sendControl(current, 0, in->seq); } @@ -790,7 +790,7 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) { // Found matching entry? // Send "untracked" as it has already been sent once. - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Sending retransmit of " << hex << match->seqNum; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Sending retransmit of " << hex << match->seqNum; match->retransmitCount++; udpMutex.lock(); current->socket->writeDatagram(match->data, current->ipAddress, current->port); @@ -802,7 +802,7 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) else if (in->type == 0x00 && in->seq != 0x00) { //if (current->type == "CIV") { - // qDebug(logUdpServer()) << "Got:" << in->seq; + // qInfo(logUdpServer()) << "Got:" << in->seq; //} current->rxMutex.lock(); if (current->rxSeqBuf.isEmpty()) @@ -814,7 +814,7 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) std::sort(current->rxSeqBuf.begin(), current->rxSeqBuf.end()); if (in->seq < current->rxSeqBuf.front()) { - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): ******* seq number may have rolled over ****** previous highest: " << hex << current->rxSeqBuf.back() << " current: " << hex << in->seq; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): ******* seq number may have rolled over ****** previous highest: " << hex << current->rxSeqBuf.back() << " current: " << hex << in->seq; // Looks like it has rolled over so clear buffer and start again. current->rxSeqBuf.clear(); current->rxMutex.unlock(); // Must unlock the Mutex! @@ -831,7 +831,7 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) auto s = std::find_if(current->rxMissing.begin(), current->rxMissing.end(), [&cs = in->seq](SEQBUFENTRY& s) { return s.seqNum == cs; }); if (s != current->rxMissing.end()) { - qDebug(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Missing SEQ has been received! " << hex << in->seq; + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Missing SEQ has been received! " << hex << in->seq; s = current->rxMissing.erase(s); } current->missMutex.unlock(); @@ -846,7 +846,7 @@ void udpServer::commonReceived(QList* l,CLIENT* current, QByteArray r) void udpServer::sendControl(CLIENT* c, quint8 type, quint16 seq) { - //qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending control packet: " << type; + //qInfo(logUdpServer()) << c->ipAddress.toString() << ": Sending control packet: " << type; control_packet p; memset(p.packet, 0x0, CONTROL_SIZE); // We can't be sure it is initialized with 0x00! @@ -892,13 +892,13 @@ void udpServer::sendPing(QList *l,CLIENT* c, quint16 seq, bool reply) if (c->lastHeard.secsTo(now) > STALE_CONNECTION) { - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Deleting stale connection "; + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Deleting stale connection "; deleteConnection(l, c); return; } - //qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending Ping"; + //qInfo(logUdpServer()) << c->ipAddress.toString() << ": Sending Ping"; quint32 pingTime = 0; if (reply) { @@ -932,7 +932,7 @@ void udpServer::sendPing(QList *l,CLIENT* c, quint16 seq, bool reply) void udpServer::sendLoginResponse(CLIENT* c, bool allowed) { - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending Login response: " << c->txSeq; + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending Login response: " << c->txSeq; login_response_packet p; memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! @@ -982,7 +982,7 @@ void udpServer::sendLoginResponse(CLIENT* c, bool allowed) void udpServer::sendCapabilities(CLIENT* c) { - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending Capabilities :" << c->txSeq; + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending Capabilities :" << c->txSeq; capabilities_packet p; memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! @@ -1101,7 +1101,7 @@ void udpServer::sendCapabilities(CLIENT* c) // Also used to display currently connected used information. void udpServer::sendConnectionInfo(CLIENT* c) { - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending ConnectionInfo :" << c->txSeq; + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending ConnectionInfo :" << c->txSeq; conninfo_packet p; memset(p.packet, 0x0, sizeof(p)); p.len = sizeof(p); @@ -1152,7 +1152,7 @@ void udpServer::sendConnectionInfo(CLIENT* c) void udpServer::sendTokenResponse(CLIENT* c, quint8 type) { - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending Token response for type: " << type; + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending Token response for type: " << type; token_packet p; memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! @@ -1194,7 +1194,7 @@ void udpServer::sendTokenResponse(CLIENT* c, quint8 type) void udpServer::watchdog(CLIENT* c) { c->txMutex.lock(); - //qDebug(logUdpServer()) << c->ipAddress.toString() << ":" << c->port << ":Buffers tx:"<< c->txSeqBuf.length() << " rx:" << c->rxSeqBuf.length(); + //qInfo(logUdpServer()) << c->ipAddress.toString() << ":" << c->port << ":Buffers tx:"<< c->txSeqBuf.length() << " rx:" << c->rxSeqBuf.length(); // Erase old entries from the tx packet buffer. Keep the first 100 sent packets as we seem to get asked for these? if (!c->txSeqBuf.isEmpty()) { @@ -1226,7 +1226,7 @@ void udpServer::watchdog(CLIENT* c) void udpServer::sendStatus(CLIENT* c) { - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending Status"; + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending Status"; status_packet p; memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! @@ -1271,7 +1271,7 @@ void udpServer::sendStatus(CLIENT* c) void udpServer::dataForServer(QByteArray d) { - //qDebug(logUdpServer()) << "Server got:" << d; + //qInfo(logUdpServer()) << "Server got:" << d; foreach(CLIENT * client, civClients) { int lastFE = d.lastIndexOf((quint8)0xfe); @@ -1295,7 +1295,7 @@ void udpServer::dataForServer(QByteArray d) client->txSeqBuf.last().data = t; client->txMutex.unlock(); - //qDebug(logUdpServer()) << "Sending:" << d; + //qInfo(logUdpServer()) << "Sending:" << d; udpMutex.lock(); client->socket->writeDatagram(t, client->ipAddress, client->port); udpMutex.unlock(); @@ -1327,7 +1327,7 @@ void udpServer::sendRxAudio() void udpServer::receiveAudioData(const audioPacket &d) { - //qDebug(logUdpServer()) << "Server got:" << d.data.length(); + //qInfo(logUdpServer()) << "Server got:" << d.data.length(); foreach(CLIENT * client, audioClients) { if (client != Q_NULLPTR && client->connected) { @@ -1383,12 +1383,12 @@ void udpServer::sendRetransmitRequest(CLIENT *c) { for (quint16 j = *i + 1; j < *(i + 1); j++) { - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Found missing seq between " << *i << " : " << *(i + 1) << " (" << j << ")"; + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Found missing seq between " << *i << " : " << *(i + 1) << " (" << j << ")"; auto s = std::find_if(c->rxMissing.begin(), c->rxMissing.end(), [&cs = j](SEQBUFENTRY& s) { return s.seqNum == cs; }); if (s == c->rxMissing.end()) { // We haven't seen this missing packet before - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Adding to missing buffer (len="<< c->rxMissing.length() << "): " << j; + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Adding to missing buffer (len="<< c->rxMissing.length() << "): " << j; c->rxMissing.append(SEQBUFENTRY()); c->rxMissing.last().seqNum = j; c->rxMissing.last().retransmitCount = 0; @@ -1409,7 +1409,7 @@ void udpServer::sendRetransmitRequest(CLIENT *c) } } else { - qDebug(logUdpServer()) << c->ipAddress.toString() << ": Too many missing, flushing buffers"; + qInfo(logUdpServer()) << c->ipAddress.toString() << ": Too many missing, flushing buffers"; c->rxMutex.lock(); c->rxSeqBuf.clear(); c->rxMutex.unlock(); @@ -1443,14 +1443,14 @@ void udpServer::sendRetransmitRequest(CLIENT *c) if (missingSeqs.length() == 4) // This is just a single missing packet so send using a control. { p.seq = (missingSeqs[0] & 0xff) | (quint16)(missingSeqs[1] << 8); - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): sending request for missing packet : " << hex << p.seq; + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): sending request for missing packet : " << hex << p.seq; udpMutex.lock(); c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); udpMutex.unlock(); } else { - qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): sending request for multiple missing packets : " << missingSeqs.toHex(); + qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): sending request for multiple missing packets : " << missingSeqs.toHex(); missingSeqs.insert(0, p.packet, sizeof(p.packet)); udpMutex.lock(); c->socket->writeDatagram(missingSeqs, c->ipAddress, c->port); @@ -1472,7 +1472,7 @@ void udpServer::deleteConnection(QList *l, CLIENT* c) { connMutex.lock(); - qDebug(logUdpServer()) << "Deleting connection to: " << c->ipAddress.toString() << ":" << QString::number(c->port); + qInfo(logUdpServer()) << "Deleting connection to: " << c->ipAddress.toString() << ":" << QString::number(c->port); if (c->idleTimer != Q_NULLPTR) { c->idleTimer->stop(); delete c->idleTimer; @@ -1503,7 +1503,7 @@ void udpServer::deleteConnection(QList *l, CLIENT* c) } delete c; // Is this needed or will the erase have done it? c = Q_NULLPTR; - qDebug(logUdpServer()) << "Current Number of clients connected: " << l->length(); + qInfo(logUdpServer()) << "Current Number of clients connected: " << l->length(); if (l->length() == 0) { diff --git a/udpserversetup.cpp b/udpserversetup.cpp index cd4a668..88cb23e 100644 --- a/udpserversetup.cpp +++ b/udpserversetup.cpp @@ -20,7 +20,7 @@ udpServerSetup::~udpServerSetup() // Slot to receive config. void udpServerSetup::receiveServerConfig(SERVERCONFIG conf) { - qDebug() << "Getting server config"; + qInfo() << "Getting server config"; ui->enableCheckbox->setChecked(conf.enabled); ui->controlPortText->setText(QString::number(conf.controlPort)); @@ -72,7 +72,7 @@ void udpServerSetup::receiveServerConfig(SERVERCONFIG conf) void udpServerSetup::accept() { - qDebug() << "Server config stored"; + qInfo() << "Server config stored"; SERVERCONFIG config; config.enabled = ui->enableCheckbox->isChecked(); config.controlPort = ui->controlPortText->text().toInt(); @@ -105,7 +105,7 @@ void udpServerSetup::accept() void udpServerSetup::on_usersTable_cellClicked(int row, int col) { - qDebug() << "Clicked on " << row << "," << col; + qInfo() << "Clicked on " << row << "," << col; if (row == ui->usersTable->model()->rowCount() - 1 && ui->usersTable->item(row, 0) != NULL && ui->usersTable->item(row, 1) != NULL) { ui->usersTable->insertRow(ui->usersTable->rowCount()); QComboBox* comboBox = new QComboBox(); diff --git a/wfmain.cpp b/wfmain.cpp index b33e3f9..ec79339 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -577,8 +577,8 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent freqIndicatorLine->start->setCoords(0.5,0); freqIndicatorLine->end->setCoords(0.5,160); -#ifdef QT_DEBUG qDebug(logSystem()) << "Running with debugging options enabled."; +#ifdef QT_DEBUG ui->debugBtn->setVisible(true); ui->satOpsBtn->setVisible(true); #else @@ -652,7 +652,6 @@ void wfmain::openRig() // TODO: Use these if they are found -#ifdef QT_DEBUG if(!serialPortCL.isEmpty()) { qDebug(logSystem()) << "Serial port specified by user: " << serialPortCL; @@ -664,7 +663,6 @@ void wfmain::openRig() { qDebug(logSystem()) << "Remote host name specified by user: " << hostCL; } -#endif // Start rigctld if (prefs.enableRigCtlD) { @@ -712,7 +710,7 @@ void wfmain::openRig() if( (prefs.serialPortRadio.toLower() == QString("auto")) && (serialPortCL.isEmpty())) { // Find the ICOM - // qDebug(logSystem()) << "Searching for serial port..."; + // qInfo(logSystem()) << "Searching for serial port..."; QDirIterator it73("/dev/serial", QStringList() << "*IC-7300*", QDir::Files, QDirIterator::Subdirectories); QDirIterator it97("/dev/serial", QStringList() << "*IC-9700*A*", QDir::Files, QDirIterator::Subdirectories); QDirIterator it785x("/dev/serial", QStringList() << "*IC-785*A*", QDir::Files, QDirIterator::Subdirectories); @@ -747,7 +745,7 @@ void wfmain::openRig() serialPortRig = itR8600.filePath(); } else { //fall back: - qDebug(logSystem()) << "Could not find Icom serial port. Falling back to OS default. Use --port to specify, or modify preferences."; + qInfo(logSystem()) << "Could not find Icom serial port. Falling back to OS default. Use --port to specify, or modify preferences."; #ifdef Q_OS_MAC serialPortRig = QString("/dev/tty.SLAB_USBtoUART"); #endif @@ -780,12 +778,12 @@ void wfmain::openRig() void wfmain::receiveCommReady() { - qDebug(logSystem()) << "Received CommReady!! "; + qInfo(logSystem()) << "Received CommReady!! "; // taken from above: if(prefs.radioCIVAddr == 0) { // tell rigCommander to broadcast a request for all rig IDs. - // qDebug(logSystem()) << "Beginning search from wfview for rigCIV (auto-detection broadcast)"; + // qInfo(logSystem()) << "Beginning search from wfview for rigCIV (auto-detection broadcast)"; ui->statusBar->showMessage(QString("Searching CIV bus for connected radios."), 1000); emit getRigCIV(); cmdOutQue.append(cmdGetRigCIV); @@ -793,7 +791,7 @@ void wfmain::receiveCommReady() } else { // don't bother, they told us the CIV they want, stick with it. // We still query the rigID to find the model, but at least we know the CIV. - qDebug(logSystem()) << "Skipping automatic CIV, using user-supplied value of " << prefs.radioCIVAddr; + qInfo(logSystem()) << "Skipping automatic CIV, using user-supplied value of " << prefs.radioCIVAddr; getInitialRigState(); } @@ -804,7 +802,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps) { // Entry point for unknown rig being identified at the start of the program. //now we know what the rig ID is: - //qDebug(logSystem()) << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST."; + //qInfo(logSystem()) << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST."; if(rig->usingLAN()) { @@ -828,7 +826,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps) void wfmain::receiveSerialPortError(QString port, QString errorText) { - qDebug(logSystem()) << "wfmain: received serial port error for port: " << port << " with message: " << errorText; + qInfo(logSystem()) << "wfmain: received serial port error for port: " << port << " with message: " << errorText; ui->statusBar->showMessage(QString("ERROR: using port ").append(port).append(": ").append(errorText), 10000); // TODO: Dialog box, exit, etc @@ -875,7 +873,7 @@ void wfmain::setDefPrefs() void wfmain::loadSettings() { - qDebug(logSystem()) << "Loading settings from " << settings.fileName(); + qInfo(logSystem()) << "Loading settings from " << settings.fileName(); // Basic things to load: // UI: (full screen, dark theme, draw peaks, colors, etc) @@ -1026,7 +1024,7 @@ void wfmain::loadSettings() ui->audioTXCodecCombo->setCurrentIndex(f); udpPrefs.audioOutput = settings.value("AudioOutput", udpDefPrefs.audioOutput).toString(); - qDebug(logGui()) << "Got Audio Output: " << udpPrefs.audioOutput; + qInfo(logGui()) << "Got Audio Output: " << udpPrefs.audioOutput; //ui->audioOutputCombo->setEnabled(ui->lanEnableBtn->isChecked()); int audioOutputIndex = ui->audioOutputCombo->findText(udpPrefs.audioOutput); if (audioOutputIndex != -1) { @@ -1034,7 +1032,7 @@ void wfmain::loadSettings() } udpPrefs.audioInput = settings.value("AudioInput", udpDefPrefs.audioInput).toString(); - qDebug(logGui()) << "Got Audio Input: " << udpPrefs.audioInput; + qInfo(logGui()) << "Got Audio Input: " << udpPrefs.audioInput; //ui->audioInputCombo->setEnabled(ui->lanEnableBtn->isChecked()); int audioInputIndex = ui->audioInputCombo->findText(udpPrefs.audioInput); if (audioInputIndex != -1) { @@ -1107,7 +1105,7 @@ void wfmain::loadSettings() void wfmain::saveSettings() { - qDebug(logSystem()) << "Saving settings to " << settings.fileName(); + qInfo(logSystem()) << "Saving settings to " << settings.fileName(); // Basic things to load: // UI: (full screen, dark theme, draw peaks, colors, etc) @@ -1273,7 +1271,7 @@ void wfmain::prepareWf() wf->xAxis->setVisible(false); rigName->setText(rigCaps.modelName); } else { - qDebug(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this."; + qInfo(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this."; return; } @@ -1364,7 +1362,7 @@ void wfmain::shortcutF12() void wfmain::shortcutControlT() { // Transmit - qDebug(logSystem()) << "Activated Control-T shortcut"; + qInfo(logSystem()) << "Activated Control-T shortcut"; showStatusBarText(QString("Transmitting. Press Control-R to receive.")); ui->pttOnBtn->click(); } @@ -1855,7 +1853,7 @@ void wfmain::runPeriodicCommands() emit getMode(); break; case cmdGetDataMode: - // qDebug(logSystem()) << "Sending query for data mode"; + // qInfo(logSystem()) << "Sending query for data mode"; emit getDataMode(); break; case cmdSetDataModeOff: @@ -1956,7 +1954,7 @@ void wfmain::runDelayedCommand() switch(qdCmd) { case cmdNone: - //qDebug(logSystem()) << "NOOP"; + //qInfo(logSystem()) << "NOOP"; break; case cmdGetRigID: emit getRigID(); @@ -2138,14 +2136,13 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) { return; } else { -#ifdef QT_DEBUG qDebug(logSystem()) << "Rig name: " << rigCaps.modelName; qDebug(logSystem()) << "Has LAN capabilities: " << rigCaps.hasLan; qDebug(logSystem()) << "Rig ID received into wfmain: spectLenMax: " << rigCaps.spectLenMax; qDebug(logSystem()) << "Rig ID received into wfmain: spectAmpMax: " << rigCaps.spectAmpMax; qDebug(logSystem()) << "Rig ID received into wfmain: spectSeqMax: " << rigCaps.spectSeqMax; qDebug(logSystem()) << "Rig ID received into wfmain: hasSpectrum: " << rigCaps.hasSpectrum; -#endif + this->rigCaps = rigCaps; this->spectWidth = rigCaps.spectLenMax; // used once haveRigCaps is true. haveRigCaps = true; @@ -2315,7 +2312,7 @@ void wfmain::insertPeriodicCommand(cmds cmd, unsigned char priority) void wfmain::receiveFreq(freqt freqStruct) { - //qDebug(logSystem()) << "HEY WE GOT A Frequency: " << freqMhz; + //qInfo(logSystem()) << "HEY WE GOT A Frequency: " << freqMhz; ui->freqLabel->setText(QString("%1").arg(freqStruct.MHzDouble, 0, 'f')); freq = freqStruct; //showStatusBarText(QString("Frequency: %1").arg(freqMhz)); @@ -2324,7 +2321,7 @@ void wfmain::receiveFreq(freqt freqStruct) void wfmain::receivePTTstatus(bool pttOn) { // This is the only place where amTransmitting and the transmit button text should be changed: - //qDebug(logSystem()) << "PTT status: " << pttOn; + //qInfo(logSystem()) << "PTT status: " << pttOn; if (pttOn && !amTransmitting) { pttLed->setState(QLedLabel::State::StateError); @@ -2352,9 +2349,7 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e { if(!haveRigCaps) { -#ifdef QT_DEBUG qDebug(logSystem()) << "Spectrum received, but RigID incomplete."; -#endif return; } @@ -2372,19 +2367,17 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e oldLowerFreq = startFreq; oldUpperFreq = endFreq; - //qDebug(logSystem()) << "start: " << startFreq << " end: " << endFreq; + //qInfo(logSystem()) << "start: " << startFreq << " end: " << endFreq; quint16 specLen = spectrum.length(); - //qDebug(logSystem()) << "Spectrum data received at UI! Length: " << specLen; + //qInfo(logSystem()) << "Spectrum data received at UI! Length: " << specLen; //if( (specLen != 475) || (specLen!=689) ) if( specLen != rigCaps.spectLenMax ) { -#ifdef QT_DEBUG qDebug(logSystem()) << "-------------------------------------------"; qDebug(logSystem()) << "------ Unusual spectrum received, length: " << specLen; qDebug(logSystem()) << "------ Expected spectrum length: " << rigCaps.spectLenMax; qDebug(logSystem()) << "------ This should happen once at most. "; -#endif return; // safe. Using these unusual length things is a problem. } @@ -2575,7 +2568,7 @@ void wfmain::on_scopeEnableWFBtn_clicked(bool checked) void wfmain::receiveMode(unsigned char mode, unsigned char filter) { - //qDebug(logSystem()) << __func__ << "Received mode " << mode << " current mode: " << currentModeIndex; + //qInfo(logSystem()) << __func__ << "Received mode " << mode << " current mode: " << currentModeIndex; bool found=false; @@ -2594,12 +2587,12 @@ void wfmain::receiveMode(unsigned char mode, unsigned char filter) } currentModeIndex = mode; } else { - qDebug(logSystem()) << __func__ << "Invalid mode " << mode << " received. "; + qInfo(logSystem()) << __func__ << "Invalid mode " << mode << " received. "; } if(!found) { - qDebug(logSystem()) << __func__ << "Received mode " << mode << " but could not match to any index within the modeSelectCombo. "; + qInfo(logSystem()) << __func__ << "Received mode " << mode << " but could not match to any index within the modeSelectCombo. "; } if( (filter) && (filter < 4)){ @@ -2858,7 +2851,7 @@ void wfmain::on_modeSelectCombo_activated(int index) { // oops, we forgot to reset the combo box } else { - //qDebug(logSystem()) << __func__ << " at index " << index << " has newMode: " << newMode; + //qInfo(logSystem()) << __func__ << " at index " << index << " has newMode: " << newMode; currentMode = (mode_kind)newMode; emit setMode(newMode, filterSelection); } @@ -2958,7 +2951,7 @@ void wfmain::receiveBandStackReg(freqt freq, char mode, char filter, bool dataOn { // read the band stack and apply by sending out commands - qDebug(logSystem()) << __func__ << "BSR received into main: Freq: " << freq.Hz << ", mode: " << (unsigned int)mode << ", filter: " << (unsigned int)filter << ", data mode: " << dataOn; + qInfo(logSystem()) << __func__ << "BSR received into main: Freq: " << freq.Hz << ", mode: " << (unsigned int)mode << ", filter: " << (unsigned int)filter << ", data mode: " << dataOn; emit setFrequency(freq); setModeVal = (unsigned char) mode; setFilterVal = (unsigned char) filter; @@ -3219,7 +3212,7 @@ void wfmain::on_fRclBtn_clicked() issueDelayedCommand(cmdGetFreq); issueDelayedCommand(cmdGetMode); } else { - qDebug(logSystem()) << "Could not recall preset. Valid presets are 0 through 99."; + qInfo(logSystem()) << "Could not recall preset. Valid presets are 0 through 99."; } } @@ -3231,13 +3224,13 @@ void wfmain::on_rfGainSlider_valueChanged(int value) void wfmain::on_afGainSlider_valueChanged(int value) { - // qDebug(logSystem()) << "Setting AF gain to " << value; + // qInfo(logSystem()) << "Setting AF gain to " << value; emit setAfGain((unsigned char)value); } void wfmain::receiveRfGain(unsigned char level) { - // qDebug(logSystem()) << "Receive RF level of" << (int)level << " = " << 100*level/255.0 << "%"; + // qInfo(logSystem()) << "Receive RF level of" << (int)level << " = " << 100*level/255.0 << "%"; ui->rfGainSlider->blockSignals(true); ui->rfGainSlider->setValue(level); ui->rfGainSlider->blockSignals(false); @@ -3245,7 +3238,7 @@ void wfmain::receiveRfGain(unsigned char level) void wfmain::receiveAfGain(unsigned char level) { - // qDebug(logSystem()) << "Receive AF level of" << (int)level << " = " << 100*level/255.0 << "%"; + // qInfo(logSystem()) << "Receive AF level of" << (int)level << " = " << 100*level/255.0 << "%"; ui->afGainSlider->blockSignals(true); ui->afGainSlider->setValue(level); ui->afGainSlider->blockSignals(false); @@ -3326,7 +3319,7 @@ void wfmain::on_saveSettingsBtn_clicked() void wfmain::receiveATUStatus(unsigned char atustatus) { - // qDebug(logSystem()) << "Received ATU status update: " << (unsigned int) atustatus; + // qInfo(logSystem()) << "Received ATU status update: " << (unsigned int) atustatus; switch(atustatus) { case 0x00: @@ -3346,14 +3339,14 @@ void wfmain::receiveATUStatus(unsigned char atustatus) case 0x02: // ATU tuning in-progress. // Add command queue to check again and update status bar - // qDebug(logSystem()) << "Received ATU status update that *tuning* is taking place"; + // qInfo(logSystem()) << "Received ATU status update that *tuning* is taking place"; showStatusBarText("ATU is Tuning..."); cmdOutQue.append(cmdGetATUStatus); // Sometimes the first hit seems to be missed. cmdOutQue.append(cmdGetATUStatus); delayedCommand->start(); break; default: - qDebug(logSystem()) << "Did not understand ATU status: " << (unsigned int) atustatus; + qInfo(logSystem()) << "Did not understand ATU status: " << (unsigned int) atustatus; break; } } @@ -3668,7 +3661,7 @@ void wfmain::receiveModInput(rigInput input, bool dataOn) changeModLabel(input); } if(!found) - qDebug(logSystem()) << "Could not find modulation input: " << (int)input; + qInfo(logSystem()) << "Could not find modulation input: " << (int)input; } void wfmain::receiveACCGain(unsigned char level, unsigned char ab) @@ -3802,7 +3795,7 @@ void wfmain::serverConfigRequested(SERVERCONFIG conf, bool store) } else { // Store config in file! - qDebug(logSystem()) << "Storing server config"; + qInfo(logSystem()) << "Storing server config"; serverConfig = conf; } @@ -3897,7 +3890,7 @@ void wfmain::processChangingCurrentModLevel(unsigned char level) } else { currentIn = currentModSrc; } - //qDebug(logSystem()) << __func__ << ": setting current level: " << level; + //qInfo(logSystem()) << __func__ << ": setting current level: " << level; emit setModLevel(currentIn, level); } @@ -4016,7 +4009,7 @@ void wfmain::receiveSpectrumSpan(freqt freqspan, bool isSub) ui->scopeBWCombo->setCurrentIndex(7); break; default: - qDebug(logSystem()) << __func__ << "Could not match: " << freqspan.MHzDouble << " to anything like: " << (int)(freqspan.MHzDouble*1E6); + qInfo(logSystem()) << __func__ << "Could not match: " << freqspan.MHzDouble << " to anything like: " << (int)(freqspan.MHzDouble*1E6); break; } @@ -4089,7 +4082,7 @@ void wfmain::receiveRITValue(int ritValHz) ui->ritTuneDial->setValue(ritValHz); ui->ritTuneDial->blockSignals(false); } else { - qDebug(logSystem()) << "Warning: out of range RIT value received: " << ritValHz << " Hz"; + qInfo(logSystem()) << "Warning: out of range RIT value received: " << ritValHz << " Hz"; } } @@ -4209,7 +4202,7 @@ void wfmain::setBandButtons() // --- DEBUG FUNCTION --- void wfmain::on_debugBtn_clicked() { - qDebug(logSystem()) << "Debug button pressed."; - qDebug(logSystem()) << "getting mode."; + qInfo(logSystem()) << "Debug button pressed."; + qInfo(logSystem()) << "getting mode."; getMode(); }