From 02e8467fddc96d899417c2d712b83d9c89b8933a Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Thu, 31 Mar 2022 10:24:17 -0700 Subject: [PATCH] detect devices only using vendor id --- meshtastic/supported_device.py | 4 ++-- meshtastic/util.py | 44 ++++------------------------------ 2 files changed, 6 insertions(+), 42 deletions(-) diff --git a/meshtastic/supported_device.py b/meshtastic/supported_device.py index 042993ae..6ff46e5e 100755 --- a/meshtastic/supported_device.py +++ b/meshtastic/supported_device.py @@ -72,11 +72,11 @@ def __init__(self, name, version=None, for_firmware=None, device_class="esp32", rak4631_5005 = SupportedDevice(name="RAK 4631 5005", version="", for_firmware="rak4631_5005", device_class="nrf52", baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", - usb_vendor_id_in_hex="239a", usb_product_id_in_hex="8029") + usb_vendor_id_in_hex="239a", usb_product_id_in_hex="0029") rak4631_5005_epaper = SupportedDevice(name="RAK 4631 5005 14000 epaper", version="", for_firmware="rak4631_5005_epaper", device_class="nrf52", baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", - usb_vendor_id_in_hex="239a", usb_product_id_in_hex="8029") + usb_vendor_id_in_hex="239a", usb_product_id_in_hex="0029") # Note: The 19003 reports same product id as 5005 in boot mode rak4631_19003 = SupportedDevice(name="RAK 4631 19003", version="", for_firmware="rak4631_19003", device_class="nrf52", diff --git a/meshtastic/util.py b/meshtastic/util.py index f9f05e15..512be3ed 100644 --- a/meshtastic/util.py +++ b/meshtastic/util.py @@ -266,7 +266,7 @@ def camel_to_snake(a_string): def detect_supported_devices(): - """detect supported devices""" + """detect supported devices based on vendor id""" system = platform.system() #print(f'system:{system}') @@ -285,19 +285,8 @@ def detect_supported_devices(): if re.search(search, lsusb_output, re.MULTILINE): #print(f'Found vendor id that matches') devices = get_devices_with_vendor_id(vid) - # check device id for device in devices: - #print(f'device:{device} device.usb_product_id_in_hex:{device.usb_product_id_in_hex}') - if device.usb_product_id_in_hex: - search = f' {vid}:{device.usb_product_id_in_hex} ' - #print(f'search:"{search}"') - if re.search(search, lsusb_output, re.MULTILINE): - # concatenate the devices with vendor id to possibles - possible_devices.add(device) - else: - # if there is a supported device witout a product id, then it - # might be a match... so, concatenate - possible_devices.add(device) + possible_devices.add(device) elif system == "Windows": # if windows, run Get-PnpDevice @@ -313,22 +302,8 @@ def detect_supported_devices(): if re.search(search, sp_output, re.MULTILINE): #print(f'Found vendor id that matches') devices = get_devices_with_vendor_id(vid) - # check device id for device in devices: - #print(f'device:{device} device.usb_product_id_in_hex:{device.usb_product_id_in_hex}') - if device.usb_product_id_in_hex: - search = f'DeviceID.*{vid.upper()}&PID_{device.usb_product_id_in_hex.upper()}' - #print(f'search:"{search}"') - if re.search(search, sp_output, re.MULTILINE): - # concatenate the devices with vendor id to possibles - possible_devices.add(device) - # do a check to see if there is a Windows driver issue - if detect_windows_needs_driver(device, False): - print("WARNING: Need to install driver.") - else: - # if there is a supported device witout a product id, then it - # might be a match... so, concatenate - possible_devices.add(device) + possible_devices.add(device) elif system == "Darwin": # run: system_profiler SPUSBDataType @@ -343,19 +318,8 @@ def detect_supported_devices(): if re.search(search, sp_output, re.MULTILINE): #print(f'Found vendor id that matches') devices = get_devices_with_vendor_id(vid) - # check device id for device in devices: - #print(f'device:{device} device.usb_product_id_in_hex:{device.usb_product_id_in_hex}') - if device.usb_product_id_in_hex: - search = f'Product ID: 0x{device.usb_product_id_in_hex}' - #print(f'search:"{search}"') - if re.search(search, sp_output, re.MULTILINE): - # concatenate the devices with vendor id to possibles - possible_devices.add(device) - else: - # if there is a supported device witout a product id, then it - # might be a match... so, concatenate - possible_devices.add(device) + possible_devices.add(device) return possible_devices