Add a save function to ISO-TP decoder window
This commit is contained in:
@@ -182,11 +182,11 @@ UDS_HANDLER::~UDS_HANDLER()
|
||||
delete isoHandler;
|
||||
}
|
||||
|
||||
void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
|
||||
UDS_MESSAGE UDS_HANDLER::tryISOtoUDS(ISOTP_MESSAGE msg, bool *result)
|
||||
{
|
||||
qDebug() << "UDS handler got ISOTP frame";
|
||||
const unsigned char *data = reinterpret_cast<const unsigned char *>(msg.payload().constData());
|
||||
int dataLen = msg.payload().count();
|
||||
*result = true;
|
||||
UDS_MESSAGE udsMsg;
|
||||
udsMsg.bus = msg.bus;
|
||||
udsMsg.setExtendedFrameFormat(msg.hasExtendedFrameFormat());
|
||||
@@ -208,9 +208,17 @@ void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
|
||||
{
|
||||
udsMsg.service = data[1];
|
||||
if (dataLen > 2) udsMsg.subFunc = data[2];
|
||||
else return;
|
||||
else
|
||||
{
|
||||
*result = false;
|
||||
return udsMsg;
|
||||
};
|
||||
}
|
||||
else return;
|
||||
else
|
||||
{
|
||||
*result = false;
|
||||
return udsMsg;
|
||||
};
|
||||
udsMsg.payload().remove(0, 2);
|
||||
}
|
||||
else
|
||||
@@ -220,9 +228,22 @@ void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
|
||||
udsMsg.payload().remove(0, 1);
|
||||
}
|
||||
}
|
||||
else return;
|
||||
else
|
||||
{
|
||||
*result = false;
|
||||
};
|
||||
return udsMsg;
|
||||
}
|
||||
|
||||
emit newUDSMessage(udsMsg);
|
||||
void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
|
||||
{
|
||||
qDebug() << "UDS handler got ISOTP frame";
|
||||
UDS_MESSAGE udsMsg;
|
||||
|
||||
bool result;
|
||||
udsMsg = tryISOtoUDS(msg, &result);
|
||||
|
||||
if (result) emit newUDSMessage(udsMsg);
|
||||
}
|
||||
|
||||
void UDS_HANDLER::setFlowCtrl(bool state)
|
||||
|
||||
@@ -105,6 +105,7 @@ public:
|
||||
QString getShortDesc(QVector<CODE_STRUCT> &codeVector, int code);
|
||||
QString getLongDesc(QVector<CODE_STRUCT> &codeVector, int code);
|
||||
QString getDetailedMessageAnalysis(const UDS_MESSAGE &msg);
|
||||
UDS_MESSAGE tryISOtoUDS(ISOTP_MESSAGE msg, bool *result);
|
||||
|
||||
public slots:
|
||||
void gotISOTPFrame(ISOTP_MESSAGE msg);
|
||||
|
||||
@@ -31,6 +31,7 @@ ISOTP_InterpreterWindow::ISOTP_InterpreterWindow(const QVector<CANFrame> *frames
|
||||
|
||||
connect(ui->tableIsoFrames, &QTableWidget::itemSelectionChanged, this, &ISOTP_InterpreterWindow::showDetailView);
|
||||
connect(ui->btnClearList, &QPushButton::clicked, this, &ISOTP_InterpreterWindow::clearList);
|
||||
connect(ui->btnSaveList, &QPushButton::clicked, this, &ISOTP_InterpreterWindow::saveList);
|
||||
connect(ui->cbUseExtendedAddressing, SIGNAL(toggled(bool)), this, SLOT(useExtendedAddressing(bool)));
|
||||
|
||||
QStringList headers;
|
||||
@@ -172,6 +173,80 @@ void ISOTP_InterpreterWindow::clearList()
|
||||
//idFilters.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
* A bit complicated as the list doesn't have the detailed analysis in it. Have to take each list entry
|
||||
* and process it to get the details then save those details to the file as well.
|
||||
*/
|
||||
void ISOTP_InterpreterWindow::saveList()
|
||||
{
|
||||
QString buildString;
|
||||
QString filename;
|
||||
QFileDialog dialog(this);
|
||||
QSettings settings;
|
||||
|
||||
QStringList filters;
|
||||
filters.append(QString(tr("Text File (*.txt)")));
|
||||
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
dialog.setNameFilters(filters);
|
||||
dialog.setViewMode(QFileDialog::Detail);
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
dialog.setDirectory(settings.value("FrameInfo/LoadSaveDirectory", dialog.directory().path()).toString());
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
settings.setValue("FrameInfo/LoadSaveDirectory", dialog.directory().path());
|
||||
filename = dialog.selectedFiles()[0];
|
||||
if (!filename.contains('.')) filename += ".txt";
|
||||
if (dialog.selectedNameFilter() == filters[0])
|
||||
{
|
||||
QFile *outFile = new QFile(filename);
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
delete outFile;
|
||||
return;
|
||||
}
|
||||
|
||||
int rows = messages.count();
|
||||
for (int r = 0 ; r < rows; r++)
|
||||
{
|
||||
ISOTP_MESSAGE msg = messages.at(r);
|
||||
const unsigned char *data = reinterpret_cast<const unsigned char *>(msg.payload().constData());
|
||||
int dataLen = msg.payload().length();
|
||||
|
||||
if (msg.reportedLength != dataLen)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
buildString.append(QString::number(msg.timeStamp().microSeconds()) + " " + QString::number(msg.frameId(), 16) + " ");
|
||||
|
||||
//buildString.append(tr("Raw Payload: "));
|
||||
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatNumber(data[i]));
|
||||
buildString.append(" ");
|
||||
}
|
||||
buildString.append("\n\n");
|
||||
|
||||
UDS_MESSAGE udsMsg;
|
||||
bool result;
|
||||
udsMsg = udsDecoder->tryISOtoUDS(msg, &result);
|
||||
if (result)
|
||||
buildString.append(udsDecoder->getDetailedMessageAnalysis(udsMsg));
|
||||
buildString.append("\n*********************************************************\n");
|
||||
outFile->write(buildString.toUtf8());
|
||||
}
|
||||
|
||||
outFile->close();
|
||||
delete outFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ISOTP_InterpreterWindow::useExtendedAddressing(bool checked)
|
||||
{
|
||||
decoder->setExtendedAddressing(checked);
|
||||
|
||||
@@ -26,6 +26,7 @@ private slots:
|
||||
void showDetailView();
|
||||
void updatedFrames(int);
|
||||
void clearList();
|
||||
void saveList();
|
||||
void listFilterItemChanged(QListWidgetItem *item);
|
||||
void filterAll();
|
||||
void filterNone();
|
||||
|
||||
@@ -40,6 +40,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSaveList">
|
||||
<property name="text">
|
||||
<string>Save List</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
|
||||
Reference in New Issue
Block a user