Panda flashing button in "Device" panel
Added button to the "Device" panel to flash the panda using the appropriate recovery script along with the killall script as a redundancy.
This commit is contained in:
@@ -466,6 +466,33 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
|
|||||||
});
|
});
|
||||||
addItem(toggleBackup);
|
addItem(toggleBackup);
|
||||||
|
|
||||||
|
// Panda flashing button
|
||||||
|
auto flashPandaBtn = new ButtonControl(tr("Flash Panda"), tr("FLASH"), "Use this button to troubleshoot and update the Panda device's firmware.");
|
||||||
|
connect(flashPandaBtn, &ButtonControl::clicked, [this]() {
|
||||||
|
if (!ConfirmationDialog::confirm(tr("Are you sure you want to flash the Panda?"), tr("Flash"), this)) return;
|
||||||
|
QProcess process;
|
||||||
|
// Get Panda type
|
||||||
|
SubMaster &sm = *(uiState()->sm);
|
||||||
|
auto pandaStates = sm["pandaStates"].getPandaStates();
|
||||||
|
// Choose recovery script based on Panda type
|
||||||
|
if (pandaStates.size() != 0) {
|
||||||
|
auto pandaType = pandaStates[0].getPandaType();
|
||||||
|
bool isRedPanda = (pandaType == cereal::PandaState::PandaType::RED_PANDA ||
|
||||||
|
pandaType == cereal::PandaState::PandaType::RED_PANDA_V2);
|
||||||
|
QString recoveryScript = isRedPanda ? "./recover.sh" : "./recover.py";
|
||||||
|
// Run recovery script and flash Panda
|
||||||
|
process.setWorkingDirectory("/data/openpilot/panda/board");
|
||||||
|
process.start("/bin/sh", QStringList{"-c", recoveryScript});
|
||||||
|
process.waitForFinished();
|
||||||
|
}
|
||||||
|
// Run the killall script as a redundancy
|
||||||
|
process.setWorkingDirectory("/data/openpilot/panda");
|
||||||
|
process.start("/bin/sh", QStringList{"-c", "pkill -f boardd; PYTHONPATH=.. python -c \"from panda import Panda; Panda().flash()\""});
|
||||||
|
process.waitForFinished();
|
||||||
|
Hardware::soft_reboot();
|
||||||
|
});
|
||||||
|
addItem(flashPandaBtn);
|
||||||
|
|
||||||
QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) {
|
QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) {
|
||||||
for (auto btn : findChildren<ButtonControl *>()) {
|
for (auto btn : findChildren<ButtonControl *>()) {
|
||||||
btn->setEnabled(offroad);
|
btn->setEnabled(offroad);
|
||||||
|
|||||||
Reference in New Issue
Block a user