Many fixes to the IsoTP Viewer and UDS internal code.
This commit is contained in:
@@ -7,6 +7,7 @@ ISOTP_HANDLER::ISOTP_HANDLER()
|
||||
isReceiving = false;
|
||||
issueFlowMsgs = false;
|
||||
processAll = false;
|
||||
sendPartialMessages = false;
|
||||
lastSenderBus = 0;
|
||||
lastSenderID = 0;
|
||||
|
||||
@@ -106,9 +107,11 @@ void ISOTP_HANDLER::updatedFrames(int numFrames)
|
||||
{
|
||||
if (numFrames == -1) //all frames deleted. Kill the display
|
||||
{
|
||||
messageBuffer.clear();
|
||||
}
|
||||
else if (numFrames == -2) //all new set of frames. Reset
|
||||
{
|
||||
messageBuffer.clear();
|
||||
for (int i = 0; i < modelFrames->length(); i++) processFrame(modelFrames->at(i));
|
||||
}
|
||||
else //just got some new frames. See if they are relevant.
|
||||
@@ -125,7 +128,7 @@ void ISOTP_HANDLER::rapidFrames(const CANConnection* conn, const QVector<CANFram
|
||||
Q_UNUSED(conn)
|
||||
if (pFrames.length() <= 0) return;
|
||||
|
||||
//qDebug() << "received messages in ISOTP handler";
|
||||
qDebug() << "received " << QString::number(pFrames.count()) << " messages in ISOTP handler";
|
||||
|
||||
foreach(const CANFrame& thisFrame, pFrames)
|
||||
{
|
||||
@@ -158,7 +161,7 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
|
||||
ISOTP_MESSAGE *pMsg;
|
||||
QByteArray dataBytes;
|
||||
const unsigned char *data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
|
||||
qDebug() << frame.payload().count();
|
||||
//qDebug() << frame.payload().count();
|
||||
//int dataLen = frame.payload().count();
|
||||
|
||||
frameType = 0;
|
||||
@@ -196,17 +199,19 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
|
||||
msg.setTimeStamp(frame.timeStamp());
|
||||
msg.isMultiframe = false;
|
||||
if (useExtendedAddressing)
|
||||
{
|
||||
{
|
||||
for (int j = 0; j < frameLen; j++)
|
||||
{
|
||||
dataBytes.append(data[j+2]);
|
||||
if (frame.payload().count() > (j+2))
|
||||
dataBytes.append(data[j+2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < frameLen; j++)
|
||||
{
|
||||
dataBytes.append(data[j+1]);
|
||||
if (frame.payload().count() > (j+1))
|
||||
dataBytes.append(data[j+1]);
|
||||
}
|
||||
}
|
||||
qDebug() << "Emitting single frame ISOTP message";
|
||||
@@ -216,6 +221,7 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
|
||||
case 1: //first frame of a multi-frame message
|
||||
checkNeedFlush(ID);
|
||||
msg.bus = frame.bus;
|
||||
if (frame.payload().count() < 8) return; //MUST have all 8 data bytes in this first frame.
|
||||
msg.setExtendedFrameFormat( frame.hasExtendedFrameFormat() );
|
||||
msg.setFrameId(ID);
|
||||
msg.setTimeStamp(frame.timeStamp());
|
||||
@@ -323,12 +329,17 @@ void ISOTP_HANDLER::checkNeedFlush(uint64_t ID)
|
||||
if (msg->reportedLength <= msg->payload().count())
|
||||
{
|
||||
qDebug() << "Flushing full frame" << QString::number(msg->frameId(), 16) << " " << msg->reportedLength << " " << msg->payload().count();
|
||||
if (msg->reportedLength > 0) emit newISOMessage(*msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Flushing a partial frame " << QString::number(msg->frameId(), 16) << " " << msg->reportedLength << " " << msg->payload().count();
|
||||
}
|
||||
if (msg->reportedLength > 0) emit newISOMessage(*msg);
|
||||
if (sendPartialMessages)
|
||||
{
|
||||
qDebug() << "Flushing a partial frame " << QString::number(msg->frameId(), 16) << " " << msg->reportedLength << " " << msg->payload().count();
|
||||
if (msg->reportedLength > 0) emit newISOMessage(*msg);
|
||||
}
|
||||
else qDebug() << "Have a partial message but sending of such is disabled. Throwing it away";
|
||||
}
|
||||
messageBuffer.remove(ID);
|
||||
}
|
||||
}
|
||||
@@ -389,4 +400,4 @@ void ISOTP_HANDLER::clearAllFilters()
|
||||
filters.clear();
|
||||
}
|
||||
|
||||
|
||||
void setEmitPartials(bool mode);
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
~ISOTP_HANDLER();
|
||||
void setExtendedAddressing(bool mode);
|
||||
void setReception(bool mode); //set whether to accept and forward frames or not
|
||||
void setEmitPartials(bool mode);
|
||||
void sendISOTPFrame(int bus, int ID, QByteArray data);
|
||||
void setProcessAll(bool state);
|
||||
void setFlowCtrl(bool state);
|
||||
@@ -45,6 +46,7 @@ private:
|
||||
int framesUntilFlow;
|
||||
bool processAll;
|
||||
bool issueFlowMsgs;
|
||||
bool sendPartialMessages;
|
||||
QTimer frameTimer;
|
||||
uint32_t lastSenderID;
|
||||
uint32_t lastSenderBus;
|
||||
|
||||
@@ -33,6 +33,14 @@ static QVector<CODE_STRUCT> UDS_ROUTINE_SUB = {
|
||||
{3,"GET_ROUTINE_RESULTS", "Get results from routine specified by ID"},
|
||||
};
|
||||
|
||||
static QVector<CODE_STRUCT> UDS_FILE_MODEOFOP = {
|
||||
{1, "ADDFILE", "Add file to file system"},
|
||||
{2, "DELETEFILE", "Add file to file system"},
|
||||
{3, "REPLACEFILE", "Add file to file system"},
|
||||
{4, "READFILE", "Add file to file system"},
|
||||
{5, "READDIR", "Add file to file system"}
|
||||
};
|
||||
|
||||
static QVector<CODE_STRUCT> UDS_SERVICE_DESC = {
|
||||
{1, "OBDII_SHOW_CURRENT", "OBDII - Show current data"},
|
||||
{2, "OBDII_SHOW_FREEZE", "OBDII - Show freeze data"},
|
||||
@@ -328,6 +336,7 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
QString buildString;
|
||||
int dataSize;
|
||||
int addrSize;
|
||||
int compType, encType;
|
||||
const unsigned char *data = reinterpret_cast<const unsigned char *>(msg.payload().constData());
|
||||
int dataLen = msg.payload().length();
|
||||
|
||||
@@ -480,20 +489,36 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::WRITE_BY_ID:
|
||||
case UDS_SERVICES::WRITE_BY_ID:
|
||||
if (dataLen > 3)
|
||||
{
|
||||
int writeID = (data[1] * 256 + data[2]);
|
||||
buildString.append("ID to write to: " + Utility::formatHexNum(writeID) + "\nPayload: ");
|
||||
for (int i = 3; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::WRITE_BY_ID + 0x40:
|
||||
if (dataLen > 2)
|
||||
{
|
||||
int writeID = (data[1] * 256 + data[2]);
|
||||
buildString.append("ID written to: " + Utility::formatHexNum(writeID));
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::ROUTINE_CTRL:
|
||||
buildString.append("Routine Control: " + getLongDesc(UDS_ROUTINE_SUB, msg.subFunc));
|
||||
if (dataLen > 3)
|
||||
{
|
||||
int routineID;
|
||||
routineID = (data[2] * 256 + data[3]);
|
||||
routineID = (data[1] * 256 + data[2]);
|
||||
buildString.append("\nRoutine ID: " + Utility::formatHexNum(routineID));
|
||||
}
|
||||
if (dataLen > 4)
|
||||
{
|
||||
buildString.append("\nParameter bytes to routine: ");
|
||||
for (int i = 4; i < dataLen; i++)
|
||||
for (int i = 3; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
@@ -501,28 +526,63 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
break;
|
||||
case UDS_SERVICES::ROUTINE_CTRL + 0x40:
|
||||
buildString.append("Routine Control: " + getLongDesc(UDS_ROUTINE_SUB, msg.subFunc));
|
||||
if (dataLen > 3)
|
||||
if (dataLen > 2)
|
||||
{
|
||||
int routineID;
|
||||
routineID = (data[2] * 256 + data[3]);
|
||||
routineID = (data[1] * 256 + data[2]);
|
||||
buildString.append("\nRoutine ID: " + Utility::formatHexNum(routineID));
|
||||
}
|
||||
if (dataLen > 4)
|
||||
if (dataLen > 3)
|
||||
{
|
||||
buildString.append("\nBytes returned by routine: ");
|
||||
for (int i = 4; i < dataLen; i++)
|
||||
for (int i = 3; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::REQUEST_DOWNLOAD:
|
||||
break;
|
||||
case UDS_SERVICES::REQUEST_UPLOAD:
|
||||
compType = data[1] >> 4;
|
||||
encType = data[1] & 0xF;
|
||||
buildString.append("Compression Type: " + QString(compType) + "\n");
|
||||
buildString.append("Encryption Type: " + QString(encType) + "\n");
|
||||
//subfunc byte specifies address and length format, then address, then size
|
||||
dataSize = data[2] >> 4;
|
||||
addrSize = data[2] & 0xF;
|
||||
if (dataLen > (dataSize + addrSize))
|
||||
{
|
||||
buildString.append("Address: 0x");
|
||||
for (int i = 0; i < addrSize; i++) buildString.append(QString::number(data[3 + i], 16).toUpper().rightJustified(2,'0'));
|
||||
buildString.append("\nSize: 0x");
|
||||
for (int i = 0; i < dataSize; i++) buildString.append(QString::number(data[3 + i + addrSize], 16).toUpper().rightJustified(2,'0'));
|
||||
}
|
||||
else
|
||||
{
|
||||
buildString.append("Message has insufficient bytes to properly decode address and size!");
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::REQUEST_DOWNLOAD + 0x40:
|
||||
case UDS_SERVICES::REQUEST_UPLOAD + 0x40:
|
||||
dataSize = data[1] >> 4;
|
||||
buildString.append("\nMax Size of data block: 0x");
|
||||
for (int i = 0; i < dataSize; i++) buildString.append(QString::number(data[2 + i], 16).toUpper().rightJustified(2,'0'));
|
||||
break;
|
||||
case UDS_SERVICES::TRANSFER_DATA:
|
||||
case UDS_SERVICES::TRANSFER_DATA + 0x40:
|
||||
buildString.append("\nBlock Sequence: " + QString(data[1]) + "\nPayload: ");
|
||||
for (int i = 2; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::REQ_TRANS_EXIT:
|
||||
case UDS_SERVICES::REQ_TRANS_EXIT + 0x40:
|
||||
buildString.append("\nPayload: ");
|
||||
for (int i = 1; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::REQ_FILE_TRANS:
|
||||
break;
|
||||
|
||||
@@ -73,7 +73,8 @@ void ISOTP_InterpreterWindow::showEvent(QShowEvent* event)
|
||||
|
||||
qApp->processEvents();
|
||||
|
||||
decoder->rapidFrames(nullptr, *modelFrames);
|
||||
decoder->updatedFrames(-2);
|
||||
//decoder->rapidFrames(nullptr, *modelFrames);
|
||||
|
||||
progress.cancel();
|
||||
|
||||
@@ -130,7 +131,7 @@ void ISOTP_InterpreterWindow::writeSettings()
|
||||
void ISOTP_InterpreterWindow::interpretCapturedFrames()
|
||||
{
|
||||
clearList();
|
||||
decoder->rapidFrames(nullptr, *modelFrames);
|
||||
decoder->updatedFrames(-2);
|
||||
}
|
||||
|
||||
void ISOTP_InterpreterWindow::listFilterItemChanged(QListWidgetItem *item)
|
||||
|
||||
Reference in New Issue
Block a user