From 961b8a58f35d925dae26bbad4c262146f4710ebf Mon Sep 17 00:00:00 2001 From: mkozlowski <10508687+m-kozlowski@users.noreply.github.com> Date: Tue, 22 Aug 2023 11:37:12 +0200 Subject: [PATCH] Faster COM port detection --- software/script/chameleon_cli_unit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/software/script/chameleon_cli_unit.py b/software/script/chameleon_cli_unit.py index f3da704f..be635f21 100644 --- a/software/script/chameleon_cli_unit.py +++ b/software/script/chameleon_cli_unit.py @@ -198,7 +198,8 @@ def on_exec(self, args: argparse.Namespace): PSHEXE=fn break if PSHEXE: - process = subprocess.Popen([PSHEXE,"Get-CimInstance -ClassName Win32_serialport | Where-Object {$_.PNPDeviceID -like '*VID_6868&PID_8686*'} | Select -expandproperty DeviceID"],stdout=subprocess.PIPE); + #process = subprocess.Popen([PSHEXE,"Get-CimInstance -ClassName Win32_serialport | Where-Object {$_.PNPDeviceID -like '*VID_6868&PID_8686*'} | Select -expandproperty DeviceID"],stdout=subprocess.PIPE); + process = subprocess.Popen([PSHEXE,"Get-PnPDevice -Class Ports -PresentOnly | where {$_.DeviceID -like '*VID_6868&PID_8686*'} | Select-Object FriendlyName | % FriendlyName | select-string COM\d+ |% { $_.matches.value }"],stdout=subprocess.PIPE); res = process.communicate()[0] _comport = res.decode('utf-8').strip() if _comport: