655 |
655 |
656 @param boardType specific board type to search for |
656 @param boardType specific board type to search for |
657 @type str |
657 @type str |
658 @return list of tuples with the board type, the port description, the |
658 @return list of tuples with the board type, the port description, the |
659 VID and PID |
659 VID and PID |
660 @rtype list of tuple of (str, str, int, int) |
660 @rtype list of tuple of (str, str, (int, int)) |
661 """ |
661 """ |
662 foundDevices = [] |
662 foundDevices = set() |
663 |
663 |
664 availablePorts = QSerialPortInfo.availablePorts() |
664 availablePorts = QSerialPortInfo.availablePorts() |
665 for port in availablePorts: |
665 for port in availablePorts: |
666 vid = port.vendorIdentifier() |
666 vid = port.vendorIdentifier() |
667 pid = port.productIdentifier() |
667 pid = port.productIdentifier() |
687 for board in SupportedUF2Boards: |
687 for board in SupportedUF2Boards: |
688 if not boardType or (board == boardType): |
688 if not boardType or (board == boardType): |
689 with contextlib.suppress(KeyError): |
689 with contextlib.suppress(KeyError): |
690 # find mounted volume |
690 # find mounted volume |
691 volumes = SupportedUF2Boards[board]["volumes"][(0, 0)] |
691 volumes = SupportedUF2Boards[board]["volumes"][(0, 0)] |
692 ##foundVolumes = [] |
|
693 for volume, description in volumes: |
692 for volume, description in volumes: |
694 if FileSystemUtilities.findVolume(volume, findAll=True): |
693 if FileSystemUtilities.findVolume(volume, findAll=True): |
695 foundDevices.append( |
694 foundDevices.add( |
696 (board, port.description() or description, (0, 0)) |
695 (board, port.description() or description, (0, 0)) |
697 ) |
696 ) |
698 ##foundVolumes += FileSystemUtilities.findVolume(volume[0], findAll=True) |
|
699 ##if foundVolumes: |
|
700 ##foundDevices.append( |
|
701 ##( |
|
702 ##board, |
|
703 ##QCoreApplication.translate( |
|
704 ##"UF2FlashDialog", "'{0}' Board" |
|
705 ##).format(board), |
|
706 ##(0, 0), # VID/PID of (0, 0) is special |
|
707 ##) |
|
708 ##) |
|
709 |
697 |
710 # third run for CircuitPython boards in UF2 mode but with VID/PID being invalid |
698 # third run for CircuitPython boards in UF2 mode but with VID/PID being invalid |
711 for vidpid, volumes in SupportedUF2Boards["circuitpython"]["volumes"].items(): |
699 for vidpid, volumes in SupportedUF2Boards["circuitpython"]["volumes"].items(): |
712 for volume, description in volumes: |
700 for volume, description in volumes: |
713 if FileSystemUtilities.findVolume(volume, findAll=True): |
701 if FileSystemUtilities.findVolume(volume, findAll=True): |
714 foundDevices.append( |
702 foundDevices.add( |
715 ( |
703 ( |
716 "circuitpython", |
704 "circuitpython", |
717 port.description() or description, |
705 port.description() or description, |
718 vidpid, |
706 vidpid, |
719 ) |
707 ) |
720 ) |
708 ) |
721 |
709 |
722 return foundDevices |
710 return list(foundDevices) |
723 |
711 |
724 |
712 |
725 class UF2FlashDialog(QDialog, Ui_UF2FlashDialog): |
713 class UF2FlashDialog(QDialog, Ui_UF2FlashDialog): |
726 """ |
714 """ |
727 Class implementing a dialog to flash any UF2 capable device. |
715 Class implementing a dialog to flash any UF2 capable device. |