Added universal printhex header and functions. Changed radio traffic to

log to new category "rigTraffic".
half-duplex
Elliott Liggett 2023-01-21 13:38:39 -08:00
rodzic c5c01cf81d
commit deade9a38e
4 zmienionych plików z 57 dodań i 12 usunięć

42
printhex.h 100644
Wyświetl plik

@ -0,0 +1,42 @@
#ifndef PRINTHEX_H
#define PRINTHEX_H
#include <QByteArray>
#include <QString>
#include "logcategories.h"
QString inline getHex(const QByteArray &pdata)
{
QString head = "---- Begin hex dump -----:\n";
QString sdata("DATA: ");
QString index("INDEX: ");
for(int i=0; i < pdata.length(); i++)
{
sdata.append(QString("%1 ").arg((unsigned char)pdata[i], 2, 16, QChar('0')) );
index.append(QString("%1 ").arg(i, 2, 10, QChar('0')));
}
sdata.append("\n");
index.append("\n");
QString tail = "----- End hex dump -----\n";
return head + sdata + index + tail;
}
void inline printHexNow(const QByteArray &pdata, const QLoggingCategory &cat)
{
QString d = getHex(pdata);
// These lines are needed to keep the formatting as expected in the log file
if(d.endsWith("\n"))
{
d.chop(1);
}
QStringList s = d.split("\n");
for(int i=0; i < s.length(); i++)
{
qDebug(cat) << s.at(i);
}
}
#endif // PRINTHEX_H

Wyświetl plik

@ -3,6 +3,7 @@
#include "rigidentities.h"
#include "logcategories.h"
#include "printhex.h"
// Copyright 2017-2020 Elliott H. Liggett
@ -307,8 +308,10 @@ void rigCommander::prepDataAndSend(QByteArray data)
if(data[4] != '\x15')
{
// We don't print out requests for meter levels
qDebug(logRig()) << "Final payload in rig commander to be sent to rig: ";
printHex(data);
qDebug(logRigTraffic()) << "Final payload in rig commander to be sent to rig: ";
//printHex(data);
//printHex(data, logRigTraffic());
printHexNow(data, logRigTraffic());
}
emit dataForComm(data);
@ -1390,7 +1393,8 @@ void rigCommander::parseCommand()
{
// We do not log spectrum and meter data,
// as they tend to clog up any useful logging.
printHex(payloadIn);
qDebug(logRigTraffic()) << "Received from radio:";
printHexNow(payloadIn, logRigTraffic());
}
switch(payloadIn[00])

Wyświetl plik

@ -8201,15 +8201,13 @@ void wfmain::messageHandler(QtMsgType type, const QMessageLogContext& context, c
out << context.category << ": " << msg << "\n";
out.flush(); // Clear the buffered data
if(QString(context.category) != QString("rigTraffic"))
{
text.append(context.category);
text.append(": ");
text.append(msg);
logTextMutex.lock();
logStringBuffer.push_front(text);
logTextMutex.unlock();
}
text.append(context.category);
text.append(": ");
text.append(msg);
logTextMutex.lock();
logStringBuffer.push_front(text);
logTextMutex.unlock();
}
void wfmain::on_customEdgeBtn_clicked()

Wyświetl plik

@ -238,6 +238,7 @@ HEADERS += wfmain.h \
cwsender.h \
loggingwindow.h \
prefs.h \
printhex.h \
rigcommander.h \
freqmemory.h \
rigidentities.h \