Skip to content

Commit eeecccb

Browse files
committed
macOS: handle /dev/tty paths
1 parent 843ade2 commit eeecccb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/nrfcredstore/comms.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def select_device_by_serial(serial_number : Union[str, int], list_all : bool) ->
197197
return (selected_port, serial_number)
198198

199199
# Returns serial_port, serial_number of selected device
200-
def select_device(rtt : bool, serial_number : Optional[Union[str, int]], port : Optional[ListPortInfo], list_all : bool) -> Tuple[Optional[ListPortInfo], Optional[Union[str, int]]]:
200+
def select_device(rtt : bool, serial_number : Optional[Union[str, int]], port : str, list_all : bool) -> Tuple[Optional[ListPortInfo], Optional[Union[str, int]]]:
201201
if type(serial_number) == str and serial_number.isdigit():
202202
serial_number = int(serial_number)
203203

@@ -221,6 +221,12 @@ def select_device(rtt : bool, serial_number : Optional[Union[str, int]], port :
221221

222222
# Serial ports are unique, so we just check if it exists and try to get a serial number
223223
serial_devices = [x for x in get_comports_fixed_ordering() if x.device == real_path]
224+
225+
# Workaround for macOS
226+
if len(serial_devices) == 0 and real_path.startswith("/dev/tty"):
227+
real_path = real_path.replace("tty", "cu")
228+
serial_devices = [x for x in get_comports_fixed_ordering() if x.device == real_path]
229+
224230
if len(serial_devices) == 0:
225231
raise Exception(f"No device found with port {port}")
226232
extracted_serial_number = extract_serial_number_from_serial_device(

0 commit comments

Comments
 (0)