diff --git a/examples/scan_for_devices.py b/examples/scan_for_devices.py new file mode 100644 index 0000000..6dc28c3 --- /dev/null +++ b/examples/scan_for_devices.py @@ -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}') diff --git a/info/mac/heltec.txt b/info/mac/heltec.txt new file mode 100644 index 0000000..6fc263a --- /dev/null +++ b/info/mac/heltec.txt @@ -0,0 +1,20 @@ +ioreg -p IOUSB > /tmp/d + +> | +-o CP2102 USB to UART Bridge Controller@14400000 + + +system_profiler SPUSBDataType > /tmp/b + +37a38,50 +> CP2102 USB to UART Bridge Controller: +> +> Product ID: 0xea60 +> Vendor ID: 0x10c4 (Silicon Laboratories, Inc.) +> Version: 1.00 +> Serial Number: 0001 +> Speed: Up to 12 Mb/s +> Manufacturer: Silicon Labs +> Location ID: 0x14400000 / 53 +> Current Available (mA): 500 +> Current Required (mA): 100 +> Extra Operating Current (mA): 0 diff --git a/info/mac/rak4631_19003.txt b/info/mac/rak4631_19003.txt new file mode 100644 index 0000000..c60e913 --- /dev/null +++ b/info/mac/rak4631_19003.txt @@ -0,0 +1,10 @@ + + +> | +-o WisCore RAK4631 Board@14400000 + + +/dev/cu.usbmodem14401 + +% ls -al /dev/*modem* +crw-rw-rw- 1 root wheel 0x9000005 Jan 29 15:32 /dev/cu.usbmodem14401 +crw-rw-rw- 1 root wheel 0x9000004 Jan 29 15:31 /dev/tty.usbmodem14401 diff --git a/info/mac/rak4631_5005.txt b/info/mac/rak4631_5005.txt new file mode 100644 index 0000000..d2e6f96 --- /dev/null +++ b/info/mac/rak4631_5005.txt @@ -0,0 +1,18 @@ + +no device plugged in +% ioreg -p IOUSB > /tmp/a + +device plugged in, in "boot" mode +% ioreg -p IOUSB > /tmp/b + +device plugged in, botted to Meshtastic firmware +% ioreg -p IOUSB > /tmp/c + +(venv) sweet Meshtastic-python % diff /tmp/a /tmp/b (with most info removed) +> | +-o Feather nRF52840 Express@14400000 + +diff /tmp/a /tmp/c (with most info removed) +> | +-o WisCore RAK4631 Board@14400000 + + +Meshtastic detected port on /dev/cu.usbmodem14401 diff --git a/info/mac/tbeam.txt b/info/mac/tbeam.txt new file mode 100644 index 0000000..308a7bc --- /dev/null +++ b/info/mac/tbeam.txt @@ -0,0 +1,21 @@ + +meshtastic detected port: /dev/cu.usbmodem53230050571 + +ioreg -p IOUSB > /tmp/c + +> | +-o USB Single Serial@14400000 + + +system_profiler SPUSBDataType > /tmp/a + +> USB Single Serial: +> +> Product ID: 0x55d4 +> Vendor ID: 0x1a86 +> Version: 4.43 +> Serial Number: 5323005057 +> Speed: Up to 12 Mb/s +> Location ID: 0x14400000 / 50 +> Current Available (mA): 500 +> Current Required (mA): 134 +> Extra Operating Current (mA): 0 diff --git a/info/mac/tlora.txt b/info/mac/tlora.txt new file mode 100644 index 0000000..aaefa02 --- /dev/null +++ b/info/mac/tlora.txt @@ -0,0 +1,16 @@ +diff of ioreg -p IOUSB + +> | +-o USB Single Serial@14300000 + + +Diff of system_profiler SPUSBDataType +< USB Single Serial: +< +< Product ID: 0x55d4 +< Vendor ID: 0x1a86 +< Version: 4.43 +< Speed: Up to 12 Mb/s +< Location ID: 0x14300000 / 46 +< Current Available (mA): 500 +< Current Required (mA): 134 +< Extra Operating Current (mA): 0 diff --git a/info/readme.txt b/info/readme.txt new file mode 100644 index 0000000..927980f --- /dev/null +++ b/info/readme.txt @@ -0,0 +1,3 @@ +Gathering OS-level info for devices. + +This info might be helpful for developers detecting info about devices. diff --git a/info/ubuntu/heltec_v2.txt b/info/ubuntu/heltec_v2.txt new file mode 100644 index 0000000..1802941 --- /dev/null +++ b/info/ubuntu/heltec_v2.txt @@ -0,0 +1,85 @@ +Run on Ubuntu 20 + +Command: +lsusb -d 10c4: -v + +Output: +Bus 001 Device 091: ID 10c4:ea60 Silicon Labs CP210x UART Bridge +Device Descriptor: + bLength 18 + bDescriptorType 1 + bcdUSB 1.10 + bDeviceClass 0 + bDeviceSubClass 0 + bDeviceProtocol 0 + bMaxPacketSize0 64 + idVendor 0x10c4 Silicon Labs + idProduct 0xea60 CP210x UART Bridge + bcdDevice 1.00 + iManufacturer 1 + iProduct 2 + iSerial 3 + bNumConfigurations 1 + Configuration Descriptor: + bLength 9 + bDescriptorType 2 + wTotalLength 0x0020 + bNumInterfaces 1 + bConfigurationValue 1 + iConfiguration 0 + bmAttributes 0x80 + (Bus Powered) + MaxPower 100mA + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 0 + bAlternateSetting 0 + bNumEndpoints 2 + bInterfaceClass 255 Vendor Specific Class + bInterfaceSubClass 0 + bInterfaceProtocol 0 + iInterface 2 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x81 EP 1 IN + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x01 EP 1 OUT + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 + + +Command: +esptool.py chip_id + +Output: +esptool.py v3.2 +Found 3 serial ports +Serial port /dev/ttyUSB0 +Connecting.... +Detecting chip type... Unsupported detection protocol, switching and trying again... +Connecting..... +Detecting chip type... ESP32 +Chip is ESP32-D0WDQ6 (revision 1) +Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None +Crystal is 40MHz +MAC: 24:0a:c4:fc:be:f0 +Uploading stub... +Running stub... +Stub running... +Warning: ESP32 has no Chip ID. Reading MAC instead. +MAC: 24:0a:c4:fc:be:f0 +Hard resetting via RTS pin... diff --git a/info/ubuntu/rak4631_19003.txt b/info/ubuntu/rak4631_19003.txt new file mode 100644 index 0000000..c7ecd7c --- /dev/null +++ b/info/ubuntu/rak4631_19003.txt @@ -0,0 +1,118 @@ + +Note: Meshtastic firmware was installed when running these commands + +$ ls -al /dev/ttyACM* +crw-rw---- 1 root dialout 166, 0 Jan 29 21:50 /dev/ttyACM0 + +lsusb -d 239a: -v + +Bus 001 Device 097: ID 239a:8029 +Couldn't open device, some information will be missing +Device Descriptor: + bLength 18 + bDescriptorType 1 + bcdUSB 2.00 + bDeviceClass 239 Miscellaneous Device + bDeviceSubClass 2 + bDeviceProtocol 1 Interface Association + bMaxPacketSize0 64 + idVendor 0x239a + idProduct 0x8029 + bcdDevice 1.00 + iManufacturer 1 + iProduct 2 + iSerial 3 + bNumConfigurations 1 + Configuration Descriptor: + bLength 9 + bDescriptorType 2 + wTotalLength 0x004b + bNumInterfaces 2 + bConfigurationValue 1 + iConfiguration 0 + bmAttributes 0xa0 + (Bus Powered) + Remote Wakeup + MaxPower 100mA + Interface Association: + bLength 8 + bDescriptorType 11 + bFirstInterface 0 + bInterfaceCount 2 + bFunctionClass 2 Communications + bFunctionSubClass 2 Abstract (modem) + bFunctionProtocol 0 + iFunction 0 + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 0 + bAlternateSetting 0 + bNumEndpoints 1 + bInterfaceClass 2 Communications + bInterfaceSubClass 2 Abstract (modem) + bInterfaceProtocol 0 + iInterface 4 + CDC Header: + bcdCDC 1.20 + CDC Call Management: + bmCapabilities 0x00 + bDataInterface 1 + CDC ACM: + bmCapabilities 0x02 + line coding and serial state + CDC Union: + bMasterInterface 0 + bSlaveInterface 1 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x81 EP 1 IN + bmAttributes 3 + Transfer Type Interrupt + Synch Type None + Usage Type Data + wMaxPacketSize 0x0008 1x 8 bytes + bInterval 16 + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 1 + bAlternateSetting 0 + bNumEndpoints 2 + bInterfaceClass 10 CDC Data + bInterfaceSubClass 0 + bInterfaceProtocol 0 + iInterface 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x01 EP 1 OUT + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x82 EP 2 IN + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 + +$ lsusb +Bus 002 Device 005: ID 046d:c31c Logitech, Inc. Keyboard K120 +Bus 002 Device 002: ID 8087:8000 Intel Corp. +Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +Bus 001 Device 097: ID 239a:8029 +Bus 001 Device 002: ID 8087:8008 Intel Corp. +Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub +Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub + +Note: esptool.py chip_id does not detect device diff --git a/info/ubuntu/rak4631_5005.txt b/info/ubuntu/rak4631_5005.txt new file mode 100644 index 0000000..da29a17 --- /dev/null +++ b/info/ubuntu/rak4631_5005.txt @@ -0,0 +1,148 @@ + +Note: Device has Meshtastic firmware installed. + +$ ls -al /dev/ttyACM* +crw-rw---- 1 root dialout 166, 0 Jan 29 21:44 /dev/ttyACM0 + +$ lsusb -d 239a: -v + +Bus 001 Device 098: ID 239a:0029 +Couldn't open device, some information will be missing +Device Descriptor: + bLength 18 + bDescriptorType 1 + bcdUSB 2.00 + bDeviceClass 239 Miscellaneous Device + bDeviceSubClass 2 + bDeviceProtocol 1 Interface Association + bMaxPacketSize0 64 + idVendor 0x239a + idProduct 0x0029 + bcdDevice 1.00 + iManufacturer 1 + iProduct 2 + iSerial 3 + bNumConfigurations 1 + Configuration Descriptor: + bLength 9 + bDescriptorType 2 + wTotalLength 0x0062 + bNumInterfaces 3 + bConfigurationValue 1 + iConfiguration 0 + bmAttributes 0xa0 + (Bus Powered) + Remote Wakeup + MaxPower 100mA + Interface Association: + bLength 8 + bDescriptorType 11 + bFirstInterface 0 + bInterfaceCount 2 + bFunctionClass 2 Communications + bFunctionSubClass 2 Abstract (modem) + bFunctionProtocol 0 + iFunction 0 + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 0 + bAlternateSetting 0 + bNumEndpoints 1 + bInterfaceClass 2 Communications + bInterfaceSubClass 2 Abstract (modem) + bInterfaceProtocol 0 + iInterface 4 + CDC Header: + bcdCDC 1.20 + CDC Call Management: + bmCapabilities 0x00 + bDataInterface 1 + CDC ACM: + bmCapabilities 0x02 + line coding and serial state + CDC Union: + bMasterInterface 0 + bSlaveInterface 1 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x81 EP 1 IN + bmAttributes 3 + Transfer Type Interrupt + Synch Type None + Usage Type Data + wMaxPacketSize 0x0008 1x 8 bytes + bInterval 16 + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 1 + bAlternateSetting 0 + bNumEndpoints 2 + bInterfaceClass 10 CDC Data + bInterfaceSubClass 0 + bInterfaceProtocol 0 + iInterface 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x02 EP 2 OUT + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x82 EP 2 IN + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 2 + bAlternateSetting 0 + bNumEndpoints 2 + bInterfaceClass 8 Mass Storage + bInterfaceSubClass 6 SCSI + bInterfaceProtocol 80 Bulk-Only + iInterface 5 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x03 EP 3 OUT + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x83 EP 3 IN + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 + +$ lsusb +Bus 002 Device 005: ID 046d:c31c Logitech, Inc. Keyboard K120 +Bus 002 Device 002: ID 8087:8000 Intel Corp. +Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +Bus 001 Device 098: ID 239a:0029 +Bus 001 Device 002: ID 8087:8008 Intel Corp. +Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub +Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub + +Note: esptool.py chip_id does not detect device diff --git a/info/ubuntu/readme.txt b/info/ubuntu/readme.txt new file mode 100644 index 0000000..b3a6514 --- /dev/null +++ b/info/ubuntu/readme.txt @@ -0,0 +1 @@ +info run on ubuntu diff --git a/info/ubuntu/tbeam.txt b/info/ubuntu/tbeam.txt new file mode 100644 index 0000000..ca5ab9c --- /dev/null +++ b/info/ubuntu/tbeam.txt @@ -0,0 +1,94 @@ +Run on Ubuntu 20 + +Command: + lsusb -d 1a86: -v + +Output: +Bus 001 Device 096: ID 1a86:55d4 QinHeng Electronics +Device Descriptor: + bLength 18 + bDescriptorType 1 + bcdUSB 1.10 + bDeviceClass 2 Communications + bDeviceSubClass 0 + bDeviceProtocol 0 + bMaxPacketSize0 8 + idVendor 0x1a86 QinHeng Electronics + idProduct 0x55d4 + bcdDevice 4.43 + iManufacturer 0 + iProduct 2 + iSerial 3 + bNumConfigurations 1 + Configuration Descriptor: + bLength 9 + bDescriptorType 2 + wTotalLength 0x0043 + bNumInterfaces 2 + bConfigurationValue 1 + iConfiguration 0 + bmAttributes 0xa0 + (Bus Powered) + Remote Wakeup + MaxPower 134mA + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 0 + bAlternateSetting 0 + bNumEndpoints 1 + bInterfaceClass 2 Communications + bInterfaceSubClass 2 Abstract (modem) + bInterfaceProtocol 1 AT-commands (v.25ter) + iInterface 0 + CDC Header: + bcdCDC 1.10 + CDC Call Management: + bmCapabilities 0x00 + bDataInterface 1 + CDC ACM: + bmCapabilities 0x02 + line coding and serial state + CDC Union: + bMasterInterface 0 + bSlaveInterface 1 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x83 EP 3 IN + bmAttributes 3 + Transfer Type Interrupt + Synch Type None + Usage Type Data + wMaxPacketSize 0x0010 1x 16 bytes + bInterval 1 + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 1 + bAlternateSetting 0 + bNumEndpoints 2 + bInterfaceClass 10 CDC Data + bInterfaceSubClass 0 + bInterfaceProtocol 0 + iInterface 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x02 EP 2 OUT + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0020 1x 32 bytes + bInterval 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x82 EP 2 IN + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 diff --git a/info/ubuntu/tlora.txt b/info/ubuntu/tlora.txt new file mode 100644 index 0000000..131aa65 --- /dev/null +++ b/info/ubuntu/tlora.txt @@ -0,0 +1,106 @@ + +Run on Ubuntu 20 + +Note: Device has Meshtastic firmware installed + + +$ lsusb +Bus 002 Device 005: ID 046d:c31c Logitech, Inc. Keyboard K120 +Bus 002 Device 002: ID 8087:8000 Intel Corp. +Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +Bus 001 Device 099: ID 1a86:55d4 QinHeng Electronics +Bus 001 Device 002: ID 8087:8008 Intel Corp. +Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub +Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +(venv) mikekinney@top:~/Meshtastic-python/info/ubuntu$ lsusb -d 1a86: -v + +Bus 001 Device 099: ID 1a86:55d4 QinHeng Electronics +Couldn't open device, some information will be missing +Device Descriptor: + bLength 18 + bDescriptorType 1 + bcdUSB 1.10 + bDeviceClass 2 Communications + bDeviceSubClass 0 + bDeviceProtocol 0 + bMaxPacketSize0 8 + idVendor 0x1a86 QinHeng Electronics + idProduct 0x55d4 + bcdDevice 4.43 + iManufacturer 0 + iProduct 2 + iSerial 0 + bNumConfigurations 1 + Configuration Descriptor: + bLength 9 + bDescriptorType 2 + wTotalLength 0x0043 + bNumInterfaces 2 + bConfigurationValue 1 + iConfiguration 0 + bmAttributes 0xa0 + (Bus Powered) + Remote Wakeup + MaxPower 134mA + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 0 + bAlternateSetting 0 + bNumEndpoints 1 + bInterfaceClass 2 Communications + bInterfaceSubClass 2 Abstract (modem) + bInterfaceProtocol 1 AT-commands (v.25ter) + iInterface 0 + CDC Header: + bcdCDC 1.10 + CDC Call Management: + bmCapabilities 0x00 + bDataInterface 1 + CDC ACM: + bmCapabilities 0x02 + line coding and serial state + CDC Union: + bMasterInterface 0 + bSlaveInterface 1 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x83 EP 3 IN + bmAttributes 3 + Transfer Type Interrupt + Synch Type None + Usage Type Data + wMaxPacketSize 0x0010 1x 16 bytes + bInterval 1 + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 1 + bAlternateSetting 0 + bNumEndpoints 2 + bInterfaceClass 10 CDC Data + bInterfaceSubClass 0 + bInterfaceProtocol 0 + iInterface 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x02 EP 2 OUT + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0020 1x 32 bytes + bInterval 0 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x82 EP 2 IN + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0040 1x 64 bytes + bInterval 0 diff --git a/info/windows/heltec.txt b/info/windows/heltec.txt new file mode 100644 index 0000000..25905a7 --- /dev/null +++ b/info/windows/heltec.txt @@ -0,0 +1,106 @@ +Run from Windows 10 + +Might work... (nope) + Get-PnpDevice -Class 'USB' -PresentOnly | Format-List + + +> Get-PnpDevice -PresentOnly | Format-List > b +> Compare-Object (get-content a) (Get-Content b) + +InputObject SideIndicator +----------- ------------- +Caption : CP2102 USB to UART Bridge Controller <= +Description : CP2102 USB to UART Bridge Controller <= +Name : CP2102 USB to UART Bridge Controller <= +Status : Error <= +ConfigManagerErrorCode : CM_PROB_FAILED_INSTALL <= +DeviceID : USB\VID_10C4&PID_EA60\0001 <= +PNPDeviceID : USB\VID_10C4&PID_EA60\0001 <= +CompatibleID : {USB\Class_FF&SubClass_00&Prot_00, USB\Class_FF&SubClass_00, USB\Class_FF} <= +HardwareID : {USB\VID_10C4&PID_EA60&REV_0100, USB\VID_10C4&PID_EA60} <= +FriendlyName : CP2102 USB to UART Bridge Controller <= +InstanceId : USB\VID_10C4&PID_EA60\0001 <= +Problem : CM_PROB_FAILED_INSTALL <= +ClassGuid : <= +Manufacturer : <= +PNPClass : <= +Class : <= +Service : <= +InstallDate : <= +Availability : <= +ConfigManagerUserConfig : False <= +CreationClassName : Win32_PnPEntity <= +ErrorCleared : <= +ErrorDescription : <= +LastErrorCode : <= +PowerManagementCapabilities : <= +PowerManagementSupported : <= +StatusInfo : <= +SystemCreationClassName : Win32_ComputerSystem <= +SystemName : DESKTOP-FRFQN8H <= +Present : True <= +PSComputerName : <= +ProblemDescription : <= + <= + +> Get-PnpDevice -DeviceID 'USB\VID_10C4&PID_EA60\0001' + +Status Class FriendlyName InstanceId +------ ----- ------------ ---------- +Error CP2102 USB to UART Bridge Controller USB\VID_... + + +> Get-PnpDevice -PresentOnly -DeviceID 'USB\VID_10C4&PID_EA60\0001' +Get-PnpDevice : No matching Win32_PnPEntity objects found by CIM query for instances of the ROOT\cimv2\Win32_PnPEntity +class on the CIM server: SELECT * FROM Win32_PnPEntity WHERE ((DeviceId LIKE 'USB\\VID[_]10C4&PID[_]EA60\\0001')) +AND ((Present = TRUE)). Verify query parameters and retry. +At line:1 char:1 ++ Get-PnpDevice -PresentOnly -DeviceID 'USB\VID_10C4&PID_EA60\0001' ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + CategoryInfo : ObjectNotFound: (Win32_PnPEntity:String) [Get-PnpDevice], CimJobException + + FullyQualifiedErrorId : CmdletizationQuery_NotFound,Get-PnpDevice + +> Get-PnpDevice -PresentOnly -DeviceID 'USB\VID_10C4&PID_EA60\0001' + +Status Class FriendlyName InstanceId +------ ----- ------------ ---------- +Error CP2102 USB to UART Bridge Controller USB\VID_... + + + +If need to install driver +Get-PnpDevice -DeviceID 'USB\VID_10C4&PID_EA60\0001' | Format-List + + +Caption : CP2102 USB to UART Bridge Controller +Description : CP2102 USB to UART Bridge Controller +InstallDate : +Name : CP2102 USB to UART Bridge Controller +Status : Error +Availability : +ConfigManagerErrorCode : CM_PROB_FAILED_INSTALL +ConfigManagerUserConfig : False +CreationClassName : Win32_PnPEntity +DeviceID : USB\VID_10C4&PID_EA60\0001 +ErrorCleared : +ErrorDescription : +LastErrorCode : +PNPDeviceID : USB\VID_10C4&PID_EA60\0001 +PowerManagementCapabilities : +PowerManagementSupported : +StatusInfo : +SystemCreationClassName : Win32_ComputerSystem +SystemName : DESKTOP-FRFQN8H +ClassGuid : +CompatibleID : {USB\Class_FF&SubClass_00&Prot_00, USB\Class_FF&SubClass_00, USB\Class_FF} +HardwareID : {USB\VID_10C4&PID_EA60&REV_0100, USB\VID_10C4&PID_EA60} +Manufacturer : +PNPClass : +Present : True +Service : +PSComputerName : +Class : +FriendlyName : CP2102 USB to UART Bridge Controller +InstanceId : USB\VID_10C4&PID_EA60\0001 +Problem : CM_PROB_FAILED_INSTALL +ProblemDescription : diff --git a/info/windows/rak4631_19003.txt b/info/windows/rak4631_19003.txt new file mode 100644 index 0000000..d77d45b --- /dev/null +++ b/info/windows/rak4631_19003.txt @@ -0,0 +1,78 @@ +Run from Windows 10 + +> Get-PnpDevice -PresentOnly | Format-List >a +> Get-PnpDevice -PresentOnly | Format-List >b +> Compare-Object (get-content a) (Get-Content b) + +InputObject Side + Indi + cato + r +----------- ---- +Caption : USB Serial Device (COM4) => +Description : USB Serial Device => +Name : USB Serial Device (COM4) => +DeviceID : USB\VID_239A&PID_8029&MI_00\6&E8876D1&0&0000 => +PNPDeviceID : USB\VID_239A&PID_8029&MI_00\6&E8876D1&0&0000 => +ClassGuid : {4d36e978-e325-11ce-bfc1-08002be10318} => +CompatibleID : {USB\Class_02&SubClass_02&Prot_00, USB\Class_02&SubClass_02, USB\Class_02} => +HardwareID : {USB\VID_239A&PID_8029&REV_0100&MI_00, USB\VID_239A&PID_8029&MI_00} => +PNPClass : Ports => +Service : usbser => +Class : Ports => +FriendlyName : USB Serial Device (COM4) => +InstanceId : USB\VID_239A&PID_8029&MI_00\6&E8876D1&0&0000 => +Caption : USB Composite Device => +Description : USB Composite Device => +Name : USB Composite Device => +DeviceID : USB\VID_239A&PID_8029\E6CF9502B1D410D8 => +PNPDeviceID : USB\VID_239A&PID_8029\E6CF9502B1D410D8 => +ClassGuid : {36fc9e60-c465-11cf-8056-444553540000} => +CompatibleID : {USB\DevClass_00&SubClass_00&Prot_00, USB\DevClass_00&SubClass_00, USB\DevClass_00, => + USB\COMPOSITE} => +HardwareID : {USB\VID_239A&PID_8029&REV_0100, USB\VID_239A&PID_8029} => +Manufacturer : (Standard USB Host Controller) => +PNPClass : USB => +Service : usbccgp => +Class : USB => +FriendlyName : USB Composite Device => +InstanceId : USB\VID_239A&PID_8029\E6CF9502B1D410D8 => +InstallDate : => +Status : OK => +Availability : => +ConfigManagerErrorCode : CM_PROB_NONE => +ConfigManagerUserConfig : False => +CreationClassName : Win32_PnPEntity => +ErrorCleared : => +ErrorDescription : => +LastErrorCode : => +PowerManagementCapabilities : => +PowerManagementSupported : => +StatusInfo : => +SystemCreationClassName : Win32_ComputerSystem => +SystemName : DESKTOP-FRFQN8H => +Present : True => +PSComputerName : => +Problem : CM_PROB_NONE => +ProblemDescription : => +InstallDate : => +Status : OK => +Availability : => +ConfigManagerErrorCode : CM_PROB_NONE => +ConfigManagerUserConfig : False => +CreationClassName : Win32_PnPEntity => +ErrorCleared : => +ErrorDescription : => +LastErrorCode : => +PowerManagementCapabilities : => +PowerManagementSupported : => +StatusInfo : => +SystemCreationClassName : Win32_ComputerSystem => +SystemName : DESKTOP-FRFQN8H => +Manufacturer : Microsoft => +Present : True => +PSComputerName : => +Problem : CM_PROB_NONE => +ProblemDescription : => + => + => diff --git a/info/windows/rak4631_5005.txt b/info/windows/rak4631_5005.txt new file mode 100644 index 0000000..1e0a935 --- /dev/null +++ b/info/windows/rak4631_5005.txt @@ -0,0 +1,254 @@ +Run from Windows 10 + +> Get-PnpDevice -PresentOnly | Format-List >a +> Get-PnpDevice -PresentOnly | Format-List >b +> Compare-Object (get-content a) (Get-Content b) + +In "boot" mode: + +InputObject +----------- +Caption : FTHR840BOOT +Description : nRF UF2 +Name : FTHR840BOOT +DeviceID : SWD\WPDBUSENUM\_??_USBSTOR#DISK&VEN_ADAFRUIT&PROD_NRF_UF2&REV_1.0#7&27E1626&0&D121BD1C90B + 93EA2&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B} +PNPDeviceID : SWD\WPDBUSENUM\_??_USBSTOR#DISK&VEN_ADAFRUIT&PROD_NRF_UF2&REV_1.0#7&27E1626&0&D121BD1C90B + 93EA2&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B} +ClassGuid : {eec5ad98-8080-425f-922a-dabf3de3f69a} +CompatibleID : {wpdbusenum\fs, SWD\Generic} +Manufacturer : Adafruit +PNPClass : WPD +Service : WUDFWpdFs +Class : WPD +FriendlyName : FTHR840BOOT +InstanceId : SWD\WPDBUSENUM\_??_USBSTOR#DISK&VEN_ADAFRUIT&PROD_NRF_UF2&REV_1.0#7&27E1626&0&D121BD1C90B + 93EA2&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B} +DeviceID : STORAGE\VOLUME\_??_USBSTOR#DISK&VEN_ADAFRUIT&PROD_NRF_UF2&REV_1.0#7&27E1626&0&D121BD1C90B + 93EA2&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B} +PNPDeviceID : STORAGE\VOLUME\_??_USBSTOR#DISK&VEN_ADAFRUIT&PROD_NRF_UF2&REV_1.0#7&27E1626&0&D121BD1C90B + 93EA2&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B} +InstanceId : STORAGE\VOLUME\_??_USBSTOR#DISK&VEN_ADAFRUIT&PROD_NRF_UF2&REV_1.0#7&27E1626&0&D121BD1C90B + 93EA2&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B} +Caption : USB Mass Storage Device +Description : USB Mass Storage Device +Name : USB Mass Storage Device +DeviceID : USB\VID_239A&PID_0029&MI_02\6&175793A&0&0002 +PNPDeviceID : USB\VID_239A&PID_0029&MI_02\6&175793A&0&0002 +CompatibleID : {USB\Class_08&SubClass_06&Prot_50, USB\Class_08&SubClass_06, USB\Class_08} +HardwareID : {USB\VID_239A&PID_0029&REV_0100&MI_02, USB\VID_239A&PID_0029&MI_02} +Manufacturer : Compatible USB storage device +Service : USBSTOR +FriendlyName : USB Mass Storage Device +InstanceId : USB\VID_239A&PID_0029&MI_02\6&175793A&0&0002 +Caption : USB Serial Device (COM5) +Description : USB Serial Device +Name : USB Serial Device (COM5) +DeviceID : USB\VID_239A&PID_0029&MI_00\6&175793A&0&0000 +PNPDeviceID : USB\VID_239A&PID_0029&MI_00\6&175793A&0&0000 +ClassGuid : {4d36e978-e325-11ce-bfc1-08002be10318} +CompatibleID : {USB\Class_02&SubClass_02&Prot_00, USB\Class_02&SubClass_02, USB\Class_02} +HardwareID : {USB\VID_239A&PID_0029&REV_0100&MI_00, USB\VID_239A&PID_0029&MI_00} +PNPClass : Ports +Service : usbser +Class : Ports +FriendlyName : USB Serial Device (COM5) +InstanceId : USB\VID_239A&PID_0029&MI_00\6&175793A&0&0000 +DeviceID : USB\VID_239A&PID_0029\D121BD1C90B93EA2 +PNPDeviceID : USB\VID_239A&PID_0029\D121BD1C90B93EA2 +ClassGuid : {36fc9e60-c465-11cf-8056-444553540000} +HardwareID : {USB\VID_239A&PID_0029&REV_0100, USB\VID_239A&PID_0029} +PNPClass : USB +Class : USB +InstanceId : USB\VID_239A&PID_0029\D121BD1C90B93EA2 +Caption : USB Composite Device +Description : USB Composite Device +Name : USB Composite Device +ClassGuid : {36fc9e60-c465-11cf-8056-444553540000} +CompatibleID : {USB\DevClass_00&SubClass_00&Prot_00, USB\DevClass_00&SubClass_00, USB\DevClass_00, + USB\COMPOSITE} +Manufacturer : (Standard USB Host Controller) +PNPClass : USB +Service : usbccgp +Class : USB +FriendlyName : USB Composite Device +Caption : Volume +Description : Volume +Name : Volume +ClassGuid : {71a27cdd-812a-11d0-bec7-08002be2092f} +HardwareID : {STORAGE\Volume} +PNPClass : Volume +Service : volume +Class : Volume +FriendlyName : Volume +HardwareID : +Caption : Adafruit nRF UF2 USB Device +Name : Adafruit nRF UF2 USB Device +DeviceID : USBSTOR\DISK&VEN_ADAFRUIT&PROD_NRF_UF2&REV_1.0\7&27E1626&0&D121BD1C90B93EA2&0 +PNPDeviceID : USBSTOR\DISK&VEN_ADAFRUIT&PROD_NRF_UF2&REV_1.0\7&27E1626&0&D121BD1C90B93EA2&0 +CompatibleID : {USBSTOR\Disk, USBSTOR\RAW, GenDisk} +HardwareID : {USBSTOR\DiskAdafruitnRF_UF2_________1.0_, USBSTOR\DiskAdafruitnRF_UF2_________, + USBSTOR\DiskAdafruit, USBSTOR\AdafruitnRF_UF2_________1...} +FriendlyName : Adafruit nRF UF2 USB Device +InstanceId : USBSTOR\DISK&VEN_ADAFRUIT&PROD_NRF_UF2&REV_1.0\7&27E1626&0&D121BD1C90B93EA2&0 +Description : Disk drive +ClassGuid : {4d36e967-e325-11ce-bfc1-08002be10318} +Manufacturer : (Standard disk drives) +PNPClass : DiskDrive +Service : disk +Class : DiskDrive +CompatibleID : +InstallDate : +Status : OK +Availability : +ConfigManagerErrorCode : CM_PROB_NONE +ConfigManagerUserConfig : False +CreationClassName : Win32_PnPEntity +ErrorCleared : +ErrorDescription : +LastErrorCode : +PowerManagementCapabilities : +PowerManagementSupported : +StatusInfo : +SystemCreationClassName : Win32_ComputerSystem +SystemName : DESKTOP-FRFQN8H +Present : True +PSComputerName : +Problem : CM_PROB_NONE +ProblemDescription : +InstallDate : +Status : OK +Availability : +ConfigManagerErrorCode : CM_PROB_NONE +ConfigManagerUserConfig : False +CreationClassName : Win32_PnPEntity +ErrorCleared : +ErrorDescription : +LastErrorCode : +PowerManagementCapabilities : +PowerManagementSupported : +StatusInfo : +SystemCreationClassName : Win32_ComputerSystem +SystemName : DESKTOP-FRFQN8H +Present : True +PSComputerName : +Problem : CM_PROB_NONE +ProblemDescription : +InstallDate : +Status : OK +Availability : +ConfigManagerErrorCode : CM_PROB_NONE +ConfigManagerUserConfig : False +CreationClassName : Win32_PnPEntity +ErrorCleared : +ErrorDescription : +LastErrorCode : +PowerManagementCapabilities : +PowerManagementSupported : +StatusInfo : +SystemCreationClassName : Win32_ComputerSystem +SystemName : DESKTOP-FRFQN8H +Present : True +PSComputerName : +Problem : CM_PROB_NONE +ProblemDescription : + +InstallDate : +Status : OK +Availability : +ConfigManagerErrorCode : CM_PROB_NONE +ConfigManagerUserConfig : False +CreationClassName : Win32_PnPEntity +ErrorCleared : +ErrorDescription : +LastErrorCode : +PowerManagementCapabilities : +PowerManagementSupported : +StatusInfo : +SystemCreationClassName : Win32_ComputerSystem +SystemName : DESKTOP-FRFQN8H +Manufacturer : Microsoft +Present : True +PSComputerName : +Problem : CM_PROB_NONE +ProblemDescription : + + + +When you press the RST to load Meshtastic: + +> Get-PnpDevice -PresentOnly | Format-List >b +> Compare-Object (get-content a) (Get-Content b) + +InputObject Side + Indi + cato + r +----------- ---- +DeviceID : USB\VID_239A&PID_8029\D121BD1C90B93EA2 => +PNPDeviceID : USB\VID_239A&PID_8029\D121BD1C90B93EA2 => +HardwareID : {USB\VID_239A&PID_8029&REV_0100, USB\VID_239A&PID_8029} => +InstanceId : USB\VID_239A&PID_8029\D121BD1C90B93EA2 => +Caption : USB Composite Device => +Description : USB Composite Device => +Name : USB Composite Device => +ClassGuid : {36fc9e60-c465-11cf-8056-444553540000} => +CompatibleID : {USB\DevClass_00&SubClass_00&Prot_00, USB\DevClass_00&SubClass_00, USB\DevClass_00, => + USB\COMPOSITE} => +Manufacturer : (Standard USB Host Controller) => +PNPClass : USB => +Service : usbccgp => +Class : USB => +FriendlyName : USB Composite Device => +Caption : USB Serial Device (COM6) => +Description : USB Serial Device => +Name : USB Serial Device (COM6) => +DeviceID : USB\VID_239A&PID_8029&MI_00\6&39B279E2&0&0000 => +PNPDeviceID : USB\VID_239A&PID_8029&MI_00\6&39B279E2&0&0000 => +ClassGuid : {4d36e978-e325-11ce-bfc1-08002be10318} => +CompatibleID : {USB\Class_02&SubClass_02&Prot_00, USB\Class_02&SubClass_02, USB\Class_02} => +HardwareID : {USB\VID_239A&PID_8029&REV_0100&MI_00, USB\VID_239A&PID_8029&MI_00} => +PNPClass : Ports => +Service : usbser => +Class : Ports => +FriendlyName : USB Serial Device (COM6) => +InstanceId : USB\VID_239A&PID_8029&MI_00\6&39B279E2&0&0000 => +InstallDate : => +Status : OK => +Availability : => +ConfigManagerErrorCode : CM_PROB_NONE => +ConfigManagerUserConfig : False => +CreationClassName : Win32_PnPEntity => +ErrorCleared : => +ErrorDescription : => +LastErrorCode : => +PowerManagementCapabilities : => +PowerManagementSupported : => +StatusInfo : => +SystemCreationClassName : Win32_ComputerSystem => +SystemName : DESKTOP-FRFQN8H => +Present : True => +PSComputerName : => +Problem : CM_PROB_NONE => +ProblemDescription : => +InstallDate : => +Status : OK => +Availability : => +ConfigManagerErrorCode : CM_PROB_NONE => +ConfigManagerUserConfig : False => +CreationClassName : Win32_PnPEntity => +ErrorCleared : => +ErrorDescription : => +LastErrorCode : => +PowerManagementCapabilities : => +PowerManagementSupported : => +StatusInfo : => +SystemCreationClassName : Win32_ComputerSystem => +SystemName : DESKTOP-FRFQN8H => +Manufacturer : Microsoft => +Present : True => +PSComputerName : => +Problem : CM_PROB_NONE => +ProblemDescription : => + => + diff --git a/info/windows/tbeam.txt b/info/windows/tbeam.txt new file mode 100644 index 0000000..df6ae76 --- /dev/null +++ b/info/windows/tbeam.txt @@ -0,0 +1,42 @@ +Run from Windows 10 + +> Get-PnpDevice -PresentOnly | Format-List >a +> Get-PnpDevice -PresentOnly | Format-List >b +> Compare-Object (get-content a) (Get-Content b) + +InputObject SideIndicator +----------- ------------- +Caption : USB-Enhanced-SERIAL CH9102 (COM7) => +Description : USB-Enhanced-SERIAL CH9102 => +Name : USB-Enhanced-SERIAL CH9102 (COM7) => +DeviceID : USB\VID_1A86&PID_55D4\5323005057 => +PNPDeviceID : USB\VID_1A86&PID_55D4\5323005057 => +ClassGuid : {4d36e978-e325-11ce-bfc1-08002be10318} => +CompatibleID : {USB\Class_02&SubClass_02&Prot_01, USB\Class_02&SubClass_02, USB\Class_02} => +HardwareID : {USB\VID_1A86&PID_55D4&REV_0443, USB\VID_1A86&PID_55D4} => +Manufacturer : wch.cn => +PNPClass : Ports => +Service : CH343SER_A64 => +Class : Ports => +FriendlyName : USB-Enhanced-SERIAL CH9102 (COM7) => +InstanceId : USB\VID_1A86&PID_55D4\5323005057 => +InstallDate : => +Status : OK => +Availability : => +ConfigManagerErrorCode : CM_PROB_NONE => +ConfigManagerUserConfig : False => +CreationClassName : Win32_PnPEntity => +ErrorCleared : => +ErrorDescription : => +LastErrorCode : => +PowerManagementCapabilities : => +PowerManagementSupported : => +StatusInfo : => +SystemCreationClassName : Win32_ComputerSystem => +SystemName : DESKTOP-FRFQN8H => +Present : True => +PSComputerName : => +Problem : CM_PROB_NONE => +ProblemDescription : => + => + diff --git a/info/windows/tlora.txt b/info/windows/tlora.txt new file mode 100644 index 0000000..1b1741c --- /dev/null +++ b/info/windows/tlora.txt @@ -0,0 +1,41 @@ +Run from Windows 10 + +PS C:\Users\mikekinney> Get-PnpDevice -PresentOnly | Format-List > a +PS C:\Users\mikekinney> Get-PnpDevice -PresentOnly | Format-List > b +PS C:\Users\mikekinney> Compare-Object (get-content a) (Get-Content b) + +InputObject SideIndicator +----------- ------------- +Caption : USB-Enhanced-SERIAL CH9102 (COM3) <= +Description : USB-Enhanced-SERIAL CH9102 <= +Name : USB-Enhanced-SERIAL CH9102 (COM3) <= +DeviceID : USB\VID_1A86&PID_55D4\5&27435A1F&0&1 <= +PNPDeviceID : USB\VID_1A86&PID_55D4\5&27435A1F&0&1 <= +ClassGuid : {4d36e978-e325-11ce-bfc1-08002be10318} <= +CompatibleID : {USB\Class_02&SubClass_02&Prot_01, USB\Class_02&SubClass_02, USB\Class_02} <= +HardwareID : {USB\VID_1A86&PID_55D4&REV_0443, USB\VID_1A86&PID_55D4} <= +Manufacturer : wch.cn <= +PNPClass : Ports <= +Service : CH343SER_A64 <= +Class : Ports <= +FriendlyName : USB-Enhanced-SERIAL CH9102 (COM3) <= +InstanceId : USB\VID_1A86&PID_55D4\5&27435A1F&0&1 <= +InstallDate : <= +Status : OK <= +Availability : <= +ConfigManagerErrorCode : CM_PROB_NONE <= +ConfigManagerUserConfig : False <= +CreationClassName : Win32_PnPEntity <= +ErrorCleared : <= +ErrorDescription : <= +LastErrorCode : <= +PowerManagementCapabilities : <= +PowerManagementSupported : <= +StatusInfo : <= +SystemCreationClassName : Win32_ComputerSystem <= +SystemName : DESKTOP-FRFQN8H <= +Present : True <= +PSComputerName : <= +Problem : CM_PROB_NONE <= +ProblemDescription : <= + <= diff --git a/meshtastic/supported_device.py b/meshtastic/supported_device.py new file mode 100755 index 0000000..e0de3f1 --- /dev/null +++ b/meshtastic/supported_device.py @@ -0,0 +1,187 @@ +""" Supported Meshtastic Devices - This is a class and collection of Meshtastic devices. + It is used for auto detection as to which device might be connected. +""" + +import platform +import subprocess +import re + +# Goal is to detect which device and port to use from the supported devices +# without installing any libraries that are not currently in the python meshtastic library + +class SupportedDevice(): + """Devices supported on Meshtastic""" + + def __init__(self, name, version=None, for_firmware=None, device_class="esp32", + baseport_on_linux=None, baseport_on_mac=None, baseport_on_windows="COM", + usb_vendor_id_in_hex=None, usb_product_id_in_hex=None): + """ constructor """ + self.name = name + self.version = version + self.for_firmware = for_firmware + self.device_class = device_class # could be "nrf52" + + # when you run "lsusb -d xxxx:" in linux + self.usb_vendor_id_in_hex = usb_vendor_id_in_hex # store in lower case + self.usb_product_id_in_hex = usb_product_id_in_hex # store in lower case + + self.baseport_on_linux = baseport_on_linux # ex: ttyUSB or ttyACM + self.baseport_on_mac = baseport_on_mac + self.baseport_on_windows = baseport_on_windows + +# supported devices +tbeam_v0_7 = SupportedDevice(name="T-Beam", version="0.7", for_firmware="tbeam0.7", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="55d4") +tbeam_v1_1 = SupportedDevice(name="T-Beam", version="1.1", for_firmware="tbeam", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="55d4") +tbeam_M8N = SupportedDevice(name="T-Beam", version="M8N", for_firmware="tbeam", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="55d4") +tbeam_M8N_SX1262 = SupportedDevice(name="T-Beam", version="M8N_SX1262", for_firmware="tbeam", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="55d4") +tlora_v1_1 = SupportedDevice(name="T-Lora", version="1.1", for_firmware="tlora-v1", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="55d4") +tlora_v1_3 = SupportedDevice(name="T-Lora", version="1.3", for_firmware="tlora-v1-3", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="55d4") +tlora_v2_0 = SupportedDevice(name="T-Lora", version="2.0", for_firmware="tlora-v2-1", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="55d4") +tlora_v2_1 = SupportedDevice(name="T-Lora", version="2.1", for_firmware="tlora-v2-1", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="55d4") +tlora_v2_1_1_6 = SupportedDevice(name="T-Lora", version="2.1-1.6", for_firmware="tlora-v2-1-1.6", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="1a86", usb_product_id_in_hex="55d4") +heltec_v1 = SupportedDevice(name="Heltec", version="1", for_firmware="heltec-v1", + baseport_on_linux="ttyUSB", baseport_on_mac="cu.usbserial-", + usb_vendor_id_in_hex="10c4", usb_product_id_in_hex="ea60") +heltec_v2_0 = SupportedDevice(name="Heltec", version="2.0", for_firmware="heltec-v2.0", + baseport_on_linux="ttyUSB", baseport_on_mac="cu.usbserial-", + usb_vendor_id_in_hex="10c4", usb_product_id_in_hex="ea60") +heltec_v2_1 = SupportedDevice(name="Heltec", version="2.1", for_firmware="heltec-v2.1", + baseport_on_linux="ttyUSB", baseport_on_mac="cu.usbserial-", + usb_vendor_id_in_hex="10c4", usb_product_id_in_hex="ea60") +# TODO: get info on diy +meshtastic_diy_v1 = SupportedDevice(name="Meshtastic DIY", version="1", for_firmware="meshtastic-diy-v1") +# TODO: get info on TEcho +techo_1 = SupportedDevice(name="T-Echo", version="1", for_firmware="t-echo-1", device_class="nrf52") +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="0029") +rak4631_19003 = SupportedDevice(name="RAK 4631 19003", version="", for_firmware="rak4631_19003", + device_class="nrf52", + baseport_on_linux="ttyACM", baseport_on_mac="cu.usbmodem", + usb_vendor_id_in_hex="239a", usb_product_id_in_hex="8029") + +supported_devices = [tbeam_v0_7, tbeam_v1_1, tbeam_M8N, tbeam_M8N_SX1262, + tlora_v1_1, tlora_v1_3, tlora_v2_0, tlora_v2_1, tlora_v2_1_1_6, + heltec_v1, heltec_v2_0, heltec_v2_1, + meshtastic_diy_v1, techo_1, rak4631_5005, rak4631_19003] + + +def get_unique_vendor_ids(): + """Return a set of unique vendor ids""" + vids = set() + for d in supported_devices: + if d.usb_vendor_id_in_hex: + vids.add(d.usb_vendor_id_in_hex) + return vids + +def get_devices_with_vendor_id(vid): + """Return a set of unique devices with the vendor id""" + sd = set() + for d in supported_devices: + if d.usb_vendor_id_in_hex == vid: + sd.add(d) + return sd + +def active_ports_on_supported_devices(sds): + """Return a set of active ports based on the supplied supported devices""" + ports = set() + baseports = set() + system = platform.system() + + # figure out what possible base ports there are + for d in sds: + if system == "Linux": + baseports.add(d.baseport_on_linux) + elif system == "Darwin": + baseports.add(d.baseport_on_mac) + elif system == "Windows": + baseports.add(d.baseport_on_windows) + + for bp in baseports: + if system == "Linux": + # see if we have any devices (ignoring any stderr output) + command = f'ls -al /dev/{bp}* 2> /dev/null' + #print(f'command:{command}') + _, ls_output = subprocess.getstatusoutput(command) + #print(f'ls_output:{ls_output}') + # if we got output, there are ports + if len(ls_output) > 0: + #print('got output') + # for each line of output + lines = ls_output.split('\n') + #print(f'lines:{lines}') + for line in lines: + parts = line.split(' ') + #print(f'parts:{parts}') + port = parts[-1] + #print(f'port:{port}') + ports.add(port) + elif system == "Darwin": + # see if we have any devices (ignoring any stderr output) + command = f'ls -al /dev/{bp}* 2> /dev/null' + #print(f'command:{command}') + _, ls_output = subprocess.getstatusoutput(command) + #print(f'ls_output:{ls_output}') + # if we got output, there are ports + if len(ls_output) > 0: + #print('got output') + # for each line of output + lines = ls_output.split('\n') + #print(f'lines:{lines}') + for line in lines: + parts = line.split(' ') + #print(f'parts:{parts}') + port = parts[-1] + #print(f'port:{port}') + ports.add(port) + elif system == "Windows": + # for each device in supported devices found + for d in sds: + # find the port(s) + com_ports = detect_windows_port(d) + #print(f'com_ports:{com_ports}') + # add all ports + for com_port in com_ports: + ports.add(com_port) + return ports + + +def detect_windows_port(sd): + """detect if Windows port""" + ports = set() + + if sd: + system = platform.system() + + if system == "Windows": + command = 'powershell.exe "Get-PnpDevice -PresentOnly | Where-Object{ ($_.DeviceId -like ' + command += f"'*{sd.usb_vendor_id_in_hex.upper()}*'" + command += ')} | Format-List"' + + #print(f'command:{command}') + _, sp_output = subprocess.getstatusoutput(command) + #print(f'sp_output:{sp_output}') + p = re.compile(r'\(COM(.*)\)') + for x in p.findall(sp_output): + #print(f'x:{x}') + ports.add(f'COM{x}') + return ports diff --git a/meshtastic/util.py b/meshtastic/util.py index a2fa57c..3e91799 100644 --- a/meshtastic/util.py +++ b/meshtastic/util.py @@ -10,9 +10,11 @@ import time import platform import logging import threading +import subprocess import serial import serial.tools.list_ports import pkg_resources +from meshtastic.supported_device import get_unique_vendor_ids, get_devices_with_vendor_id """Some devices such as a seger jlink we never want to accidentally open""" blacklistVids = dict.fromkeys([0x1366]) @@ -257,3 +259,124 @@ def snake_to_camel(a_string): def camel_to_snake(a_string): """convert camelCase to snake_case""" return ''.join(['_'+i.lower() if i.isupper() else i for i in a_string]).lstrip('_') + + +def detect_supported_devices(): + """detect supported devices""" + system = platform.system() + #print(f'system:{system}') + + possible_devices = set() + if system == "Linux": + # if linux, run lsusb and list ports + + # linux: use lsusb + # Bus 001 Device 091: ID 10c4:ea60 Silicon Labs CP210x UART Bridge + _, lsusb_output = subprocess.getstatusoutput('lsusb') + vids = get_unique_vendor_ids() + for vid in vids: + #print(f'looking for {vid}...') + search = f' {vid}:' + #print(f'search:"{search}"') + 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) + + elif system == "Windows": + # if windows, run Get-PnpDevice + _, sp_output = subprocess.getstatusoutput('powershell.exe "Get-PnpDevice -PresentOnly | Format-List"') + #print(f'sp_output:{sp_output}') + vids = get_unique_vendor_ids() + for vid in vids: + #print(f'looking for {vid.upper()}...') + search = f'DeviceID.*{vid.upper()}&' + #search = f'{vid.upper()}' + #print(f'search:"{search}"') + 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) + + elif system == "Darwin": + # run: system_profiler SPUSBDataType + # if mac air (eg: arm m1) do not know how to get info TODO: research + + _, sp_output = subprocess.getstatusoutput('system_profiler SPUSBDataType') + vids = get_unique_vendor_ids() + for vid in vids: + #print(f'looking for {vid}...') + search = f'Vendor ID: 0x{vid}' + #print(f'search:"{search}"') + 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) + return possible_devices + + +def detect_windows_needs_driver(sd, print_reason=False): + """detect if Windows user needs to install driver for a supported device""" + need_to_install_driver = False + + if sd: + system = platform.system() + #print(f'in detect_windows_needs_driver system:{system}') + + if system == "Windows": + # if windows, see if we can find a DeviceId with the vendor id + # Get-PnpDevice | Where-Object{ ($_.DeviceId -like '*10C4*')} | Format-List + command = 'powershell.exe "Get-PnpDevice | Where-Object{ ($_.DeviceId -like ' + command += f"'*{sd.usb_vendor_id_in_hex.upper()}*'" + command += ')} | Format-List"' + + #print(f'command:{command}') + _, sp_output = subprocess.getstatusoutput(command) + #print(f'sp_output:{sp_output}') + search = f'CM_PROB_FAILED_INSTALL' + #print(f'search:"{search}"') + if re.search(search, sp_output, re.MULTILINE): + need_to_install_driver = True + # if the want to see the reason + if print_reason: + print(sp_output) + return need_to_install_driver