Add --debug option to increase debugging for release builds

merge-requests/4/head
Phil Taylor 2021-05-15 18:53:16 +01:00
rodzic a6f336c384
commit 8f135b8ddd
13 zmienionych plików z 320 dodań i 324 usunięć

Wyświetl plik

@ -781,7 +781,7 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16
// chunk size is always relative to Internal Sample Rate. // chunk size is always relative to Internal Sample Rate.
this->chunkSize = (INTERNAL_SAMPLE_RATE / 25) * radioChannels; 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; 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); const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
for (const QAudioDeviceInfo& deviceInfo : deviceInfos) { for (const QAudioDeviceInfo& deviceInfo : deviceInfos) {
if (deviceInfo.deviceName() == port) { if (deviceInfo.deviceName() == port) {
qDebug(logAudio()) << "Input Audio Device name: " << deviceInfo.deviceName(); qInfo(logAudio()) << "Input Audio Device name: " << deviceInfo.deviceName();
isInitialized = setDevice(deviceInfo); isInitialized = setDevice(deviceInfo);
break; break;
} }
} }
if (!isInitialized) { 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()); 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); const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
for (const QAudioDeviceInfo& deviceInfo : deviceInfos) { for (const QAudioDeviceInfo& deviceInfo : deviceInfos) {
if (deviceInfo.deviceName() == port) { if (deviceInfo.deviceName() == port) {
qDebug(logAudio()) << "Output Audio Device name: " << deviceInfo.deviceName(); qInfo(logAudio()) << "Output Audio Device name: " << deviceInfo.deviceName();
isInitialized = setDevice(deviceInfo); isInitialized = setDevice(deviceInfo);
break; break;
} }
} }
if (!isInitialized) { 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()); isInitialized = setDevice(QAudioDeviceInfo::defaultOutputDevice());
} }
} }
wf_resampler_get_ratio(resampler, &ratioNum, &ratioDen); 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; return isInitialized;
} }
void audioHandler::setVolume(unsigned char volume) 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) { if (audioOutput != Q_NULLPTR) {
audioOutput->setVolume((qreal)(volume / 255.0)); audioOutput->setVolume((qreal)(volume / 255.0));
} }
@ -840,34 +840,34 @@ void audioHandler::setVolume(unsigned char volume)
bool audioHandler::setDevice(QAudioDeviceInfo deviceInfo) bool audioHandler::setDevice(QAudioDeviceInfo deviceInfo)
{ {
bool ret = true; 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.isFormatSupported(format)) {
if (deviceInfo.isNull()) 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; ret = false;
} }
else { else {
/* /*
qDebug(logAudio()) << "Audio Devices found: "; qInfo(logAudio()) << "Audio Devices found: ";
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
for (const QAudioDeviceInfo& deviceInfo : deviceInfos) for (const QAudioDeviceInfo& deviceInfo : deviceInfos)
{ {
qDebug(logAudio()) << "Device name: " << deviceInfo.deviceName(); qInfo(logAudio()) << "Device name: " << deviceInfo.deviceName();
qDebug(logAudio()) << "is null (probably not good):" << deviceInfo.isNull(); qInfo(logAudio()) << "is null (probably not good):" << deviceInfo.isNull();
qDebug(logAudio()) << "channel count:" << deviceInfo.supportedChannelCounts(); qInfo(logAudio()) << "channel count:" << deviceInfo.supportedChannelCounts();
qDebug(logAudio()) << "byte order:" << deviceInfo.supportedByteOrders(); qInfo(logAudio()) << "byte order:" << deviceInfo.supportedByteOrders();
qDebug(logAudio()) << "supported codecs:" << deviceInfo.supportedCodecs(); qInfo(logAudio()) << "supported codecs:" << deviceInfo.supportedCodecs();
qDebug(logAudio()) << "sample rates:" << deviceInfo.supportedSampleRates(); qInfo(logAudio()) << "sample rates:" << deviceInfo.supportedSampleRates();
qDebug(logAudio()) << "sample sizes:" << deviceInfo.supportedSampleSizes(); qInfo(logAudio()) << "sample sizes:" << deviceInfo.supportedSampleSizes();
qDebug(logAudio()) << "sample types:" << deviceInfo.supportedSampleTypes(); qInfo(logAudio()) << "sample types:" << deviceInfo.supportedSampleTypes();
} }
qDebug(logAudio()) << "----- done with audio info -----"; qInfo(logAudio()) << "----- done with audio info -----";
*/ */
ret=false; 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); deviceInfo.nearestFormat(format);
} }
this->deviceInfo = deviceInfo; this->deviceInfo = deviceInfo;
@ -877,7 +877,7 @@ bool audioHandler::setDevice(QAudioDeviceInfo deviceInfo)
void audioHandler::reinit() 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) { if (audioOutput != Q_NULLPTR && audioOutput->state() != QAudio::StoppedState) {
this->stop(); this->stop();
} }
@ -913,7 +913,7 @@ void audioHandler::reinit()
void audioHandler::start() 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) && if ((audioOutput == Q_NULLPTR || audioOutput->state() != QAudio::StoppedState) &&
(audioInput == Q_NULLPTR || audioInput->state() != QAudio::StoppedState) ) { (audioInput == Q_NULLPTR || audioInput->state() != QAudio::StoppedState) ) {
@ -933,7 +933,7 @@ void audioHandler::start()
void audioHandler::flush() void audioHandler::flush()
{ {
qDebug(logAudio()) << (isInput ? "Input" : "Output") << "flush() running"; qInfo(logAudio()) << (isInput ? "Input" : "Output") << "flush() running";
this->stop(); this->stop();
if (isInput) { if (isInput) {
audioInput->reset(); audioInput->reset();
@ -973,7 +973,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen)
// Calculate output length, always full samples // Calculate output length, always full samples
int sentlen = 0; 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. // We must lock the mutex for the entire time that the buffer may be modified.
// Get next packet from buffer. // Get next packet from buffer.
@ -989,7 +989,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen)
int timediff = packet->time.msecsTo(QTime::currentTime()); int timediff = packet->time.msecsTo(QTime::currentTime());
if (timediff > (int)latency * 2) { 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!) " << " arrived too late (increase output latency!) " <<
dec << packet->time.msecsTo(QTime::currentTime()) << "ms"; dec << packet->time.msecsTo(QTime::currentTime()) << "ms";
while (packet !=audioBuffer.end() && timediff > (int)latency) { 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); int send = qMin((int)maxlen-sentlen, packet->dataout.length() - packet->sent);
lastSeq = packet->seq; 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); 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) if (send == packet->dataout.length() - packet->sent)
{ {
//qDebug(logAudio()) << "Get next packet"; //qInfo(logAudio()) << "Get next packet";
packet = audioBuffer.erase(packet); // returns next packet packet = audioBuffer.erase(packet); // returns next packet
} }
else else
@ -1026,7 +1026,7 @@ qint64 audioHandler::readData(char* data, qint64 maxlen)
break; break;
} }
} else { } 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; lastSeq = packet->seq;
} }
} }
@ -1108,31 +1108,31 @@ void audioHandler::stateChanged(QAudio::State state)
{ {
case QAudio::IdleState: 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) if (audioOutput != Q_NULLPTR && audioOutput->error() == QAudio::UnderrunError)
{ {
qDebug(logAudio()) << (isInput ? "Input" : "Output") << "buffer underrun"; qInfo(logAudio()) << (isInput ? "Input" : "Output") << "buffer underrun";
audioOutput->suspend(); audioOutput->suspend();
} }
break; break;
} }
case QAudio::ActiveState: 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; break;
} }
case QAudio::SuspendedState: 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; break;
} }
case QAudio::StoppedState: 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; break;
} }
default: { 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. 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 /* 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. 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); err = wf_resampler_process_interleaved_int(resampler, (const qint16*)data.datain.constData(), &inFrames, (qint16*)data.dataout.data(), &outFrames);
} }
if (err) { 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 { else {
@ -1204,7 +1204,7 @@ void audioHandler::incomingAudio(audioPacket data)
// Restart playback // Restart playback
if (audioOutput->state() == QAudio::SuspendedState) if (audioOutput->state() == QAudio::SuspendedState)
{ {
qDebug(logAudio()) << "Output Audio Suspended, Resuming..."; qInfo(logAudio()) << "Output Audio Suspended, Resuming...";
audioOutput->resume(); audioOutput->resume();
} }
} }
@ -1212,7 +1212,7 @@ void audioHandler::incomingAudio(audioPacket data)
void audioHandler::changeLatency(const quint16 newSize) 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; latency = newSize;
} }
@ -1238,7 +1238,7 @@ void audioHandler::getNextAudioChunk(QByteArray& ret)
while (packet != audioBuffer.end()) while (packet != audioBuffer.end())
{ {
if (packet->time.msecsTo(QTime::currentTime()) > 100) { 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 packet = audioBuffer.erase(packet); // returns next packet
} }
else { else {
@ -1265,10 +1265,10 @@ void audioHandler::getNextAudioChunk(QByteArray& ret)
err = wf_resampler_process_interleaved_int(resampler, in, &inFrames, out, &outFrames); err = wf_resampler_process_interleaved_int(resampler, in, &inFrames, out, &outFrames);
} }
if (err) { 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; //qInfo(logAudio()) << "Resampler run " << err << " inFrames:" << inFrames << " outFrames:" << outFrames;
//qDebug(logAudio()) << "Resampler run inLen:" << packet->datain.length() << " outLen:" << packet->dataout.length(); //qInfo(logAudio()) << "Resampler run inLen:" << packet->datain.length() << " outLen:" << packet->dataout.length();
if (radioSampleBits == 8) if (radioSampleBits == 8)
{ {
packet->datain=packet->dataout; // Copy output packet back to input buffer. packet->datain=packet->dataout; // Copy output packet back to input buffer.

Wyświetl plik

@ -23,9 +23,9 @@ commHandler::commHandler()
setupComm(); // basic parameters setupComm(); // basic parameters
openPort(); 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... //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())); connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn()));
} }
@ -48,9 +48,9 @@ commHandler::commHandler(QString portName, quint32 baudRate)
setupComm(); // basic parameters setupComm(); // basic parameters
openPort(); 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... //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())); connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn()));
} }
@ -79,11 +79,9 @@ void commHandler::sendDataOut(const QByteArray &writeData)
mutex.lock(); mutex.lock();
#ifdef QT_DEBUG
qint64 bytesWritten; qint64 bytesWritten;
bytesWritten = port->write(writeData); bytesWritten = port->write(writeData);
if(bytesWritten != (qint64)writeData.size()) if(bytesWritten != (qint64)writeData.size())
{ {
qDebug(logSerial()) << "bytesWritten: " << bytesWritten << " length of byte array: " << writeData.length()\ 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()); << " Wrote all bytes? " << (bool) (bytesWritten == (qint64)writeData.size());
} }
#else
port->write(writeData);
#endif
mutex.unlock(); mutex.unlock();
} }
@ -118,21 +112,21 @@ void commHandler::receiveDataIn()
if(rolledBack) 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); //printHex(inPortData, false, true);
rolledBack = false; rolledBack = false;
} }
} else { } else {
// did not receive the entire thing so roll back: // did not receive the entire thing so roll back:
// qDebug(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); //printHex(inPortData, false, true);
port->rollbackTransaction(); port->rollbackTransaction();
rolledBack = true; rolledBack = true;
} }
} else { } else {
port->commitTransaction(); // do not emit data, do not keep data. port->commitTransaction(); // do not emit data, do not keep data.
//qDebug(logSerial()) << "Warning: received data with invalid start. Dropping data."; //qInfo(logSerial()) << "Warning: received data with invalid start. Dropping data.";
//qDebug(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!"; //qInfo(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!";
// THIS SHOULD ONLY HAPPEN ONCE! // THIS SHOULD ONLY HAPPEN ONCE!
// unrecoverable. We did not receive the start and must // unrecoverable. We did not receive the start and must
@ -154,10 +148,10 @@ void commHandler::openPort()
port->setDataTerminalReady(false); port->setDataTerminalReady(false);
port->setRequestToSend(false); port->setRequestToSend(false);
isConnected = true; isConnected = true;
qDebug(logSerial()) << "Opened port: " << portName; qInfo(logSerial()) << "Opened port: " << portName;
return; return;
} else { } else {
qDebug(logSerial()) << "Could not open serial port " << portName << " , please restart."; qInfo(logSerial()) << "Could not open serial port " << portName << " , please restart.";
isConnected = false; isConnected = false;
serialError = true; serialError = true;
emit haveSerialPortError(portName, "Could not open port. Please restart."); emit haveSerialPortError(portName, "Could not open port. Please restart.");
@ -178,7 +172,7 @@ void commHandler::closePort()
void commHandler::debugThis() void commHandler::debugThis()
{ {
// Do not use, function is for debug only and subject to change. // Do not use, function is for debug only and subject to change.
qDebug(logSerial()) << "comm debug called."; qInfo(logSerial()) << "comm debug called.";
inPortData = port->readAll(); inPortData = port->readAll();
emit haveDataFromPort(inPortData); emit haveDataFromPort(inPortData);

Wyświetl plik

@ -15,7 +15,7 @@ freqMemory::freqMemory()
void freqMemory::initializePresets() void freqMemory::initializePresets()
{ {
// qDebug() << "Initializing " << numPresets << " memory channels"; // qInfo() << "Initializing " << numPresets << " memory channels";
for(unsigned int p=0; p < numPresets; p++) for(unsigned int p=0; p < numPresets; p++)
{ {
@ -61,6 +61,6 @@ void freqMemory::dumpMemory()
{ {
for(unsigned int p=0; p < numPresets; p++) 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;
} }
} }

Wyświetl plik

@ -8,6 +8,7 @@
// Smart pointer to log file // Smart pointer to log file
QScopedPointer<QFile> m_logFile; QScopedPointer<QFile> m_logFile;
QMutex logMutex; QMutex logMutex;
bool debugMode=false;
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg); 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.setOrganizationDomain("wfview.org");
a.setApplicationName("wfview"); a.setApplicationName("wfview");
#ifdef QT_DEBUG
debugMode = true;
#endif
QString serialPortCL; QString serialPortCL;
QString hostCL; QString hostCL;
@ -30,21 +33,26 @@ int main(int argc, char *argv[])
QString currentArg; 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<argc; c++) for(int c=1; c<argc; c++)
{ {
//qDebug() << "Argc: " << c << " argument: " << argv[c]; //qInfo() << "Argc: " << c << " argument: " << argv[c];
currentArg = QString(argv[c]); currentArg = QString(argv[c]);
if((currentArg == "-p") || currentArg == "--port") if ((currentArg == "-p") || (currentArg == "--port"))
{ {
if(argc > c) if (argc > c)
{ {
serialPortCL = argv[c+1]; serialPortCL = argv[c + 1];
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) if(argc > c)
{ {
@ -90,11 +98,9 @@ int main(int argc, char *argv[])
qInfo(logSystem()) << "Starting wfview"; qInfo(logSystem()) << "Starting wfview";
#ifdef QT_DEBUG qDebug(logSystem()) << "SerialPortCL as set by parser: " << serialPortCL;
qInfo(logSystem()) << "SerialPortCL as set by parser: " << serialPortCL; qDebug(logSystem()) << "remote host as set by parser: " << hostCL;
qInfo(logSystem()) << "remote host as set by parser: " << hostCL; qDebug(logSystem()) << "CIV as set by parser: " << civCL;
qInfo(logSystem()) << "CIV as set by parser: " << civCL;
#endif
a.setWheelScrollLines(1); // one line per wheel click a.setWheelScrollLines(1); // one line per wheel click
wfmain w( serialPortCL, hostCL); wfmain w( serialPortCL, hostCL);
@ -110,6 +116,10 @@ int main(int argc, char *argv[])
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{ {
// Open stream file writes // Open stream file writes
if (type == QtDebugMsg && !debugMode)
{
return;
}
QMutexLocker locker(&logMutex); QMutexLocker locker(&logMutex);
QTextStream out(m_logFile.data()); QTextStream out(m_logFile.data());
@ -119,11 +129,21 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt
switch (type) switch (type)
{ {
case QtInfoMsg: out << "INF "; break; case QtDebugMsg:
case QtDebugMsg: out << "DBG "; break; out << "DBG ";
case QtWarningMsg: out << "WRN "; break; break;
case QtCriticalMsg: out << "CRT "; break; case QtInfoMsg:
case QtFatalMsg: out << "FTL "; break; 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 // Write to the output category of the message and the message itself
out << context.category << ": " << msg << "\n"; out << context.category << ": " << msg << "\n";

Wyświetl plik

@ -57,20 +57,20 @@ void pttyHandler::openPort()
if (ptfd >=0) 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)) if (grantpt(ptfd))
{ {
qDebug(logSerial()) << "Failed to grantpt"; qInfo(logSerial()) << "Failed to grantpt";
return; return;
} }
if (unlockpt(ptfd)) if (unlockpt(ptfd))
{ {
qDebug(logSerial()) << "Failed to unlock pt"; qInfo(logSerial()) << "Failed to unlock pt";
return; return;
} }
// we're good! // 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); ptReader = new QSocketNotifier(ptfd, QSocketNotifier::Read, this);
connect(ptReader, &QSocketNotifier::activated, connect(ptReader, &QSocketNotifier::activated,
@ -83,7 +83,7 @@ void pttyHandler::openPort()
if (!success) if (!success)
{ {
ptfd = 0; ptfd = 0;
qDebug(logSerial()) << "Could not open pseudo terminal port, please restart."; qInfo(logSerial()) << "Could not open pseudo terminal port, please restart.";
isConnected = false; isConnected = false;
serialError = true; serialError = true;
emit haveSerialPortError(portName, "Could not open pseudo terminal port. Please restart."); emit haveSerialPortError(portName, "Could not open pseudo terminal port. Please restart.");
@ -98,9 +98,9 @@ void pttyHandler::openPort()
{ {
if (!QFile::link(ptDevSlave, portName)) if (!QFile::link(ptDevSlave, portName))
{ {
qDebug(logSerial()) << "Error creating link to" << ptDevSlave << "from" << portName; qInfo(logSerial()) << "Error creating link to" << ptDevSlave << "from" << portName;
} else { } else {
qDebug(logSerial()) << "Created link to" << ptDevSlave << "from" << portName; qInfo(logSerial()) << "Created link to" << ptDevSlave << "from" << portName;
} }
} }
#endif #endif
@ -123,7 +123,7 @@ void pttyHandler::receiveDataFromRigToPtty(const QByteArray& data)
// 0xE1 = wfview // 0xE1 = wfview
// 0xE0 = pseudo-term host // 0xE0 = pseudo-term host
// 0x00 = broadcast to all // 0x00 = broadcast to all
//qDebug(logSerial()) << "Sending data from radio to pseudo-terminal"; //qInfo(logSerial()) << "Sending data from radio to pseudo-terminal";
sendDataOut(data); sendDataOut(data);
} }
} }
@ -132,7 +132,7 @@ void pttyHandler::sendDataOut(const QByteArray& writeData)
{ {
qint64 bytesWritten = 0; qint64 bytesWritten = 0;
//qDebug(logSerial()) << "Data to pseudo term:"; //qInfo(logSerial()) << "Data to pseudo term:";
//printHex(writeData, false, true); //printHex(writeData, false, true);
if (isConnected) { if (isConnected) {
mutex.lock(); mutex.lock();
@ -142,7 +142,7 @@ void pttyHandler::sendDataOut(const QByteArray& writeData)
bytesWritten = ::write(ptfd, writeData.constData(), writeData.size()); bytesWritten = ::write(ptfd, writeData.constData(), writeData.size());
#endif #endif
if (bytesWritten != writeData.length()) { 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()\ << " size of byte array: " << writeData.size()\
<< " Wrote all bytes? " << (bool)(bytesWritten == (qint64)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); ssize_t got = ::read(fd, inPortData.data(), available);
int err = errno; int err = errno;
if (got < 0) { 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; return;
} }
inPortData.resize(got); 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) { 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. // This is (should be) the remotes CIV id.
civId = (quint8)inPortData[lastFE + 2]; 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) else if (civId != 0 && inPortData.length() > lastFE + 2 && (quint8)inPortData[lastFE + 2] != civId)
{ {
civId = (quint8)inPortData[lastFE + 2]; 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. // 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"))) 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); //printHex(inPortData, false, true);
QByteArray reply= QByteArrayLiteral("\xfe\xfe\x00\x00\xfb\xfd"); QByteArray reply= QByteArrayLiteral("\xfe\xfe\x00\x00\xfb\xfd");
reply[2] = inPortData[3]; 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)) else if (inPortData.length() > lastFE + 2 && ((quint8)inPortData[lastFE + 1] == civId || (quint8)inPortData[lastFE + 2] == civId))
{ {
emit haveDataFromPort(inPortData); emit haveDataFromPort(inPortData);
//qDebug(logSerial()) << "Data from pseudo term:"; //qInfo(logSerial()) << "Data from pseudo term:";
//printHex(inPortData, false, true); //printHex(inPortData, false, true);
} }
if (rolledBack) 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); //printHex(inPortData, false, true);
rolledBack = false; rolledBack = false;
} }
} }
else { else {
// did not receive the entire thing so roll back: // did not receive the entire thing so roll back:
// qDebug(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); //printHex(inPortData, false, true);
rolledBack = true; rolledBack = true;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -237,8 +237,8 @@ void pttyHandler::receiveDataIn(int fd) {
} }
else { else {
port->commitTransaction(); // do not emit data, do not keep data. port->commitTransaction(); // do not emit data, do not keep data.
//qDebug(logSerial()) << "Warning: received data with invalid start. Dropping data."; //qInfo(logSerial()) << "Warning: received data with invalid start. Dropping data.";
//qDebug(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!"; //qInfo(logSerial()) << "THIS SHOULD ONLY HAPPEN ONCE!!";
// THIS SHOULD ONLY HAPPEN ONCE! // THIS SHOULD ONLY HAPPEN ONCE!
} }
#else #else
@ -270,7 +270,7 @@ void pttyHandler::closePort()
void pttyHandler::debugThis() void pttyHandler::debugThis()
{ {
// Do not use, function is for debug only and subject to change. // Do not use, function is for debug only and subject to change.
qDebug(logSerial()) << "comm debug called."; qInfo(logSerial()) << "comm debug called.";
inPortData = port->readAll(); inPortData = port->readAll();
emit haveDataFromPort(inPortData); emit haveDataFromPort(inPortData);

Wyświetl plik

@ -17,7 +17,7 @@ QLedLabel::QLedLabel(QWidget* parent) :
void QLedLabel::setState(State state) void QLedLabel::setState(State state)
{ {
qDebug() << "setState" << state; qInfo() << "setState" << state;
switch (state) { switch (state) {
case StateOk: case StateOk:
setStyleSheet(greenSS); setStyleSheet(greenSS);

Wyświetl plik

@ -192,7 +192,7 @@ void rigCommander::process()
void rigCommander::handleSerialPortError(const QString port, const QString errorText) 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); emit haveSerialPortError(port, errorText);
} }
@ -230,14 +230,14 @@ void rigCommander::prepDataAndSend(QByteArray data)
data.prepend(payloadPrefix); data.prepend(payloadPrefix);
//printHex(data, false, true); //printHex(data, false, true);
data.append(payloadSuffix); data.append(payloadSuffix);
#ifdef QT_DEBUG
if(data[4] != '\x15') if(data[4] != '\x15')
{ {
// We don't print out requests for meter levels // We don't print out requests for meter levels
qDebug(logRig()) << "Final payload in rig commander to be sent to rig: "; qDebug(logRig()) << "Final payload in rig commander to be sent to rig: ";
printHex(data); printHex(data);
} }
#endif
emit dataForComm(data); emit dataForComm(data);
} }
@ -254,10 +254,8 @@ void rigCommander::powerOn()
payload.append("\x18\x01"); payload.append("\x18\x01");
payload.append(payloadSuffix); // FD payload.append(payloadSuffix); // FD
#ifdef QT_DEBUG
qDebug(logRig()) << "Power ON command in rigcommander to be sent to rig: "; qDebug(logRig()) << "Power ON command in rigcommander to be sent to rig: ";
printHex(payload); printHex(payload);
#endif
emit dataForComm(payload); emit dataForComm(payload);
@ -497,7 +495,7 @@ void rigCommander::getSpectrumRefLevel(unsigned char mainSub)
void rigCommander::setSpectrumRefLevel(int level) void rigCommander::setSpectrumRefLevel(int level)
{ {
//qDebug(logRig()) << __func__ << ": Setting scope to level " << level; //qInfo(logRig()) << __func__ << ": Setting scope to level " << level;
QByteArray setting; QByteArray setting;
QByteArray number; QByteArray number;
QByteArray pn; QByteArray pn;
@ -515,7 +513,7 @@ void rigCommander::setSpectrumRefLevel(int level)
setting.append(number); setting.append(number);
setting.append(pn); 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); //printHex(setting, false, true);
prepDataAndSend(setting); prepDataAndSend(setting);
@ -590,7 +588,7 @@ QByteArray rigCommander::makeFreqPayload(double freq)
result.append(a); result.append(a);
//printHex(result, false, true); //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); //printHex(result, false, true);
return result; return result;
} }
@ -762,7 +760,7 @@ void rigCommander::setTone(quint16 tone)
payload.setRawData("\x1B\x00", 2); payload.setRawData("\x1B\x00", 2);
payload.append(fenc); payload.append(fenc);
//qDebug() << __func__ << "TONE encoded payload: "; //qInfo() << __func__ << "TONE encoded payload: ";
printHex(payload); printHex(payload);
prepDataAndSend(payload); prepDataAndSend(payload);
@ -776,7 +774,7 @@ void rigCommander::setTSQL(quint16 tsql)
payload.setRawData("\x1B\x01", 2); payload.setRawData("\x1B\x01", 2);
payload.append(fenc); payload.append(fenc);
//qDebug() << __func__ << "TSQL encoded payload: "; //qInfo() << __func__ << "TSQL encoded payload: ";
printHex(payload); printHex(payload);
prepDataAndSend(payload); prepDataAndSend(payload);
@ -791,7 +789,7 @@ void rigCommander::setDTCS(quint16 dcscode, bool tinv, bool rinv)
payload.setRawData("\x1B\x02", 2); payload.setRawData("\x1B\x02", 2);
payload.append(denc); payload.append(denc);
//qDebug() << __func__ << "DTCS encoded payload: "; //qInfo() << __func__ << "DTCS encoded payload: ";
printHex(payload); printHex(payload);
prepDataAndSend(payload); prepDataAndSend(payload);
@ -987,7 +985,7 @@ void rigCommander::parseData(QByteArray dataInput)
// use this: // use this:
QList <QByteArray> dataList = dataInput.split('\xFD'); QList <QByteArray> dataList = dataInput.split('\xFD');
QByteArray data; QByteArray data;
// qDebug(logRig()) << "data list has this many elements: " << dataList.size(); // qInfo(logRig()) << "data list has this many elements: " << dataList.size();
if (dataList.last().isEmpty()) if (dataList.last().isEmpty())
{ {
dataList.removeLast(); // if the original ended in FD, then there is a blank entry at the end. dataList.removeLast(); // if the original ended in FD, then there is a blank entry at the end.
@ -1011,14 +1009,14 @@ void rigCommander::parseData(QByteArray dataInput)
// Data from the rig that was not asked for is sent to controller 0x00: // Data from the rig that was not asked for is sent to controller 0x00:
// fe fe 00 94 ...... fd (for example, user rotates the tune control or changes the mode) // fe fe 00 94 ...... fd (for example, user rotates the tune control or changes the mode)
//qDebug(logRig()) << "Data received: "; //qInfo(logRig()) << "Data received: ";
//printHex(data, false, true); //printHex(data, false, true);
if(data.length() < 4) if(data.length() < 4)
{ {
if(data.length()) if(data.length())
{ {
// Finally this almost never happens // Finally this almost never happens
// qDebug(logRig()) << "Data length too short: " << data.length() << " bytes. Data:"; // qInfo(logRig()) << "Data length too short: " << data.length() << " bytes. Data:";
//printHex(data, false, true); //printHex(data, false, true);
} }
// no // no
@ -1029,18 +1027,18 @@ void rigCommander::parseData(QByteArray dataInput)
if(!data.startsWith("\xFE\xFE")) 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, // find 94 e0 and shift over,
// or look inside for a second FE FE // or look inside for a second FE FE
// Often a local echo will miss a few bytes at the beginning. // Often a local echo will miss a few bytes at the beginning.
if(data.startsWith('\xFE')) if(data.startsWith('\xFE'))
{ {
data.prepend('\xFE'); data.prepend('\xFE');
// qDebug(logRig()) << "Warning: Working with prepended data stream."; // qInfo(logRig()) << "Warning: Working with prepended data stream.";
parseData(payloadIn); parseData(payloadIn);
return; return;
} else { } else {
//qDebug(logRig()) << "Error: Could not reconstruct corrupted data: "; //qInfo(logRig()) << "Error: Could not reconstruct corrupted data: ";
//printHex(data, false, true); //printHex(data, false, true);
// data.right(data.length() - data.find('\xFE\xFE')); // data.right(data.length() - data.find('\xFE\xFE'));
// if found do not return and keep going. // if found do not return and keep going.
@ -1053,7 +1051,7 @@ void rigCommander::parseData(QByteArray dataInput)
// data is or begins with an echoback from what we sent // data is or begins with an echoback from what we sent
// find the first 'fd' and cut it. Then continue. // find the first 'fd' and cut it. Then continue.
//payloadIn = data.right(data.length() - data.indexOf('\xfd')-1); //payloadIn = data.right(data.length() - data.indexOf('\xfd')-1);
// qDebug(logRig()) << "[FOUND] Trimmed off echo:"; // qInfo(logRig()) << "[FOUND] Trimmed off echo:";
//printHex(payloadIn, false, true); //printHex(payloadIn, false, true);
//parseData(payloadIn); //parseData(payloadIn);
//return; //return;
@ -1067,7 +1065,7 @@ void rigCommander::parseData(QByteArray dataInput)
// // data is or begins with an echoback from what we sent // // data is or begins with an echoback from what we sent
// // find the first 'fd' and cut it. Then continue. // // find the first 'fd' and cut it. Then continue.
// payloadIn = data.right(data.length() - data.indexOf('\xfd')-1); // payloadIn = data.right(data.length() - data.indexOf('\xfd')-1);
// //qDebug(logRig()) << "Trimmed off echo:"; // //qInfo(logRig()) << "Trimmed off echo:";
// //printHex(payloadIn, false, true); // //printHex(payloadIn, false, true);
// parseData(payloadIn); // parseData(payloadIn);
// break; // break;
@ -1090,9 +1088,7 @@ void rigCommander::parseData(QByteArray dataInput)
// This is an echo of our own broadcast request. // This is an echo of our own broadcast request.
// The data are "to 00" and "from E1" // The data are "to 00" and "from E1"
// Don't use it! // Don't use it!
#ifdef QT_DEBUG
qDebug(logRig()) << "Caught it! Found the echo'd broadcast request from us!"; qDebug(logRig()) << "Caught it! Found the echo'd broadcast request from us!";
#endif
} else { } else {
payloadIn = data.right(data.length() - 4); payloadIn = data.right(data.length() - 4);
parseCommand(); parseCommand();
@ -1108,7 +1104,7 @@ void rigCommander::parseData(QByteArray dataInput)
/* /*
if(dataList.length() > 1) 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. // 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)); bool isSpectrumData = payloadIn.startsWith(QByteArray().setRawData("\x27\x00", 2));
if( (!isSpectrumData) && (payloadIn[00] != '\x15') ) if( (!isSpectrumData) && (payloadIn[00] != '\x15') )
@ -1126,7 +1121,6 @@ void rigCommander::parseCommand()
// as they tend to clog up any useful logging. // as they tend to clog up any useful logging.
printHex(payloadIn); printHex(payloadIn);
} }
#endif
switch(payloadIn[00]) switch(payloadIn[00])
{ {
@ -1145,19 +1139,19 @@ void rigCommander::parseCommand()
} }
break; break;
case '\x01': case '\x01':
//qDebug(logRig()) << "Have mode data"; //qInfo(logRig()) << "Have mode data";
this->parseMode(); this->parseMode();
break; break;
case '\x04': case '\x04':
//qDebug(logRig()) << "Have mode data"; //qInfo(logRig()) << "Have mode data";
this->parseMode(); this->parseMode();
break; break;
case '\x05': case '\x05':
//qDebug(logRig()) << "Have frequency data"; //qInfo(logRig()) << "Have frequency data";
this->parseFrequency(); this->parseFrequency();
break; break;
case '\x06': case '\x06':
//qDebug(logRig()) << "Have mode data"; //qInfo(logRig()) << "Have mode data";
this->parseMode(); this->parseMode();
break; break;
case '\x0F': case '\x0F':
@ -1178,11 +1172,11 @@ void rigCommander::parseCommand()
parseRegister16(); parseRegister16();
break; break;
case '\x19': case '\x19':
// qDebug(logRig()) << "Have rig ID: " << (unsigned int)payloadIn[2]; // qInfo(logRig()) << "Have rig ID: " << (unsigned int)payloadIn[2];
// printHex(payloadIn, false, true); // printHex(payloadIn, false, true);
model = determineRadioModel(payloadIn[2]); // verify this is the model not the CIV model = determineRadioModel(payloadIn[2]); // verify this is the model not the CIV
determineRigCaps(); determineRigCaps();
qDebug(logRig()) << "Have rig ID: decimal: " << (unsigned int)model; qInfo(logRig()) << "Have rig ID: decimal: " << (unsigned int)model;
break; break;
@ -1201,7 +1195,7 @@ void rigCommander::parseCommand()
break; break;
case '\x27': case '\x27':
// scope data // scope data
//qDebug(logRig()) << "Have scope data"; //qInfo(logRig()) << "Have scope data";
//printHex(payloadIn, false, true); //printHex(payloadIn, false, true);
parseWFData(); parseWFData();
//parseSpectrum(); //parseSpectrum();
@ -1225,16 +1219,15 @@ void rigCommander::parseCommand()
break; break;
case '\xFA': case '\xFA':
// error // error
#ifdef QT_DEBUG
qDebug(logRig()) << "Error (FA) received from rig."; qDebug(logRig()) << "Error (FA) received from rig.";
printHex(payloadIn, false ,true); printHex(payloadIn, false ,true);
#endif
break; break;
default: default:
// This gets hit a lot when the pseudo-term is // This gets hit a lot when the pseudo-term is
// using commands wfview doesn't know yet. // using commands wfview doesn't know yet.
// qDebug(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); // printHex(payloadIn, false, true);
break; break;
} }
@ -1244,7 +1237,7 @@ void rigCommander::parseCommand()
void rigCommander::parseLevels() void rigCommander::parseLevels()
{ {
//qDebug(logRig()) << "Received a level status readout: "; //qInfo(logRig()) << "Received a level status readout: ";
// printHex(payloadIn, false, true); // printHex(payloadIn, false, true);
// wrong: unsigned char level = (payloadIn[2] * 100) + payloadIn[03]; // wrong: unsigned char level = (payloadIn[2] * 100) + payloadIn[03];
@ -1254,7 +1247,7 @@ void rigCommander::parseLevels()
unsigned char level = (100*hundreds) + (10*tens) + units; 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): // Typical RF gain response (rather low setting):
// "INDEX: 00 01 02 03 04 " // "INDEX: 00 01 02 03 04 "
@ -1305,7 +1298,7 @@ void rigCommander::parseLevels()
break; break;
default: 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; break;
} }
@ -1346,7 +1339,7 @@ void rigCommander::parseLevels()
break; break;
default: 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; break;
} }
@ -1910,7 +1903,7 @@ void rigCommander::setRefAdjustCourse(unsigned char level)
void rigCommander::setRefAdjustFine(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 // 1A 05 00 73 0000-0255
QByteArray payload; QByteArray payload;
payload.setRawData("\x1A\x05\x00\x73", 4); payload.setRawData("\x1A\x05\x00\x73", 4);
@ -2012,7 +2005,7 @@ void rigCommander::parseRegister21()
void rigCommander::parseATU() void rigCommander::parseATU()
{ {
// qDebug(logRig()) << "Have ATU status from radio. Emitting."; // qInfo(logRig()) << "Have ATU status from radio. Emitting.";
// Expect: // Expect:
// [0]: 0x1c // [0]: 0x1c
// [1]: 0x01 // [1]: 0x01
@ -2046,7 +2039,7 @@ void rigCommander::parseRegisters1A()
// 01: band stacking memory contents (last freq used is stored here per-band) // 01: band stacking memory contents (last freq used is stored here per-band)
// 03: filter width // 03: filter width
// 04: AGC rate // 04: AGC rate
// qDebug(logRig()) << "Looking at register 1A :"; // qInfo(logRig()) << "Looking at register 1A :";
// printHex(payloadIn, false, true); // printHex(payloadIn, false, true);
// "INDEX: 00 01 02 03 04 " // "INDEX: 00 01 02 03 04 "
@ -2133,7 +2126,7 @@ void rigCommander::parseRegister16()
void rigCommander::parseBandStackReg() void rigCommander::parseBandStackReg()
{ {
//qDebug(logRig()) << "Band stacking register response received: "; //qInfo(logRig()) << "Band stacking register response received: ";
//printHex(payloadIn, false, true); //printHex(payloadIn, false, true);
// Reference output, 20 meters, regCode 01 (latest): // Reference output, 20 meters, regCode 01 (latest):
@ -2156,9 +2149,9 @@ void rigCommander::parseBandStackReg()
// 14, 15 tone squelch freq setting // 14, 15 tone squelch freq setting
// if more, memory name (label) ascii // if more, memory name (label) ascii
qDebug(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()) << "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; //qInfo(logRig()) << "mode: " << (QString)mode << " dataOn: " << dataOn;
//qDebug(logRig()) << "Freq Hz: " << freqs.Hz; //qInfo(logRig()) << "Freq Hz: " << freqs.Hz;
emit haveBandStackReg(freqs, mode, filter, dataOn); emit haveBandStackReg(freqs, mode, filter, dataOn);
} }
@ -2447,20 +2440,20 @@ void rigCommander::parseWFData()
isSub = payloadIn.at(2)==0x01; isSub = payloadIn.at(2)==0x01;
freqSpan = parseFrequency(payloadIn, 6); freqSpan = parseFrequency(payloadIn, 6);
emit haveScopeSpan(freqSpan, isSub); 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); //printHex(payloadIn, false, true);
break; break;
case 0x16: case 0x16:
// read edge mode center in edge mode // read edge mode center in edge mode
emit haveScopeEdge((char)payloadIn[2]); emit haveScopeEdge((char)payloadIn[2]);
qDebug(logRig()) << "Received 0x16 edge in center mode:"; qInfo(logRig()) << "Received 0x16 edge in center mode:";
printHex(payloadIn, false, true); printHex(payloadIn, false, true);
// [1] 0x16 // [1] 0x16
// [2] 0x01, 0x02, 0x03: Edge 1,2,3 // [2] 0x01, 0x02, 0x03: Edge 1,2,3
break; break;
case 0x17: case 0x17:
// Hold status (only 9700?) // Hold status (only 9700?)
qDebug(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); printHex(payloadIn, false, true);
break; break;
case 0x19: case 0x19:
@ -2473,7 +2466,7 @@ void rigCommander::parseWFData()
parseSpectrumRefLevel(); parseSpectrumRefLevel();
break; break;
default: default:
qDebug(logRig()) << "Unknown waveform data received: "; qInfo(logRig()) << "Unknown waveform data received: ";
printHex(payloadIn, false, true); printHex(payloadIn, false, true);
break; break;
} }
@ -2816,7 +2809,7 @@ void rigCommander::determineRigCaps()
rigCaps.bands = standardHF; rigCaps.bands = standardHF;
rigCaps.bands.insert(rigCaps.bands.end(), standardVU.begin(), standardVU.end()); rigCaps.bands.insert(rigCaps.bands.end(), standardVU.begin(), standardVU.end());
rigCaps.bands.insert(rigCaps.bands.end(), {band23cm, band4m, band630m, band2200m, bandGen}); 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; break;
} }
haveRigCaps = true; haveRigCaps = true;
@ -2824,15 +2817,14 @@ void rigCommander::determineRigCaps()
{ {
lookingForRig = false; lookingForRig = false;
foundRig = true; foundRig = true;
#ifdef QT_DEBUG
qDebug(logRig()) << "---Rig FOUND from broadcast query:"; qDebug(logRig()) << "---Rig FOUND from broadcast query:";
#endif
this->civAddr = incomingCIVAddr; // Override and use immediately. this->civAddr = incomingCIVAddr; // Override and use immediately.
payloadPrefix = QByteArray("\xFE\xFE"); payloadPrefix = QByteArray("\xFE\xFE");
payloadPrefix.append(civAddr); payloadPrefix.append(civAddr);
payloadPrefix.append((char)compCivAddr); payloadPrefix.append((char)compCivAddr);
// if there is a compile-time error, remove the following line, the "hex" part is the issue: // if there is a compile-time error, remove the following line, the "hex" part is the issue:
qDebug(logRig()) << "Using incomingCIVAddr: (int): " << this->civAddr << " hex: " << hex << this->civAddr; qInfo(logRig()) << "Using incomingCIVAddr: (int): " << this->civAddr << " hex: " << hex << this->civAddr;
emit discoveredRigID(rigCaps); emit discoveredRigID(rigCaps);
} else { } else {
emit haveRigID(rigCaps); emit haveRigID(rigCaps);
@ -2843,15 +2835,13 @@ void rigCommander::parseSpectrum()
{ {
if(!haveRigCaps) if(!haveRigCaps)
{ {
#ifdef QT_DEBUG
qDebug(logRig()) << "Spectrum received in rigCommander, but rigID is incomplete."; qDebug(logRig()) << "Spectrum received in rigCommander, but rigID is incomplete.";
#endif
return; return;
} }
if(rigCaps.spectSeqMax == 0) if(rigCaps.spectSeqMax == 0)
{ {
// there is a chance this will happen with rigs that support spectrum. Once our RigID query returns, we will parse correctly. // there is a chance this will happen with rigs that support spectrum. Once our RigID query returns, we will parse correctly.
qDebug(logRig()) << "Warning: Spectrum sequence max was zero, yet spectrum was received."; qInfo(logRig()) << "Warning: Spectrum sequence max was zero, yet spectrum was received.";
return; return;
} }
// Here is what to expect: // Here is what to expect:
@ -2894,7 +2884,7 @@ void rigCommander::parseSpectrum()
// unsigned char waveInfo = payloadIn[06]; // really just one byte? // 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 // Sequnce 2, index 05 is the start of data
// Sequence 11. index 05, is the last chunk // Sequence 11. index 05, is the last chunk
@ -2949,13 +2939,13 @@ void rigCommander::parseSpectrum()
// sequence numbers 2 through 10, 50 pixels each. Total after sequence 10 is 450 pixels. // sequence numbers 2 through 10, 50 pixels each. Total after sequence 10 is 450 pixels.
payloadIn.chop(1); payloadIn.chop(1);
spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5)); // write over the FD, last one doesn't, oh well. spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5)); // write over the FD, last one doesn't, oh well.
//qDebug(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) } else if (sequence == rigCaps.spectSeqMax)
{ {
// last spectrum, a little bit different (last 25 pixels). Total at end is 475 pixels (7300). // last spectrum, a little bit different (last 25 pixels). Total at end is 475 pixels (7300).
payloadIn.chop(1); payloadIn.chop(1);
spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5)); spectrumLine.insert(spectrumLine.length(), payloadIn.right(payloadIn.length() - 5));
//qDebug(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); emit haveSpectrumData(spectrumLine, spectrumStartFreq, spectrumEndFreq);
} }
} }
@ -3023,7 +3013,7 @@ QByteArray rigCommander::bcdEncodeInt(unsigned int num)
{ {
if(num > 9999) 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(); return QByteArray();
} }
@ -3035,7 +3025,7 @@ QByteArray rigCommander::bcdEncodeInt(unsigned int num)
char b0 = hundreds | (thousands << 4); char b0 = hundreds | (thousands << 4);
char b1 = units | (tens << 4); char b1 = units | (tens << 4);
//qDebug(logRig()) << __FUNCTION__ << " encoding value " << num << " as hex:"; //qInfo(logRig()) << __FUNCTION__ << " encoding value " << num << " as hex:";
//printHex(QByteArray(b0), false, true); //printHex(QByteArray(b0), false, true);
//printHex(QByteArray(b1), false, true); //printHex(QByteArray(b1), false, true);
@ -3204,7 +3194,7 @@ void rigCommander::setATU(bool enabled)
void rigCommander::getATUStatus() 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"); QByteArray payload("\x1C\x01");
prepDataAndSend(payload); prepDataAndSend(payload);
} }
@ -3343,7 +3333,7 @@ void rigCommander::printHex(const QByteArray &pdata, bool printVert, bool printH
void rigCommander::dataFromServer(QByteArray data) void rigCommander::dataFromServer(QByteArray data)
{ {
//qDebug(logRig()) << "emit dataForComm()"; //qInfo(logRig()) << "emit dataForComm()";
emit dataForComm(data); emit dataForComm(data);
} }

Wyświetl plik

@ -18,7 +18,7 @@ void rigCtlD::receiveFrequency(freqt freq)
void rigCtlD::receiveStateInfo(rigStateStruct* state) void rigCtlD::receiveStateInfo(rigStateStruct* state)
{ {
qDebug("Setting rig state"); qInfo("Setting rig state");
rigState = state; rigState = state;
} }
@ -27,12 +27,12 @@ void rigCtlD::receiveStateInfo(rigStateStruct* state)
int rigCtlD::startServer(qint16 port) int rigCtlD::startServer(qint16 port)
{ {
if (!this->listen(QHostAddress::Any, 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; return -1;
} }
else else
{ {
qDebug(logRigCtlD()) << "started on port " << port; qInfo(logRigCtlD()) << "started on port " << port;
} }
return 0; return 0;
} }
@ -45,13 +45,13 @@ void rigCtlD::incomingConnection(qintptr socket) {
void rigCtlD::stopServer() void rigCtlD::stopServer()
{ {
qDebug(logRigCtlD()) << "stopping server"; qInfo(logRigCtlD()) << "stopping server";
emit onStopped(); emit onStopped();
} }
void rigCtlD::receiveRigCaps(rigCapabilities caps) void rigCtlD::receiveRigCaps(rigCapabilities caps)
{ {
qDebug(logRigCtlD()) << "Got rigcaps for:" << caps.modelName; qInfo(logRigCtlD()) << "Got rigcaps for:" << caps.modelName;
this->rigCaps = caps; this->rigCaps = caps;
} }
@ -66,13 +66,13 @@ rigCtlClient::rigCtlClient(int socketId, rigCapabilities caps, rigStateStruct* s
this->parent = parent; this->parent = parent;
if (!socket->setSocketDescriptor(sessionId)) if (!socket->setSocketDescriptor(sessionId))
{ {
qDebug(logRigCtlD()) << " error binding socket: " << sessionId; qInfo(logRigCtlD()) << " error binding socket: " << sessionId;
return; return;
} }
connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()), Qt::DirectConnection); connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()), Qt::DirectConnection);
connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()), Qt::DirectConnection); connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()), Qt::DirectConnection);
connect(parent, SIGNAL(sendData(QString)), this, SLOT(sendData(QString)), 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() void rigCtlClient::socketReadyRead()
@ -84,7 +84,7 @@ void rigCtlClient::socketReadyRead()
bool longReply = false; bool longReply = false;
if (commandBuffer.endsWith('\n')) if (commandBuffer.endsWith('\n'))
{ {
qDebug(logRigCtlD()) << sessionId << "command received" << commandBuffer; qInfo(logRigCtlD()) << sessionId << "command received" << commandBuffer;
commandBuffer.chop(1); // Remove \n character commandBuffer.chop(1); // Remove \n character
if (commandBuffer.endsWith('\r')) if (commandBuffer.endsWith('\r'))
{ {
@ -95,7 +95,7 @@ void rigCtlClient::socketReadyRead()
if (rigState == Q_NULLPTR) if (rigState == Q_NULLPTR)
{ {
qDebug(logRigCtlD()) << "no rigState!"; qInfo(logRigCtlD()) << "no rigState!";
return; return;
} }
@ -181,7 +181,7 @@ void rigCtlClient::socketReadyRead()
{ {
// Set mode // Set mode
if (command.length() > 1) { 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); emit parent->setMode(getMode(command[1]), 0x06);
} }
sendData(QString("RPRT 0\n")); sendData(QString("RPRT 0\n"));
@ -198,7 +198,7 @@ void rigCtlClient::socketReadyRead()
void rigCtlClient::socketDisconnected() void rigCtlClient::socketDisconnected()
{ {
qDebug(logRigCtlD()) << sessionId << "disconnected"; qInfo(logRigCtlD()) << sessionId << "disconnected";
socket->deleteLater(); socket->deleteLater();
this->deleteLater(); this->deleteLater();
} }
@ -210,14 +210,14 @@ void rigCtlClient::closeSocket()
void rigCtlClient::sendData(QString data) void rigCtlClient::sendData(QString data)
{ {
qDebug(logRigCtlD()) << "Sending:" << data; qInfo(logRigCtlD()) << "Sending:" << data;
if (socket != Q_NULLPTR && socket->isValid() && socket->isOpen()) if (socket != Q_NULLPTR && socket->isValid() && socket->isOpen())
{ {
socket->write(data.toLatin1()); socket->write(data.toLatin1());
} }
else else
{ {
qDebug(logRigCtlD()) << "socket not open!"; qInfo(logRigCtlD()) << "socket not open!";
} }
} }

Wyświetl plik

@ -104,7 +104,6 @@ private:
unsigned char getMode(QString modeString); unsigned char getMode(QString modeString);
QString getFilter(unsigned char mode, unsigned char filter); QString getFilter(unsigned char mode, unsigned char filter);
//Interface commands;
}; };

Wyświetl plik

@ -24,7 +24,7 @@ udpHandler::udpHandler(udpPreferences prefs) :
this->password = prefs.password; this->password = prefs.password;
this->compName = prefs.clientName.mid(0,8) + "-wfview"; 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; " 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. // 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) { if (addr.protocol() == QAbstractSocket::IPv4Protocol) {
radioIP = addr; radioIP = addr;
qDebug(logUdp()) << "Got IP Address :" << prefs.ipAddress << ": " << addr.toString(); qInfo(logUdp()) << "Got IP Address :" << prefs.ipAddress << ": " << addr.toString();
break; break;
} }
} }
if (radioIP.isNull()) 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; return;
} }
} }
@ -93,7 +93,7 @@ udpHandler::~udpHandler()
if (civ != Q_NULLPTR) { if (civ != Q_NULLPTR) {
delete civ; delete civ;
} }
qDebug(logUdp()) << "Sending token removal packet"; qInfo(logUdp()) << "Sending token removal packet";
sendToken(0x01); sendToken(0x01);
if (tokenTimer != Q_NULLPTR) if (tokenTimer != Q_NULLPTR)
{ {
@ -153,7 +153,7 @@ void udpHandler::dataReceived()
control_packet_t in = (control_packet_t)r.constData(); control_packet_t in = (control_packet_t)r.constData();
if (in->type == 0x04) { if (in->type == 0x04) {
// If timer is active, stop it as they are obviously there! // If timer is active, stop it as they are obviously there!
qDebug(logUdp()) << this->metaObject()->className() << ": Received I am here from: " <<datagram.senderAddress(); qInfo(logUdp()) << this->metaObject()->className() << ": Received I am here from: " <<datagram.senderAddress();
if (areYouThereTimer->isActive()) { if (areYouThereTimer->isActive()) {
// send ping packets every second // 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. // This is "I am ready" in response to "Are you ready" so send login.
else if (in->type == 0x06) else if (in->type == 0x06)
{ {
qDebug(logUdp()) << this->metaObject()->className() << ": Received I am ready"; qInfo(logUdp()) << this->metaObject()->className() << ": Received I am ready";
sendLogin(); // send login packet sendLogin(); // send login packet
} }
break; break;
@ -234,12 +234,12 @@ void udpHandler::dataReceived()
if (in->error == 0x00ffffff && !streamOpened) if (in->error == 0x00ffffff && !streamOpened)
{ {
emit haveNetworkError(radioIP.toString(), "Auth failed, try rebooting the radio."); emit haveNetworkError(radioIP.toString(), "Auth failed, try rebooting the radio.");
qDebug(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) else if (in->error == 0x00000000 && in->disc == 0x01)
{ {
emit haveNetworkError(radioIP.toString(), "Got radio disconnected."); 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) { if (streamOpened) {
// Close stream connections but keep connection open to the radio. // Close stream connections but keep connection open to the radio.
if (audio != Q_NULLPTR) { if (audio != Q_NULLPTR) {
@ -269,7 +269,7 @@ void udpHandler::dataReceived()
if (in->error == 0xfeffffff) if (in->error == 0xfeffffff)
{ {
emit haveNetworkStatus("Invalid Username/Password"); emit haveNetworkStatus("Invalid Username/Password");
qDebug(logUdp()) << this->metaObject()->className() << ": Invalid Username/Password"; qInfo(logUdp()) << this->metaObject()->className() << ": Invalid Username/Password";
} }
else if (!isAuthenticated) else if (!isAuthenticated)
{ {
@ -277,7 +277,7 @@ void udpHandler::dataReceived()
if (in->tokrequest == tokRequest) if (in->tokrequest == tokRequest)
{ {
emit haveNetworkStatus("Radio Login OK!"); 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; token = in->token;
sendToken(0x02); sendToken(0x02);
tokenTimer->start(TOKEN_RENEWAL); // Start token request timer tokenTimer->start(TOKEN_RENEWAL); // Start token request timer
@ -285,7 +285,7 @@ void udpHandler::dataReceived()
} }
else 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; highBandwidthConnection = true;
} }
qDebug(logUdp()) << this->metaObject()->className() << ": Detected connection speed " << in->connection; qInfo(logUdp()) << this->metaObject()->className() << ": Detected connection speed " << in->connection;
} }
break; break;
} }
@ -324,7 +324,7 @@ void udpHandler::dataReceived()
emit haveNetworkStatus(devName); 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... // Stuff can change in the meantime because of a previous login...
remoteId = in->sentid; remoteId = in->sentid;
@ -361,7 +361,7 @@ void udpHandler::dataReceived()
audioType = in->audio; audioType = in->audio;
devName = in->name; devName = in->name;
//replyId = r.mid(0x42, 16); //replyId = r.mid(0x42, 16);
qDebug(logUdp()) << this->metaObject()->className() << "Received radio capabilities, Name:" << qInfo(logUdp()) << this->metaObject()->className() << "Received radio capabilities, Name:" <<
devName << " Audio:" << devName << " Audio:" <<
audioType; audioType;
} }
@ -417,10 +417,10 @@ void udpHandler::sendAreYouThere()
{ {
if (areYouThereCounter == 20) if (areYouThereCounter == 20)
{ {
qDebug(logUdp()) << this->metaObject()->className() << ": Radio not responding."; qInfo(logUdp()) << this->metaObject()->className() << ": Radio not responding.";
emit haveNetworkStatus("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++; areYouThereCounter++;
udpBase::sendControl(false,0x03,0x00); udpBase::sendControl(false,0x03,0x00);
@ -429,7 +429,7 @@ void udpHandler::sendAreYouThere()
void udpHandler::sendLogin() // Only used on control stream. 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<quint16>(rand() | rand() << 8); // Generate random token request. tokRequest = static_cast<quint16>(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 // Class that manages all Civ Data to/from the rig
udpCivData::udpCivData(QHostAddress local, QHostAddress ip, quint16 civPort) udpCivData::udpCivData(QHostAddress local, QHostAddress ip, quint16 civPort)
{ {
qDebug(logUdp()) << "Starting udpCivData"; qInfo(logUdp()) << "Starting udpCivData";
localIP = local; localIP = local;
port = civPort; port = civPort;
radioIP = ip; radioIP = ip;
@ -548,7 +548,7 @@ void udpCivData::watchdog()
if (lastReceived.msecsTo(QTime::currentTime()) > 500) if (lastReceived.msecsTo(QTime::currentTime()) > 500)
{ {
if (!alerted) { 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) if (startCivDataTimer != Q_NULLPTR)
{ {
startCivDataTimer->start(100); startCivDataTimer->start(100);
@ -564,7 +564,7 @@ void udpCivData::watchdog()
void udpCivData::send(QByteArray d) void udpCivData::send(QByteArray d)
{ {
// qDebug(logUdp()) << "Sending: (" << d.length() << ") " << d; // qInfo(logUdp()) << "Sending: (" << d.length() << ") " << d;
data_packet p; data_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
p.len = sizeof(p)+d.length(); p.len = sizeof(p)+d.length();
@ -613,7 +613,7 @@ void udpCivData::dataReceived()
while (udp->hasPendingDatagrams()) while (udp->hasPendingDatagrams())
{ {
QNetworkDatagram datagram = udp->receiveDatagram(); QNetworkDatagram datagram = udp->receiveDatagram();
//qDebug(logUdp()) << "Received: " << datagram.data(); //qInfo(logUdp()) << "Received: " << datagram.data();
QByteArray r = datagram.data(); QByteArray r = datagram.data();
switch (r.length()) switch (r.length())
@ -671,7 +671,7 @@ void udpCivData::dataReceived()
// Audio stream // 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) 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->localIP = local;
this->port = audioPort; this->port = audioPort;
this->radioIP = ip; 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 /* Just log it at the moment, maybe try signalling the control channel that it needs to
try requesting civ/audio again? */ 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; alerted = true;
} }
} }
@ -848,7 +848,7 @@ void udpAudio::sendTxAudio()
QByteArray tx = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); QByteArray tx = QByteArray::fromRawData((const char*)p.packet, sizeof(p));
tx.append(partial); tx.append(partial);
len = len + partial.length(); len = len + partial.length();
//qDebug(logUdp()) << "Sending audio packet length: " << tx.length(); //qInfo(logUdp()) << "Sending audio packet length: " << tx.length();
sendTrackedPacket(tx); sendTrackedPacket(tx);
sendAudioSeq++; sendAudioSeq++;
counter++; counter++;
@ -870,7 +870,7 @@ void udpAudio::dataReceived()
{ {
while (udp->hasPendingDatagrams()) { while (udp->hasPendingDatagrams()) {
QNetworkDatagram datagram = udp->receiveDatagram(); QNetworkDatagram datagram = udp->receiveDatagram();
//qDebug(logUdp()) << "Received: " << datagram.data(); //qInfo(logUdp()) << "Received: " << datagram.data();
QByteArray r = datagram.data(); QByteArray r = datagram.data();
switch (r.length()) switch (r.length())
@ -934,7 +934,7 @@ void udpBase::init()
udp = new QUdpSocket(this); udp = new QUdpSocket(this);
udp->bind(); // Bind to random port. udp->bind(); // Bind to random port.
localPort = udp->localPort(); localPort = udp->localPort();
qDebug(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(); uint32_t addr = localIP.toIPv4Address();
myId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (localPort & 0xffff); myId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (localPort & 0xffff);
@ -946,7 +946,7 @@ void udpBase::init()
udpBase::~udpBase() udpBase::~udpBase()
{ {
qDebug(logUdp()) << "Closing UDP stream :" << radioIP.toString() << ":" << port; qInfo(logUdp()) << "Closing UDP stream :" << radioIP.toString() << ":" << port;
if (udp != Q_NULLPTR) { if (udp != Q_NULLPTR) {
sendControl(false, 0x05, 0x00); // Send disconnect sendControl(false, 0x05, 0x00); // Send disconnect
udp->close(); udp->close();
@ -1009,14 +1009,14 @@ void udpBase::dataReceived(QByteArray r)
// Found matching entry? // Found matching entry?
// Send "untracked" as it has already been sent once. // Send "untracked" as it has already been sent once.
// Don't constantly retransmit the same packet, give-up eventually // 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++; match->retransmitCount++;
QMutexLocker udplocker(&udpMutex); QMutexLocker udplocker(&udpMutex);
udp->writeDatagram(match->data, radioIP, port); udp->writeDatagram(match->data, radioIP, port);
} }
} }
if (in->type == 0x04) { if (in->type == 0x04) {
qDebug(logUdp()) << this->metaObject()->className() << ": Received I am here "; qInfo(logUdp()) << this->metaObject()->className() << ": Received I am here ";
areYouThereCounter = 0; areYouThereCounter = 0;
// I don't think that we will ever receive an "I am here" other than in response to "Are you there?" // I don't think that we will ever receive an "I am here" other than in response to "Are you there?"
remoteId = in->sentid; remoteId = in->sentid;
@ -1060,11 +1060,11 @@ void udpBase::dataReceived(QByteArray r)
} }
else { else {
// Not sure what to do here, need to spend more time with the protocol but will try sending ping with same seq next time. // Not sure what to do here, need to spend more time with the protocol but will try sending ping with same seq next time.
//qDebug(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 { 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; return s.seqNum == cs;
}); });
if (match == txSeqBuf.end()) { 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. // Just send idle packet.
sendControl(false, 0, match->seqNum); sendControl(false, 0, match->seqNum);
} }
else { else {
// Found matching entry? // Found matching entry?
// Send "untracked" as it has already been sent once. // 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++; match->retransmitCount++;
QMutexLocker udplocker(&udpMutex); QMutexLocker udplocker(&udpMutex);
udp->writeDatagram(match->data, radioIP, port); udp->writeDatagram(match->data, radioIP, port);
@ -1124,7 +1124,7 @@ void udpBase::dataReceived(QByteArray r)
std::sort(rxSeqBuf.begin(), rxSeqBuf.end()); std::sort(rxSeqBuf.begin(), rxSeqBuf.end());
if (in->seq < rxSeqBuf.front()) 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++; //seqPrefix++;
// Looks like it has rolled over so clear buffer and start again. // Looks like it has rolled over so clear buffer and start again.
rxSeqBuf.clear(); rxSeqBuf.clear();
@ -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; }); auto s = std::find_if(rxMissing.begin(), rxMissing.end(), [&cs = in->seq](SEQBUFENTRY& s) { return s.seqNum == cs; });
if (s != rxMissing.end()) 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); s = rxMissing.erase(s);
} }
} }
@ -1168,12 +1168,12 @@ void udpBase::sendRetransmitRequest()
{ {
for (quint16 j = *i + 1; j < *(i + 1); j++) 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; }); auto s = std::find_if(rxMissing.begin(), rxMissing.end(), [&cs = j](SEQBUFENTRY& s) { return s.seqNum == cs; });
if (s == rxMissing.end()) if (s == rxMissing.end())
{ {
// We haven't seen this missing packet before // 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; SEQBUFENTRY b;
b.seqNum = j; b.seqNum = j;
b.retransmitCount = 0; b.retransmitCount = 0;
@ -1193,7 +1193,7 @@ void udpBase::sendRetransmitRequest()
} }
} }
else { else {
qDebug(logUdp()) << this->metaObject()->className() << ": Too many missing, flushing buffers"; qInfo(logUdp()) << this->metaObject()->className() << ": Too many missing, flushing buffers";
rxSeqBuf.clear(); rxSeqBuf.clear();
missingSeqs.clear(); missingSeqs.clear();
break; break;
@ -1225,13 +1225,13 @@ void udpBase::sendRetransmitRequest()
if (missingSeqs.length() == 4) // This is just a single missing packet so send using a control. 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); 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); QMutexLocker udplocker(&udpMutex);
udp->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), radioIP, port); udp->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), radioIP, port);
} }
else 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)); missingSeqs.insert(0, p.packet, sizeof(p.packet));
QMutexLocker udplocker(&udpMutex); QMutexLocker udplocker(&udpMutex);
udp->writeDatagram(missingSeqs, radioIP, port); udp->writeDatagram(missingSeqs, radioIP, port);

