kopia lustrzana https://gitlab.com/eliggett/wfview
Added universal printhex header and functions. Changed radio traffic to
log to new category "rigTraffic".half-duplex
rodzic
c5c01cf81d
commit
deade9a38e
|
@ -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
|
|
@ -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])
|
||||
|
|
16
wfmain.cpp
16
wfmain.cpp
|
@ -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()
|
||||
|
|
|
@ -238,6 +238,7 @@ HEADERS += wfmain.h \
|
|||
cwsender.h \
|
||||
loggingwindow.h \
|
||||
prefs.h \
|
||||
printhex.h \
|
||||
rigcommander.h \
|
||||
freqmemory.h \
|
||||
rigidentities.h \
|
||||
|
|
Ładowanie…
Reference in New Issue