src/eric7/MicroPython/UF2FlashDialog.py

branch
eric7
changeset 9904
5d9a7d1afbd9
parent 9903
52132654939b
child 9953
1aa8517bc61f
equal deleted inserted replaced
9903:52132654939b 9904:5d9a7d1afbd9
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()
673 for board in SupportedUF2Boards: 673 for board in SupportedUF2Boards:
674 if (not boardType or (board.startswith(boardType))) and ( 674 if (not boardType or (board.startswith(boardType))) and (
675 vid, 675 vid,
676 pid, 676 pid,
677 ) in SupportedUF2Boards[board]["volumes"]: 677 ) in SupportedUF2Boards[board]["volumes"]:
678 foundDevices.append( 678 foundDevices.add(
679 ( 679 (
680 board, 680 board,
681 port.description(), 681 port.description(),
682 (vid, pid), 682 (vid, pid),
683 ) 683 )
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.

eric ide

mercurial