41 (0x1B4F, 0x8D22), # SparkFun SAMD21 Mini Breakout |
41 (0x1B4F, 0x8D22), # SparkFun SAMD21 Mini Breakout |
42 (0x1B4F, 0x8D23), # SparkFun SAMD21 Dev Breakout |
42 (0x1B4F, 0x8D23), # SparkFun SAMD21 Dev Breakout |
43 (0x1209, 0x2017), # Mini SAM M4 |
43 (0x1209, 0x2017), # Mini SAM M4 |
44 (0x1209, 0x7102), # Mini SAM M0 |
44 (0x1209, 0x7102), # Mini SAM M0 |
45 ], |
45 ], |
46 "description": "CircuitPython Boards", |
46 "description": "CircuitPython Board", |
47 "icon": "circuitPythonDevice", |
47 "icon": "circuitPythonDevice", |
48 }, |
48 }, |
49 |
49 |
50 "bbc_microbit": { |
50 "bbc_microbit": { |
51 "ids": [ |
51 "ids": [ |
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, PID and description for unknown |
|
99 devices |
|
100 @rtype tuple of (list of tuples of (str, str, str), list of tuples of |
|
101 (int, int, str) |
99 """ |
102 """ |
100 from PyQt5.QtSerialPort import QSerialPortInfo |
103 from PyQt5.QtSerialPort import QSerialPortInfo |
101 |
104 |
102 foundDevices = [] |
105 foundDevices = [] |
|
106 unknownDevices = [] |
103 |
107 |
104 availablePorts = QSerialPortInfo.availablePorts() |
108 availablePorts = QSerialPortInfo.availablePorts() |
105 for port in availablePorts: |
109 for port in availablePorts: |
|
110 supported = False |
106 vid = port.vendorIdentifier() |
111 vid = port.vendorIdentifier() |
107 pid = port.productIdentifier() |
112 pid = port.productIdentifier() |
108 for board in SupportedBoards: |
113 for board in SupportedBoards: |
109 if ((vid, pid) in SupportedBoards[board]["ids"] or |
114 if ((vid, pid) in SupportedBoards[board]["ids"] or |
110 (vid, None) in SupportedBoards[board]["ids"]): |
115 (vid, None) in SupportedBoards[board]["ids"]): |
111 foundDevices.append( |
116 foundDevices.append( |
112 (board, SupportedBoards[board]["description"], |
117 (board, SupportedBoards[board]["description"], |
113 port.portName())) |
118 port.portName())) |
114 else: |
119 supported = True |
115 logging.debug("Unknown device: (0x%04x:0x%04x)", vid, pid) |
120 if not supported: |
116 |
121 if vid and pid: |
117 return foundDevices |
122 unknownDevices.append((vid, pid, port.description())) |
|
123 logging.debug("Unknown device: (0x%04x:0x%04x %s)", |
|
124 vid, pid, port.description()) |
|
125 |
|
126 return foundDevices, unknownDevices |
118 |
127 |
119 |
128 |
120 def getDeviceIcon(boardName, iconFormat=True): |
129 def getDeviceIcon(boardName, iconFormat=True): |
121 """ |
130 """ |
122 Function to get the icon for the given board. |
131 Function to get the icon for the given board. |