add device and port detection on linux

This commit is contained in:
Mike Kinney
2022-01-30 00:57:56 +00:00
parent 069056edad
commit 28a2aa47e8
20 changed files with 1350 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
"""Program to scan for hardware
To run: python examples/scan_for_devices.py
"""
import sys
import meshtastic
from meshtastic.supported_device import get_unique_vendor_ids, active_ports_on_supported_devices
from meshtastic.util import detect_supported_devices
# 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}')