user is now given the option to ignore the popup to reset a device into bootloader mode. if ignored that device will not trigger a popup again unless the utility is restarted or the device is disconnected
This commit is contained in:
@@ -82,6 +82,10 @@ struct USBDevIds
|
|||||||
{0x04D8, 0xECEE} // from microchip sublicense
|
{0x04D8, 0xECEE} // from microchip sublicense
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If the user ignores the popup to reset a device in normal mode into bootloader mode
|
||||||
|
// the path of the device that triggered the popup will be added to this list and will
|
||||||
|
// not prompt the user again unless it gets disconnected from the computer.
|
||||||
|
QList<QString> IgnoredHIDDevsList;
|
||||||
|
|
||||||
//Surely the micro doesn't have a programmable memory region greater than 268 Megabytes...
|
//Surely the micro doesn't have a programmable memory region greater than 268 Megabytes...
|
||||||
//Value used for error checking device reponse values.
|
//Value used for error checking device reponse values.
|
||||||
@@ -381,8 +385,28 @@ void MainWindow::Connection(void)
|
|||||||
// check if a device is found in normal non-bootloader mode
|
// check if a device is found in normal non-bootloader mode
|
||||||
hid_device_info *hidDevs = hid_enumerate(0, 0);
|
hid_device_info *hidDevs = hid_enumerate(0, 0);
|
||||||
hid_device_info *d = hidDevs;
|
hid_device_info *d = hidDevs;
|
||||||
|
// a new ignored list will be created & only currently ignored devices that are still connected will be saved
|
||||||
|
QList<QString> filteredIgnoredDevsList;
|
||||||
|
bool ignoreRemaining = false;
|
||||||
while (d)
|
while (d)
|
||||||
{
|
{
|
||||||
|
// check if the device is ignored & add to new list if it is
|
||||||
|
QString qstrPath = QString::fromUtf8(d->path);
|
||||||
|
if (IgnoredHIDDevsList.contains(qstrPath))
|
||||||
|
{
|
||||||
|
filteredIgnoredDevsList.append(qstrPath);
|
||||||
|
d = d->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if user ignored a previous device do not continue checking for matching devices
|
||||||
|
if (ignoreRemaining)
|
||||||
|
{
|
||||||
|
d = d->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the device matches any of our PID/VID combinations
|
||||||
for (unsigned int i=0;i<sizeof(NormalModeDevIds)/sizeof(USBDevIds);i++)
|
for (unsigned int i=0;i<sizeof(NormalModeDevIds)/sizeof(USBDevIds);i++)
|
||||||
{
|
{
|
||||||
USBDevIds ids = NormalModeDevIds[i];
|
USBDevIds ids = NormalModeDevIds[i];
|
||||||
@@ -393,13 +417,20 @@ void MainWindow::Connection(void)
|
|||||||
QMessageBox msgbox(QMessageBox::Information,
|
QMessageBox msgbox(QMessageBox::Information,
|
||||||
"Device detected in non-FW update mode",
|
"Device detected in non-FW update mode",
|
||||||
"A device was detected in normal operating mode. Press OK to reset the device into firmware update mode and proceed.",
|
"A device was detected in normal operating mode. Press OK to reset the device into firmware update mode and proceed.",
|
||||||
QMessageBox::Ok,
|
QMessageBox::Ok | QMessageBox::Ignore,
|
||||||
this,
|
this);
|
||||||
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
|
||||||
msgbox.setWindowModality(Qt::ApplicationModal);
|
msgbox.setWindowModality(Qt::ApplicationModal);
|
||||||
msgbox.exec();
|
msgbox.setWindowFlags(msgbox.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
|
||||||
// the user has closed the message box - send the bootloader entry command to the device
|
// if user chose to ignore, add device to ignored list, exit the loop & cleanup HID resources
|
||||||
|
if (msgbox.exec() != QMessageBox::Ok)
|
||||||
|
{
|
||||||
|
ignoreRemaining = true;
|
||||||
|
filteredIgnoredDevsList.append(qstrPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open the HID device and send the command to it
|
||||||
hid_device *dev = hid_open_path(d->path);
|
hid_device *dev = hid_open_path(d->path);
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
{
|
{
|
||||||
@@ -414,12 +445,16 @@ void MainWindow::Connection(void)
|
|||||||
QMessageBox::critical(this, "Error", errMsg);
|
QMessageBox::critical(this, "Error", errMsg);
|
||||||
}
|
}
|
||||||
hid_close(dev);
|
hid_close(dev);
|
||||||
|
|
||||||
|
// do not continue iterating over the list of enumerated HID devices
|
||||||
|
ignoreRemaining = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d = d->next;
|
d = d->next;
|
||||||
}
|
}
|
||||||
|
// copy the latest ignored devices array to the global list
|
||||||
|
IgnoredHIDDevsList = QList<QString>(filteredIgnoredDevsList);
|
||||||
hid_free_enumeration(hidDevs);
|
hid_free_enumeration(hidDevs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user