From 8988e8cf0ac831307871eae226c77aedd7d06191 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 4 Sep 2018 11:36:58 +0200 Subject: [PATCH] Firmware updater: Fix MMU2 lookup wrt. other Prusa devices being connected --- xs/src/slic3r/GUI/FirmwareDialog.cpp | 22 ++++++++++++++-------- xs/src/slic3r/Utils/Serial.cpp | 7 ++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/xs/src/slic3r/GUI/FirmwareDialog.cpp b/xs/src/slic3r/GUI/FirmwareDialog.cpp index d0cd9f8cf..0c06e517e 100644 --- a/xs/src/slic3r/GUI/FirmwareDialog.cpp +++ b/xs/src/slic3r/GUI/FirmwareDialog.cpp @@ -367,7 +367,7 @@ void FirmwareDialog::priv::wait_for_mmu_bootloader(unsigned retries) auto ports = Utils::scan_serial_ports_extended(); ports.erase(std::remove_if(ports.begin(), ports.end(), [=](const SerialPortInfo &port ) { - return port.id_vendor != USB_VID_PRUSA && port.id_product != USB_PID_MMU_BOOT; + return port.id_vendor != USB_VID_PRUSA || port.id_product != USB_PID_MMU_BOOT; }), ports.end()); if (ports.size() == 1) { @@ -390,23 +390,22 @@ void FirmwareDialog::priv::mmu_reboot(const SerialPortInfo &port) void FirmwareDialog::priv::lookup_port_mmu() { + static const auto msg_not_found = + "The Multi Material Control device was not found.\n" + "If the device is connected, please press the Reset button next to the USB connector ..."; + BOOST_LOG_TRIVIAL(info) << "Flashing MMU 2.0, looking for VID/PID 0x2c99/3 or 0x2c99/4 ..."; auto ports = Utils::scan_serial_ports_extended(); ports.erase(std::remove_if(ports.begin(), ports.end(), [=](const SerialPortInfo &port ) { - return port.id_vendor != USB_VID_PRUSA && + return port.id_vendor != USB_VID_PRUSA || port.id_product != USB_PID_MMU_BOOT && port.id_product != USB_PID_MMU_APP; }), ports.end()); if (ports.size() == 0) { BOOST_LOG_TRIVIAL(info) << "MMU 2.0 device not found, asking the user to press Reset and waiting for the device to show up ..."; - - queue_status(_(L( - "The Multi Material Control device was not found.\n" - "If the device is connected, please press the Reset button next to the USB connector ..." - ))); - + queue_status(_(L(msg_not_found))); wait_for_mmu_bootloader(30); } else if (ports.size() > 1) { BOOST_LOG_TRIVIAL(error) << "Several VID/PID 0x2c99/3 devices found"; @@ -417,6 +416,13 @@ void FirmwareDialog::priv::lookup_port_mmu() BOOST_LOG_TRIVIAL(info) << boost::format("Found VID/PID 0x2c99/4 at `%1%`, rebooting the device ...") % ports[0].port; mmu_reboot(ports[0]); wait_for_mmu_bootloader(10); + + if (! port) { + // The device in bootloader mode was not found, inform the user and wait some more... + BOOST_LOG_TRIVIAL(info) << "MMU 2.0 bootloader device not found after reboot, asking the user to press Reset and waiting for the device to show up ..."; + queue_status(_(L(msg_not_found))); + wait_for_mmu_bootloader(30); + } } else { port = ports[0]; } diff --git a/xs/src/slic3r/Utils/Serial.cpp b/xs/src/slic3r/Utils/Serial.cpp index 183119b44..601719b50 100644 --- a/xs/src/slic3r/Utils/Serial.cpp +++ b/xs/src/slic3r/Utils/Serial.cpp @@ -231,7 +231,12 @@ std::vector scan_serial_ports_extended() spi.port = path; #ifdef __linux__ auto friendly_name = sysfs_tty_prop(name, "product"); - spi.friendly_name = friendly_name ? (boost::format("%1% (%2%)") % *friendly_name % path).str() : path; + if (friendly_name) { + spi.is_printer = looks_like_printer(*friendly_name); + spi.friendly_name = (boost::format("%1% (%2%)") % *friendly_name % path).str(); + } else { + spi.friendly_name = path; + } auto vid = sysfs_tty_prop_hex(name, "idVendor"); auto pid = sysfs_tty_prop_hex(name, "idProduct"); if (vid && pid) {