-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserious_test.py
33 lines (26 loc) · 953 Bytes
/
serious_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import serial
import serial.tools.list_ports
def print_serial(port):
print("---------------[ %s ]---------------" % port.name)
print("Path: %s" % port.device)
print("Descript: %s" % port.description)
print("HWID: %s" % port.hwid)
if not None == port.manufacturer:
print("Manufacture: %s" % port.manufacturer)
if not None == port.product:
print("Product: %s" % port.product)
if not None == port.interface:
print("Interface: %s" % port.interface)
print()
def detect_serials(description="target device", vid=0x10c4, pid=0xea60):
ports = serial.tools.list_ports.comports()
for port in ports:
print_serial(port)
if port.description.__contains__(description):
port_path = port.device
return port_path
else:
print("Cannot find the target device: %s" % description)
return None
if __name__ == '__main__':
detect_serials()