Added ability to read buildid which is necessary in order to grab the proper firmware files for the given hardware
This commit is contained in:
@@ -46,6 +46,7 @@ UDSFirmwareUploaderWindow::UDSFirmwareUploaderWindow(const QVector<CANFrame> *fr
|
||||
connect(ui->btnLoadFile, &QPushButton::clicked, this, &UDSFirmwareUploaderWindow::handleLoadFile);
|
||||
connect(ui->btnStartStop, &QPushButton::clicked, this, &UDSFirmwareUploaderWindow::handleStartStop);
|
||||
connect(ui->btnAbort, &QPushButton::clicked, this, &UDSFirmwareUploaderWindow::handleAbort);
|
||||
connect(ui->btnReadBuildID, &QPushButton::clicked, this, &UDSFirmwareUploaderWindow::handleReadBuildID);
|
||||
connect(ui->btnBrowseTeslaDir, &QPushButton::clicked, this, &UDSFirmwareUploaderWindow::handleBrowseTeslaDir);
|
||||
connect(ui->btnReloadNodes, &QPushButton::clicked, this, &UDSFirmwareUploaderWindow::handleReloadNodes);
|
||||
connect(udsHandler, &UDS_HANDLER::newUDSMessage, this, &UDSFirmwareUploaderWindow::gotUDSReply);
|
||||
@@ -83,6 +84,7 @@ void UDSFirmwareUploaderWindow::setState(UPLOAD_STATE newState)
|
||||
ui->btnStartStop->setEnabled(true);
|
||||
ui->btnAbort->setEnabled(false);
|
||||
ui->btnLoadFile->setEnabled(true);
|
||||
ui->btnReadBuildID->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +156,7 @@ void UDSFirmwareUploaderWindow::startUpload()
|
||||
ui->btnStartStop->setEnabled(false);
|
||||
ui->btnAbort->setEnabled(true);
|
||||
ui->btnLoadFile->setEnabled(false);
|
||||
ui->btnReadBuildID->setEnabled(false);
|
||||
|
||||
udsHandler->setReception(true);
|
||||
udsHandler->addFilter(busId, responseId, 0x7FF);
|
||||
@@ -332,6 +335,41 @@ void UDSFirmwareUploaderWindow::sendTesterPresent()
|
||||
udsHandler->sendUDSFrame(msg);
|
||||
}
|
||||
|
||||
void UDSFirmwareUploaderWindow::handleReadBuildID()
|
||||
{
|
||||
if (currentState != STATE_IDLE && currentState != STATE_COMPLETE && currentState != STATE_ERROR)
|
||||
return;
|
||||
|
||||
busId = ui->spinBus->value();
|
||||
targetId = Utility::ParseStringToNum(ui->txtTargetID->text());
|
||||
responseId = Utility::ParseStringToNum(ui->txtResponseID->text());
|
||||
|
||||
ui->btnReadBuildID->setEnabled(false);
|
||||
|
||||
udsHandler->setReception(true);
|
||||
udsHandler->addFilter(busId, responseId, 0x7FF);
|
||||
|
||||
logMessage(QString("Reading build ID from 0x%1 (response 0x%2, bus %3)...")
|
||||
.arg(targetId, 0, 16).arg(responseId, 0, 16).arg(busId));
|
||||
|
||||
sendReadBuildID();
|
||||
}
|
||||
|
||||
void UDSFirmwareUploaderWindow::sendReadBuildID()
|
||||
{
|
||||
UDS_MESSAGE msg;
|
||||
msg.bus = busId;
|
||||
msg.setFrameId(targetId);
|
||||
msg.service = UDS_SERVICES::READ_BY_ID;
|
||||
msg.subFuncLen = 2;
|
||||
msg.subFunc = 0xF180;
|
||||
|
||||
udsHandler->setFlowCtrl(true); //we need to generate flow control messages for this read request.
|
||||
udsHandler->sendUDSFrame(msg);
|
||||
setState(STATE_WAIT_BUILD_ID_RESP);
|
||||
timeoutTimer->start();
|
||||
}
|
||||
|
||||
void UDSFirmwareUploaderWindow::handleNRC(int nrc)
|
||||
{
|
||||
QString desc = udsHandler->getNegativeResponseLong(nrc);
|
||||
@@ -455,6 +493,28 @@ void UDSFirmwareUploaderWindow::gotUDSReply(UDS_MESSAGE msg)
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_WAIT_BUILD_ID_RESP:
|
||||
{
|
||||
// READ_BY_ID (0x22) positive response (0x62): service byte stripped by UDS handler.
|
||||
// msg.payload() = [0xF1, 0x80, ..., buildId at indices 6-9]
|
||||
// This corresponds to bytes 6-10 of the raw ISOTP assembled frame.
|
||||
if (dataLen >= 10)
|
||||
{
|
||||
quint32 buildId = (data[6] << 24) + (data[7] << 16) + (data[8] << 8) + data[9];
|
||||
QString buildIdStr = QString::number(buildId);
|
||||
logMessage("Build ID: " + buildIdStr);
|
||||
ui->lblBuildID->setText(buildIdStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
logMessage(QString("Build ID response too short (%1 bytes in payload)").arg(dataLen));
|
||||
}
|
||||
udsHandler->clearAllFilters();
|
||||
udsHandler->setReception(false);
|
||||
setState(STATE_IDLE);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ enum UPLOAD_STATE
|
||||
STATE_WAIT_EXIT_RESP,
|
||||
STATE_SEND_ECU_RESET,
|
||||
STATE_WAIT_RESET_RESP,
|
||||
STATE_WAIT_BUILD_ID_RESP,
|
||||
STATE_COMPLETE,
|
||||
STATE_ERROR
|
||||
};
|
||||
@@ -60,6 +61,7 @@ private slots:
|
||||
void handleLoadFile();
|
||||
void handleStartStop();
|
||||
void handleAbort();
|
||||
void handleReadBuildID();
|
||||
void handleBrowseTeslaDir();
|
||||
void handleReloadNodes();
|
||||
void handleNodeChanged(int index);
|
||||
@@ -83,6 +85,7 @@ private:
|
||||
void sendTransferExit();
|
||||
void sendECUReset();
|
||||
void sendTesterPresent();
|
||||
void sendReadBuildID();
|
||||
void handleNRC(int nrc);
|
||||
void advanceState();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>624</width>
|
||||
<height>520</height>
|
||||
<height>527</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -44,44 +44,83 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="btnBrowseTeslaDir">
|
||||
<property name="text">
|
||||
<string>Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="btnReloadNodes">
|
||||
<property name="text">
|
||||
<string>Reload</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelNode">
|
||||
<property name="text">
|
||||
<string>Target ECU:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="cmbTeslaNode"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="labelRespID">
|
||||
<property name="text">
|
||||
<string>Target Response ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="txtResponseID">
|
||||
<property name="text">
|
||||
<string>0x7E8</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="labelTargetID">
|
||||
<property name="text">
|
||||
<string>Target Request ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="txtTargetID">
|
||||
<property name="text">
|
||||
<string>0x7E0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelBuildID">
|
||||
<property name="text">
|
||||
<string>Device Build ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnReadBuildID">
|
||||
<property name="text">
|
||||
<string>Read Build ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblBuildID">
|
||||
<property name="text">
|
||||
<string>(not read)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelSession">
|
||||
<property name="text">
|
||||
@@ -110,20 +149,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="labelAddr">
|
||||
<property name="text">
|
||||
<string>Flash Address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QLineEdit" name="txtFlashAddr">
|
||||
<property name="text">
|
||||
<string>0x08000000</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
@@ -151,17 +176,17 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="btnReloadNodes">
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="labelAddr">
|
||||
<property name="text">
|
||||
<string>Reload</string>
|
||||
<string>Flash Address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="btnBrowseTeslaDir">
|
||||
<item row="10" column="1">
|
||||
<widget class="QLineEdit" name="txtFlashAddr">
|
||||
<property name="text">
|
||||
<string>Browse...</string>
|
||||
<string>0x08000000</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user