Wyświetl plik

@ -6,7 +6,7 @@
udpServer::udpServer(SERVERCONFIG config) : udpServer::udpServer(SERVERCONFIG config) :
config(config) config(config)
{ {
qDebug(logUdpServer()) << "Starting udp server"; qInfo(logUdpServer()) << "Starting udp server";
} }
void udpServer::init() void udpServer::init()
@ -35,24 +35,24 @@ void udpServer::init()
uint32_t addr = localIP.toIPv4Address(); 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); controlId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (config.controlPort & 0xffff);
civId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (config.civPort & 0xffff); civId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (config.civPort & 0xffff);
audioId = (addr >> 8 & 0xff) << 24 | (addr & 0xff) << 16 | (config.audioPort & 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 = new QUdpSocket(this);
udpControl->bind(config.controlPort); udpControl->bind(config.controlPort);
QUdpSocket::connect(udpControl, &QUdpSocket::readyRead, this, &udpServer::controlReceived); 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 = new QUdpSocket(this);
udpCiv->bind(config.civPort); udpCiv->bind(config.civPort);
QUdpSocket::connect(udpCiv, &QUdpSocket::readyRead, this, &udpServer::civReceived); 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 = new QUdpSocket(this);
udpAudio->bind(config.audioPort); udpAudio->bind(config.audioPort);
QUdpSocket::connect(udpAudio, &QUdpSocket::readyRead, this, &udpServer::audioReceived); QUdpSocket::connect(udpAudio, &QUdpSocket::readyRead, this, &udpServer::audioReceived);
@ -60,7 +60,7 @@ void udpServer::init()
udpServer::~udpServer() udpServer::~udpServer()
{ {
qDebug(logUdpServer()) << "Closing udpServer"; qInfo(logUdpServer()) << "Closing udpServer";
connMutex.lock(); connMutex.lock();
@ -221,7 +221,7 @@ void udpServer::controlReceived()
current->commonCap = 0x8010; current->commonCap = 0x8010;
qDebug(logUdpServer()) << current->ipAddress.toString() << ": New Control connection created"; qInfo(logUdpServer()) << current->ipAddress.toString() << ": New Control connection created";
connMutex.lock(); connMutex.lock();
controlClients.append(current); controlClients.append(current);
connMutex.unlock(); connMutex.unlock();
@ -238,7 +238,7 @@ void udpServer::controlReceived()
control_packet_t in = (control_packet_t)r.constData(); control_packet_t in = (control_packet_t)r.constData();
if (in->type == 0x05) 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); sendControl(current, 0x00, in->seq);
//current->wdTimer->stop(); // Keep watchdog running to delete stale connection. //current->wdTimer->stop(); // Keep watchdog running to delete stale connection.
deleteConnection(&controlClients, current); deleteConnection(&controlClients, current);
@ -265,7 +265,7 @@ void udpServer::controlReceived()
current->pingSeq++; current->pingSeq++;
} }
else { 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; current->identb = in->identb;
if (in->res == 0x02) { if (in->res == 0x02) {
// Request for new token // Request for new token
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received create token request"; qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received create token request";
sendCapabilities(current); sendCapabilities(current);
sendConnectionInfo(current); sendConnectionInfo(current);
} }
else if (in->res == 0x01) { else if (in->res == 0x01) {
// Token disconnect // Token disconnect
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received token disconnect request"; qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received token disconnect request";
sendTokenResponse(current, in->res); sendTokenResponse(current, in->res);
} }
else if (in->res == 0x04) { else if (in->res == 0x04) {
@ -298,7 +298,7 @@ void udpServer::controlReceived()
sendConnectionInfo(current); sendConnectionInfo(current);
} }
else { else {
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received token request"; qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received token request";
sendTokenResponse(current, in->res); sendTokenResponse(current, in->res);
} }
break; break;
@ -306,7 +306,7 @@ void udpServer::controlReceived()
case (LOGIN_SIZE): case (LOGIN_SIZE):
{ {
login_packet_t in = (login_packet_t)r.constData(); login_packet_t in = (login_packet_t)r.constData();
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Received 'login'"; qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received 'login'";
bool userOk = false; bool userOk = false;
foreach(SERVERUSER user, config.users) 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; current->tokenTx =(quint8)rand() | (quint8)rand() << 8 | (quint8)rand() << 16 | (quint8)rand() << 24;
if (userOk) { 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); sendLoginResponse(current, true);
} }
else { else {
qDebug(logUdpServer()) << current->ipAddress.toString() << ": Incorrect username/password"; qInfo(logUdpServer()) << current->ipAddress.toString() << ": Incorrect username/password";
sendLoginResponse(current, false); sendLoginResponse(current, false);
} }
@ -344,7 +344,7 @@ void udpServer::controlReceived()
case (CONNINFO_SIZE): case (CONNINFO_SIZE):
{ {
conninfo_packet_t in = (conninfo_packet_t)r.constData(); conninfo_packet_t in = (conninfo_packet_t)r.constData();
qDebug(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! // Request to start audio and civ!
current->isStreaming = true; current->isStreaming = true;
current->rxSeq = in->seq; current->rxSeq = in->seq;
@ -359,7 +359,7 @@ void udpServer::controlReceived()
sendStatus(current); sendStatus(current);
current->authInnerSeq = 0x00; current->authInnerSeq = 0x00;
sendConnectionInfo(current); 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 << " rxSampleRate" << current->rxSampleRate <<
" txSampleRate" << current->rxSampleRate << " txSampleRate" << current->rxSampleRate <<
" txBufferLen" << current->txBufferLen; " txBufferLen" << current->txBufferLen;
@ -504,7 +504,7 @@ void udpServer::civReceived()
connect(current->retransmitTimer, &QTimer::timeout, this, std::bind(&udpServer::sendRetransmitRequest, this, current)); connect(current->retransmitTimer, &QTimer::timeout, this, std::bind(&udpServer::sendRetransmitRequest, this, current));
current->retransmitTimer->start(RETRANSMIT_PERIOD); 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(); connMutex.lock();
civClients.append(current); civClients.append(current);
connMutex.unlock(); connMutex.unlock();
@ -537,7 +537,7 @@ void udpServer::civReceived()
current->pingSeq++; current->pingSeq++;
} }
else { 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: // Strip all '0xFE' command preambles first:
int lastFE = r.lastIndexOf((char)0xfe); 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) { 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. // This is (should be) the remotes CIV id.
current->civId = (quint8)r[lastFE + 2]; 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) else if (current->civId != 0 && r.length() > lastFE + 2 && (quint8)r[lastFE + 2] != current->civId)
{ {
current->civId = (quint8)r[lastFE + 2]; 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)); emit haveDataFromServer(r.mid(0x15));
} }
else { 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)); connect(current->retransmitTimer, &QTimer::timeout, this, std::bind(&udpServer::sendRetransmitRequest, this, current));
current->retransmitTimer->start(RETRANSMIT_PERIOD); current->retransmitTimer->start(RETRANSMIT_PERIOD);
current->seqPrefix = 0; 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(); connMutex.lock();
audioClients.append(current); audioClients.append(current);
connMutex.unlock(); connMutex.unlock();
@ -662,7 +662,7 @@ void udpServer::audioReceived()
current->pingSeq++; current->pingSeq++;
} }
else { 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.time = QTime::currentTime();;
tempAudio.sent = 0; tempAudio.sent = 0;
tempAudio.datain = r.mid(0x18); tempAudio.datain = r.mid(0x18);
//qDebug(logUdpServer()) << "sending tx audio " << in->seq; //qInfo(logUdpServer()) << "sending tx audio " << in->seq;
emit haveAudioData(tempAudio); emit haveAudioData(tempAudio);
} }
} }
@ -718,7 +718,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
if (r.length() < 0x10) if (r.length() < 0x10)
{ {
// Invalid packet // 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; return;
} }
@ -728,13 +728,13 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
{ {
control_packet_t in = (control_packet_t)r.constData(); control_packet_t in = (control_packet_t)r.constData();
if (in->type == 0x03) { if (in->type == 0x03) {
qDebug(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; current->remoteId = in->sentid;
sendControl(current, 0x04, in->seq); sendControl(current, 0x04, in->seq);
} // This is This is "Are you ready" in response to "I am here". } // This is This is "Are you ready" in response to "I am here".
else if (in->type == 0x06) else if (in->type == 0x06)
{ {
qDebug(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; current->remoteId = in->sentid;
sendControl(current, 0x06, in->seq); sendControl(current, 0x06, in->seq);
if (current->idleTimer != Q_NULLPTR && !current->idleTimer->isActive()) { if (current->idleTimer != Q_NULLPTR && !current->idleTimer->isActive()) {
@ -744,7 +744,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
else if (in->type == 0x01) else if (in->type == 0x01)
{ {
// Single packet request // 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) { auto match = std::find_if(current->txSeqBuf.begin(), current->txSeqBuf.end(), [&cs = in->seq](SEQBUFENTRY& s) {
return s.seqNum == cs; return s.seqNum == cs;
@ -753,7 +753,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
if (match != current->txSeqBuf.end() && match->retransmitCount < 5) { if (match != current->txSeqBuf.end() && match->retransmitCount < 5) {
// Found matching entry? // Found matching entry?
// Don't constantly retransmit the same packet, give-up eventually // 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++; match->retransmitCount++;
udpMutex.lock(); udpMutex.lock();
current->socket->writeDatagram(match->data, current->ipAddress, current->port); current->socket->writeDatagram(match->data, current->ipAddress, current->port);
@ -782,7 +782,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
return s.seqNum == cs; return s.seqNum == cs;
}); });
if (match == current->txSeqBuf.end()) { 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. // Just send idle packet.
sendControl(current, 0, in->seq); sendControl(current, 0, in->seq);
} }
@ -790,7 +790,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
{ {
// Found matching entry? // Found matching entry?
// Send "untracked" as it has already been sent once. // Send "untracked" as it has already been sent once.
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++; match->retransmitCount++;
udpMutex.lock(); udpMutex.lock();
current->socket->writeDatagram(match->data, current->ipAddress, current->port); current->socket->writeDatagram(match->data, current->ipAddress, current->port);
@ -802,7 +802,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
else if (in->type == 0x00 && in->seq != 0x00) else if (in->type == 0x00 && in->seq != 0x00)
{ {
//if (current->type == "CIV") { //if (current->type == "CIV") {
// qDebug(logUdpServer()) << "Got:" << in->seq; // qInfo(logUdpServer()) << "Got:" << in->seq;
//} //}
current->rxMutex.lock(); current->rxMutex.lock();
if (current->rxSeqBuf.isEmpty()) if (current->rxSeqBuf.isEmpty())
@ -814,7 +814,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
std::sort(current->rxSeqBuf.begin(), current->rxSeqBuf.end()); std::sort(current->rxSeqBuf.begin(), current->rxSeqBuf.end());
if (in->seq < current->rxSeqBuf.front()) 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. // Looks like it has rolled over so clear buffer and start again.
current->rxSeqBuf.clear(); current->rxSeqBuf.clear();
current->rxMutex.unlock(); // Must unlock the Mutex! current->rxMutex.unlock(); // Must unlock the Mutex!
@ -831,7 +831,7 @@ void udpServer::commonReceived(QList<CLIENT*>* 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; }); 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()) 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); s = current->rxMissing.erase(s);
} }
current->missMutex.unlock(); current->missMutex.unlock();
@ -846,7 +846,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l,CLIENT* current, QByteArray r)
void udpServer::sendControl(CLIENT* c, quint8 type, quint16 seq) 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; control_packet p;
memset(p.packet, 0x0, CONTROL_SIZE); // We can't be sure it is initialized with 0x00! memset(p.packet, 0x0, CONTROL_SIZE); // We can't be sure it is initialized with 0x00!
@ -892,13 +892,13 @@ void udpServer::sendPing(QList<CLIENT*> *l,CLIENT* c, quint16 seq, bool reply)
if (c->lastHeard.secsTo(now) > STALE_CONNECTION) if (c->lastHeard.secsTo(now) > STALE_CONNECTION)
{ {
qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Deleting stale connection "; qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Deleting stale connection ";
deleteConnection(l, c); deleteConnection(l, c);
return; return;
} }
//qDebug(logUdpServer()) << c->ipAddress.toString() << ": Sending Ping"; //qInfo(logUdpServer()) << c->ipAddress.toString() << ": Sending Ping";
quint32 pingTime = 0; quint32 pingTime = 0;
if (reply) { if (reply) {
@ -932,7 +932,7 @@ void udpServer::sendPing(QList<CLIENT*> *l,CLIENT* c, quint16 seq, bool reply)
void udpServer::sendLoginResponse(CLIENT* c, bool allowed) 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; login_response_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
@ -982,7 +982,7 @@ void udpServer::sendLoginResponse(CLIENT* c, bool allowed)
void udpServer::sendCapabilities(CLIENT* c) 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; capabilities_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
@ -1101,7 +1101,7 @@ void udpServer::sendCapabilities(CLIENT* c)
// Also used to display currently connected used information. // Also used to display currently connected used information.
void udpServer::sendConnectionInfo(CLIENT* c) void udpServer::sendConnectionInfo(CLIENT* c)
{ {
qDebug(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending ConnectionInfo :" << c->txSeq; qInfo(logUdpServer()) << c->ipAddress.toString() << "(" << c->type << "): Sending ConnectionInfo :" << c->txSeq;
conninfo_packet p; conninfo_packet p;
memset(p.packet, 0x0, sizeof(p)); memset(p.packet, 0x0, sizeof(p));
p.len = sizeof(p); p.len = sizeof(p);
@ -1152,7 +1152,7 @@ void udpServer::sendConnectionInfo(CLIENT* c)
void udpServer::sendTokenResponse(CLIENT* c, quint8 type) 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; token_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
@ -1194,7 +1194,7 @@ void udpServer::sendTokenResponse(CLIENT* c, quint8 type)
void udpServer::watchdog(CLIENT* c) void udpServer::watchdog(CLIENT* c)
{ {
c->txMutex.lock(); 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? // 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()) if (!c->txSeqBuf.isEmpty())
{ {
@ -1226,7 +1226,7 @@ void udpServer::watchdog(CLIENT* c)
void udpServer::sendStatus(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; status_packet p;
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
@ -1271,7 +1271,7 @@ void udpServer::sendStatus(CLIENT* c)
void udpServer::dataForServer(QByteArray d) void udpServer::dataForServer(QByteArray d)
{ {
//qDebug(logUdpServer()) << "Server got:" << d; //qInfo(logUdpServer()) << "Server got:" << d;
foreach(CLIENT * client, civClients) foreach(CLIENT * client, civClients)
{ {
int lastFE = d.lastIndexOf((quint8)0xfe); int lastFE = d.lastIndexOf((quint8)0xfe);
@ -1295,7 +1295,7 @@ void udpServer::dataForServer(QByteArray d)
client->txSeqBuf.last().data = t; client->txSeqBuf.last().data = t;
client->txMutex.unlock(); client->txMutex.unlock();
//qDebug(logUdpServer()) << "Sending:" << d; //qInfo(logUdpServer()) << "Sending:" << d;
udpMutex.lock(); udpMutex.lock();
client->socket->writeDatagram(t, client->ipAddress, client->port); client->socket->writeDatagram(t, client->ipAddress, client->port);
udpMutex.unlock(); udpMutex.unlock();
@ -1327,7 +1327,7 @@ void udpServer::sendRxAudio()
void udpServer::receiveAudioData(const audioPacket &d) void udpServer::receiveAudioData(const audioPacket &d)
{ {
//qDebug(logUdpServer()) << "Server got:" << d.data.length(); //qInfo(logUdpServer()) << "Server got:" << d.data.length();
foreach(CLIENT * client, audioClients) foreach(CLIENT * client, audioClients)
{ {
if (client != Q_NULLPTR && client->connected) { if (client != Q_NULLPTR && client->connected) {
@ -1383,12 +1383,12 @@ void udpServer::sendRetransmitRequest(CLIENT *c)
{ {
for (quint16 j = *i + 1; j < *(i + 1); j++) 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; }); auto s = std::find_if(c->rxMissing.begin(), c->rxMissing.end(), [&cs = j](SEQBUFENTRY& s) { return s.seqNum == cs; });
if (s == c->rxMissing.end()) if (s == c->rxMissing.end())
{ {
// We haven't seen this missing packet before // 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.append(SEQBUFENTRY());
c->rxMissing.last().seqNum = j; c->rxMissing.last().seqNum = j;
c->rxMissing.last().retransmitCount = 0; c->rxMissing.last().retransmitCount = 0;
@ -1409,7 +1409,7 @@ void udpServer::sendRetransmitRequest(CLIENT *c)
} }
} }
else { 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->rxMutex.lock();
c->rxSeqBuf.clear(); c->rxSeqBuf.clear();
c->rxMutex.unlock(); 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. 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); 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(); udpMutex.lock();
c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port);
udpMutex.unlock(); udpMutex.unlock();
} }
else 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)); missingSeqs.insert(0, p.packet, sizeof(p.packet));
udpMutex.lock(); udpMutex.lock();
c->socket->writeDatagram(missingSeqs, c->ipAddress, c->port); c->socket->writeDatagram(missingSeqs, c->ipAddress, c->port);
@ -1472,7 +1472,7 @@ void udpServer::deleteConnection(QList<CLIENT*> *l, CLIENT* c)
{ {
connMutex.lock(); 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) { if (c->idleTimer != Q_NULLPTR) {
c->idleTimer->stop(); c->idleTimer->stop();
delete c->idleTimer; delete c->idleTimer;
@ -1503,7 +1503,7 @@ void udpServer::deleteConnection(QList<CLIENT*> *l, CLIENT* c)
} }
delete c; // Is this needed or will the erase have done it? delete c; // Is this needed or will the erase have done it?
c = Q_NULLPTR; c = Q_NULLPTR;
qDebug(logUdpServer()) << "Current Number of clients connected: " << l->length(); qInfo(logUdpServer()) << "Current Number of clients connected: " << l->length();
if (l->length() == 0) { if (l->length() == 0) {

Wyświetl plik

@ -20,7 +20,7 @@ udpServerSetup::~udpServerSetup()
// Slot to receive config. // Slot to receive config.
void udpServerSetup::receiveServerConfig(SERVERCONFIG conf) void udpServerSetup::receiveServerConfig(SERVERCONFIG conf)
{ {
qDebug() << "Getting server config"; qInfo() << "Getting server config";
ui->enableCheckbox->setChecked(conf.enabled); ui->enableCheckbox->setChecked(conf.enabled);
ui->controlPortText->setText(QString::number(conf.controlPort)); ui->controlPortText->setText(QString::number(conf.controlPort));
@ -72,7 +72,7 @@ void udpServerSetup::receiveServerConfig(SERVERCONFIG conf)
void udpServerSetup::accept() void udpServerSetup::accept()
{ {
qDebug() << "Server config stored"; qInfo() << "Server config stored";
SERVERCONFIG config; SERVERCONFIG config;
config.enabled = ui->enableCheckbox->isChecked(); config.enabled = ui->enableCheckbox->isChecked();
config.controlPort = ui->controlPortText->text().toInt(); config.controlPort = ui->controlPortText->text().toInt();
@ -105,7 +105,7 @@ void udpServerSetup::accept()
void udpServerSetup::on_usersTable_cellClicked(int row, int col) 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) { 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()); ui->usersTable->insertRow(ui->usersTable->rowCount());
QComboBox* comboBox = new QComboBox(); QComboBox* comboBox = new QComboBox();

Wyświetl plik

@ -577,8 +577,8 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
freqIndicatorLine->start->setCoords(0.5,0); freqIndicatorLine->start->setCoords(0.5,0);
freqIndicatorLine->end->setCoords(0.5,160); freqIndicatorLine->end->setCoords(0.5,160);
#ifdef QT_DEBUG
qDebug(logSystem()) << "Running with debugging options enabled."; qDebug(logSystem()) << "Running with debugging options enabled.";
#ifdef QT_DEBUG
ui->debugBtn->setVisible(true); ui->debugBtn->setVisible(true);
ui->satOpsBtn->setVisible(true); ui->satOpsBtn->setVisible(true);
#else #else
@ -652,7 +652,6 @@ void wfmain::openRig()
// TODO: Use these if they are found // TODO: Use these if they are found
#ifdef QT_DEBUG
if(!serialPortCL.isEmpty()) if(!serialPortCL.isEmpty())
{ {
qDebug(logSystem()) << "Serial port specified by user: " << serialPortCL; qDebug(logSystem()) << "Serial port specified by user: " << serialPortCL;
@ -664,7 +663,6 @@ void wfmain::openRig()
{ {
qDebug(logSystem()) << "Remote host name specified by user: " << hostCL; qDebug(logSystem()) << "Remote host name specified by user: " << hostCL;
} }
#endif
// Start rigctld // Start rigctld
if (prefs.enableRigCtlD) { if (prefs.enableRigCtlD) {
@ -712,7 +710,7 @@ void wfmain::openRig()
if( (prefs.serialPortRadio.toLower() == QString("auto")) && (serialPortCL.isEmpty())) if( (prefs.serialPortRadio.toLower() == QString("auto")) && (serialPortCL.isEmpty()))
{ {
// Find the ICOM // 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 it73("/dev/serial", QStringList() << "*IC-7300*", QDir::Files, QDirIterator::Subdirectories);
QDirIterator it97("/dev/serial", QStringList() << "*IC-9700*A*", QDir::Files, QDirIterator::Subdirectories); QDirIterator it97("/dev/serial", QStringList() << "*IC-9700*A*", QDir::Files, QDirIterator::Subdirectories);
QDirIterator it785x("/dev/serial", QStringList() << "*IC-785*A*", QDir::Files, QDirIterator::Subdirectories); QDirIterator it785x("/dev/serial", QStringList() << "*IC-785*A*", QDir::Files, QDirIterator::Subdirectories);
@ -747,7 +745,7 @@ void wfmain::openRig()
serialPortRig = itR8600.filePath(); serialPortRig = itR8600.filePath();
} else { } else {
//fall back: //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 #ifdef Q_OS_MAC
serialPortRig = QString("/dev/tty.SLAB_USBtoUART"); serialPortRig = QString("/dev/tty.SLAB_USBtoUART");
#endif #endif
@ -780,12 +778,12 @@ void wfmain::openRig()
void wfmain::receiveCommReady() void wfmain::receiveCommReady()
{ {
qDebug(logSystem()) << "Received CommReady!! "; qInfo(logSystem()) << "Received CommReady!! ";
// taken from above: // taken from above:
if(prefs.radioCIVAddr == 0) if(prefs.radioCIVAddr == 0)
{ {
// tell rigCommander to broadcast a request for all rig IDs. // tell rigCommander to broadcast a request for all rig IDs.
// qDebug(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); ui->statusBar->showMessage(QString("Searching CIV bus for connected radios."), 1000);
emit getRigCIV(); emit getRigCIV();
cmdOutQue.append(cmdGetRigCIV); cmdOutQue.append(cmdGetRigCIV);
@ -793,7 +791,7 @@ void wfmain::receiveCommReady()
} else { } else {
// don't bother, they told us the CIV they want, stick with it. // don't bother, they told us the CIV they want, stick with it.
// We still query the rigID to find the model, but at least we know the CIV. // We still query the rigID to find the model, but at least we know the CIV.
qDebug(logSystem()) << "Skipping automatic CIV, using user-supplied value of " << prefs.radioCIVAddr; qInfo(logSystem()) << "Skipping automatic CIV, using user-supplied value of " << prefs.radioCIVAddr;
getInitialRigState(); getInitialRigState();
} }
@ -804,7 +802,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
{ {
// Entry point for unknown rig being identified at the start of the program. // Entry point for unknown rig being identified at the start of the program.
//now we know what the rig ID is: //now we know what the rig ID is:
//qDebug(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()) if(rig->usingLAN())
{ {
@ -828,7 +826,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
void wfmain::receiveSerialPortError(QString port, QString errorText) 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); ui->statusBar->showMessage(QString("ERROR: using port ").append(port).append(": ").append(errorText), 10000);
// TODO: Dialog box, exit, etc // TODO: Dialog box, exit, etc
@ -875,7 +873,7 @@ void wfmain::setDefPrefs()
void wfmain::loadSettings() void wfmain::loadSettings()
{ {
qDebug(logSystem()) << "Loading settings from " << settings.fileName(); qInfo(logSystem()) << "Loading settings from " << settings.fileName();
// Basic things to load: // Basic things to load:
// UI: (full screen, dark theme, draw peaks, colors, etc) // UI: (full screen, dark theme, draw peaks, colors, etc)
@ -1026,7 +1024,7 @@ void wfmain::loadSettings()
ui->audioTXCodecCombo->setCurrentIndex(f); ui->audioTXCodecCombo->setCurrentIndex(f);
udpPrefs.audioOutput = settings.value("AudioOutput", udpDefPrefs.audioOutput).toString(); 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()); //ui->audioOutputCombo->setEnabled(ui->lanEnableBtn->isChecked());
int audioOutputIndex = ui->audioOutputCombo->findText(udpPrefs.audioOutput); int audioOutputIndex = ui->audioOutputCombo->findText(udpPrefs.audioOutput);
if (audioOutputIndex != -1) { if (audioOutputIndex != -1) {
@ -1034,7 +1032,7 @@ void wfmain::loadSettings()
} }
udpPrefs.audioInput = settings.value("AudioInput", udpDefPrefs.audioInput).toString(); 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()); //ui->audioInputCombo->setEnabled(ui->lanEnableBtn->isChecked());
int audioInputIndex = ui->audioInputCombo->findText(udpPrefs.audioInput); int audioInputIndex = ui->audioInputCombo->findText(udpPrefs.audioInput);
if (audioInputIndex != -1) { if (audioInputIndex != -1) {
@ -1107,7 +1105,7 @@ void wfmain::loadSettings()
void wfmain::saveSettings() void wfmain::saveSettings()
{ {
qDebug(logSystem()) << "Saving settings to " << settings.fileName(); qInfo(logSystem()) << "Saving settings to " << settings.fileName();
// Basic things to load: // Basic things to load:
// UI: (full screen, dark theme, draw peaks, colors, etc) // UI: (full screen, dark theme, draw peaks, colors, etc)
@ -1273,7 +1271,7 @@ void wfmain::prepareWf()
wf->xAxis->setVisible(false); wf->xAxis->setVisible(false);
rigName->setText(rigCaps.modelName); rigName->setText(rigCaps.modelName);
} else { } else {
qDebug(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this."; qInfo(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this.";
return; return;
} }
@ -1364,7 +1362,7 @@ void wfmain::shortcutF12()
void wfmain::shortcutControlT() void wfmain::shortcutControlT()
{ {
// Transmit // Transmit
qDebug(logSystem()) << "Activated Control-T shortcut"; qInfo(logSystem()) << "Activated Control-T shortcut";
showStatusBarText(QString("Transmitting. Press Control-R to receive.")); showStatusBarText(QString("Transmitting. Press Control-R to receive."));
ui->pttOnBtn->click(); ui->pttOnBtn->click();
} }
@ -1855,7 +1853,7 @@ void wfmain::runPeriodicCommands()
emit getMode(); emit getMode();
break; break;
case cmdGetDataMode: case cmdGetDataMode:
// qDebug(logSystem()) << "Sending query for data mode"; // qInfo(logSystem()) << "Sending query for data mode";
emit getDataMode(); emit getDataMode();
break; break;
case cmdSetDataModeOff: case cmdSetDataModeOff:
@ -1956,7 +1954,7 @@ void wfmain::runDelayedCommand()
switch(qdCmd) switch(qdCmd)
{ {
case cmdNone: case cmdNone:
//qDebug(logSystem()) << "NOOP"; //qInfo(logSystem()) << "NOOP";
break; break;
case cmdGetRigID: case cmdGetRigID:
emit getRigID(); emit getRigID();
@ -2138,14 +2136,13 @@ void wfmain::receiveRigID(rigCapabilities rigCaps)
{ {
return; return;
} else { } else {
#ifdef QT_DEBUG
qDebug(logSystem()) << "Rig name: " << rigCaps.modelName; qDebug(logSystem()) << "Rig name: " << rigCaps.modelName;
qDebug(logSystem()) << "Has LAN capabilities: " << rigCaps.hasLan; qDebug(logSystem()) << "Has LAN capabilities: " << rigCaps.hasLan;
qDebug(logSystem()) << "Rig ID received into wfmain: spectLenMax: " << rigCaps.spectLenMax; 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: spectAmpMax: " << rigCaps.spectAmpMax;
qDebug(logSystem()) << "Rig ID received into wfmain: spectSeqMax: " << rigCaps.spectSeqMax; qDebug(logSystem()) << "Rig ID received into wfmain: spectSeqMax: " << rigCaps.spectSeqMax;
qDebug(logSystem()) << "Rig ID received into wfmain: hasSpectrum: " << rigCaps.hasSpectrum; qDebug(logSystem()) << "Rig ID received into wfmain: hasSpectrum: " << rigCaps.hasSpectrum;
#endif
this->rigCaps = rigCaps; this->rigCaps = rigCaps;
this->spectWidth = rigCaps.spectLenMax; // used once haveRigCaps is true. this->spectWidth = rigCaps.spectLenMax; // used once haveRigCaps is true.
haveRigCaps = true; haveRigCaps = true;
@ -2315,7 +2312,7 @@ void wfmain::insertPeriodicCommand(cmds cmd, unsigned char priority)
void wfmain::receiveFreq(freqt freqStruct) 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')); ui->freqLabel->setText(QString("%1").arg(freqStruct.MHzDouble, 0, 'f'));
freq = freqStruct; freq = freqStruct;
//showStatusBarText(QString("Frequency: %1").arg(freqMhz)); //showStatusBarText(QString("Frequency: %1").arg(freqMhz));
@ -2324,7 +2321,7 @@ void wfmain::receiveFreq(freqt freqStruct)
void wfmain::receivePTTstatus(bool pttOn) void wfmain::receivePTTstatus(bool pttOn)
{ {
// This is the only place where amTransmitting and the transmit button text should be changed: // This is the only place where amTransmitting and the transmit button text should be changed:
//qDebug(logSystem()) << "PTT status: " << pttOn; //qInfo(logSystem()) << "PTT status: " << pttOn;
if (pttOn && !amTransmitting) if (pttOn && !amTransmitting)
{ {
pttLed->setState(QLedLabel::State::StateError); pttLed->setState(QLedLabel::State::StateError);
@ -2352,9 +2349,7 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
{ {
if(!haveRigCaps) if(!haveRigCaps)
{ {
#ifdef QT_DEBUG
qDebug(logSystem()) << "Spectrum received, but RigID incomplete."; qDebug(logSystem()) << "Spectrum received, but RigID incomplete.";
#endif
return; return;
} }
@ -2372,19 +2367,17 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
oldLowerFreq = startFreq; oldLowerFreq = startFreq;
oldUpperFreq = endFreq; oldUpperFreq = endFreq;
//qDebug(logSystem()) << "start: " << startFreq << " end: " << endFreq; //qInfo(logSystem()) << "start: " << startFreq << " end: " << endFreq;
quint16 specLen = spectrum.length(); 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 != 475) || (specLen!=689) )
if( specLen != rigCaps.spectLenMax ) if( specLen != rigCaps.spectLenMax )
{ {
#ifdef QT_DEBUG
qDebug(logSystem()) << "-------------------------------------------"; qDebug(logSystem()) << "-------------------------------------------";
qDebug(logSystem()) << "------ Unusual spectrum received, length: " << specLen; qDebug(logSystem()) << "------ Unusual spectrum received, length: " << specLen;
qDebug(logSystem()) << "------ Expected spectrum length: " << rigCaps.spectLenMax; qDebug(logSystem()) << "------ Expected spectrum length: " << rigCaps.spectLenMax;
qDebug(logSystem()) << "------ This should happen once at most. "; qDebug(logSystem()) << "------ This should happen once at most. ";
#endif
return; // safe. Using these unusual length things is a problem. 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) 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; bool found=false;
@ -2594,12 +2587,12 @@ void wfmain::receiveMode(unsigned char mode, unsigned char filter)
} }
currentModeIndex = mode; currentModeIndex = mode;
} else { } else {
qDebug(logSystem()) << __func__ << "Invalid mode " << mode << " received. "; qInfo(logSystem()) << __func__ << "Invalid mode " << mode << " received. ";
} }
if(!found) 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)){ if( (filter) && (filter < 4)){
@ -2858,7 +2851,7 @@ void wfmain::on_modeSelectCombo_activated(int index)
{ {
// oops, we forgot to reset the combo box // oops, we forgot to reset the combo box
} else { } else {
//qDebug(logSystem()) << __func__ << " at index " << index << " has newMode: " << newMode; //qInfo(logSystem()) << __func__ << " at index " << index << " has newMode: " << newMode;
currentMode = (mode_kind)newMode; currentMode = (mode_kind)newMode;
emit setMode(newMode, filterSelection); 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 // 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); emit setFrequency(freq);
setModeVal = (unsigned char) mode; setModeVal = (unsigned char) mode;
setFilterVal = (unsigned char) filter; setFilterVal = (unsigned char) filter;
@ -3219,7 +3212,7 @@ void wfmain::on_fRclBtn_clicked()
issueDelayedCommand(cmdGetFreq); issueDelayedCommand(cmdGetFreq);
issueDelayedCommand(cmdGetMode); issueDelayedCommand(cmdGetMode);
} else { } 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) 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); emit setAfGain((unsigned char)value);
} }
void wfmain::receiveRfGain(unsigned char level) 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->blockSignals(true);
ui->rfGainSlider->setValue(level); ui->rfGainSlider->setValue(level);
ui->rfGainSlider->blockSignals(false); ui->rfGainSlider->blockSignals(false);
@ -3245,7 +3238,7 @@ void wfmain::receiveRfGain(unsigned char level)
void wfmain::receiveAfGain(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->blockSignals(true);
ui->afGainSlider->setValue(level); ui->afGainSlider->setValue(level);
ui->afGainSlider->blockSignals(false); ui->afGainSlider->blockSignals(false);
@ -3326,7 +3319,7 @@ void wfmain::on_saveSettingsBtn_clicked()
void wfmain::receiveATUStatus(unsigned char atustatus) 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) switch(atustatus)
{ {
case 0x00: case 0x00:
@ -3346,14 +3339,14 @@ void wfmain::receiveATUStatus(unsigned char atustatus)
case 0x02: case 0x02:
// ATU tuning in-progress. // ATU tuning in-progress.
// Add command queue to check again and update status bar // Add command queue to check again and update status bar
// qDebug(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..."); showStatusBarText("ATU is Tuning...");
cmdOutQue.append(cmdGetATUStatus); // Sometimes the first hit seems to be missed. cmdOutQue.append(cmdGetATUStatus); // Sometimes the first hit seems to be missed.
cmdOutQue.append(cmdGetATUStatus); cmdOutQue.append(cmdGetATUStatus);
delayedCommand->start(); delayedCommand->start();
break; break;
default: default:
qDebug(logSystem()) << "Did not understand ATU status: " << (unsigned int) atustatus; qInfo(logSystem()) << "Did not understand ATU status: " << (unsigned int) atustatus;
break; break;
} }
} }
@ -3668,7 +3661,7 @@ void wfmain::receiveModInput(rigInput input, bool dataOn)
changeModLabel(input); changeModLabel(input);
} }
if(!found) 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) void wfmain::receiveACCGain(unsigned char level, unsigned char ab)
@ -3802,7 +3795,7 @@ void wfmain::serverConfigRequested(SERVERCONFIG conf, bool store)
} }
else { else {
// Store config in file! // Store config in file!
qDebug(logSystem()) << "Storing server config"; qInfo(logSystem()) << "Storing server config";
serverConfig = conf; serverConfig = conf;
} }
@ -3897,7 +3890,7 @@ void wfmain::processChangingCurrentModLevel(unsigned char level)
} else { } else {
currentIn = currentModSrc; currentIn = currentModSrc;
} }
//qDebug(logSystem()) << __func__ << ": setting current level: " << level; //qInfo(logSystem()) << __func__ << ": setting current level: " << level;
emit setModLevel(currentIn, level); emit setModLevel(currentIn, level);
} }
@ -4016,7 +4009,7 @@ void wfmain::receiveSpectrumSpan(freqt freqspan, bool isSub)
ui->scopeBWCombo->setCurrentIndex(7); ui->scopeBWCombo->setCurrentIndex(7);
break; break;
default: 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; break;
} }
@ -4089,7 +4082,7 @@ void wfmain::receiveRITValue(int ritValHz)
ui->ritTuneDial->setValue(ritValHz); ui->ritTuneDial->setValue(ritValHz);
ui->ritTuneDial->blockSignals(false); ui->ritTuneDial->blockSignals(false);
} else { } 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 --- // --- DEBUG FUNCTION ---
void wfmain::on_debugBtn_clicked() void wfmain::on_debugBtn_clicked()
{ {
qDebug(logSystem()) << "Debug button pressed."; qInfo(logSystem()) << "Debug button pressed.";
qDebug(logSystem()) << "getting mode."; qInfo(logSystem()) << "getting mode.";
getMode(); getMode();
} }