| 1 |
import platform, sys |
| 2 |
import serial.tools.list_ports |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
print("platform.system: %s" % platform.system()) |
| 23 |
print("platform.version: %s" % platform.version()) |
| 24 |
print("platform.release: %s" % platform.release()) |
| 25 |
|
| 26 |
ports = serial.tools.list_ports.comports() |
| 27 |
i = 0 |
| 28 |
for port in ports: |
| 29 |
i += 1 |
| 30 |
print("Port %d:" % i) |
| 31 |
if port.device: |
| 32 |
print(" device: '%s'" % port.device) |
| 33 |
if port.name: |
| 34 |
print(" name: '%s'" % port.name) |
| 35 |
if port.hwid: |
| 36 |
print(" hwid: '%s'" % port.hwid) |
| 37 |
if port.manufacturer: |
| 38 |
print(" manufacturer: '%s'" % port.manufacturer) |
| 39 |
if port.product: |
| 40 |
print(" product: '%s'" % port.product) |
| 41 |
if port.vid: |
| 42 |
print(" vid: %04x" % port.vid) |
| 43 |
if port.pid: |
| 44 |
print(" pid: %04x" % port.pid) |
| 45 |
if port.location: |
| 46 |
print(" location: '%s'" % port.location) |
| 47 |
if port.serial_number: |
| 48 |
print(" serial_number: '%s'" % port.serial_number) |
| 49 |
if port.interface: |
| 50 |
print(" interface: '%s'" % port.interface) |
| 51 |
|
| 52 |
if len(sys.argv) < 2 or sys.argv[1] != "loop": |
| 53 |
sys.exit(0) |
| 54 |
|
| 55 |
|
| 56 |
while True: |
| 57 |
for port in serial.tools.list_ports.comports(): |
| 58 |
if port.vid == 0x1209: |
| 59 |
if not port.location: |
| 60 |
print("BAD", flush=True) |
| 61 |
else: |
| 62 |
print(".", end="", flush=True) |
| 63 |
|