diff --git a/can_structs.h b/can_structs.h index 7a4fc6e..0326947 100644 --- a/can_structs.h +++ b/can_structs.h @@ -36,7 +36,8 @@ public: int bus; bool extended; bool isReceived; - int len; + int len; //# of bytes this message should have (as reported) + int actualSize; //# we actually got QVector data; uint64_t timestamp; }; diff --git a/isotp_decoder.cpp b/isotp_decoder.cpp index 93e1ec3..08d0a4d 100644 --- a/isotp_decoder.cpp +++ b/isotp_decoder.cpp @@ -1,5 +1,36 @@ #include "isotp_decoder.h" +//in order descriptions based on the list above. But, just in order one after the other +QString UDS_SERVICE_DESCRIPT[] = +{ + "Diagnostic session control", + "Reset ECU", + "Clear diagnostic trouble codes", + "Read diagnostic trouble codes", + "Read data by ID", + "Read data by address", + "Read scaling data by ID", + "Request security access", + "Communication control", + "Read data by ID periodically", + "Create dynamic data ID", + "Write data by ID", + "Input/Output control (force)", + "Call a service routine", + "Request data download (from client to server)", + "Request data upload (from server to client)", + "Transfer data", + "Request that data transfer cease", + "Request file transfer", + "Write data by address", + "Tester is present", + "Read or write comm timing parameters", + "Secured data transmission", + "Control DTC settings", + "Request start/stop transmission on event", + "Control comm link" +}; + ISOTP_DECODER::ISOTP_DECODER(const QVector *frames, QObject *parent) : QObject(parent) { diff --git a/isotp_decoder.h b/isotp_decoder.h index 51d130c..a170f36 100644 --- a/isotp_decoder.h +++ b/isotp_decoder.h @@ -5,6 +5,50 @@ #include #include "can_structs.h" +enum OBDII_FUNCTS +{ + UDS_OBDII_SHOW_CURRENT = 1, + UDS_OBDII_SHOW_FREEZE = 2, + UDS_OBDII_SHOW_STORED_DTC = 3, + UDS_OBDII_CLEAR_DTC = 4, + UDS_OBDII_TEST_O2 = 5, + UDS_OBDII_TEST_RESULTS = 6, + UDS_OBDII_SHOW_PENDING_DTC = 7, + UDS_OBDII_CONTROL_DEVICES = 8, + UDS_OBDII_VEH_INFO = 9, + UDS_OBDII_PERM_DTC = 0xA +}; + +enum UDS_FUNCTS +{ + UDS_DIAG_CONTROL=0x10, + UDS_ECU_RESET=0x11, + UDS_CLEAR_DIAG=0x14, + UDS_READ_DTC=0x19, + UDS_READ_BY_ID=0x22, + UDS_READ_BY_ADDR=0x23, + UDS_READ_SCALING_ID=0x24, + UDS_SECURITY_ACCESS=0x27, + UDS_COMM_CTRL=0x28, + UDS_READ_DATA_ID_PERIODIC=0x2A, + UDS_DYNAMIC_DATA_DEFINE=0x2C, + UDS_WRITE_BY_ID=0x2E, + UDS_IO_CTRL=0x2F, + UDS_ROUTINE_CTRL=0x31, + UDS_REQUEST_DOWNLOAD=0x34, + UDS_REQUEST_UPLOAD=0x35, + UDS_TRANSFER_DATA=0x36, + UDS_REQ_TRANS_EXIT=0x37, + UDS_REQ_FILE_TRANS=0x38, + UDS_WRITE_BY_ADDR=0x3D, + UDS_TESTER_PRESENT=0x3E, + UDS_ACCESS_TIMING=0x83, + UDS_SECURED_DATA_TRANS=0x84, + UDS_CTRL_DTC_SETTINGS=0x85, + UDS_RESPONSE_ON_EVENT=0x86, + UDS_RESPONSE_LINK_CTRL=0x87 +}; + class ISOTP_DECODER : public QObject { Q_OBJECT diff --git a/isotp_interpreterwindow.cpp b/isotp_interpreterwindow.cpp index 14a4cd8..6d3c95e 100644 --- a/isotp_interpreterwindow.cpp +++ b/isotp_interpreterwindow.cpp @@ -11,9 +11,12 @@ ISOTP_InterpreterWindow::ISOTP_InterpreterWindow(const QVector *frames decoder = new ISOTP_DECODER(modelFrames); + connect(MainWindow::getReference(), &MainWindow::framesUpdated, this, &ISOTP_InterpreterWindow::updatedFrames); connect(MainWindow::getReference(), &MainWindow::framesUpdated, decoder, &ISOTP_DECODER::updatedFrames); connect(decoder, &ISOTP_DECODER::newISOMessage, this, &ISOTP_InterpreterWindow::newISOMessage); + connect(ui->tableIsoFrames, &QTableWidget::itemSelectionChanged, this, &ISOTP_InterpreterWindow::showDetailView); + QStringList headers; headers << "Timestamp" << "ID" << "Bus" << "Dir" << "Length" << "Data"; ui->tableIsoFrames->setColumnCount(6); @@ -68,11 +71,65 @@ void ISOTP_InterpreterWindow::writeSettings() } } +void ISOTP_InterpreterWindow::updatedFrames(int numFrames) +{ + if (numFrames == -1) //all frames deleted. Kill the display + { + messages.clear(); + ui->tableIsoFrames->clear(); + } + else if (numFrames == -2) //all new set of frames. Reset + { + messages.clear(); + ui->tableIsoFrames->clear(); + } + else //just got some new frames. See if they are relevant. + { + } +} + +void ISOTP_InterpreterWindow::showDetailView() +{ + QString buildString; + ISOTP_MESSAGE *msg; + int rowNum = ui->tableIsoFrames->currentRow(); + + ui->txtFrameDetails->clear(); + if (rowNum == -1) return; + + msg = &messages[rowNum]; + + if (msg->len != msg->data.length()) + { + buildString.append("Message didn't have the correct number of bytes.\rExpected " + + QString::number(msg->len) + " got " + + QString::number(msg->data.length()) + "\r\r"); + } + + buildString.append(tr("Raw Payload: ")); + for (int i = 0; i < messages[rowNum].data.count(); i++) + { + buildString.append(Utility::formatNumber(messages[rowNum].data[i])); + buildString.append(" "); + } + buildString.append("\r\r"); + + //if (ui->cb->isChecked()) + //{ + + //} + + ui->txtFrameDetails->setText(buildString); + +} + void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE &msg) { int rowNum; QString tempString; + if ((msg.len != msg.data.count()) && !ui->cbShowIncomplete->isChecked()) return; + messages.append(msg); rowNum = ui->tableIsoFrames->rowCount(); @@ -85,7 +142,7 @@ void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE &msg) else ui->tableIsoFrames->setItem(rowNum, 3, new QTableWidgetItem("Tx")); ui->tableIsoFrames->setItem(rowNum, 4, new QTableWidgetItem(QString::number(msg.len))); - for (int i = 0; i < msg.data.length(); i++) + for (int i = 0; i < msg.data.count(); i++) { tempString.append(Utility::formatNumber(msg.data[i])); tempString.append(" "); diff --git a/isotp_interpreterwindow.h b/isotp_interpreterwindow.h index a8992ba..3818e76 100644 --- a/isotp_interpreterwindow.h +++ b/isotp_interpreterwindow.h @@ -20,6 +20,8 @@ public: private slots: void newISOMessage(ISOTP_MESSAGE &msg); + void showDetailView(); + void updatedFrames(int); private: Ui::ISOTP_InterpreterWindow *ui; diff --git a/isotp_interpreterwindow.ui b/isotp_interpreterwindow.ui index eb92d78..3219b39 100644 --- a/isotp_interpreterwindow.ui +++ b/isotp_interpreterwindow.ui @@ -7,7 +7,7 @@ 0 0 792 - 571 + 725 @@ -25,21 +25,96 @@ - + - Data Details of Selected Message + Show incomplete and/or corrupted messages - - - - - - Interpret Data as UDS - - + + + + + + + Data Details of Selected Message + + + + + + + + + Interpret As: + + + + + + + Raw + + + true + + + + + + + UDS + + + + + + + OBDII + + + + + + + + + + + + + + + + IDs to Decode + + + + + + + + + + + + All + + + + + + + None + + + + + + + +