@@ -189,6 +189,8 @@ def select_jlink(jlinks : List[int], list_all: bool) -> int:
189189 choices = [(f"{ serial } { extract_product_name_from_jlink_serial (serial )} " , serial ) for serial in serial_numbers ],
190190 )
191191 answer = inquirer .prompt ([question ])
192+ if not answer :
193+ raise Exception ("No J-Link device selected" )
192194 return answer ["serial" ]
193195
194196
@@ -214,6 +216,8 @@ def select_device_by_serial(serial_number : Union[str, int], list_all : bool) ->
214216 choices = [(port .device , port ) for port in serial_devices ],
215217 )
216218 answer = inquirer .prompt ([question ])
219+ if not answer :
220+ raise Exception ("No serial port selected" )
217221 selected_port = answer ["port" ]
218222 return (selected_port , serial_number )
219223
@@ -259,6 +263,8 @@ def select_device(rtt : bool, serial_number : Optional[Union[str, int]], port :
259263 choices = sorted ([(f"{ port .device } { extract_product_name_from_serial_device (port )} " , port ) for port in ports ]),
260264 )
261265 answer = inquirer .prompt ([question ])
266+ if not answer :
267+ raise Exception ("No serial port selected" )
262268 selected_port = answer ["port" ]
263269 extracted_serial_number = extract_serial_number_from_serial_device (
264270 selected_port
@@ -278,6 +284,8 @@ def select_device(rtt : bool, serial_number : Optional[Union[str, int]], port :
278284 choices = [(f"{ port .device } { name } " , port ) for name , serial , port in nordic_boards ],
279285 )
280286 answer = inquirer .prompt ([question ])
287+ if not answer :
288+ raise Exception ("No serial port selected" )
281289 selected_port = answer ["port" ]
282290 extracted_serial_number = extract_serial_number_from_serial_device (selected_port )
283291 return (selected_port , extracted_serial_number )
@@ -336,7 +344,7 @@ def expect_response(self, ok_str=None, error_str=None, store_str=None, timeout=1
336344 output = ''
337345 time_end = time .time () + timeout
338346 while time .time () < time_end :
339- line = self .read_line ()
347+ line = self .read_line () # type: ignore
340348 if line :
341349 line = line .strip ()
342350 # Remove ANSI escape codes
@@ -364,12 +372,12 @@ def reset_device(self):
364372
365373 def write_line (self , data : str ):
366374 logger .debug (f"> { data } " )
367- self .write ((data + self .line_ending ).encode ('ascii' ))
375+ self .write ((data + self .line_ending ).encode ('ascii' )) # type: ignore
368376
369377 def _readline_rtt (self ) -> Optional [str ]:
370378 time_end = time .time () + self .timeout
371379 while time .time () < time_end :
372- self ._rtt_line_buffer += self .jlink_api .rtt_read (channel_index = 0 , length = 4096 )
380+ self ._rtt_line_buffer += self .jlink_api .rtt_read (channel_index = 0 , length = 4096 ) # type: ignore
373381 # Find first line ending
374382 line_end = self ._rtt_line_buffer .find (self .line_ending )
375383 if line_end != - 1 :
@@ -383,7 +391,7 @@ def _readline_rtt(self) -> Optional[str]:
383391
384392 def _readline_serial (self ) -> Optional [str ]:
385393 # Read a line from the serial port
386- line = self .serial_api .readline ()
394+ line = self .serial_api .readline () # type: ignore
387395 if line :
388396 line = line .decode ('utf-8' , errors = "replace" ).strip ()
389397 logger .debug (f"< { line } " )
@@ -393,11 +401,11 @@ def _readline_serial(self) -> Optional[str]:
393401 def _write_rtt (self , data : bytes ):
394402 # Hacky workaround from old rtt_interface
395403 for i in range (0 , len (data ), 12 ):
396- self .jlink_api .rtt_write (channel_index = 0 , msg = data [i : i + 12 ])
404+ self .jlink_api .rtt_write (channel_index = 0 , msg = data [i : i + 12 ]) # type: ignore
397405 time .sleep (0.01 )
398406
399407 def _write_serial (self , data : bytes ):
400- self .serial_api .write (data )
408+ self .serial_api .write (data ) # type: ignore
401409
402410 def _reset_input_buffer_rtt (self ):
403411 # RTT does not have an input buffer to reset, but we can clear the line buffer
0 commit comments