@@ -122,13 +122,11 @@ def get_connected_nordic_boards() -> List[Tuple[str, Union[str, int], ListPortIn
122122 break
123123 return main_ports
124124
125-
126125# Returns a list of SEGGER J-Link serial numbers as int
127126def get_connected_jlinks () -> List [int ]:
128127 with LowLevel .API (LowLevel .DeviceFamily .UNKNOWN ) as api :
129128 return api .enum_emu_snr () or []
130129
131-
132130# For a serial device, return the serial number
133131def extract_serial_number_from_serial_device (dev : ListPortInfo ) -> Union [str , int , None ]:
134132 hwid = dev .hwid
@@ -159,15 +157,13 @@ def extract_product_name_from_jlink_serial(serial : int) -> str:
159157 return name
160158 return ''
161159
162-
163160# Find the main port for a device if it's a Nordic board
164161def get_port_index (dev : ListPortInfo ) -> Optional [int ]:
165162 for pattern , name , main_port in usb_patterns :
166163 if f"SER={ pattern } " in dev .hwid :
167164 return main_port
168165 return None
169166
170-
171167def select_jlink (jlinks : List [int ], list_all : bool ) -> int :
172168 if len (jlinks ) == 0 :
173169 raise Exception ("No J-Link device found" )
@@ -221,7 +217,6 @@ def select_device_by_serial(serial_number : Union[str, int], list_all : bool) ->
221217 selected_port = answer ["port" ]
222218 return (selected_port , serial_number )
223219
224-
225220# Returns serial_port, serial_number of selected device
226221def select_device (rtt : bool , serial_number : Optional [Union [str , int ]], port : Optional [ListPortInfo ], list_all : bool ) -> Tuple [Optional [ListPortInfo ], Optional [Union [str , int ]]]:
227222 if type (serial_number ) == str and serial_number .isdigit ():
@@ -286,8 +281,6 @@ def select_device(rtt : bool, serial_number : Optional[Union[str, int]], port :
286281 selected_port = answer ["port" ]
287282 extracted_serial_number = extract_serial_number_from_serial_device (selected_port )
288283 return (selected_port , extracted_serial_number )
289-
290-
291284class Comms :
292285 def __init__ (
293286 self ,
@@ -444,4 +437,3 @@ def _init_serial(self, serial_port, baudrate, xonxoff, rtscts, dsrdtr):
444437 self .write = self ._write_serial
445438 self .read_line = self ._readline_serial
446439 self .reset_input_buffer = self .serial_api .reset_input_buffer
447-
0 commit comments