FrogPilot features - Panda flashing button in "Device" panel

This commit is contained in:
FrogAi 2024-05-09 22:29:38 -07:00
parent 693a2a083e
commit 7e71422936

View File

@ -470,6 +470,30 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
});
addItem(deleteDrivingDataBtn);
// Panda flashing button
auto flashPandaBtn = new ButtonControl(tr("Flash Panda"), tr("FLASH"), tr("Use this button to troubleshoot and update the Panda device's firmware."));
connect(flashPandaBtn, &ButtonControl::clicked, [=]() {
if (ConfirmationDialog::confirm(tr("Are you sure you want to flash the Panda?"), tr("Flash"), this)) {
std::thread([=]() {
QProcess process;
flashPandaBtn->setValue(tr("Flashing..."));
process.setWorkingDirectory("/data/openpilot/panda/board");
process.start("/bin/sh", QStringList{"-c", "./recover.py"});
process.waitForFinished();
process.start("/bin/sh", QStringList{"-c", "./flash.py"});
process.waitForFinished();
process.setWorkingDirectory("/data/openpilot/panda/tests");
process.start("/bin/sh", QStringList{"-c", "python reflash_internal_panda.py"});
process.waitForFinished();
Hardware::reboot();
}).detach();
}
});
addItem(flashPandaBtn);
QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) {
for (auto btn : findChildren<ButtonControl *>()) {
btn->setEnabled(offroad);