180 """ |
180 """ |
181 Function to check the serial ports for supported MicroPython devices. |
181 Function to check the serial ports for supported MicroPython devices. |
182 |
182 |
183 @return tuple containing a list of tuples with the board type, the port |
183 @return tuple containing a list of tuples with the board type, the port |
184 description, a description, the serial port it is connected at, the |
184 description, a description, the serial port it is connected at, the |
185 VID and PID for known device types and a list of tuples with VID, PID |
185 VID and PID for known device types, a list of tuples with VID, PID |
186 and description for unknown devices |
186 and description for unknown devices and a list of tuples with VID, |
|
187 PID, description and port name for ports with missing VID or PID |
187 @rtype tuple of (list of tuples of (str, str, str, str, int, int), |
188 @rtype tuple of (list of tuples of (str, str, str, str, int, int), |
188 list of tuples of (int, int, str) |
189 list of tuples of (int, int, str), |
|
190 list of tuples of (int, int, str, str) |
189 """ |
191 """ |
190 from PyQt5.QtSerialPort import QSerialPortInfo |
192 from PyQt5.QtSerialPort import QSerialPortInfo |
191 |
193 |
192 foundDevices = [] |
194 foundDevices = [] |
193 unknownDevices = [] |
195 unknownDevices = [] |
239 vid, |
241 vid, |
240 pid, |
242 pid, |
241 )) |
243 )) |
242 supported = True |
244 supported = True |
243 if not supported: |
245 if not supported: |
244 if vid and pid and (vid, pid) not in IgnoredBoards: |
246 if vid and pid: |
245 unknownDevices.append((vid, pid, port.description())) |
247 if (vid, pid) not in IgnoredBoards: |
246 logging.debug("Unknown device: (0x%04x:0x%04x %s)", |
248 unknownDevices.append((vid, pid, port.description())) |
247 vid, pid, port.description()) |
249 logging.debug("Unknown device: (0x%04x:0x%04x %s)", |
|
250 vid, pid, port.description()) |
248 else: |
251 else: |
|
252 # either VID or PID or both not detected |
249 desc = port.description() |
253 desc = port.description() |
250 if not desc: |
254 if not desc: |
251 desc = "Unknown Device" |
255 desc = QCoreApplication.translate("MicroPythonDevice", |
|
256 "Unknown Device") |
252 unknownPorts.append((vid, pid, desc, port.portName())) |
257 unknownPorts.append((vid, pid, desc, port.portName())) |
253 |
258 |
254 return foundDevices, unknownDevices, unknownPorts |
259 return foundDevices, unknownDevices, unknownPorts |
255 |
260 |
256 |
261 |