File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ from boards import boards_dict
2+ from serial .tools import list_ports
3+ import re
4+
5+ def check_ports ():
6+ not_arduinos = []
7+ arduinos = []
8+ for connection in list_ports .comports ():
9+ port ,hwid ,desc = connection
10+ vid_pid = re .search (r"(?<=VID\:PID\=)[0-9|A-Z|a-z]{4}\:[0-9|A-Z|a-z]{4}" , desc )
11+ vid_pid = None if vid_pid is None else vid_pid .group ()
12+ print (vid_pid )
13+ if vid_pid is None :
14+ not_arduinos .append (connection )
15+ else :
16+ try :
17+ board = boards_dict [vid_pid ]
18+ arduinos .append ((board ,connection ))
19+ except KeyError :
20+ not_arduinos .append (connection )
21+ return arduinos , not_arduinos
22+
23+ if __name__ == "__main__" :
24+ arduinos , not_arduinos = check_ports ()
25+ for ard in arduinos :
26+ print (ard )
27+ for nard in not_arduinos :
28+ print (nard )
You can’t perform that action at this time.
0 commit comments