{"record":{"id":"f3aa167d69d541b8","repo":"commaai/openpilot","slug":"failed-to-open-panda-s","errorCode":null,"errorMessage":"failed to open panda %s\n","messagePattern":"failed to open panda (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"openpilot/tools/cabana/streams/pandastream.cc","lineNumber":128,"sourceCode":"  for (auto serial : Panda::list()) {\n    serial_edit->addItem(QString::fromStdString(serial));\n  }\n}\n\nvoid OpenPandaWidget::buildConfigForm() {\n  for (int i = form_layout->rowCount() - 1; i > 0; --i) {\n    form_layout->removeRow(i);\n  }\n\n  QString serial = serial_edit->currentText();\n  bool has_fd = false;\n  bool has_panda = !serial.isEmpty();\n  if (has_panda) {\n    try {\n      Panda panda(serial.toStdString());\n      has_fd = (panda.hw_type == cereal::PandaState::PandaType::RED_PANDA) || (panda.hw_type == cereal::PandaState::PandaType::RED_PANDA_V2);\n    } catch (const std::exception& e) {\n      fprintf(stderr, \"failed to open panda %s\\n\", serial.toUtf8().constData());\n      has_panda = false;\n    }\n  }\n\n  if (has_panda) {\n    config.serial = serial.toStdString();\n    config.bus_config.resize(3);\n    for (int i = 0; i < config.bus_config.size(); i++) {\n      QHBoxLayout *bus_layout = new QHBoxLayout;\n\n      // CAN Speed\n      bus_layout->addWidget(new QLabel(tr(\"CAN Speed (kbps):\")));\n      QComboBox *can_speed = new QComboBox;\n      for (int j = 0; j < std::size(speeds); j++) {\n        can_speed->addItem(QString::number(speeds[j]));\n\n        if (data_speeds[j] == config.bus_config[i].can_speed_kbps) {\n          can_speed->setCurrentIndex(j);","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/commaai/openpilot/blob/516ec1e68203439a73f340f1d0b3b91eabc626ee/openpilot/tools/cabana/streams/pandastream.cc#L110-L146","documentation":"Emitted in the panda stream settings dialog (tools/cabana/streams/pandastream.cc) when constructing a Panda object for the user-selected serial throws std::exception — i.e. opening that specific panda by serial failed (claim/open USB device with that serial did not succeed). The dialog responds by clearing has_panda, disabling panda streaming and FD options for that serial.","triggerScenarios":"Opening the stream settings dialog (or changing the serial combo box, triggering the re-scan) while the selected serial cannot be opened: the device with that serial is no longer present (stale combo entry), another process (a second cabana, boardd, flasher) holds the panda's USB interface exclusively, or USB permissions deny opening the device. The try block around `Panda panda(serial.toStdString())` catches and prints, then treats the serial as unusable.","commonSituations":"Selecting a serial from the dropdown left over from a previous session after unplugging that panda; running boardd/cabana simultaneously — only one can claim the interface; Linux udev rules missing so the device node is root-only; panda mid-flash when the dialog opened.","solutions":["Confirm the panda with that serial is actually connected: `lsusb` and check the serials cabana lists (the combo repopulates from live devices).","Stop other processes holding the panda (boardd, another cabana, panda flash tools) and reopen the dialog.","Install/refresh openpilot udev rules so the user can open the USB device without root.","Replug the panda and reopen the dialog so the serial list is rebuilt from live devices."],"exampleFix":"# before: dialog shows serial, message printed, panda options disabled\nps aux | grep boardd   # boardd claimed the panda\n\n# after\npkill boardd\n# reopen the stream settings dialog — Panda(serial) constructs, FD options appear","handlingStrategy":"validation","validationCode":"// Before selecting a serial in the dialog, confirm it can be opened:\n#include \"panda/panda.h\"\nbool pandaSerialOpenable(const std::string &serial) {\n  try { Panda p(serial); return p.connected(); }\n  catch (const std::exception &) { return false; }\n}","typeGuard":null,"tryCatchPattern":"// The dialog already demonstrates the pattern — wrap construction, degrade on throw:\ntry {\n  Panda panda(serial.toStdString());\n  has_fd = panda.hw_type == cereal::PandaState::PandaType::RED_PANDA /* ... */;\n} catch (const std::exception &) {\n  has_panda = false;  // disable panda options instead of crashing the dialog\n}","preventionTips":["Only pick serials from the freshly-scanned list; stale entries from an old session fail to open.","Ensure no other process (boardd, flasher, second cabana) holds the panda's USB interface.","Install openpilot's udev rules so panda devices are openable without root."],"tags":["panda","usb","exclusive-open","settings-dialog","hardware"],"backgroundTag":null,"analyzedSha":"516ec1e68203439a73f340f1d0b3b91eabc626ee","analyzedAt":"2026-08-15T00:17:37.461Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}