eric6/MicroPython/MicroPythonDevices.py

changeset 7588
881eebfefd34
parent 7549
fcfbb9e94471
child 7592
f79dc58bdf62
equal deleted inserted replaced
7587:635f4f018e76 7588:881eebfefd34
91 91
92 def getFoundDevices(): 92 def getFoundDevices():
93 """ 93 """
94 Function to check the serial ports for supported MicroPython devices. 94 Function to check the serial ports for supported MicroPython devices.
95 95
96 @return set of tuples with the board type, a description and the serial 96 @return tuple containing a list of tuples with the board type, a
97 port it is connected at 97 description and the serial port it is connected at for known device
98 @rtype set of tuples of (str, str, str) 98 types and a list of tuples with VID and PID for unknown devices
99 @rtype tuple of (list of tuples of (str, str, str), list of tuples of
100 (str, str)
99 """ 101 """
100 from PyQt5.QtSerialPort import QSerialPortInfo 102 from PyQt5.QtSerialPort import QSerialPortInfo
101 103
102 foundDevices = [] 104 foundDevices = []
105 unknownDevices = []
103 106
104 availablePorts = QSerialPortInfo.availablePorts() 107 availablePorts = QSerialPortInfo.availablePorts()
105 for port in availablePorts: 108 for port in availablePorts:
109 supported = False
106 vid = port.vendorIdentifier() 110 vid = port.vendorIdentifier()
107 pid = port.productIdentifier() 111 pid = port.productIdentifier()
108 for board in SupportedBoards: 112 for board in SupportedBoards:
109 if ((vid, pid) in SupportedBoards[board]["ids"] or 113 if ((vid, pid) in SupportedBoards[board]["ids"] or
110 (vid, None) in SupportedBoards[board]["ids"]): 114 (vid, None) in SupportedBoards[board]["ids"]):
111 foundDevices.append( 115 foundDevices.append(
112 (board, SupportedBoards[board]["description"], 116 (board, SupportedBoards[board]["description"],
113 port.portName())) 117 port.portName()))
114 else: 118 supported = True
115 logging.debug("Unknown device: (0x%04x:0x%04x)", vid, pid) 119 if not supported:
116 120 if vid and pid:
117 return foundDevices 121 unknownDevices.append(("VID: {0:04x}".format(vid),
122 "PID: {0:04x}".format(pid)))
123 logging.debug("Unknown device: (0x%04x:0x%04x)", vid, pid)
124
125 return foundDevices, unknownDevices
118 126
119 127
120 def getDeviceIcon(boardName, iconFormat=True): 128 def getDeviceIcon(boardName, iconFormat=True):
121 """ 129 """
122 Function to get the icon for the given board. 130 Function to get the icon for the given board.

eric ide

mercurial