File: scan_for_devices.py

package info (click to toggle)
meshtastic 2.7.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,616 kB
  • sloc: python: 10,936; sh: 76; makefile: 33
file content (29 lines) | stat: -rw-r--r-- 706 bytes parent folder | download | duplicates (2)
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
"""Program to scan for hardware
   To run: python examples/scan_for_devices.py
"""

import sys

from meshtastic.util import (
    active_ports_on_supported_devices,
    detect_supported_devices,
    get_unique_vendor_ids,
)

# simple arg check
if len(sys.argv) != 1:
    print(f"usage: {sys.argv[0]}")
    print("Detect which device we might have.")
    sys.exit(3)

vids = get_unique_vendor_ids()
print(f"Searching for all devices with these vendor ids {vids}")

sds = detect_supported_devices()
if len(sds) > 0:
    print("Detected possible devices:")
for d in sds:
    print(f" name:{d.name}{d.version} firmware:{d.for_firmware}")

ports = active_ports_on_supported_devices(sds)
print(f"ports:{ports}")