Skip to content

Commit 843e92b

Browse files
Add windows compatibility to list_devices
The port.product returns None under windows, so no devices are found when using list_devices. This change will filter the devices based on the description on windows.
1 parent b472b78 commit 843e92b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ppk2_api/ppk2_api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import serial
99
import struct
1010
import logging
11-
11+
import os
1212
import queue
1313
import multiprocessing
1414

@@ -210,7 +210,10 @@ def _handle_raw_data(self, adc_value):
210210
def list_devices():
211211
import serial.tools.list_ports
212212
ports = serial.tools.list_ports.comports()
213-
devices = [port.device for port in ports if port.product == 'PPK2']
213+
if os.name == 'nt':
214+
devices = [port.device for port in ports if port.description.startswith("nRF Connect USB CDC ACM")]
215+
else:
216+
devices = [port.device for port in ports if port.product == 'PPK2']
214217
return devices
215218

216219
def get_data(self):

0 commit comments

Comments
 (0)